Flux Kontext
Context-aware image generation with style transfer and content understanding
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/generateTask/flux-kontext | Create generation task |
| GET | /api/v1/statusTask/flux-kontext | Query task status |
Authentication
All requests require an API Key in the header:
Request Body
Parameters
Parameter
Required
Default
Description
request_typestring—
asyncasync (polling) or callback (webhook)
callback_urlstring✱
—
Callback URL, required when request_type=callback
providerstring—
autoRouting strategy: auto, value, or official
inputobject✓
—
Model input parameters
Mode Options:
pro— Higher quality, slower generationmax— Balanced quality and speed
Example
Text-to-Image
Image-to-Image (Style Transfer)
Response
POST /api/v1/generateTask/flux-kontext
Returns taskId on success for subsequent status queries.
Success:
Error:
GET /api/v1/statusTask/flux-kontext
Query task execution status and results via taskId.
Success:
Failed:
Status Response Fields
| Field | Type | Description |
|---|---|---|
taskId | string | Unique task identifier |
state | string | pending processing success failed |
resultJson | string | JSON containing resultUrls array (on success) |
failCode | string | Error code (on failure) |
failMsg | string | Error message (on failure) |
createTime | integer | Task creation timestamp (ms) |
completeTime | integer | Task completion timestamp (ms) |
costTime | integer | Processing duration (ms) |
Error Codes
| Code | Description |
|---|---|
| 400 | Invalid parameters or request error |
| 401 | Invalid or missing API Key |
| 429 | Rate limit exceeded |
| Fail Code | Description |
|---|---|
CONTENT_VIOLATION | Content violates safety guidelines |
INVALID_IMAGE_URL | Cannot access provided image URL |
Rate Limits
| Limit | Value |
|---|---|
| Requests | 10000 / minute |
| Concurrent tasks | 1000 |
Exceeding limits returns 429 error. Wait and retry.
Tips
- Generation time: Average ~30 seconds. Submit task, wait 20 seconds, then poll every 3 seconds.
- Callback mode: For high-concurrency scenarios, use
callbackmode to avoid frequent polling. - Image expiration: Result URLs are valid for 15 days. Download and store important outputs promptly.
- Content moderation: Prompts must comply with content safety guidelines. Violations return
CONTENT_VIOLATION. - Reference images:
image_urlssupports JPG, PNG, WebP formats, max 10MB per image. - Context understanding: Kontext mode excels at understanding reference image style and composition.
- Mode selection:
promode offers higher quality but slower speed;maxbalances quality and speed.