Errors
Every error type the API returns, what causes it, whether to retry, and whether the request was billed.
The error body#
Every error has the same body. type is a stable machine value: branch on it, never on message. message is safe to show and never contains upstream text. param names the field the error is about, when there is one. request_id is what to quote to support. doc_url links to the entry below. New type values may be added: treat one you do not know by its HTTP status.
{
"error": {
"type": "invalid_request",
"message": "temperature must be between 0 and 2.",
"param": "temperature",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#invalid_request"
}
}import os, time import requests URL = "https://api.panward.ai/v1/chat/completions" RETRYABLE = {"rate_limit_exceeded", "no_capacity", "upstream_unavailable", "upstream_timeout", "internal_error"} def ask(messages): for attempt in range(5): r = requests.post( URL, headers={"Authorization": f"Bearer {os.environ['PANWARD_API_KEY']}"}, json={"model": "z-ai/glm-5.3", "messages": messages}, ) if r.ok: return r.json() error = r.json()["error"] if error["type"] not in RETRYABLE: raise RuntimeError(f"{error['type']}: {error['message']} ({error['request_id']})") time.sleep(float(r.headers.get("Retry-After", 2 ** attempt))) raise RuntimeError("gave up")
const URL = "https://api.panward.ai/v1/chat/completions"; const RETRYABLE = new Set(["rate_limit_exceeded", "no_capacity", "upstream_unavailable", "upstream_timeout", "internal_error"]); const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); type ErrorBody = { error: { type: string; message: string; request_id: string } }; export async function ask(messages: Array<{ role: string; content: string }>) { for (let attempt = 0; attempt < 5; attempt++) { const response = await fetch(URL, { method: "POST", headers: { Authorization: `Bearer ${process.env.PANWARD_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "z-ai/glm-5.3", messages }), }); if (response.ok) return response.json(); const { error } = (await response.json()) as ErrorBody; if (!RETRYABLE.has(error.type)) throw new Error(`${error.type}: ${error.message} (${error.request_id})`); await sleep(Number(response.headers.get("Retry-After") ?? 2 ** attempt) * 1000); } throw new Error("gave up"); }
curl -s -D headers.txt -o body.json https://api.panward.ai/v1/chat/completions \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "z-ai/glm-5.3", "messages": [{"role": "user", "content": "Hello"}]}' if ! head -1 headers.txt | grep -q ' 200'; then jq -r '.error | "\(.type): \(.message) (\(.request_id))"' body.json grep -i '^retry-after:' headers.txt fi
Catalogue#
27 error types, generated from the API contract. The retry column says whether repeating the same request can succeed; wait for Retry-After when the response has it.
| Status | Type | Retry |
|---|---|---|
| 400 | invalid_request | No |
| 400 | context_length_exceeded | No |
| 400 | unsupported_parameter | No |
| 401 | authentication_required | No |
| 401 | invalid_api_key | No |
| 402 | insufficient_credit | No |
| 402 | spend_limit_reached | No |
| 402 | billing_unavailable | Yes |
| 403 | permission_denied | No |
| 403 | model_not_enabled | No |
| 403 | policy_blocked | No |
| 403 | region_not_allowed | No |
| 403 | ip_not_allowed | No |
| 403 | organization_suspended | No |
| 404 | not_found | No |
| 404 | model_not_found | No |
| 410 | gone | No |
| 413 | request_too_large | No |
| 429 | rate_limit_exceeded | Yes |
| 500 | internal_error | Yes |
| 502 | upstream_unavailable | Yes |
| 502 | upstream_rejected | No |
| 503 | no_capacity | Yes |
| 503 | sealed_unavailable | Yes |
| 503 | verification_unavailable | Yes |
| 503 | receipt_unavailable | Yes |
| 504 | upstream_timeout | Yes |
invalid_request400#
- What happened
- The request is malformed or not acceptable.
- Common causes
- Malformed JSON, an unknown parameter, an invalid value, or conflicting values such as different max_tokens and max_completion_tokens, or reasoning and reasoning_effort.
- How to fix it
- Read param, which names the field, and compare the request with the reference.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "invalid_request",
"message": "temperature must be between 0 and 2.",
"param": "temperature",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#invalid_request"
}
}context_length_exceeded400#
- What happened
- The input and the maximum output together do not fit the model's context.
- Common causes
- Input plus the maximum output exceeds the model's context length.
- How to fix it
- Shorten the input, lower max_completion_tokens, or choose a model with a larger context.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "context_length_exceeded",
"message": "The input and max_tokens together exceed this model's context of 200000 tokens.",
"param": "max_tokens",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#context_length_exceeded"
}
}unsupported_parameter400#
- What happened
- A parameter is valid but this model or this combination cannot honour it.
- Common causes
- The model lacks the capability (tools, JSON schema, vision, reasoning), stream was combined with panward-hold-until-verified, or an image was requested by url.
- How to fix it
- Check the model's capabilities in the catalog. Panward rejects the request before any upstream call and never drops a parameter silently.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "unsupported_parameter",
"message": "This model does not support tools.",
"param": "tools",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#unsupported_parameter"
}
}authentication_required401#
- What happened
- No API key was sent.
- Common causes
- The Authorization header is missing.
- How to fix it
- Send Authorization: Bearer with your key.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "authentication_required",
"message": "An API key is required. Send it as 'Authorization: Bearer <key>'.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#authentication_required"
}
}invalid_api_key401#
- What happened
- The key is not valid.
- Common causes
- The key is unknown, revoked or expired.
- How to fix it
- Create a new key, or rotate the key.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "invalid_api_key",
"message": "The API key is invalid, revoked or expired.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#invalid_api_key"
}
}insufficient_credit402#
- What happened
- The balance is too low for the request.
- Common causes
- The estimated cost of the request is more than the balance.
- How to fix it
- Add credit, or turn on automatic top-up in the console.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "insufficient_credit",
"message": "Your balance is too low for this request. Add credit and try again.",
"param": "max_tokens",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#insufficient_credit"
}
}spend_limit_reached402#
- What happened
- A spend limit has been reached.
- Common causes
- The organization's monthly cap, a project budget with a hard stop, or the key's monthly limit is reached.
- How to fix it
- Raise the limit, or wait for the next calendar month (UTC).
- Retry
- No: change the request or your account first.
{
"error": {
"type": "spend_limit_reached",
"message": "The monthly spend limit for this key has been reached.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#spend_limit_reached"
}
}billing_unavailable402#
- What happened
- Panward's billing could not be reached to cover the request.
- Common causes
- Panward's billing system could not extend your balance lease.
- How to fix it
- Retry shortly and check the status page. Contact support if it persists.
- Retry
- Yes, with a delay.
{
"error": {
"type": "billing_unavailable",
"message": "Billing is temporarily unavailable. Try again shortly.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#billing_unavailable"
}
}permission_denied403#
- What happened
- The key is valid but lacks a scope.
- Common causes
- The key does not have the scope the operation needs.
- How to fix it
- Add the scope to the key, or use another key.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "permission_denied",
"message": "This API key does not have the 'receipts.read' scope.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#permission_denied"
}
}model_not_enabled403#
- What happened
- The model exists but is not allowed for this request.
- Common causes
- The model is not enabled for the organization or project, or is not in the key's allowed models or the policy's allow-list.
- How to fix it
- Enable the model, or use an allowed model.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "model_not_enabled",
"message": "The model 'z-ai/glm-5.3' is not enabled for this project.",
"param": "model",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#model_not_enabled"
}
}policy_blocked403#
- What happened
- The project's policy refused the request.
- Common causes
- Routed was requested under Sealed only, the minimum level cannot be met, or another policy rule applies. A signed receipt with decision deny exists.
- How to fix it
- Use a Sealed model, or change the policy.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "policy_blocked",
"message": "This project's policy allows Sealed models only, and 'acme/atlas-2' is offered in the Routed tier.",
"param": "model",
"request_id": "req_01JC7Q6D4H9K2M5P8R1T3V6X7Z",
"doc_url": "https://panward.ai/docs/errors#policy_blocked"
}
}region_not_allowed403#
- What happened
- The gateway region is outside the policy's allowed regions.
- Common causes
- A request reached a gateway in a region that your organization's policy does not allow.
- How to fix it
- Call the host of an allowed region, or allow the region in the policy.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "region_not_allowed",
"message": "Your organization's policy does not allow requests in this region. Use api.eu.panward.ai.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#region_not_allowed"
}
}ip_not_allowed403#
- What happened
- The caller's address is not allowed.
- Common causes
- The address is outside the key's or the policy's allowlist.
- How to fix it
- Add the range, or call from an allowed address.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "ip_not_allowed",
"message": "Requests from this address are not allowed for this key.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#ip_not_allowed"
}
}organization_suspended403#
- What happened
- The organization is suspended.
- Common causes
- The organization has been suspended.
- How to fix it
- Contact support.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "organization_suspended",
"message": "This organization is suspended.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#organization_suspended"
}
}not_found404#
- What happened
- The resource does not exist or is not visible to the caller.
- Common causes
- An unknown id, another organization's receipt, or a receipt past its retention period.
- How to fix it
- Check the id.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "not_found",
"message": "No such receipt.",
"param": "id",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#not_found"
}
}model_not_found404#
- What happened
- The model id is not a canonical model id.
- Common causes
- An unknown id. Aliases are not resolved.
- How to fix it
- Use a canonical id from the model catalog.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "model_not_found",
"message": "The model 'z-ai/glm-9' does not exist.",
"param": "model",
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#model_not_found"
}
}gone410#
- What happened
- The resource existed and is no longer available.
- Common causes
- A share link was revoked or has expired, or a confirmation token has expired.
- How to fix it
- Ask the owner for a new link, or start again.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "gone",
"message": "This share link has been revoked.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#gone"
}
}request_too_large413#
- What happened
- The request body is over the endpoint's limit.
- Common causes
- The body is over the cap of the endpoint: 10 MB unless stated for the endpoint, 25 MB for an audio file.
- How to fix it
- Send less, or split the input.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "request_too_large",
"message": "The request body is larger than the 10 MB limit.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#request_too_large"
}
}rate_limit_exceeded429#
- What happened
- A rate limit has been reached.
- Common causes
- A per-minute limit of the key, the project, the organization or the caller's address is reached.
- How to fix it
- Wait for Retry-After, then back off.
- Retry
- Yes, with a delay.
{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit reached for this key. Retry in 12 seconds.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#rate_limit_exceeded"
}
}internal_error500#
- What happened
- Something failed inside Panward.
- Common causes
- A fault in Panward.
- How to fix it
- Retry. If it keeps happening, report the request_id.
- Retry
- Yes, with a delay.
{
"error": {
"type": "internal_error",
"message": "Something went wrong on our side. Try again.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#internal_error"
}
}upstream_unavailable502#
- What happened
- The model's capacity failed before or during the response.
- Common causes
- No attempt produced a response, or a stream was interrupted.
- How to fix it
- Retry. After a stream was interrupted, decide what to do with the partial output first.
- Retry
- Yes, with a delay.
{
"error": {
"type": "upstream_unavailable",
"message": "The model's capacity is unavailable. Try again.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#upstream_unavailable"
}
}upstream_rejected502#
- What happened
- The serving capacity rejected a request that Panward had accepted.
- Common causes
- A request Panward considered valid was refused upstream. It is reported to Panward automatically.
- How to fix it
- Report the request_id. This is a Panward defect, so retrying the same request is unlikely to help.
- Retry
- No: change the request or your account first.
{
"error": {
"type": "upstream_rejected",
"message": "The request could not be processed. It has been reported.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#upstream_rejected"
}
}no_capacity503#
- What happened
- No eligible capacity has room for the request now.
- Common causes
- No offer for this model, tier and region has headroom.
- How to fix it
- Wait for Retry-After (when the model's offers are temporarily closed it is the time until one is tried again), send panward-fallback: allow, or allow another region.
- Retry
- Yes, with a delay.
{
"error": {
"type": "no_capacity",
"message": "No capacity is available for this model right now. Retry in 5 seconds.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#no_capacity"
}
}sealed_unavailable503#
- What happened
- No Sealed offer is eligible now.
- Common causes
- Every Sealed offer for the model is unavailable. The request is never sent to a Routed offer.
- How to fix it
- Wait for Retry-After: when the model's Sealed offers are temporarily closed it is the time until one is tried again. Panward does not fall back to Routed.
- Retry
- Yes, with a delay.
{
"error": {
"type": "sealed_unavailable",
"message": "No Sealed capacity is available for this model right now. The request was not sent to a Routed offer.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#sealed_unavailable"
}
}verification_unavailable503#
- What happened
- The verification level could not be established.
- Common causes
- panward-hold-until-verified was set and the level of the response could not be established, or verification material could not be produced.
- How to fix it
- Retry, or send the request without the header and check the receipt afterwards.
- Retry
- Yes, with a delay.
{
"error": {
"type": "verification_unavailable",
"message": "The gateway could not establish the verification level in time, so the response was not returned.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#verification_unavailable"
}
}receipt_unavailable503#
- What happened
- The receipt exists but cannot be read right now.
- Common causes
- The request was answered moments ago by another gateway instance and its receipt is not stored yet, or the stored receipt failed its integrity check, in which case it is never returned and Panward investigates.
- How to fix it
- Retry after the delay in the Retry-After header.
- Retry
- Yes, with a delay.
{
"error": {
"type": "receipt_unavailable",
"message": "This receipt cannot be read right now. Try again.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#receipt_unavailable"
}
}upstream_timeout504#
- What happened
- No first byte arrived in time.
- Common causes
- No attempt produced a first byte within the time budget, or the total time was exceeded.
- How to fix it
- Retry. Consider streaming for long responses.
- Retry
- Yes, with a delay.
{
"error": {
"type": "upstream_timeout",
"message": "The model did not answer in time. Try again.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#upstream_timeout"
}
}Errors during a stream#
Before the first byte, an error is a normal JSON response, and the gateway may already have tried another attempt. After the first byte the gateway cannot change the status: it sends an event: error frame with the error object and ends the stream without data: [DONE]. It makes no retry. The tokens already produced are billed, and the receipt's level is failed.
data: {"id":"chatcmpl-01JC7Q5B1V","object":"chat.completion.chunk","created":1790000100,"model":"z-ai/glm-5.3","choices":[{"index":0,"delta":{"role":"assistant","content":"Hel"},"finish_reason":null}]}
event: error
data: {"error":{"type":"upstream_unavailable","message":"The response was interrupted. Tokens already produced are billed.","param":null,"request_id":"req_01JC7Q5B0Z7N3K8M2T4V6X9Y1A","doc_url":"https://panward.ai/docs/errors#upstream_unavailable"}}Errors and receipts#
A refusal by Panward's policy, a limit or a lack of Sealed capacity also has a signed receipt, with decision: "deny", and the panward-receipt-id header is present. A request that is refused before your organization's policy is reached (no valid key, an unknown model, a malformed body) has no receipt.
Errors and billing#
Not billed: requests Panward refuses (authentication, policy, limits, validation) and upstream failures before any output. Billed: the tokens actually produced, including the part of a stream that an error cut short. Receipts and verification are free.