Query the status and results of a generation task.
Endpoint
GET https://api.apixo.ai/api/v1/statusTask/{model}?taskId={taskId}
Parameters
Model ID used when the task was submitted (e.g., nano-banana, flux-2).
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
| State | Description |
|---|
pending | Task received, waiting to be processed |
processing | Task is being processed by the AI model |
success | Generation completed successfully |
failed | Generation failed (see error details) |
Response Fields
Current task state: pending, processing, success, or failed.
JSON string containing resultUrls array. Only present when state is success. Parse with JSON.parse().
Processing time in milliseconds. Only present on completion.
Task creation timestamp (Unix milliseconds).
Task completion timestamp (Unix milliseconds). Only present on completion.
Error code. Only present when state is failed.
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"
const response = await fetch(
'https://api.apixo.ai/api/v1/statusTask/nano-banana?taskId=task_abc123',
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
}
);
const { data } = await response.json();
if (data.state === 'success') {
const urls = JSON.parse(data.resultJson).resultUrls;
console.log('Generated:', urls);
}
import json
response = requests.get(
'https://api.apixo.ai/api/v1/statusTask/nano-banana',
params={'taskId': 'task_abc123'},
headers={'Authorization': 'Bearer YOUR_API_KEY'},
)
data = response.json()['data']
if data['state'] == 'success':
urls = json.loads(data['resultJson'])['resultUrls']
print(f'Generated: {urls}')
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');
}
import time
import json
def wait_for_result(model: str, task_id: str, api_key: str) -> list[str]:
max_attempts = 60
poll_interval = 3 # seconds
for _ in range(max_attempts):
response = requests.get(
f'https://api.apixo.ai/api/v1/statusTask/{model}',
params={'taskId': task_id},
headers={'Authorization': f'Bearer {api_key}'},
)
data = response.json()['data']
if data['state'] == 'success':
return json.loads(data['resultJson'])['resultUrls']
elif data['state'] == 'failed':
raise Exception(f"{data['failCode']}: {data['failMsg']}")
time.sleep(poll_interval)
raise Exception('Timeout waiting for result')
Error Responses
| Code | Description |
|---|
401 | Invalid or missing API key |
404 | Task not found |
429 | Rate limit exceeded |
See Errors for detailed error handling.