Natural-Language NetSuite Reporting: Building a SuiteQL Copilot with an LLM
By Ketan Tiwari, NetSuite technical consultant
Summary
A SuiteQL copilot lets finance and operations users ask NetSuite questions in plain English. An LLM turns the question into SuiteQL using a curated schema, the query runs under a read-only NetSuite role through the SuiteQL REST endpoint, and the model summarises the result. Accuracy depends on schema context, guardrails and evaluation, not just on the model.
What a SuiteQL copilot does
Ad-hoc reporting is one of the biggest sources of developer tickets in a NetSuite account. A SuiteQL copilot removes most of them: the user asks a question, the system generates SuiteQL, executes it against NetSuite's REST API and returns a table plus a short explanation.
I built this kind of internal assistant on Azure OpenAI so finance and ops teams could query ERP data without waiting for a developer.
Architecture
- Front end: a chat UI or a Slack/Teams bot.
- Orchestrator: a small service (for example Python) that holds the prompt, the schema context and the guardrails.
- LLM: generates SuiteQL and summarises results (Azure OpenAI, Claude or another model).
- NetSuite: the SuiteQL REST endpoint, called with OAuth 2.0 or token-based authentication under a read-only role.
POST https://<ACCOUNT_ID>.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=100
Prefer: transient
Authorization: Bearer <access token>
Content-Type: application/json
{ "q": "SELECT id, tranid, trandate, BUILTIN.DF(entity) AS customer, foreigntotal FROM transaction WHERE type = 'SalesOrd' ORDER BY trandate DESC" }Give the model a curated schema, not the whole data dictionary
NetSuite's schema is large and full of fields that look similar. Feed the model a short, hand-written description of the tables and joins you actually support (transaction, transactionline, item, customer, subsidiary, currency and so on), the meaning of status codes, and a handful of verified example queries. This does more for accuracy than any prompt trick.
Account-specific custom fields (custbody_…, custcol_…) need their own descriptions, because the model cannot guess what they mean.
Guardrails
- Run under a dedicated read-only role: SuiteQL then cannot see what the role cannot see.
- Reject anything that is not a single SELECT statement before it reaches NetSuite.
- Always apply a row limit and paginate large results.
- Show the generated SuiteQL to the user so results can be checked and reused.
Make the numbers tie out
Multi-entity accounts add traps: multiple accounting books, foreign versus consolidated amounts, and lines that fan out when joined. Encode these rules in the schema context (for example, which amount field to use and when to filter to the primary accounting book) and test answers against NetSuite's own reports.
Evaluate before you roll out
Build a test set of real questions with known-correct answers taken from saved searches or reports, run it on every prompt or model change, and track accuracy. Treat the copilot like any other financial report: it is not done until it reconciles.