Find the error's code below. Show message to your user, keep detail for yourself, and branch on code: messages can change, codes do not.
{ "ok": false, "statusCode": 429, "code": "rate_limited", "message": "The assistant is busy. Try again in 12 seconds.", "detail": "The key minute limit (10) was reached. Retry after 12 seconds, or change limits at /app/auth. Refused before the model; no Usage log row.", "retryAfter": 12}| Field | Type | Meaning |
|---|---|---|
ok | boolean, required | Always false on an error. |
statusCode | integer, required | The HTTP status, repeated. |
code | string, required | The reason, from the table below. |
message | string, required | A sentence for your user. |
detail | string, optional | For you, never for users: what to fix, and the request id when the question reached the model. |
retryAfter | integer, optional | Seconds to wait, when the wait is known. Also sent as the Retry-After header. |
If your server forwards questions, pass the status, the body and Retry-After through unchanged. Errors from the table packages, such as a lost connection, are in @gridsay/core.
| Code | Status | Charged | Send again unchanged? |
|---|---|---|---|
invalid_request | 400 | No | No: fix the field. |
invalid_api_key | 401 | No | No: fix the key. |
unauthenticated_user | 401 | No | After the user signs in again. |
quota_exceeded | 402 | No | Not until the plan or credits change. |
billing_limit_exceeded | 402 | No | Not until the cap, plan or period changes. |
origin_not_allowed | 403 | No | No: fix the origin or the key's list. |
forbidden | 403 | No | No: set up the key's sign-in. |
not_found | 404 | No | No: fix the path. |
context_too_large | 413 | No | No: send less. |
query_not_understood | 422 | Yes | It is charged again; let the user ask differently. |
rate_limited | 429 | No | Yes, after the wait. |
upstream_unavailable | 502, 503 | No | Yes: once after a short wait for 502, later for 503. |
internal_error | 500 | Maybe | Check Usage first. |
Charged means credits are used, trial credits included. An answer (201) and a refusal (422) are charged; a 502, a 503 and everything refused before the model are not. A 500 can come after the question was charged, so it is not safe to send again without checking Usage. When the connection drops before a response arrives, the question may have been answered and charged too: check Usage the same way.
400. "The assistant could not read this request." Not charged.
The body is not JSON, a required field is missing, or a field is the wrong type or too long. detail names the first field at fault. On the Data Grid endpoint, context must be a JSON string of column descriptions, not an array.
Fix the field, then send again. The limits are in Limits.
401. "The assistant is not available right now." Not charged.
The x-api-key header is missing, malformed, expired, disabled or unknown, or the key's saved settings are not valid. Use an enabled key of your organization from the console. A secret key belongs on your server only. See Authentication.
401. "Sign in to use the assistant." Not charged.
A publishable key's call has no valid user token. detail says which:
Authorization: Bearer <token>, or your webhook's header;Ask your user to sign in again. See Browser keys.
402. "The assistant is not available right now." or "The assistant has reached its usage limit." Not charged. No retryAfter.
No plan is in force, the trial has ended or cannot cover the question, the account is blocked, or a payment is overdue. detail says which. Open Billing in the console. A key set to auto may still answer on a cheaper tier when a fixed tier cannot.
402. "The assistant has reached this month's limit." Not charged. No retryAfter.
A paid plan's credit ceiling for the period, including the extra-usage cap, cannot cover the question. Raise the cap or change plan in Billing, or wait for the next period. See Tiers and credits.
403. "The assistant is not available on this site." Not charged.
The request's Origin is not on the key's allowed origins, a publishable key has no allowed origins, or a publishable call has no Origin header. Add the exact origin, such as https://app.example.com, to the key. Local development is a different origin. See Allowed origins.
403. "The assistant is not available right now." Not charged.
The publishable key has no sign-in method. Choose one for the key in the console: see Browser keys. The sessions endpoint also answers forbidden to a publishable key: mint session tokens with a secret key.
404. "Not found" Not charged.
The path or method is wrong. Questions are POST to /api/v1/datagrid/prompt. If your server forwards them, check it keeps the path.
413. "This table is too large for the assistant." Not charged.
The body, the context string, or what the question would send the model is over its limit. detail gives the size and what to shorten: fewer or shorter example values, shorter descriptions, or fewer columns. See Limits.
422. The assistant's own sentence, such as "I can't compare a person's salary with their manager's, because the grid has no manager column and cannot compare two columns." Charged at the tier that answered.
The question cannot be done with your table: it needs a column you did not send, a feature you switched off, or something no table setting can do. On the Data Grid endpoint, an answer that still names an unknown column, an operator the column does not allow or a switched-off feature after its one correction also ends here, with the reason as the sentence, such as "Sorting is switched off for this table." Show the sentence; your user can ask differently. Check which columns and features you send. Do not resend it unchanged: each refusal is charged. detail has the request id.
429. Not charged. Wait retryAfter seconds, or the Retry-After header; when the wait is not known, both are left out.
detail says which limit:
| Limit | Sentence | What to do |
|---|---|---|
| A minute or hour limit you set on a publishable key | "The assistant is busy. Try again in N seconds." | Wait, or change the limit. See User limits. |
| A day limit you set | "The assistant has reached today's limit. Try again tomorrow." | Wait, or change the limit. |
| A month limit you set | "The assistant has reached this month's limit. Try again next month." | Wait, or change the limit. |
| A user rule with its own sentence | Your rule's sentence, in place of the three above | Wait, or change the rule. |
| Sign-in checks: more than 20 a minute for one key and client address, counting failed checks and checks still in progress | "Too many attempts. Try again in N seconds." | Fix the token, then wait. |
| The key check's own rate limit, off in our normal setup | "The assistant is busy. Try again in N seconds.", or "The assistant is busy. Try again in a moment." with no wait | Wait. |
| Questions in progress for your organization, a user or a key | "The assistant is busy. Try again in a moment." | Wait 5 seconds; send fewer questions at once. |
| Too many failed questions this hour, day, week or period | "The assistant is not available right now. Try again later." | Wait, look at the failed requests in Usage, and contact us if it repeats. |
See Limits.
"The assistant is temporarily unavailable. Try again." Not charged.
detail has the request id.detail says which. Check your sign-in settings when it names them; otherwise retry later.Neither has a retryAfter; do not retry in a tight loop.
500. "Something went wrong. Try again in a moment."
An unexpected failure. Most come before any credit is used, but one can come after the question was charged, so a 500 does not prove the question was free. Check Usage before you resend, and contact us with the endpoint and the time if it repeats.