The Image Generator endpoint accepts a natural-language text prompt and returns an AI-generated image as a base64-encoded PNG data URL. It routes the request through Cloudflare Workers AI using theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/ai360/llms.txt
Use this file to discover all available pages before exploring further.
@cf/black-forest-labs/flux-1-schnell model — a fast, high-quality text-to-image model optimised for speed.
The returned data:image/png;base64,... string can be used directly as an <img src> value in the browser without any additional processing.
Request
A natural-language description of the image to generate. More descriptive
prompts (including style, lighting, composition, and subject details) produce
better results.
Response
A successful request returns HTTP 200 with the following body:A base64-encoded PNG data URL in the format
data:image/png;base64,<encoded-data>. This can be set directly as the
src attribute of an HTML <img> tag.Error Responses
| Status | Body | Cause |
|---|---|---|
500 | { "error": "Cloudflare API returned an error" } | The Cloudflare Workers AI API responded with success: false. |
500 | { "error": "Failed to generate image" } | Network failure, invalid credentials, or an unexpected server error. |
The
flux-1-schnell model prioritises speed. For highly detailed or
photorealistic results, craft prompts that explicitly specify style,
medium, and lighting (e.g. "photorealistic, golden hour, DSLR, 4K").Environment Variables
| Variable | Description |
|---|---|
CLOUDFLARE_ID | Your Cloudflare account ID. |
CLOUDFLARE_API_KEY | A Cloudflare API token with Workers AI permission. |