GuidesAI APIS
Free AI image generation APIs
Seven of the 13 image generation APIs we tested on 28 October 2026 send CORS headers, so browser code can call them directly; Replicate, Runway, Cloudflare Workers AI, Ideogram and Black Forest Labs are blocked, and OpenAI's 401 errors arrive without CORS headers. Only Pollinations returns an image with no key at all, while Stability AI gives new accounts 25 free credits and Cloudflare 10,000 Neurons a day. For the blocked APIs, cors.dev Pro ($5 a month for 500,000 requests, 7-day trial with 1,000 requests, no card) forwards the POST and Authorization header from origins you register; the free tier cannot, because it is GET and HEAD only.
Image APIs compared
On 28 October 2026 we sent a JSON POST with a test key to 13 image generation APIs from Origin: https://example.com, preceded by the OPTIONS preflight a browser sends. We checked both responses for Access-Control-Allow-Origin and then repeated each POST through https://proxy.cors.dev/.
| API | Free tier | Key | Price example | Browser CORS | Through cors.dev |
|---|---|---|---|---|---|
| Pollinations | Free legacy endpoint | No | Free | Yes | Not needed |
| Stability AI | 25 credits for new accounts | Yes | Stable Image Core, 3 credits ($0.03) | Yes | Not needed |
| Cloudflare Workers AI | 10,000 Neurons a day | Yes | FLUX.1 schnell, 4.80 Neurons per tile plus 9.60 per step | No | cors.dev Pro forwards POST and Authorization |
| Replicate | Some models free to try | Yes | flux-schnell, $3.00 per 1,000 images | No | cors.dev Pro forwards POST and Authorization |
| fal.ai | None listed | Yes | FLUX.1 schnell, $0.003 per megapixel | Yes | Not needed |
| Together AI | None listed for images | Yes | FLUX.2 dev, $0.0154 per image | Yes | Not needed |
| Hugging Face | None for free accounts | Yes | Hugging Face's PRO plan includes $2.00 of credits a month | Yes | Not needed |
| Google Gemini | Image models not on the free tier | Yes | Nano Banana 2, $0.067 per 1K image | Yes | Not needed |
| OpenAI | None listed | Yes | gpt-image-2.5-flare, $30 per 1M image output tokens | Preflight yes, 401 without | cors.dev Pro if you need readable errors |
| Runway | None listed | Yes | gen4_image, 5 credits ($0.05) at 720p | No, preflight answers 401 | cors.dev Pro forwards POST, Authorization and X-Runway-Version |
| Leonardo | $5 of API credit for new API accounts | Yes | Pay as you go, priced per model and settings | Yes | Not needed |
| Ideogram | None listed | Yes | Prepaid credits at 1 cent each | No, empty Access-Control-Allow-Origin | cors.dev Pro forwards POST and its key header |
| Black Forest Labs | None listed | Yes | FLUX.2 pro, from $0.03 per image | No, preflight answers 400 | cors.dev Pro forwards POST and its key header |
Seven of the 13 APIs returned CORS headers on both the preflight and the response: Pollinations, Stability AI, fal.ai, Together AI, Hugging Face, Google Gemini and Leonardo. Replicate, Runway, Cloudflare Workers AI, Ideogram and Black Forest Labs are blocked in the browser, while OpenAI passes the preflight but omits CORS headers on its 401 error response.
Which image APIs answer a browser
- Pollinations:
GET https://image.pollinations.ai/prompt/<prompt>?width=512&height=512&seed=7returned200image/jpegwithAccess-Control-Allow-Origin: *and no key. - Stability AI:
POST https://api.stability.ai/v2beta/stable-image/generate/coreanswered the preflight with204,Access-Control-Allow-Origin: *and allowedAuthorization, and its401response for a test key also carriedAccess-Control-Allow-Origin: *along with a JSONerrorsarray. - fal.ai:
POST https://fal.run/fal-ai/flux/schnellandhttps://queue.fal.run/...echoed the origin and allowedAuthorizationandContent-Type. - Together AI:
POST https://api.together.xyz/v1/images/generationssentAccess-Control-Allow-Origin: *on both the preflight and the401. - Hugging Face:
https://router.huggingface.cosentAccess-Control-Allow-Origin: *on the preflight and on the401. - Google Gemini:
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image:generateContentwithx-goog-api-keyechoed the origin on the preflight and on the400for a test key. - Leonardo:
POST https://cloud.leonardo.ai/api/rest/v1/generationsechoed the origin and allowedAuthorization. - OpenAI:
POST https://api.openai.com/v1/images/generationspassed the preflight (200,Access-Control-Allow-Origin: *), but the401for a test key had no CORS header, so a failed call shows up in the browser as a network error with no readable body. - Replicate: the preflight to
https://api.replicate.com/v1/models/black-forest-labs/flux-schnell/predictionsanswered200withoutAccess-Control-Allow-Origin, and the401had none either, so browsers block it. - Runway:
https://api.dev.runwayml.com/v1/text_to_imageanswered theOPTIONSpreflight itself with401and no CORS header. - Cloudflare Workers AI:
https://api.cloudflare.com/client/v4/accounts/<id>/ai/run/@cf/black-forest-labs/flux-1-schnellansweredOPTIONSwith405and thePOSTwithout CORS headers. - Ideogram:
https://api.ideogram.aianswered the preflight with an emptyAccess-Control-Allow-Originvalue, which browsers reject. - Black Forest Labs:
https://api.bfl.aianswered the preflight with400Disallowed CORS origin.
No key at all: Pollinations
GET https://image.pollinations.ai/prompt/<prompt>?width=512&height=512&seed=7 returns 200 image/jpeg with Access-Control-Allow-Origin: * and needs no API key. In our test a 512x512 image was 55,950 bytes, and a new, uncached prompt took 4.2 seconds. Without a key it allows 1 new image every 45 seconds per IP: a faster request gets 402 with a FREE_LIMIT error and a Retry-After header, while URLs that were already generated still load from cache.
An img tag can load that URL with no CORS at all, or you can fetch it as a Blob. Call it directly, no proxy needed; it also worked through https://proxy.cors.dev/.
function pollinationsUrl(prompt, { width = 512, height = 512, seed = 7 } = {}) {
const url = new URL('https://image.pollinations.ai/prompt/' + encodeURIComponent(prompt));
url.searchParams.set('width', width);
url.searchParams.set('height', height);
url.searchParams.set('seed', seed);
return url.href;
}
// An img tag needs no CORS at all
function showImage(prompt) {
const img = document.createElement('img');
img.alt = prompt;
img.src = pollinationsUrl(prompt);
document.body.append(img);
}
// Or fetch it as a Blob: the endpoint sends Access-Control-Allow-Origin: *
async function fetchImage(prompt) {
const res = await fetch(pollinationsUrl(prompt));
if (!res.ok) throw new Error(`Pollinations HTTP ${res.status}`);
return res.blob();
}
// Use one or the other: without a key, Pollinations allows 1 new image every 45 seconds per IP
showImage('a red bicycle');image.pollinations.ai is the legacy endpoint. The current Pollinations docs point to gen.pollinations.ai, which answered 401 A valid API key is required.
Calling a CORS-enabled API with the user's key
Any API key in browser code, in a query string or a header, is visible to every visitor in DevTools. Keep your own production key on a backend; direct browser calls fit internal tools, prototypes and bring-your-own-key apps where each user pastes their own key.
Stability AI works from the browser directly, no proxy needed. Send multipart/form-data with prompt and output_format to POST https://api.stability.ai/v2beta/stable-image/generate/core with Authorization: Bearer <key> and Accept: image/*, and the response body is the image.
async function stabilityCore(prompt, userKey) {
const form = new FormData();
form.append('prompt', prompt);
form.append('output_format', 'webp');
const res = await fetch('https://api.stability.ai/v2beta/stable-image/generate/core', {
method: 'POST',
headers: { Authorization: `Bearer ${userKey}`, Accept: 'image/*' },
body: form,
});
if (!res.ok) {
const { errors = [] } = await res.json();
throw new Error(`Stability HTTP ${res.status}: ${errors.join(', ')}`);
}
return URL.createObjectURL(await res.blob());
}
const userKey = prompt('Your Stability AI API key');
const imageUrl = await stabilityCore('a red bicycle', userKey);Replicate, Runway and the APIs without CORS headers
Through the free https://proxy.cors.dev/ tier, every one of these POST requests answered 405 with method_not_allowed in the X-Cors-Error header: the free tier is GET and HEAD only. It also refuses Authorization and X-Api-Key headers with 400 header_not_allowed, and drops other unsupported headers, naming them in X-Cors-Dropped-Headers.
For APIs that block browsers, such as Replicate and Runway, use cors.dev Pro: $5 a month for 500,000 requests, with a 7-day trial of 1,000 requests and no card. It forwards POST, PUT, PATCH and DELETE, bodies up to 1 MiB, and Authorization, Content-Type and custom headers such as Runway's required X-Runway-Version. Responses are capped at 6 MiB within a 30-second upstream deadline, and cors.dev Pro allows 3,000 requests a minute per account and 100 in flight.
- Sign in at cors.dev
use Google to start the 7-day trial or cors.dev Pro.
- Create a Connection
list your exact page origins and the API hosts you call.
- Send the Connection key
pass it in the
X-Cors-Keyheader when callinghttps://proxy.cors.dev/followed by the target URL. It is a publishable identifier that only works from your registered origins; it is not a secret and does not hide your API key.
Replicate and Runway are both asynchronous: you create a job with a POST, then poll a GET until the image is ready. Runway tasks start at /v1/text_to_image and are polled at GET /v1/tasks/{id}; Replicate predictions start at /v1/models/{owner}/{name}/predictions and are polled at GET /v1/predictions/{id}.
What the free tiers buy
- Pollinations: free with no key on the legacy
image.pollinations.aihost, at 1 new image every 45 seconds per IP. - Stability AI: 25 free credits buy 8 Stable Image Core images at 3 credits each, or 3 Stable Image Ultra images at 8.
- Cloudflare Workers AI: 10,000 Neurons a day at no charge. At Cloudflare's listed rates, a FLUX.1 schnell image comes back at 1024x1024, which is four 512x512 tiles, so at the default 4 steps it uses 4 x 4.80 + 4 x 9.60 = 57.6 Neurons, about 173 images a day; past that, the Workers Paid plan charges $0.011 per 1,000 Neurons.
- Replicate: select models are free to try before billing; after that,
flux-schnellis $0.003 an image. - Hugging Face: nothing for free accounts; Hugging Face's PRO plan includes $2.00 of credits a month.
- Google Gemini: image models are not on the free tier; Nano Banana 2 (
gemini-3.1-flash-image) is $0.067 per 1K image. - fal.ai, Together AI, OpenAI and Runway: no free image credits listed, so you pay from the first image: $0.003 per megapixel for FLUX.1 schnell on fal.ai, $0.0154 per FLUX.2 dev image on Together AI, $0.02 per
gen4_image_turboimage on Runway.
Good questions.
Which AI image API is free with no API key?
The legacy Pollinations endpoint at GET https://image.pollinations.ai/prompt/<prompt>?width=512&height=512&seed=7 returns a 200 image/jpeg response with Access-Control-Allow-Origin: * and no API key. You can put that URL straight into an img tag or fetch it from browser JavaScript. The newer gen.pollinations.ai host in the current docs returns 401 A valid API key is required.
Can I call the OpenAI image API from the browser?
OpenAI's POST https://api.openai.com/v1/images/generations endpoint passes the browser's OPTIONS preflight with 200 and Access-Control-Allow-Origin: *. However, when we tested it with a test key, the 401 error response came back with no CORS header at all. A failed call therefore surfaces in browser JavaScript as a generic network error with no readable body, and any key you ship in page code is visible to every visitor.
Why does Replicate give a CORS error in JavaScript?
When a browser sends a preflight OPTIONS request to https://api.replicate.com/v1/models/black-forest-labs/flux-schnell/predictions, Replicate answers 200 without an Access-Control-Allow-Origin header. Its 401 response doesn't include Access-Control-Allow-Origin either, so the browser refuses to let your frontend code read the response. To call it from the browser, route the POST and the polling GET requests through a proxy that forwards bodies and Authorization headers, such as cors.dev Pro ($5 a month for 500,000 requests, 7-day trial with 1,000 requests, no card).
How many free images does Stability AI give?
New Stability AI accounts get 25 free credits, where 1 credit equals $0.01. Stable Image Core costs 3 credits per generation, so the free allowance covers 8 images. If you use Stable Image Ultra at 8 credits or SD 3.5 Large at 6.5 credits, you'll get 3 images from those 25 credits.
Can the free cors.dev proxy send a POST to an image API?
No, the free https://proxy.cors.dev/ endpoint only allows GET and HEAD requests and rejects POST with 405 method_not_allowed. It also blocks Authorization and X-Api-Key headers with 400 header_not_allowed, though it forwards query-string keys on GET requests, with a 6 MiB response limit and about 600 requests a minute per IP. Sending POST requests and Authorization headers requires cors.dev Pro or its 7-day trial.