Skip to main content

Overview

Qwen 2 Image is an asynchronous text-to-image API. It supports standard and pro generation modes, multiple aspect ratios, prompt extension, optional negative prompts, and up to 6 images per task.
CapabilityValue
Model IDqwen-2-image
Modestext-to-image, text-to-image-pro
Default modetext-to-image
Prompt length1-800 characters
Negative promptOptional, up to 500 characters
Images per tasknum_images defaults to 1; range 1-6
Aspect ratios1:1, 3:4, 4:3, 9:16, 16:9
Prompt extensionprompt_extend, default true
Watermarkwatermark, default false

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/qwen-2-imageSubmit a text-to-image task
GET/statusTask/qwen-2-image?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

curl -X POST "https://api.apixo.ai/api/v1/generateTask/qwen-2-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image-pro",
      "prompt": "a premium poster for a bookstore event, crisp typography, elegant layout",
      "negative_prompt": "blurry text, distorted letters, low resolution",
      "aspect_ratio": "16:9",
      "num_images": 2,
      "prompt_extend": true,
      "watermark": false
    }
  }'
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/qwen-2-image?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Success response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/image.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Parse resultJson after state becomes success:
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;

Request body

Standard text-to-image

{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a minimalist product poster for wireless earbuds, clean layout",
    "aspect_ratio": "4:3",
    "num_images": 1,
    "prompt_extend": true,
    "watermark": false
  }
}

Pro text-to-image

{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "text-to-image-pro",
    "prompt": "a high-end brand key visual with readable headline text and premium lighting",
    "negative_prompt": "blurred typography, misspelled words, jagged edges",
    "aspect_ratio": "9:16",
    "num_images": 2,
    "seed": 123456
  }
}

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 callback URL that can receive the final task payload. See Webhooks.
input
object
required
Qwen 2 Image input parameters.

Response format

Submit task response

POST /generateTask/qwen-2-image 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 generated image URLs in resultUrls. 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 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/qwen-2-image" \
  -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": "text-to-image-pro",
      "prompt": "a premium campaign poster with readable headline text",
      "aspect_ratio": "16:9",
      "num_images": 1
    }
  }'
See Webhooks for delivery requirements and retry behavior.

Billing

Qwen 2 Image is billed per generated image.
ModeAPIXO price
text-to-image$0.03 / image
text-to-image-pro$0.07 / image
Billing behavior:
precharge = requested_num_images * unit_price_for_mode
final_charge = successful_images * unit_price_for_mode
refund = precharge - final_charge (if partial failure)
For current route and market comparison pricing, see Pricing.

Latency and polling

Qwen 2 Image tasks are asynchronous. Actual latency varies by prompt complexity, requested image count, and queue load.
Use caseRecommended first pollPoll interval
Standard generation10s after task creation5s-10s
Pro mode or multiple images10s-15s after task creation5s-10s
For production queues or batches, 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, parameter type, or valueFix 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
404Task not foundVerify the taskId and model ID
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server or unmapped model errorRetry with backoff
502Model service errorRetry with backoff
504Model service timeoutRetry or use callback mode for long-running jobs

Request validation

ConditionBackend behavior
Invalid modeReturns Invalid mode type. Supported: text-to-image, text-to-image-pro
Missing or empty promptReturns a missing-parameter or validation error
Prompt exceeds 800 charactersReturns a length error
Invalid num_imagesReturns The parameter {{num_images}} must be between 1 and 6.
Invalid aspect_ratioReturns the supported aspect-ratio list
Invalid prompt_extend or watermarkReturns a boolean type error
Invalid seedReturns the supported seed range
See Error Codes for the full error reference.