For the complete documentation index, see llms.txt. This page is also available as Markdown.

Image Generation

Generate Image

post

Generates images from text prompts.

FastRouter supports both synchronous and asynchronous image generation.

By default, if response_type is omitted, FastRouter prefers a synchronous provider whenever one is available. If no synchronous provider exists for the selected model, FastRouter automatically falls back to an asynchronous provider.

Set response_type to explicitly control execution:

  • sync — Return the generated image directly.

  • async — Return a taskId. Retrieve the completed image using GET /api/v1/images/{task_id} or POST /api/v1/getAsyncResponse.

Supported models include OpenAI, Google, Leonardo AI, Black Forest Labs (Flux), ByteDance (Seedream), xAI (Grok), and others.

Tip: Call GET /api/v1/models to retrieve the latest models and their supported parameters.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
promptstringRequired

Text description of the desired image

Example: A cute baby sea otter wearing a beret
modelstring · enumRequired

Image generation model to use.

Models may support synchronous or asynchronous execution depending on the available providers.

If response_type is omitted, FastRouter automatically selects the best available provider, preferring synchronous execution and falling back to asynchronous when necessary.

Call GET /api/v1/models for the latest supported models.

Example: openai/gpt-image-1Possible values:
response_typestring · enum · nullableOptional

Controls how the image generation request is processed.

  • sync — Force a synchronous provider. The generated image is returned directly in the response.
  • async — Force an asynchronous provider. The response returns a taskId; retrieve the completed image using GET /api/v1/images/{task_id} or POST /api/v1/getAsyncResponse.
  • Omit this field to let FastRouter automatically select the best provider, preferring synchronous execution and falling back to asynchronous when necessary.
Possible values:
ninteger · min: 1 · max: 10 · nullableOptional

Number of images to generate. Supported range varies by model.

Default: 1
sizestring · nullableOptional

Image dimensions. Supported values vary by model, e.g. gpt-image-1/mini: auto, 1024×1024, 1536×1024, 1024×1536. Check GET /api/v1/models for per-model supported sizes.

Default: autoExample: 1024x1024
qualitystring · enum · nullableOptional

Image quality level (model-specific), e.g. gpt-image-1/mini: auto, high, medium, low. Check GET /api/v1/models for per-model supported values.

Default: autoPossible values:
output_formatstring · enum · nullableOptional

Output image format. Only supported for gpt-image-1 and gpt-image-1-mini

Default: pngPossible values:
backgroundstring · enum · nullableOptional

Background style. Only for gpt-image-1 and gpt-image-1-mini. Note: transparent requires png or webp format

Default: autoPossible values:
stylestring · enumOptional

Image style, where supported by the model.

Default: vividPossible values:
response_formatstring · enumOptional

Format of the response data

Default: urlPossible values:
Responses
200

Successful response.

If the request is processed synchronously, the generated image (URL or base64) is returned directly.

If the request is processed asynchronously, the response contains a taskId. Poll GET /api/v1/images/{task_id} or POST /api/v1/getAsyncResponse until the image is ready.

application/json
or
post/api/v1/images/generations

Note: Leonardo models (leonardo/...) respond asynchronously and return a taskId. Retrieve the completed image by polling the async response endpoint using either the GET or POST method.

Get Image Status

get

Retrieves the status and result of an asynchronous image generation by its task_id (e.g. Leonardo models, which return a task_id from POST /api/v1/images/generations).

Poll this endpoint until the image is ready. When complete, data[] contains the generated image URL(s) and fastrouter_assets.status is ready.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Path parameters
task_idstringRequired

The task ID returned from POST /api/v1/images/generations (e.g. a Leonardo leo_ prefixed ID).

Example: leo_22c6720f-75c9-4cdb-ba72-5a6ac6ed0d31
Responses
200

Image generation status / result

application/json
chat_idstringOptional

FastRouter transaction ID for this generation.

createdintegerOptional

Unix timestamp when the image was created.

sizestringOptional

Image dimensions.

Example: 1024x1024
get/api/v1/images/{task_id}

Get Async Response

post

Polls for asynchronous video generation results. Poll with the taskId returned from POST /api/v1/videos until status is succeed or completed, then download from the provided URL.

taskId and model rules:

  • If taskId includes a provider prefix (e.g. pol_ for Pollo), then model is optional.

  • If taskId has no provider prefix, then model is required and must match the model used in the original /videos request.

Response shape varies by provider:

  • Pollo — per-generation id, createdDate, status, url, etc.

  • Klingdata.status: completed; generations have duration and url.

  • Veo (Google)data.status: completed; generations have bytesBase64Encoded. Use fastrouter_assets.urls for download.

  • Sora — OpenAI-style response with progress, status, etc.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
taskIdstringRequired

The taskId returned from POST /api/v1/videos. When it includes a provider prefix (e.g. pol_ for Pollo), model can be omitted.

Example: pol_cmm22zlht0bqsc5uw50j8aw5q
modelstringOptional

The video model used in the original /videos request. Required when taskId has no provider prefix; optional when taskId has a provider prefix (e.g. pol_).

Example: google/veo2
Responses
200

Video generation status or completed video

application/json
or
post/api/v1/getAsyncResponse

Last updated