Automatically fall back to the next model in a list when the primary is unavailable or errors.
Model fallbacks let you pass an ordered models array (up to 4 slugs) instead of a single model string. If the first model errors or is unavailable, OpenDunes retries the request with the next model in the list — transparently, with no extra code on your side.
Replace the "model" field with a "models" array of up to 4 entries. Each entry is a standard provider/model slug. OpenDunes tries them in order until one succeeds.
The response is identical to a normal chat completion — the model field in the response body tells you which model actually answered.
OpenDunes triggers a fallback on the following conditions:
| Condition | Triggers fallback? |
|---|---|
Model temporarily unavailable (503) | Yes |
Provider timeout (504) | Yes |
Model not found or inactive (404) | Yes |
Insufficient credits (402) | No — top up your balance |
Invalid request (400) | No — fix the request |
| Successful response | No — stops at first success |
If every model in the list fails, OpenDunes returns the error from the last attempt with the standard error shape.
Fallbacks work with streaming ("stream": true). If the primary model starts streaming and then drops the connection mid-response, OpenDunes does not restart from the fallback — a partial stream is returned as-is. Fallbacks only activate before the first token is sent.
The X-Request-Id header in the response always reflects the final successful attempt. If you need to know which model answered, read the model field in the response JSON.
Each attempt is billed independently at that model's DA rate — only the attempt that returns a response is charged. Attempts that fail before any tokens are generated cost nothing.
Check per-model DA rates (input/output per million tokens) at GET /api/models/{slug} or in the model catalog.
The OpenAI SDK sends whichever value you pass as model. To use fallbacks, pass the models array as an extra body field using the SDK's extra_body / extra_headers escape hatch.
Note. When
modelsis present, anymodelfield in the same request is ignored. Themodelfield in the response always reflects which model actually handled the request.