200 text/event-stream; once streaming has started, later failures are delivered as Server-Sent Events instead of non-2xx HTTP responses.
For AI error objects, error.code is the numeric internal code, such as 2001, and error.name is the symbolic code, such as PROVIDER_TIMEOUT.
Quick Reference
HTTP Status Codes
Full table of every HTTP status returned by active endpoints.
Error Code Reference
Exact error codes from the API with resolution guidance.
AI Error Object
Field reference for enriched Completions errors.
Streaming Errors
How errors are delivered after an SSE stream has started.
Authentication Errors
401 and 403 errors — missing tokens, expired credentials, permission issues.
Rate Limiting
Spending limits, endpoint quotas, and streaming provider rate limits.
Endpoint-Specific Errors
Error details for Completions, Ingestion, Content Controls, and Search.
Best Practices
Patterns for reliable error handling across all endpoints.
HTTP Status Codes
Error Code Reference
AI Error Object
Completions errors include an enriched top-levelerror object. Use it for programmatic handling instead of parsing human-readable messages.
Hitting persistent inference issues? If model inference keeps failing —
for example a repeating
2013 / PROVIDER_INFERENCE_ERROR or 3001 / INTERNAL_ERROR — open a ticket with us at
hello@gloo.us and include the trace_id from the
error response. The trace_id lets us look up the exact request and resolve
the issue faster.Common Error Scenarios
Authentication Errors
These errors occur when there is an issue with your API key or the permissions associated with it.401 Unauthorized — Missing or Invalid API Key
Returned when theAuthorization header is missing from the request.
Authorization header is present but malformed or the API key is invalid, the gateway returns 403 with the forbidden code.
403 Forbidden — Insufficient Permissions
Returned when the request includes authorization, but the caller does not have permission for the requested resource or publisher, or the gateway rejects the authorization header.For the Ingestion API, a 403 most commonly means the
publisher_id doesn’t
belong to your organization, or the item you are referencing does not belong
to the specified publisher.Validation Errors (400 / 422)
These errors indicate a problem with the parameters or body of your request.400 Bad Request signals a structurally invalid request, while 422 Unprocessable Entity signals valid JSON that fails field-level validation.
Missing Required Field
Returned when a required body field is absent. Example:model is required when specifying direct model routing for Completions V2.
Invalid Routing Configuration
Completions V2 returns this as400 when more than one — or no — routing mechanism is specified.
Invalid Data Type
Returned when a field receives a value of the wrong type. Example:certainty expects a float.
Resource Not Found (404)
Returned when the requested item does not exist or has been permanently deleted.Publisher not found and invalid collection cases return
400, not 404. See
Ingestion and Search &
Recommendations for these examples.Duplicate Upload Results
Duplicate Content (Ingestion)
When files are submitted that were already ingested, the API returns200 OK with a duplicates array in the response body — this is not an HTTP error.
Duplicates are returned in the response body, not as a
409 Conflict error.Rate Limiting (429)
An HTTP429 can represent a Completions spending limit or an endpoint-specific request quota. These conditions do not share one response format or retry policy.
For Completions endpoints, a spending-limit response has the following shape:
SPENDING_LIMIT_EXCEEDED is not retryable and does not include Retry-After. Retry only after the account’s spending-limit condition is resolved.
Endpoint-specific quotas can also return HTTP 429. Their error bodies and headers vary by endpoint. Honor Retry-After when it is present; do not assume that every response includes X-RateLimit-Limit, X-RateLimit-Remaining, or X-RateLimit-Reset.
An upstream provider rate limit that occurs after a Completions stream starts is not an HTTP 429. It is delivered inside the HTTP 200 stream as a 2004 / RATE_LIMIT SSE error event. Use error.retryable to decide whether to retry.
See Rate Limits for response-specific retry
guidance and pseudocode.
Server Errors (5xx)
500 Internal Server Error
An unexpected error occurred on the Gloo platform or during model inference. Retry with exponential backoff.502 Bad Gateway
Returned by Content Controls endpoints when a vector-store update fails in the underlying data store.503 Service Unavailable
The upstream provider or backing service is temporarily unavailable. Retry with exponential backoff.Streaming Errors
Whenstream=true on Completions endpoints, the response starts as 200 text/event-stream. After the SSE headers have been sent, the API cannot change the HTTP status code. Stream-time failures are therefore sent as SSE events.
A stream error event has choices[0].finish_reason set to "error" and includes the same enriched top-level error object used by non-streaming Completions errors.
5xx, provider bad request, provider auth failure, routing error, unsupported model, empty stream, provider unavailable, malformed provider SSE, connection drop, and internal platform error.
If a stream error event includes
error.retryable: true, retry with
exponential backoff. If error.retryable is false, retry only after
changing the request or model selection.Content Filter During Streaming
Content moderation during streaming is represented differently from other stream errors. It does not emit a top-levelerror object. Instead, the stream sends a final assistant content event and then a terminal event with finish_reason: "content_filter".
Grounded Streaming Citations
For Grounded Completions, whenstream=true, include_citations=true, and citations are available, the first SSE event may contain a citations array before model content begins. This is a normal 200 stream event, not an error.
Endpoint-Specific Errors
Completions V2
Completions V2 Reference
POST /ai/v2/chat/completions
application/json responses for non-streaming requests and text/event-stream responses for stream=true.
Invalid Routing Configuration — 400
Specify exactly one of auto_routing, model, or model_family per request.
messages array.
messages field is required. An absent messages array returns a validation error.
Grounded Completions
Grounded Completions Reference
POST /ai/v2/chat/completions/grounded
application/json responses for non-streaming requests and text/event-stream responses for stream=true. For streaming grounded responses, citations may be emitted as the first stream event when include_citations=true.
No Relevant Content Retrieved — 200
Zero results is not an error — it means no retrieved content exceeded the certainty threshold. The response returns 200 OK with "sources_returned": false. Lower certainty toward 0.5 or verify that content has been ingested.
Ingestion
Ingestion V2 Reference
POST /ingestion/v2/files
Authorization header is missing.
duplicates array of a successful 200 OK response, not as an HTTP error. See Duplicate Upload Results.
Content Controls (Data Engine)
Single Item Patch
PATCH /engine/v2/item
Multi-Item Patch
PATCH /engine/v2/items
Delete Items
DELETE /engine/v2/items
Get Item Metadata
GET /engine/v2/items/
Get Item by Producer ID
POST /engine/v2/publisher//items/by-producer
producer_id:
Search & Recommendations
Search
POST /ai/v1/data/search
Recommendations
POST /ai/v1/data/items/recommendations/base
Authorization header is missing.
Authorization header is present but malformed or the API key is invalid.
query, empty collection, and invalid limit values return HTTP 403 rather than 422. Don’t treat these as permission errors — they indicate an invalid request body.
Empty query:
limit:
Zero results is not an error — it means no content exceeded the certainty
threshold. Lower
certainty toward 0.5 or verify that content has been
ingested.Error Handling Best Practices
Logerror.name and error.code, not just the status — Status codes tell you the category; the symbolic name and numeric code tell you exactly what went wrong. Log them in your error handler for precise alerting and debugging.
Use error.retryable for Completions retries — For non-streaming responses, use the HTTP status plus error.retryable. For streaming responses, inspect stream error events and use error.retryable. Some failures happen inside an HTTP 200 stream after headers have been sent.
Retry only transient failures — 408 provider timeouts and retryable 5xx failures are candidates for bounded retries. A 429 is not automatically retryable: 1005 / SPENDING_LIMIT_EXCEEDED requires the limit condition to be resolved, while an endpoint-specific quota may provide Retry-After.
Use exponential backoff for retries — Wait (2^attempt) + jitter between retries, up to 5 attempts for non-streaming requests. Live streaming needs much lower ceilings — see Handling Streaming Failures for streaming retry budgets and Rate Limits for pseudocode.
Use detail to pinpoint validation failures — For 422 responses, the detail array tells you exactly which field failed: loc is the field path, msg is the reason, and input is the value you sent.
Open a ticket with the trace_id for persistent inference issues — If inference errors continue after retrying with backoff, contact us at hello@gloo.us and include the trace_id returned in the error response. The trace_id lets us trace the exact request and resolve the issue faster.
