Model Ladder
The Model Ladder lets you pass a chain of models with per-model retry counts in a single model field. The worker walks the rungs in order: each rung gets up to N attempts, and the first real image wins. You never ship a blank result.
Why it exists
GPT Image 2 frequently refuses requests on content policy grounds. Without the ladder you would have to catch the refusal, pick a fallback model, retry — all in your code. With the ladder you express the entire strategy as one string:
"model": "gpt_image_2:5,nano_banana_pro:3,nano_banana_2:3"
Competitors (Replicate, fal, etc.) make you orchestrate retries and cross-model fallback yourself. Here it is one API field.
Spec syntax
<model_slug>:<attempts>[,<model_slug>:<attempts>...]
model_slug— a known model identifier (e.g.gpt_image_2,nano_banana_pro,nano_banana_2,nano_banana).attempts— how many times to try this model before advancing to the next rung (1–10; excess is clamped).- A bare slug with no
:or,is treated as a single attempt — fully backwards-compatible. - Max 10 attempts per rung, max 30 total across all rungs (excess truncated silently).
Worked example
curl -s https://nokai.studio/api/v1/jobs/createTask \
-H "Authorization: Bearer $NOKAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt_image_2:5,nano_banana_pro:3,nano_banana_2:3",
"input": {
"prompt": "a lighthouse at dusk, 35mm film",
"aspect_ratio": "3:2"
}
}'The worker will:
- Try GPT Image 2 up to 5 times. First successful image → done.
- If all 5 attempts fail or are refused, try Nano Banana Pro up to 3 times.
- If those 3 also fail, try Nano Banana 2 up to 3 times.
- If all rungs are exhausted, the job is marked
failed.
How billing works
You are billed once — for the winning attempt only. Failed and refused attempts cost nothing. The winning attempt is billed at that model's rate.
If the entire ladder is exhausted with no image, you are not charged.
Attempt log
Every attempt is recorded in the job's recordInfo response under attempts:
{
"taskId": "...",
"state": "success",
"attempts": [
{ "model": "gpt_image_2", "attempt": 1, "state": "refused", "failCode": "CONTENT_POLICY" },
{ "model": "gpt_image_2", "attempt": 2, "state": "refused", "failCode": "CONTENT_POLICY" },
{ "model": "nano_banana_pro", "attempt": 3, "state": "success" }
]
}Use this to debug why a particular rung was skipped, or to tune your retry counts.
Caps
| Limit | Value |
|---|---|
| Max attempts per rung | 10 |
| Max total attempts across all rungs | 30 |
| Behavior when exceeded | Excess attempts truncated silently |
Polling for the result
curl -s "https://nokai.studio/api/v1/jobs/recordInfo?taskId=<id>" \
-H "Authorization: Bearer $NOKAI_KEY"Poll until state is "success" or "failed". See Jobs for the full state machine and Webhooks to receive completion events without polling.