Images API
TokenFlux exposes a unified image generation surface that fronts multiple visual model providers. Every request uses a canonical model ID and a structuredinput payload that is validated against the model’s JSON schema before reaching the upstream provider. Responses share a consistent shape regardless of the backing service, making it easy to build tooling around job creation, polling, and history management.
Available endpoints
All authenticated endpoints accept API keys in
Authorization: Bearer or X-Api-Key headers via the shared authentication middleware. Requests are rejected with 403 Forbidden when the caller has less than 0.01 credits remaining.
List image models
Endpoint
Response
The endpoint returns aJSONResult envelope with a data array of model descriptors. TokenFlux caches the list for 24 hours in memory so you can safely cache it in clients as well. Each entry includes:
Create image generation
Endpoint
Request body
Invalid payloads return
400 Bad Request with a descriptive validation error message.
Response
The endpoint returns the newly created job wrapped in aJSONResult. The status is usually starting immediately after creation. Use the job id to poll until the status becomes succeeded or failed.
Get a generation
Endpoint
Behavior
- Looks up the generation in the database and, if the job is still
startingorprocessing, refreshes the status and image list by querying the upstream provider. - Persists provider responses (including image URLs and costs) before returning the unified
datapayload.
Response
Status values
List recent generations
Endpoint
Response
Returns up to 100 successful generations for the authenticated user ordered bycreated_at DESC. In-progress or failed jobs are excluded from this list. Use the individual GET /{id} endpoint to inspect pending jobs.
Data model
Each response’sdata field conforms to the following structure.
Image objects provide:
Error handling
Usage tips
- TokenFlux stores every request’s original input and provider response, so you can safely replay generations or audit output costs later.
- The optional
webhookURL is persisted and ready for future asynchronous callback support. Until then, pollGET /v1/images/generations/{id}for job completion. - Pair this API with the Chat Completions API to build multimodal assistants that mix text and image generation.