X-Request-Id header, and returns only the information you need to
debug your request.
OpenAI — /v1/chat/completions (and image/video endpoints)
Anthropic — /v1/messages
Gemini — /v1beta/models/{model}:generateContent
Status mapping
The errortype / status is derived from the HTTP status:
Model parameter rejections
When a model does not accept a value in your request, the endpoint returns HTTP400 with the model’s own explanation. Reasoning settings use the code invalid_reasoning_effort, and the message lists the values that model accepts, so the request can be corrected without guessing. Each model’s accepted reasoning levels, its default and whether reasoning can be disabled are published in GET /v1/models under capability_metadata.reasoning.
Rate limiting returns 429, and a request that exceeds the time budget returns 504. A 502 means the platform could not obtain a usable answer from the model after retrying — it is not a verdict on your parameters, so read the response body before changing them.
Media generation errors and retries
For image and video generation, use the structurederror.code and the task’s
status (task.status in your client) to decide what to display and whether to retry.
Only suggest content changes for an explicit policy code or a clear content-policy
refusal. A message merely mentioning
safety, or HTTP 502 alone, is not evidence
of a policy violation. If an asynchronous task is still pending or processing,
continue querying /v1/tasks/{task_id} with the same task_id; do not submit a
duplicate generation request.
Minor-sensitive media prompts
Image and video requests are rejected with HTTP400 and code
content_policy when a prompt clearly combines a minor with exposure or
emphasis of sensitive body areas, or with explicit sexual or nudity content.
This check happens before task creation and credit reservation, so no credits
are charged.