API

API Troubleshooting

Handle API errors consistently and collect useful support information.

Error format

{
  "error": {
    "message": "The `model` field is required.",
    "type": "invalid_request_error",
    "code": "invalid_request_error"
  }
}
Status Typical code Action
400 invalid_request_error Fix the JSON, model, or messages.
401 invalid_api_key Supply a valid active API key.
403 account_suspended Check account status or the company seat.
404 model_not_found Refresh GET /models and use a public model ID.
409 idempotency_in_progress, idempotency_key_reused Do not run the logical request again. Reconcile the original request ID.
429 quota_exhausted or request throttling Honor Retry-After; inspect the quota reset time.
502 upstream_error Retry with backoff and the same idempotency key.
503 no_route_available, overloaded Retry briefly or select another capable public model.

Log useful fields

Log the HTTP status, error.type, error.code, public model ID, idempotency key, session ID, attempt number, latency, and X-Censi-Request-Id. Redact the bearer token, prompts, tool results, image URLs, and personal data unless your policy explicitly allows them.

For a streamed response, parse each event because an error can arrive inside an HTTP 200 stream.