Something went wrong? The response says what:
error.message in English, fout in Dutch, and error.code for your program. The rule of thumb: 4xx means the request or key must change, so retrying does not help (except 429); 429 and 5xx mean wait and try again.
{"error": {"message": "missing or invalid API key", "type": "authentication_error", "code": "invalid_api_key"},
"fout": "geen of verkeerde sleutel"}
| Code | Status | What happened | What you do | Retry? |
|---|---|---|---|---|
invalid_api_key | 401 | No key was sent, the key is unknown, or it has been revoked, suspended or has expired. Also after the service has ended. | Send the header Authorization: Bearer followed by your key. Check under Keys in the portal that the key is active; an administrator of your organisation can create a new one there. Note: after 30 responses with 401 within one minute your address is blocked for 5 minutes up to 1 hour. | No |
adres_niet_toegestaan | 403 | The key has a list of allowed addresses, and the address you are calling from is not on it. | An administrator of your organisation adds the public IP address of your server under Keys, with Add address. The networks refused in the last 30 days are listed under the key. | No |
geen_toegang | 403 | This key is not allowed to query models. | Use a key of your AI service from the portal. | No |
klasse_niet_toegestaan | 403 | The model belongs to a class this key may not use, for example a public model outside the Netherlands. | Choose one of our own models (processed in the Netherlands), or ask your supplier to enable public models for the key. | No |
model_niet_toegestaan | 403 | The model exists but is not on this key's list. | Pick a model from GET /v1/models, or ask your supplier to enable the model for the key. | No |
model_niet_gevonden | 404 | This model name does not exist or is not available to this key. | Get the exact names with GET /v1/models and copy them literally. | No |
onbekend_pad | 404 | This path does not exist on ai.zeta.nl. | Check the address: the base URL is https://ai.zeta.nl/v1, the path for example /chat/completions. See the API reference. | No |
maandgrens_bereikt | 403 | The monthly limit of the key or service has been reached (requests, tokens or the budget for public models). Deliberately a 403 rather than 429: retrying only helps next month. | Is it the monthly limit of the key: an administrator of your organisation can raise or remove the limit of this key in the portal, tab Keys. Is it the limit or budget of the service: ask your supplier to raise it. Or wait for the next month. | No |
tempo | 429 | Too many requests in a short time: the per-minute limit of the key (or of a helper endpoint) has been reached. | Wait at least the number of seconds in Retry-After. Spread your requests; the headers X-Ratelimit-Remaining-Requests and X-Ratelimit-Reset-Requests show how much room is left. | Yes, after Retry-After |
geen_plek | 429 | All of the key's slots are busy and no slot became free within the waiting time (or the short queue was already full). | Retry after Retry-After. If your application often sends more requests at once than you have slots, lower its concurrency or ask for more slots. | Yes, after Retry-After |
tokens_per_minuut | 429 | Too many tokens in a short time: the tokens-per-minute limit has been reached. This limit is currently only measured, not enforced. | Wait the number of seconds in Retry-After. The headers X-Ratelimit-Remaining-Tokens and X-Ratelimit-Reset-Tokens show how much room is left. | Yes, after Retry-After |
te_druk | 503 / 429 | The model server is busy for everyone right now (503), or the public model reports it is busy (429). It is not caused by your key. | Retry after Retry-After, with increasing waits. | Yes, after Retry-After |
te_groot | 413 | The request is empty or larger than allowed. | Make the request smaller (see Limits), shrink images or split a recording into parts. | No |
ongeldige_aanvraag | 400 | The request is invalid. The fout field says why: for example invalid JSON, missing messages, n greater than 1, an image as a URL, an invalid value for a field. | Read error.message (English) or fout (Dutch) and correct the request. Send images as base64 inside the request. | No |
context_te_lang | 400 | The prompt with the conversation history and the requested answer length does not fit in the model's context window. | Shorten the prompt, send less history, lower max_tokens, or choose a model with a larger context window (see Models). | No |
model_niet_beschikbaar | 502 | The model is not available right now, for example during a restart or maintenance. | Retry in a few seconds up to a minute. | Yes, with backoff |
tijdelijk_niet_beschikbaar | 503 | The model is temporarily unavailable. | Retry after Retry-After. | Yes, after Retry-After |
aanbieder_weigert | 502 | The provider of a public model refused the request. | Retry later or choose another model. | Yes, with backoff |
aanbieder_fout | 502 / 504 | The model server or helper service gave no (usable) answer: an outage, a timeout, or the service was restarted. | Retry with backoff, a few times at most. If it persists, report the time and the x-request-id. | Yes, with backoff |
niet_beschikbaar | 503 | The service is temporarily unavailable, for example during a restart or when the gateway cannot refresh its settings. | Retry after Retry-After. | Yes, after Retry-After |
intern | 500 | Something went wrong inside the gateway. | Retry once. If it happens again, report the time and the x-request-id. | Once |
afgebroken | 499 | Your application closed the connection before there was an answer (also while the request was waiting for a slot). | Check your application's timeout; long answers can take minutes. | Not applicable |
stroom_afgebroken | 200 (in de stroom) | A streamed answer broke off halfway. The status was already 200; the stream ends with an error event and without [DONE]. | Treat a stream without [DONE] as failed and ask again. | Yes, with backoff |
Responses from the front door
Before the gateway there is a front door that protects ai.zeta.nl. It can answer itself, without the JSON above: 429 at more than 30 requests per second from one address, 413 for a body above 17 MB (26 MB for speech), 405 for a wrong method, 404 for an unknown path. After 30 responses with 401 within a minute your address is blocked for 5 minutes, rising to 1 hour on repeat.
Retrying well
import random, time
for poging in range(5):
r = stuur()
if r.status_code not in (429, 500, 502, 503, 504):
break
wacht = float(r.headers.get("Retry-After", 1)) * (2 ** poging)
time.sleep(wacht + random.random()) # a little random extra: not everyone retries at once
Questions? Contact your ZETA contact person or your supplier. Mention the time and the x-request-id of the request.