The image generation endpoint accepts a text prompt, runs it through the Cloudflare Workers AIDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Akari-Art/llms.txt
Use this file to discover all available pages before exploring further.
@cf/black-forest-labs/flux-1-schnell model, converts the resulting base64-encoded PNG to a hosted asset via Cloudinary, and returns the secure_url of the uploaded image. This is the core generation step in the Akari Art creation flow.
Endpoint
Authentication
A valid NextAuth.js session cookie is required. The Next.js middleware automatically enforces this — unauthenticated requests are redirected to/signin before they reach this handler. When calling from the browser, the session cookie is included automatically.
Request Body
The text description of the image to generate. Should be descriptive and
specific for best results.Example:
"A purple nebula with glowing stars, digital art style"Response
200 — Success
The Cloudinary
secure_url of the generated and uploaded image. This is a
permanent HTTPS URL served from Cloudinary’s CDN.Example: "https://res.cloudinary.com/your-cloud/image/upload/v1234567890/abc123.png"500 — Error
A message describing the failure. One of two values:
"Cloudflare API returned an error"— the Cloudflare Workers AI API responded withsuccess: false"Failed to generate image"— an unexpected error occurred (network failure, Cloudinary upload error, etc.)
Example Request
How It Works
Call Cloudflare Workers AI
An HTTP The request is authenticated with a
POST request is made to the Cloudflare AI API using the
@cf/black-forest-labs/flux-1-schnell model:Bearer token from the
CLOUDFLARE_API_KEY environment variable. If the response includes
success: false, a 500 error is returned immediately.Extract base64 image
On success, the Cloudflare response contains
result.image — a base64-encoded PNG string.Upload to Cloudinary
The base64 string is prefixed with
data:image/png;base64, and uploaded
directly to Cloudinary using the configured Cloudinary SDK instance. Cloudinary
stores the image and returns an upload result object.Required Environment Variables
| Variable | Description |
|---|---|
CLOUDFLARE_ID | Your Cloudflare account ID |
CLOUDFLARE_API_KEY | Cloudflare API token with Workers AI permissions |
CLOUDINARY_CLOUD_NAME | Your Cloudinary cloud name |
CLOUDINARY_API_KEY | Cloudinary API key |
CLOUDINARY_API_SECRET | Cloudinary API secret |