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 2 is a Black Forest Labs image model for high-quality text-to-image generation and reference-guided image editing. Use this page when you are ready to call the API after trying Flux 2 in the APIXO playground.
CapabilityValue
Model IDflux-2
Modespro-text-to-image, pro-image-to-image, flex-text-to-image, flex-image-to-image
Prompt length3-5000 characters
Reference images1-8 URLs for image-to-image modes
Aspect ratios1:1, 4:3, 3:4, 3:2, 2:3, 16:9, 9:16, auto
Resolution tiers1K, 2K

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/flux-2Submit a generation task
GET/statusTask/flux-2?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-2" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "pro-text-to-image",
      "prompt": "a cozy cyberpunk cafe with neon signs and rain on the windows",
      "aspect_ratio": "16:9",
      "resolution": "1K"
    }
  }'
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-2?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
  }
}
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-text-to-image",
    "prompt": "a minimal poster for a jazz night, with crisp readable typography",
    "aspect_ratio": "3:4",
    "resolution": "1K"
  }
}

Image-to-image

{
  "request_type": "async",
  "input": {
    "mode": "flex-image-to-image",
    "prompt": "turn this product photo into a polished studio campaign image",
    "image_urls": [
      "https://example.com/source.png"
    ],
    "aspect_ratio": "1:1",
    "resolution": "2K"
  }
}

Parameters

request_type
string
default:"async"
required
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 2 input parameters.

Mode options

ModeUse case
pro-text-to-imagePro text-to-image generation
pro-image-to-imagePro image-to-image editing with reference images
flex-text-to-imageFlex text-to-image generation
flex-image-to-imageFlex image-to-image editing with reference images

Response format

Submit task response

POST /generateTask/flux-2 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: 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 successful completion.

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-2" \
  -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-text-to-image",
      "prompt": "a premium coffee bag label with exact readable brand typography",
      "aspect_ratio": "1:1",
      "resolution": "2K"
    }
  }'
See Webhooks for delivery requirements and retry behavior.

Billing

Flux 2 is billed per generated image. The selected mode tier and resolution determine the unit price.
Mode tierResolutionAPIXO Value priceOfficial priceMarket price
pro-*1K$0.035 / image$0.045 / image$0.045 / image
pro-*2K$0.05 / image$0.07 / image$0.07 / image
flex-*1K$0.10 / image$0.12 / image$0.12 / image
flex-*2K$0.16 / image$0.22 / image$0.22 / image
For current route and market comparison pricing, see Pricing.

Latency and polling

Actual latency may vary by prompt complexity, reference image count, provider route, and current queue load.
Typical generation timeRecommended first pollPoll interval
About 30 seconds20 seconds after task creation3-10 seconds
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, prompt length issue, or inaccessible 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 model, or provider rejected the contentCheck permissions and adjust the prompt or images
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server error or unknown upstream failureRetry with backoff
502Upstream provider errorRetry with backoff
504Upstream timeoutRetry or use callback mode for long-running jobs

Task failure codes

Fail codeMeaningWhat to do
SensitiveContentPrompt, input image, or output was flagged by provider safety checksChange the prompt or reference image
ProhibitedContentDetectedProvider rejected the task for prohibited contentAdjust the prompt or input image
ImageNotAccessA reference image URL could not be fetchedUse a public, direct image URL
PromptInvalidPrompt was invalid or rejected by the providerRewrite the prompt
MissingParameterOne or more required parameters were missingCheck mode, prompt, aspect_ratio, resolution, and image_urls
RateLimitedProvider or account rate limit was reachedRetry with backoff
TimeoutProvider timed outRetry, reduce input complexity, or use callback mode
Unknown errorUpstream failure did not match a known error ruleRetry with backoff or contact support if it persists
See Error Codes for the full error reference.