When a question cannot be answered, the grid changes nothing and its AI Assistant panel shows one sentence. The sentence is for your user; the status, the code and the detail are for you.
Gridsay declines a question the grid cannot show: a column that does not exist, a condition on a total, an edit, a feature your grid has switched off. The model writes the sentence, in the user's language:
departments with more than 100 people
I can't filter on counts of people per department, since that would be a condition on an aggregate.
Your user reads this sentence. The table stays as it was.Delete all rows
I can't delete rows.
Your user reads this sentence. The table stays as it was.The response has status 422:
{ "ok": false, "statusCode": 422, "code": "query_not_understood", "message": "I can't filter on counts of people per department, since that would be a condition on an aggregate.", "detail": "The question could not be applied to this table. Check the columns and enabled features sent by your resolver. Request …; find it at /app/usage."}A declined question is charged at the tier that answered it, because a model read it: on an auto key, the tier Gridsay picked for that question. It appears on the Usage page; detail names its request id. When the model wrote no sentence of its own, the user reads "I couldn't apply that request to this table. Try rephrasing it."
Each feature page lists what it declines: filtering, sorting, grouping, aggregation, pivoting, charts.
| Status | code | Your user sees | When | Charged |
|---|---|---|---|---|
| 422 | query_not_understood | The model's sentence | The question cannot be applied to this table | Yes |
| 502 | upstream_unavailable | The assistant is temporarily unavailable. Try again. | The model failed or gave an unusable answer | No |
| 503 | upstream_unavailable | The assistant is temporarily unavailable. Try again. | A service Gridsay needs is not available, or your sign-in provider could not be reached | No |
| 400 | invalid_request | The assistant could not read this request. | The body is not what the grid sends: check that your route forwards it unchanged | No |
| 413 | context_too_large | This table is too large for the assistant. | The question would send the model more than 72 KiB, or the body is over 2 MB: fewer or shorter example values, descriptions or columns | No |
| 401 | invalid_api_key | The assistant is not available right now. | The key is missing, mistyped, disabled or revoked | No |
| 401 | unauthenticated_user | Sign in to use the assistant. | A publishable key's question has no valid sign-in | No |
| 403 | origin_not_allowed | The assistant is not available on this site. | The page's origin is not on the key's list | No |
| 403 | forbidden | The assistant is not available right now. | A publishable key has no sign-in method yet | No |
| 402 | quota_exceeded | The assistant is not available right now, or has reached its usage limit. | No plan, the trial's allowance is used, or a payment is overdue | No |
| 402 | billing_limit_exceeded | The assistant has reached this month's limit. | Your organization reached its spending cap | No |
| 429 | rate_limited | The assistant is busy. Try again in N seconds; or today's or this month's limit; or your rule's sentence | A limit you set for the key or the user | No |
| 429 | rate_limited | Too many attempts. Try again in N seconds. | Too many failed sign-ins from one address | No |
| 429 | rate_limited | The assistant is not available right now. Try again later. | Too many questions failed lately for this organization, user or key | No |
| 429 | rate_limited | The assistant is busy. Try again in a moment. | Too many questions in progress at once | No |
| 500 | internal_error | Something went wrong. Try again in a moment. | An unexpected failure | Maybe. Check Usage before sending again. |
A 502 is not charged, but with a publishable key it still counts against the user's limits. For a 429, retryAfter is the number of seconds to wait, when Gridsay knows it.
Some failures happen before a question reaches Gridsay, or after its response leaves. The Gridsay helper gives each a code:
code | Your user sees | When |
|---|---|---|
unauthenticated_user | Sign in to use the assistant. | getToken threw or returned nothing. Nothing was sent. Also a 401 whose body names no other code, such as your route's own sign-in check |
unexpected_error | The assistant couldn't complete your request. Try again. | Your headers function threw. Nothing was sent; what it threw is in cause |
connection_failed | The connection was interrupted. Try again. | No response arrived, or it was cut off |
not_json | The assistant couldn't respond. Try again. | The response was not JSON. With status 404, the url is usually wrong |
invalid_answer | The assistant couldn't complete your request. Try again. | The response was not an answer the grid can apply, or an error without a sentence |
The short onPrompt function from From the browser shows the same sentences for no sign-in and no answer, without codes.
message as it is. MUI's grid does this for you: it puts the thrown error's message in the panel.detail: it is for you, and names your settings.code, status, retryAfter and detail:import { createPromptResolver, GridsayError, type PromptResolver,} from '@gridsay/mui-x-data-grid'; const resolve = createPromptResolver({ url: '/api/ai-assistant', apiRef }); const onPrompt: PromptResolver = async (query, context, conversationId) => { try { return await resolve(query, context, conversationId); } catch (error) { if (error instanceof GridsayError) { // code, status, retryAfter and detail are for you; never show detail to your user. console.warn('[Gridsay]', error.code, error.status, error.detail); } throw error; // the grid shows error.message in its assistant panel }};