Create image
Creates an image given a prompt.
Request
- Base URL: https://api.tokenlab.sh
- URL: https://api.tokenlab.sh/v1/images/generations
- Auth: HTTP bearer
Headers
Per-request Delivery policy. Overrides the API key and Workspace defaults. Auto tries TokenLab Verified first and may switch once to Official only before output, request acceptance, or persistent resource creation.
Request body
Image description. Required for every model that takes a prompt; a tool whose contract lists no prompt (background removal, upscaling, vectorizing) is called without one.
Model to use. Send this explicitly; query GET /v1/models?recommended_for=image for current recommendations.
Public image operation family. Reference-image models use image-to-image with image_url, image_urls, or reference_image_urls.
Single reference image URL for compatible image-to-image models.
Reference image URLs for compatible image-to-image models.
Alias used by compatible reference-image model families.
Optional mask URL for compatible image operations.
Number of images to generate
Image size. Defaults are model-specific. For gpt-image-2, omit this field or use auto for automatic sizing, or send WIDTHxHEIGHT; custom dimensions must both be multiples of 16, longest edge <= 3840px, long/short ratio <= 3:1, and total pixels between 655,360 and 8,294,400. For Google image models with resolution tiers (gemini-3.1-flash-image, gemini-3-pro-image, gemini-3.1-flash-lite-image, gemini-nano-banana-2.1, nano-banana-2, nano-banana-2.1, nano-banana-pro), send an output size from the model's size table or a resolution tier: 1K, 2K, or 4K. TokenLab sends a tier as resolution. A tier that the model does not support, or a tier that is different from resolution, returns 400 invalid_image_size_contract. The recommended form for these models is aspect_ratio with resolution.
Image quality. Defaults and accepted values are model-specific. For gpt-image-2, omit this field or use auto for automatic quality, or send low, medium, or high. Other models may accept different values; check the model details.
Optional model-specific style selector. Only send when the selected model documents support for this parameter.
Ask compatible models to expand or enhance the prompt.
For z-image-turbo, enable prompt expansion. Defaults to false. Enabling it uses the model's prompt-expansion price.
Content to avoid for compatible image models.
Seed for deterministic-compatible image models.
How the images are returned. Omitted: when the model returns image bytes, each image is in data[].b64_json, and also in data[].url when TokenLab stored it; when the model returns a link, each image is in data[].url. url: only data[].url. b64_json: only data[].b64_json. Links are TokenLab media-result URLs that stay valid for 30 days.
Return a task before the final image is ready when the selected model supports public async execution.
Background handling for compatible image flows. For gpt-image-2 generation and edits, accepted values are auto and opaque; transparent is not supported. Other models may support different values.
Output image format for compatible image models such as gpt-image-2
Output compression level from 0 to 100 for compressed formats
Alias for output_compression when supported by the selected model
Moderation strictness for compatible image models such as gpt-image-2
Reserved image streaming flag. The public generation route currently rejects true.
Aspect-ratio selector for compatible image model families.
Resolution selector for compatible image model families.
End-user identifier
Response
Successful response
Unix timestamp
Task ID when the request runs as a task.
Task status when the request runs as a task.
URL to poll for the task result.
Example response
{
"media_retention": {
"days": 30
}
}Changes
No recorded changes to this operation across all 1 revision of this API.