Overview
NanoGPT APIs return standard HTTP status codes. Many endpoints also follow OpenAI- or Anthropic-compatible error shapes so you can reuse existing SDK error handling. If you contact support about an API error, include theX-Request-ID response header (when present).
Error Response Formats
NanoGPT has a few common error envelopes depending on the API surface.OpenAI-compatible (most /api/v1/* endpoints)
Used by endpoints like:
POST /api/v1/chat/completionsPOST /api/v1/responsesPOST /api/v1/embeddingsGET /api/v1/models
error.message: human-readableerror.type: high-level category (see Error Types)error.code: optional machine-readable code (see Error Codes)error.param: optional name of the request field that caused the error
Anthropic-compatible (POST /api/v1/messages)
The Messages API uses the Anthropic-style wrapper:
Legacy / simple format (some /api/* endpoints)
Some older endpoints return a simpler body:
requiredBalance on 402).
Status Codes
This table covers the most common HTTP error statuses you may encounter.| Status | Meaning | Typical client action |
|---|---|---|
400 | Invalid request / validation failed | Fix the request, then retry |
401 | Missing/invalid API key | Do not retry until credentials are fixed |
402 | Insufficient balance | Add funds or disable paid enhancements, then retry |
403 | Authenticated but not permitted | Choose an allowed model/feature or change permissions |
404 | Resource not found | Check the model/resource ID |
408 / 504 | Timeout | Retry with backoff |
409 | Conflict | Resolve state (duplicate/redeemed/already processed) |
413 | Payload too large | Reduce payload size and retry |
429 | Rate limited | Wait (use Retry-After if present), then retry |
500 | Server error | Retry with backoff |
503 | Temporarily unavailable | Retry with backoff; consider changing model if persistent |
- Some endpoints include convenience fields like
statusin the JSON body mirroring the HTTP status code. - Some error responses include
Retry-After(seconds) for429.
Error Types
Depending on the endpoint, you may see different type strings. Common values include:invalid_request_error(400)authentication_error(401)permission_denied_errororpermission_error(403)not_found_error(404)rate_limit_error(429)server_error,service_unavailable, orapi_error(500/503)
Error Codes
Not every error includes acode. When present, codes are useful for programmatic handling.
Common codes include:
Request validation
missing_required_parameterinvalid_parameter_valueinvalid_jsoninvalid_json_schematool_choice_unsupportedimage_input_not_supported
Content and context
content_policy_violationcontext_length_exceededempty_response
Model and routing
model_not_foundmodel_not_allowedmodel_not_availableall_fallbacks_failedno_fallback_availablefallback_blocked_for_cache_consistency
Balance and payment
memory_balance_requiredwebSearch_balance_requiredboth_balance_required
Rate limiting
rate_limit_exceeded
Streaming Errors
When using Server-Sent Events ("stream": true), errors can happen:
- Before streaming begins (you get a normal JSON error response with an HTTP status code)
- Mid-stream (you may receive an error frame/chunk, or the connection may terminate)
- Surface/log the error message
- Log the
X-Request-IDheader if available - Retry only when the status/category indicates it is safe to retry (for example 408/429/500/503)
Retry Guidance
General retry recommendations:- Retry:
408,429,500,503(use exponential backoff and respectRetry-After) - Do not blindly retry:
400,401,402,403,404,409,413
Balance Errors (402)
Some endpoints return402 Payment Required when your account balance is insufficient. These responses often include a requiredBalance field.
Example:
code such as memory_balance_required or webSearch_balance_required.
Content Policy and Empty Responses
- If a request is blocked by safety checks (
content_policy_violation), the API will return a400error and is intended to avoid charging for the blocked request. - If the API returns
empty_response, the request is intended to avoid charging (common causes: stop sequences, very lowmax_tokens, or filtering).