Skip to main content

Documentation Index

Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Flux Kontext is a Black Forest Labs image model for prompt-based image generation and reference-guided image editing. Use this page when you are ready to call the API after trying the model in the APIXO playground.
CapabilityValue
Model IDflux-kontext
Modespro, max
Workflowstext-to-image, image-to-image
Prompt length1-10000 characters
Reference imagesOptional, 1 image URL
Aspect ratios1:1, 4:3, 3:4, 9:16, 16:9, 21:9
Output formatsjpeg, png

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/flux-kontextSubmit a generation task
GET/statusTask/flux-kontext?taskId={taskId}Poll task status and retrieve results
All requests require your APIXO API key:
Authorization: Bearer YOUR_API_KEY
Submit requests also require:
Content-Type: application/json

Copy-paste async quickstart

This minimal request submits a text-to-image task and returns a taskId.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-kontext" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "pro",
      "prompt": "a castle on a quiet hill at sunset",
      "aspect_ratio": "16:9",
      "output_format": "jpeg"
    }
  }'
Successful response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Save the taskId; you need it to poll for the final result.

Poll for result

curl -X GET "https://api.apixo.ai/api/v1/statusTask/flux-kontext?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Processing response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
Success response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/xxx.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Failed response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates provider policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
Parse resultJson after state becomes success:
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;

Request body

Text-to-image

{
  "request_type": "async",
  "input": {
    "mode": "pro",
    "prompt": "a quiet greenhouse filled with bioluminescent plants",
    "aspect_ratio": "16:9",
    "output_format": "jpeg"
  }
}

Image-to-image

{
  "request_type": "async",
  "input": {
    "mode": "max",
    "prompt": "turn this room into a warm mid-century interior",
    "aspect_ratio": "4:3",
    "image_urls": [
      "https://example.com/source.jpg"
    ],
    "output_format": "png",
    "promptUpsampling": false,
    "safetyTolerance": 2
  }
}

Parameters

request_type
string
default:"async"
Result delivery mode. Use async for polling with statusTask, or callback for webhook delivery.
callback_url
string
Required when request_type is callback. Must be a public HTTPS URL that can receive the final task payload. See Webhooks.
input
object
required
Flux Kontext input parameters.

Response format

Submit task response

POST /generateTask/flux-kontext returns a task ID when the task is accepted:
code
integer
API status code. 200 means the task was accepted.
message
string
Human-readable status message.
data.taskId
string
Unique task identifier used with the status endpoint.

Status response fields

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing the generated image URLs. Present when state is success.
failCode
string
Machine-readable failure code. Present when state is failed.
failMsg
string
Human-readable failure message. Present when state is failed.
createTime
integer
Task creation timestamp in Unix milliseconds.
completeTime
integer
Task completion timestamp in Unix milliseconds. Present after completion.
costTime
integer
Processing duration in milliseconds. Present after completion when available.

Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-kontext" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "pro",
      "prompt": "a clean product photo of a ceramic lamp on soft stone",
      "aspect_ratio": "1:1",
      "output_format": "jpeg"
    }
  }'
See Webhooks for delivery requirements and retry behavior.

Billing

Flux Kontext is billed per generated image. The selected mode determines the unit price.
ModeAPIXO priceMarket reference
pro$0.03 / image$0.04 / image
max$0.06 / image$0.08 / image
For current route and market comparison pricing, see Pricing.

Latency and polling

Actual latency may vary by prompt complexity, reference image accessibility, provider route, and current queue load.
ModeTypical generation timeRecommended first pollPoll interval
proAround 30s20s after task creation3s-5s
maxAround 30s or longer20s after task creation3s-5s
For high-concurrency production workloads, use callback mode to avoid frequent polling.
Rate limits and concurrency can vary by account, API key, and route. If you receive 429, slow down requests and retry with backoff. For account-level details, see System APIs.

Errors and troubleshooting

HTTP errors

CodeMeaningWhat to do
400Invalid request body, missing parameter, unsupported value, or unreachable image URLFix the request before retrying
401Missing or invalid API keyCheck the Authorization header
402Insufficient balance or quotaAdd balance or switch account/key
403Key or route cannot access the modelCheck permissions and route strategy
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server error or unmapped provider failureRetry with backoff
502Upstream provider errorRetry with backoff
504Upstream timeoutRetry or use callback mode for long-running jobs

Parameter validation

FieldRequirement
input.modeRequired. Must be pro or max.
input.promptRequired string. Must not be empty and cannot exceed 10000 characters.
input.aspect_ratioRequired. Must be 1:1, 4:3, 3:4, 9:16, 16:9, or 21:9.
input.image_urlsOptional array. If present, it cannot be empty and cannot contain more than 1 image URL.
input.output_formatOptional. Must be jpeg or png.
input.safetyToleranceOptional integer. Must be 0, 1, or 2.

Task failure codes

Fail codeMeaningWhat to do
ImageNotAccessA reference image URL could not be fetched or was not a public HTTP(S) URLUse a public, direct image URL
PromptInvalidPrompt was rejected or malformedChange the prompt and retry
SensitiveContentPrompt or reference image failed provider safety checksChange the prompt or input image
RateLimitedProvider-side rate limit reachedRetry with exponential backoff
TimeoutProvider-side timeoutRetry, reduce input complexity, or use callback mode
Unknown errorProvider returned an unmapped failureRetry with backoff or contact support with the taskId
See Error Codes for the full error reference.