Skip to main content
POST
Images

Endpoint

Generate images from a text prompt. Responses are buffered JSON with inline base64 image data and an x-receipt-id header for verification.

Models and Pricing

The live model catalog lists image models with image in output_modalities. It currently offers black-forest-labs/flux.2-klein-4b at $0.015 per returned image, published as pricing.image_generation in USD per image. Check the catalog for current availability and pricing.

Request Body

string
required
Image model ID, for example black-forest-labs/flux.2-klein-4b.
string
required
Text describing the image, up to 32,000 Unicode characters.
integer
Maximum number of images to generate, from 1 through 10. Defaults to 1. Providers may return fewer images; billing uses the returned count.
string
Image dimensions, for example 512x512, or auto if supported by the model.
string
Model-specific quality setting.
string
Model-specific background setting.
string
Requested image encoding, subject to model support. The current FLUX route returns JPEG bytes even when png is requested. Save its output as .jpg; do not infer the encoding from this parameter.
integer
Compression setting from 0 through 100, if supported by the model and encoding.
string
Model-specific moderation setting.
string
Omit this field or set it to b64_json. The gateway requests inline base64 output. Image URLs are not supported.
string
Accepted for SDK compatibility but removed before forwarding upstream.
object
The same routing constraints as Chat Completions, including zdr, aci_verified, and aci_session_ids. The Phala endpoint requires verified serving independently of request-level constraints.
The gateway validates option types; supported values and defaults depend on the model. user and style are accepted as strings but removed before forwarding. Unknown fields, including seed, are rejected. Omit stream and partial_images entirely, including stream: false. Streaming and ACI E2EE are not supported on this endpoint.

Examples

Both examples save the first FLUX image as image.jpg. The cURL example also saves the raw response and headers, including the receipt ID.

Response

Example for one FLUX image at the current rate. The base64 data is shortened.
created is a Unix timestamp in seconds. data is a nonempty array of images with b64_json; an item may also contain revised_prompt as a string or null. The current FLUX response does not include top-level size or output_format fields. When present, usage includes integer token counts, with missing counts filled with 0. The gateway adds usage.cost in USD when pricing is available: returned image count times the per-image rate, plus token charges if token usage and rates are available. Zero token counts do not imply free image generation.

Verification

Capture x-receipt-id from the response headers and fetch GET /v1/aci/receipts/{id} with the same bearer token. Image receipts have chat_id: null; use the receipt ID. See Get Receipt and Verify a Response. Ordinary cURL and OpenAI SDK clients do not verify the gateway or audit receipts.

Errors

Errors use a JSON error object, with error.code and error.param where applicable. Authentication, budget, and other routing errors follow Error Handling.

List Models

Get Receipt