Build and test KusArt generation APIs in one place
Review the supported B2B task interfaces, required parameters, response envelopes, curl examples, billing behavior, polling, and webhook delivery flow.
Authentication
All B2B routes use the X-API-Key header. Firebase web tokens are not required for these routes.
Billing
Legacy keys with billing_account_id use that dedicated credit account. New user-scoped keys freeze from the user credit pool.
Response envelope
Business responses use code/message/data. Business errors may still return HTTP 200.
End-to-end call flow
How task-create, credit freezing, polling, results, and webhook callbacks fit together.
Create
Partner sends X-API-Key plus task parameters to a B2B create endpoint.
Authenticate
Backend validates the API key and attaches the owning user plus optional billing account.
Freeze credits
Worker calculates cost and freezes credits from the dedicated account or user credit pool.
Execute
The selected worker calls internal or external generation capability and stores task output.
Get result
Partner polls /tasks/get or /tasks/get_result until the task is completed or failed.
Webhook
If webhook_url is supported and provided, backend POSTs the final task payload and settles credits.
X-API-Key: ak_xxx{
"code": 0,
"message": "Success",
"data": {
"task_id": "00000000-0000-0000-0000-000000000000",
"status": "PENDING",
"queue_position": 2,
"generation_params": {
"prompt": "anime engineer debugging an API dashboard",
"watermark": false
}
}
}{
"code": 0,
"message": "Success",
"data": {
"task_id": "00000000-0000-0000-0000-000000000000",
"task_type": "API_TEXT_TO_IMAGE_GPT_IMAGE_2",
"status": "COMPLETED",
"result": {
"images": [
{
"display_url": "https://cdn.kusa.pics/generated/example.png",
"width": 1024,
"height": 1024,
"index": 0
}
],
"image_count": 1
}
}
}{
"code": 0,
"data": {
"task_id": "00000000-0000-0000-0000-000000000000",
"status": "COMPLETED",
"result": {
"images": [
{
"display_url": "https://cdn.kusa.pics/generated/example.png",
"width": 1024,
"height": 1024,
"index": 0
}
]
}
}
}0Success
Request accepted or data returned successfully.
40000Invalid parameters
JSON body, task params, files, or URLs are invalid.
40100Unauthorized
Missing or invalid authentication context.
42002Insufficient balance
The API key or user does not have enough available credits to freeze the task cost.

