Error Handling Reference
Understand, catch, and gracefully recover from API errors. Built for resilience at scale.
HTTP Status Codes
400 Bad Request
Malformed syntax, invalid parameters, or missing required fields. Check payload structure.
401 Unauthorized
Missing or invalid API key. Verify your authentication header: `Authorization: Bearer <key>`.
429 Rate Limited
Too many requests. Implement exponential backoff. Check `Retry-After` header.
500 Server Error
Unexpected internal failure. Our systems self-heal. Retry with jitter after 5-15s.
503 Service Unavailable
Model overload or scheduled maintenance. Monitor status page before retrying.
200 Success
Request processed successfully. Response body contains model output & metadata.
Implementation Examples
Live Error Simulator
Test how your implementation handles common failure scenarios.
Best Practices
Implement Retry with Jitter
Never retry immediately. Use exponential backoff + random jitter to prevent thundering herd effects.
Circuit Breakers
Wrap API calls in circuit breaker patterns. Fail fast when downstream models are degraded.
Idempotent Requests
Use idempotency keys for write operations. Prevents duplicate charges or state corruption on retries.
Structured Logging
Log error codes, request IDs, and payloads. NexusAI includes `x-request-id` for trace correlation.