Using the API
Errors
What the errors mean and what to do about them.
An error has the same shape as OpenAI's, so the SDKs can read it:
{
"error": {
"message": "You exceeded your current quota. Add credits at https://platform.danskllm.dk to continue.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota"
}
}| Status | code | Meaning | What to do |
|---|---|---|---|
| 400 | null | The request is invalid. param points at the field when we can tell which. | Fix the request. |
| 400 | context_length_exceeded | The prompt and the answer don't fit in the context window. | Shorten the conversation or lower max_tokens. |
| 401 | null | There was no API key. | Send the key in the Authorization header. |
| 401 | invalid_api_key | The key doesn't exist or was deleted. | Create a new key on the platform. |
| 401 | account_deactivated | The account is blocked. | Write to us. |
| 404 | model_not_found | The model doesn't exist or is turned off. | See the models. |
| 413 | null | The request is larger than 2 MB. | Send less text. |
| 429 | insufficient_quota | The balance is used up. | Get more credit. Don't retry before then. |
| 429 | rate_limit_exceeded | Too many requests at once, or too many refused keys from your IP address. See limits. | Wait until a request has finished, or for the time in Retry-After. |
| 503 | null | The model is temporarily unavailable. | Try again in a moment. |
| 500 | null | An error on our side. | Try again. If it persists, write to us with the X-Request-ID from the response. |
Retries
OpenAI's SDKs retry by themselves on status 429 and 5xx. With insufficient_quota we send the header x-should-retry: false, so they don't retry. With 503 we send Retry-After, so they know how long to wait.
Errors in the middle of a stream
Once a stream has started, the status is already 200. If the model stops answering along the way, the error arrives as the last event in the stream. See streaming.