Skip to content
MUI’s hosted AI Assistant backend shuts down at the end of 2026.Switch in two lines →
  • Products
    • AG Grid AI Toolkit Early accessThe model and the server behind the toolkit.
    • MUI X Data Grid StableThe backend for the Premium AI Assistant.
    • TanStack Table Public alphaA plugin that applies each answer to your table.
    • AG Studio Early accessA hosted backend for its assistant, not built yet.
  • How it works
  • Accuracy
  • Pricing
  • Security
  • Docs
    • Quickstart: server route
    • Quickstart: TanStack Table
    • Browser keys
    • Moving from MUI’s hosted service
    • Guide: when MUI’s service retires
Sign inStart a 7-day trial
Menu
  • Products
    • AG Grid AI Toolkit Early access
    • MUI X Data Grid Stable
    • TanStack Table Public alpha
    • AG Studio Early access
  • How it works
  • Accuracy
  • Pricing
  • Security
  • Docs
    • Quickstart: server route
    • Quickstart: TanStack Table
    • Browser keys
    • Moving from MUI’s hosted service
    • Guide: when MUI’s service retires
  • Sign in

Product

  • How it works
  • Accuracy
  • Pricing
  • Data and security

Grids

  • AG Grid AI ToolkitEarly access
  • MUI X Data Grid PremiumStable
  • TanStack TablePublic alpha
  • AG StudioEarly access

Docs

  • Quickstart: server route
  • Browser keys
  • Guide: when MUI’s service retires

Company

  • Contact
  • Terms
  • Privacy

Not affiliated with or endorsed by MUI or AG Grid. MUI and AG Grid are trademarks of their respective owners.

© 2026 Gridsay

Docs pages
Start
  • Documentation
  • How it works
  • Examples
MUI X Data Grid
  • Quickstart: server route
  • From the browser
  • Using the helper
  • Filtering
  • Sorting
  • Grouping
  • Aggregation
  • Pivoting
  • Charts
  • Row selection
  • Follow-up questions
  • Refusals and errors
  • Moving from MUI’s service
  • Reference
TanStack Table
  • Quickstart
  • Describing columns
  • Filtering
  • Sorting
  • Grouping
  • Row selection
  • Server-side data
  • Controlled state
  • Undo and reset
  • Refusals and errors
  • API reference
Keys and sign-in
  • Secret and publishable keys
  • Browser keys
  • JWT and OIDC
  • Session tokens
  • Identity webhook
  • Per-user limits
  • The console
  • Data and privacy
HTTP API
  • HTTP API
  • Authentication
  • Data Grid endpoint
  • Follow-up questions
  • Private mode
Reference
  • Errors
  • Limits
  • Tiers and credits
  • @gridsay/core
On this page

On this page

  1. What you need
  2. 1. Create a secret key
  3. 2. Check the key
  4. 3. Add the route
  5. 4. Point the grid at the route
  6. Ask a first question
  7. See a first refusal
  8. Optional: name the user, or private mode
  9. Choosing a tier
  10. Errors
  11. Next
Skip to the article
Start
  • Documentation
  • How it works
  • Examples
MUI X Data Grid
  • Quickstart: server route
  • From the browser
  • Using the helper
  • Filtering
  • Sorting
  • Grouping
  • Aggregation
  • Pivoting
  • Charts
  • Row selection
  • Follow-up questions
  • Refusals and errors
  • Moving from MUI’s service
  • Reference
TanStack Table
  • Quickstart
  • Describing columns
  • Filtering
  • Sorting
  • Grouping
  • Row selection
  • Server-side data
  • Controlled state
  • Undo and reset
  • Refusals and errors
  • API reference
Keys and sign-in
  • Secret and publishable keys
  • Browser keys
  • JWT and OIDC
  • Session tokens
  • Identity webhook
  • Per-user limits
  • The console
  • Data and privacy
HTTP API
  • HTTP API
  • Authentication
  • Data Grid endpoint
  • Follow-up questions
  • Private mode
Reference
  • Errors
  • Limits
  • Tiers and credits
  • @gridsay/core

Quickstart: server route

On this page

  1. What you need
  2. 1. Create a secret key
  3. 2. Check the key
  4. 3. Add the route
  5. 4. Point the grid at the route
  6. Ask a first question
  7. See a first refusal
  8. Optional: name the user, or private mode
  9. Choosing a tier
  10. Errors
  11. Next

Create a secret key, add one route to your server, and point the grid's AI Assistant at it. Your users can then ask the grid in plain words, and the grid filters, sorts, groups or totals to show the answer.

This path uses MUI's own resolver. You install nothing from Gridsay.

What you need#

  • A grid built with DataGridPremium from @mui/x-data-grid-premium. Gridsay is compatible with MUI X Data Grid Premium and tested with version 9.18.0.
  • Your own MUI X Premium licence. Data Grid Premium is MUI's commercial product.
  • A server that can forward a POST request. The example is a Next.js route handler.
  • A Gridsay account. The trial is 7 days on Pro 20, and nothing is charged during it.

Already forwarding to MUI's hosted service? Change two lines instead: Moving from MUI's service.

1. Create a secret key#

  1. Start the trial, or sign in. Open API keys and choose Create key.
  2. Choose the type Secret and a tier. fast is the default and suits most grids; the tiers are compared below.
  3. Copy the key: it is shown only once. The same screen shows your Gridsay URL.

Put both in your server's environment:

.env.local
# Save at your app root, beside package.json. Restart your dev server after saving.GRIDSAY_URL=<your Gridsay URL, from the dashboard>GRIDSAY_SECRET_KEY=<your secret key>

Keep the secret key on your server. Anyone who has it can spend your credits.

2. Check the key#

Send one question from a terminal before you change your app. It costs one credit on a fast key.

Shell
# Run from your app root, after filling .env.local.set -a. ./.env.localset +a curl -s -X POST "$GRIDSAY_URL/api/v1/datagrid/prompt" \  -H "content-type: application/json" \  -H "x-api-key: $GRIDSAY_SECRET_KEY" \  -d '{"query":"highest salary first","context":"[{\"field\":\"salary\",\"type\":\"number\",\"description\":null,\"examples\":[],\"allowedOperators\":[\">\",\"<\"]}]"}'

The response has status 201:

JSON
{  "ok": true,  "data": {    "conversationId": "…",    "select": -1,    "filters": [],    "filterOperator": "and",    "aggregation": {},    "sorting": [{ "column": "salary", "direction": "desc" }],    "grouping": [],    "pivoting": {},    "chart": null  },  "meta": { "tier": "fast", "usedQueries": 1, "remainingQueries": null, "resetAt": "…" }}

data is what the grid applies: here, sorting. meta.tier is the tier that answered and was charged. If ok is false, the response has a code: look it up in Errors.

3. Add the route#

The route checks that the caller is signed in to your app, adds your secret key, and forwards the grid's request unchanged. It returns Gridsay's body and status as they came.

app/api/ai-assistant/route.ts
// If your app uses src/, create src/app/api/ai-assistant/route.ts instead. export async function POST(request: Request) {  // Each question spends your credits, so only your signed-in users may ask.  if (!(await isSignedIn(request))) {    return Response.json({ ok: false, code: 'unauthenticated_user', message: 'Sign in to use the assistant.' }, { status: 401 });  }   const key = process.env.GRIDSAY_SECRET_KEY;  const gateway = process.env.GRIDSAY_URL;  if (!key || !gateway) {    console.error('[Gridsay] Set GRIDSAY_SECRET_KEY and GRIDSAY_URL in .env.local at your app root. Restart your dev server.');    return Response.json({ ok: false, message: 'The assistant is not configured. Please contact the app owner.' }, { status: 500 });  }   const body = await request.text();  let response: Response;  try {    response = await fetch(`${gateway}/api/v1/datagrid/prompt`, {      method: 'POST',      headers: {        'content-type': 'application/json',        'x-api-key': key,        origin: request.headers.get('origin') ?? '',      },      body,      // Never follow a redirect: it would send your key to another address.      redirect: 'error',    });  } catch {    console.error('[Gridsay] Could not reach the gateway. Check GRIDSAY_URL and your server’s network connection.');    return Response.json({ ok: false, message: 'The assistant cannot connect right now. Try again later.' }, { status: 503 });  }  if (!response.ok) console.error('[Gridsay] Request failed:', response.status, await response.clone().text());  const headers = new Headers({ 'content-type': 'application/json' });  const retryAfter = response.headers.get('Retry-After');  if (retryAfter !== null) headers.set('Retry-After', retryAfter);  return new Response(response.body, { status: response.status, headers });} async function isSignedIn(request: Request) {  // Your sign-in check goes here, e.g. return Boolean(await getSignedInUser(request));  if (process.env.NODE_ENV === 'development') return true;  console.error('[Gridsay] Refused: add your sign-in check to isSignedIn before you deploy.');  return false;}

Before you deploy, put your own sign-in check in isSignedIn. As copied, the route answers only on your development server and refuses every request in production. A secret key does not tell Gridsay who your user is: checking that is your route's job.

Not on Next.js? Do the same five things: check the caller, forward the JSON body unchanged with the x-api-key header, refuse redirects, forward the browser's Origin if your key is locked to origins, and return Gridsay's JSON body and status.

4. Point the grid at the route#

Give MUI's stock resolver the route's path. slots and showToolbar put the assistant's button and panel on the grid; leave them out if your grid has them already.

TSX
'use client'; import {  DataGridPremium,  GridAiAssistantPanel,  unstable_gridDefaultPromptResolver,} from '@mui/x-data-grid-premium'; function onPrompt(query: string, context: string, conversationId?: string) {  return unstable_gridDefaultPromptResolver('/api/ai-assistant', query, context, conversationId);} // Keep your rows and columns; put this in your client component's return value.// With Next.js Cache Components, wrap that component in Suspense in its parent.<DataGridPremium  rows={rows}  columns={columns}  aiAssistant  onPrompt={onPrompt}  slots={{ aiAssistantPanel: GridAiAssistantPanel }}  showToolbar/>

With MUI's stock resolver, the browser sends the question and your column definitions: field, type, description, allowed filter operators and example values. Example values are cells from your rows only if you turn on allowAiAssistantDataSampling or write them into your columns.

Ask a first question#

Open the AI Assistant panel and ask about a column you have. On a table of employees with a remote column:

Ask

only remote people

Changes1 change
  1. 1filter remote is true

Then ask a follow-up, such as "now sort them by salary, highest first". The grid keeps the filter and adds the sort: Follow-up questions explains how.

Both questions appear under Requests on the Usage page of the dashboard.

See a first refusal#

Ask something the grid cannot show. A condition on a group's count is one:

Ask

departments with more than 100 people

ChangesNo change
Refused

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.

The panel shows the sentence and the grid stays as it was. The response has status 422 and the code query_not_understood. A refusal is charged like an answer, because the model read the question. Refusals and errors lists every case.

Optional: name the user, or private mode#

Your route can add options to the body before it forwards it:

  • metadata.referenceId is your id for the user, up to 127 characters. The dashboard groups usage by it, and Gridsay stores it only as a keyed hash. Gridsay also counts its allowance for failed questions per user by it instead of for the whole key. It does not sign the user in or give them limits of their own.
  • privateMode: true stops Gridsay storing the question and the answer. It also turns off follow-ups that build on earlier answers: see private mode.
  • additionalContext explains your data in up to 20,000 characters, for example which currency an amount is in. Keep secrets and personal data out of it.
app/api/ai-assistant/route.ts
// Replace const body = await request.text() with:const body = await request.json();body.options = {  ...body.options,  privateMode: true,  metadata: { referenceId: currentUserId }, // your own user id};// In fetch, replace body, with body: JSON.stringify(body),

To verify each user and give each their own limit, use a publishable key from the browser instead.

Choosing a tier#

The key sets the tier. To use different tiers on different screens, create one key per tier.

TierCredits per questionUse it for
fastCredits per question1Use it forMost grids
standardCredits per question10Use it forVague or multi-step questions, and screens where a wrong answer is costly
maxCredits per question25Use it forThe questions where being right matters most
autoCredits per question1 or 10; 25 if the key allows maxUse it forKeys where you would rather not choose

On auto, Gridsay picks the tier for each question, and the question costs what that tier costs. How often each tier is right: accuracy.

Errors#

The grid shows the response's message to your user; code and detail are for you. A JSON parsing error in the panel usually means the grid is calling a path where your route is not.

Every status and code, what the user sees and whether it is charged: Refusals and errors.

Next#

  • From the browser with a publishable key
  • Using the Gridsay helper
  • Filtering