Errors

Model endpoints return an error object plus a top-level trace_id; billing endpoints return only error.code and error.message. Include the trace_id (or the x-trace-id response header) when you contact us.

Error shape

Model endpoints:

json
{
  "error": {
    "message": "Missing auth credential. Provide x-api-key: sk-moyiapi-* or Authorization: Bearer <token>.",
    "type": "missing_auth_credential",
    "code": 401,
    "details": null
  },
  "trace_id": "4c9530c5-2bcc-472d-9c73-e07262bbbdb9"
}

Billing endpoints:

json
{
  "error": {"code": "invalid_request", "message": "request_id must be a valid UUID"}
}

Common codes

HTTP status error.type When it happens
401 missing_auth_credential No supported auth header was sent
401 invalid_api_key The key in x-api-key or x-goog-api-key is wrong, incomplete, or deleted
401 invalid_bearer_token The key in Authorization: Bearer is wrong, incomplete, or deleted
400 model_not_available The model ID does not exist or is temporarily unavailable; check GET /v1/models
400 model_not_supported The model cannot be called at the moment; switch models as the message suggests
400 invalid_request_error The request is invalid: model and protocol mismatch (such as calling Claude through the Responses API), an image sent to a text-only model, a malformed request, and so on; message explains which
402 or 400 insufficient_balance The account is out of credit. Anthropic native and Gemini native endpoints return 402; the OpenAI-compatible endpoints (/v1/chat/completions, /v1/responses) return 400. details.recharge_url is the top-up link

Billing endpoints additionally:

HTTP status error.code When it happens
400 invalid_request Invalid parameters, such as a bad time range or a non-UUID request_id
404 not_found The record does not exist or is not accessible
429 rate_limit_exceeded Too many requests; retry later
500 internal_error Internal error

Troubleshooting

  • On 400, read error.message first; it names the field or mismatch
  • 400 means the request itself is wrong, so do not retry blindly; retry 429 and 5xx with exponential backoff
  • Streaming errors differ before and after the stream starts; see Streaming
Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
Errors · Docs