Overview
All Nadoo AI API responses follow a consistent envelope format. When an error occurs, the response includes anull data field, an "error" status, the HTTP status code, and a human-readable message describing what went wrong. This predictable structure makes it straightforward to implement centralized error handling in your client.
Error Response Format
Every error response uses this standard structure:| Field | Type | Description |
|---|---|---|
data | null | Always null for error responses |
status | string | Always "error" for error responses |
code | integer | The HTTP status code |
message | string | A human-readable description of the error |
HTTP Status Codes
Client Errors (4xx)
400 Bad Request
400 Bad Request
The request body or query parameters are invalid. This typically means a required field is missing, a value has the wrong type, or a validation rule was violated.Common causes:
- Missing required fields in the request body
- Invalid JSON syntax
- Field value outside allowed range (e.g.,
temperature> 2.0) - Invalid UUID format for resource IDs
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
The authenticated user does not have permission to perform the requested action on the target resource.Common causes:
- Attempting to modify a resource in a workspace where you have a read-only role
- Accessing an application that belongs to a different workspace
- API key scoped to a workspace that does not own the resource
- Public API access disabled for the workspace
404 Not Found
404 Not Found
The requested resource does not exist or has been deleted.Common causes:
- Incorrect resource ID
- Resource was deleted
- Resource belongs to a different workspace
409 Conflict
409 Conflict
The request conflicts with the current state of the resource.Common causes:
- Duplicate resource name within a workspace
- Email address already registered
- Concurrent modification conflict
413 Payload Too Large
413 Payload Too Large
The uploaded file or request body exceeds the maximum allowed size.Configuration: The maximum upload size is controlled by the
NADOO_MAX_UPLOAD_SIZE environment variable (default: 100 MB).422 Unprocessable Entity
422 Unprocessable Entity
The request body is syntactically valid JSON but fails semantic validation. This is FastAPI’s default for Pydantic validation errors.Common causes:
- Field value violates a Pydantic validation rule
- Enum value not in the allowed set
- Nested object fails schema validation
429 Too Many Requests
429 Too Many Requests
The rate limit has been exceeded. The response includes a Rate limits:
Retry-After header indicating how many seconds to wait.| Scope | Limit |
|---|---|
| IP-based | 300 requests/min |
| User-based (authenticated) | 600 requests/min |
Server Errors (5xx)
500 Internal Server Error
500 Internal Server Error
An unexpected error occurred on the server. These errors are logged with a request ID for troubleshooting.What to do:
- Retry the request after a short delay
- If the error persists, contact support with the request ID
- Check the system health endpoint to verify service status
502 Bad Gateway
502 Bad Gateway
The server received an invalid response from an upstream service, typically an AI model provider.Common causes:
- AI provider (OpenAI, Anthropic, etc.) is temporarily unavailable
- Invalid API key configured for the model provider
- Network connectivity issue between Nadoo AI and the provider
503 Service Unavailable
503 Service Unavailable
504 Gateway Timeout
504 Gateway Timeout
The request timed out while waiting for an upstream service (e.g., an LLM call or document processing job).Common causes:
- Large prompt or high
max_tokensvalue causing slow LLM response - Document processing exceeding the timeout limit
- Network latency to the AI provider
Streaming Error Events
When an error occurs during SSE or WebSocket streaming, the error is delivered as an event within the stream rather than as an HTTP error response.SSE Error Event
WebSocket Error Message
Streaming Error Codes
| Code | Description |
|---|---|
rate_limit | The AI provider’s rate limit was exceeded |
context_overflow | The input exceeded the model’s context window |
tool_error | A tool invocation failed during agent execution |
timeout | The request or LLM call timed out |
provider_error | The AI provider returned an unexpected error |
auth_error | Authentication or authorization failure mid-stream |
Streaming errors do not close the connection by default. The server may attempt automatic retries (with exponential backoff) before emitting a terminal error event. Monitor the
error event and decide whether to retry or surface the error to the user.Error Handling Best Practices
Implement centralized error handling
Implement centralized error handling
Wrap all API calls in a shared error handler that inspects the
status and code fields. This avoids duplicating error logic across your application.Handle token expiration gracefully
Handle token expiration gracefully
JWT access tokens expire after a configurable period (default: 24 hours). When you receive a
401 response, attempt to refresh the token before prompting the user to log in again.Respect rate limits with backoff
Respect rate limits with backoff
When you receive a
429 response, read the Retry-After header and wait the specified number of seconds before retrying. For burst workloads, implement a token bucket or leaky bucket pattern on the client side to stay under the limit proactively.| Scope | Limit | Strategy |
|---|---|---|
| IP-based | 300 req/min | Throttle unauthenticated requests |
| User-based | 600 req/min | Queue and batch API calls |
Use request IDs for debugging
Use request IDs for debugging
Server error responses (
5xx) include a request ID in the message. Save this ID when logging errors on the client side, and provide it when contacting support. This allows the team to trace the exact request through server logs.Validate before sending
Validate before sending
Reduce
400 and 422 errors by validating inputs on the client side before sending the request. Match the server’s validation rules:temperature: 0.0 to 2.0max_tokens: positive integer- Resource IDs: valid UUID v4 format
- File uploads: check size and extension against allowed values
Handle streaming errors differently
Handle streaming errors differently
SSE and WebSocket errors arrive as in-stream events, not HTTP status codes. Register handlers for the
error event type in both SSE (EventSource) and WebSocket (onmessage) listeners. Decide based on the error code whether to retry, reconnect, or surface the error.