Skip to main content
Query the status and results of a generation task.

Endpoint

GET https://api.apixo.ai/api/v1/statusTask/{model}?taskId={taskId}

Parameters

model
string
required
Model ID used when the task was submitted (e.g., nano-banana, flux-2).
taskId
string
required
Task ID returned from the Generate Task endpoint.

Headers

Authorization
string
required
Bearer token for API authentication. Format: Bearer YOUR_API_KEY

Response

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://cdn.apixo.ai/output/abc123.jpg\"]}",
    "costTime": 12500,
    "createTime": 1704067200000,
    "completeTime": 1704067212500
  }
}

Task States

StateDescription
pendingTask received, waiting to be processed
processingTask is being processed by the AI model
successGeneration completed successfully
failedGeneration failed (see error details)

Response Fields

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing resultUrls array. Only present when state is success. Parse with JSON.parse().
costTime
integer
Processing time in milliseconds. Only present on completion.
createTime
integer
Task creation timestamp (Unix milliseconds).
completeTime
integer
Task completion timestamp (Unix milliseconds). Only present on completion.
failCode
string
Error code. Only present when state is failed.
failMsg
string
Human-readable error message. Only present when state is failed.

State-Specific Responses

Pending / Processing

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "processing",
    "createTime": 1704067200000
  }
}

Success

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://cdn.apixo.ai/output/abc123.jpg\"]}",
    "costTime": 12500,
    "createTime": 1704067200000,
    "completeTime": 1704067212500
  }
}
Parsing resultJson:
const result = JSON.parse(data.resultJson);
const urls = result.resultUrls; // Array of generated content URLs

Failed

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content violates usage policy",
    "createTime": 1704067200000,
    "completeTime": 1704067205000
  }
}
HTTP 200 with state: "failed" means the API request succeeded but the task itself failed. Check failCode and failMsg for the reason. See Errors for all failure codes.

Result URLs

The resultUrls array contains direct links to generated content:
{
  "resultUrls": [
    "https://cdn.apixo.ai/output/abc123.jpg",
    "https://cdn.apixo.ai/output/abc124.jpg"
  ]
}
Result URLs expire after 24 hours. Download and store important outputs promptly.

Examples

curl "https://api.apixo.ai/api/v1/statusTask/nano-banana?taskId=task_abc123" \
  -H "Authorization: Bearer YOUR_API_KEY"

Polling Example

async function waitForResult(model, taskId, apiKey) {
  const maxAttempts = 60;
  const pollInterval = 3000; // 3 seconds
  
  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch(
      `https://api.apixo.ai/api/v1/statusTask/${model}?taskId=${taskId}`,
      { headers: { 'Authorization': `Bearer ${apiKey}` } }
    );
    
    const { data } = await response.json();
    
    switch (data.state) {
      case 'success':
        return JSON.parse(data.resultJson).resultUrls;
      case 'failed':
        throw new Error(`${data.failCode}: ${data.failMsg}`);
      default:
        await new Promise(r => setTimeout(r, pollInterval));
    }
  }
  
  throw new Error('Timeout waiting for result');
}

Error Responses

CodeDescription
401Invalid or missing API key
404Task not found
429Rate limit exceeded
See Errors for detailed error handling.