Skip to content

Errors

All error responses use a consistent shape:

{
"error": {
"message": "Invalid API key",
"type": "auth_error"
}
}

Some errors — most notably wrong endpoint × model mismatches — include an optional details object. Existing integrations keep working off error.message and error.type; the details object is a backward-compatible addition.

{
"error": {
"message": "The model \"google/gemini-3.1-flash-image\" does not support /v1/images/edits. Use /v1/images/generations instead. For image-to-image, try-on or image merging, send reference images via the 'file_ids' field (after uploading them through /v1/files), or via 'image_urls' for hosted URLs.",
"type": "unsupported_operation",
"details": {
"param": "model",
"model": "google/gemini-3.1-flash-image",
"attempted_endpoint": "/v1/images/edits",
"supported_endpoints": ["/v1/images/generations"],
"suggested_endpoint": "/v1/images/generations",
"hint": "For image-to-image, try-on or image merging, send reference images via the 'file_ids' field (after uploading them through /v1/files), or via 'image_urls' for hosted URLs.",
"docs_url": "https://llmtr.com/docs/gateway/image-generation/"
}
}
}

Fields inside details:

FieldDescription
paramThe offending request field (usually model)
modelCanonical model ID from the request
attempted_endpointEndpoint the request was sent to
supported_endpointsEndpoints this model actually supports
suggested_endpointClosest correct endpoint to retry against
hintProvider- and model-specific actionable note (e.g. use file_ids)
docs_urlDocumentation pointer for the relevant guide

Retired model identifiers return HTTP 410 with replacement details:

{
"error": {
"message": "Model \"mimo/mimo-v2-pro\" was retired on 2026-06-30. Use \"mimo/mimo-v2.5-pro\" instead.",
"type": "model_retired",
"details": {
"model": "mimo/mimo-v2-pro",
"replacement_model": "mimo/mimo-v2.5-pro",
"retirement_date": "2026-06-30"
}
}
}
HTTPtypeReasonWhat to do
400invalid_request_errorInvalid JSON, missing field, unknown parameterFix the request and check the schema
401auth_errorInvalid or revoked keyGenerate a new key in the dashboard
402insufficient_balanceCredit balance is too lowTop up from Dashboard > Billing
403forbiddenThe model is not available for this accountVerify model access
404model_not_foundUnknown model valueCheck the canonical ID (provider/model)
410model_retiredModel identifier has been retiredSwitch to error.details.replacement_model
413request_too_largeContext window exceededShorten the messages content
429rate_limit_exceededRate limit hitRetry with exponential backoff
500internal_errorGateway internal errorRetry after a short delay
502provider_errorProvider-side failureOften transient, retry
503provider_unavailableProvider unreachableRetry later
504timeoutRequest timed outRequest fewer tokens or try streaming
Retry only for 429, 500, 502, 503, 504.
Backoff: exponential + jitter.
Max retry: 3.

Example (Python):

import time, random
from openai import OpenAI, APIStatusError
RETRIABLE = {429, 500, 502, 503, 504}
def call(client, payload, attempt=0):
try:
return client.chat.completions.create(**payload)
except APIStatusError as e:
if e.status_code in RETRIABLE and attempt < 3:
time.sleep(2 ** attempt + random.random())
return call(client, payload, attempt + 1)
raise

When implementing retries, also account for client-side timeouts, broken connections, and duplicate sends.