Skip to main content

Documentation 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.

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 the @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

POST /api/utilities/image-generator
Content-Type: application/json
prompt
string
required
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:
image
string
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.
{
  "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}

Error Responses

StatusBodyCause
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.
Both CLOUDFLARE_ID and CLOUDFLARE_API_KEY must be set as environment variables on the server. Missing credentials will cause a 500 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

VariableDescription
CLOUDFLARE_IDYour Cloudflare account ID.
CLOUDFLARE_API_KEYA Cloudflare API token with Workers AI permission.

Example

Request
curl -X POST https://your-domain.com/api/utilities/image-generator \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at night with neon lights reflecting on wet streets, cyberpunk style, highly detailed, 4K"
  }'
Response
{
  "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQA..."
}
Using the result in HTML
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQA..." alt="Generated image" />

Build docs developers (and LLMs) love