Aurabase Logo
aurabasedocs
Aurabase Logo
aurabasedocs
API/AI Gateway/Natural Language to SQL

Natural Language to SQL

POST/v1/ai/{project_id}/nl2sql

Converts natural language into secure, read-only PostgreSQL queries checked by an Abstract Syntax Tree (AST) parser.

#
Request

Parameters

ParameterTypeRequiredDescription
questionstringyesNatural language question about the project's data.
dialectstringnoDatabase dialect. Accepts 'postgresql' or 'postgres'.
examplesobject[]noOptional few-shot examples [{ question, sql }] guiding query generation.
limitnumbernoMaximum row limit injected if omitted by model (default 100, max 1000).
#
Security

AST Mutation Guards

Info

The server parses the generated SQL with an Abstract Syntax Tree (AST) engine prior to returning it:

  • Any non-SELECT mutation statement (INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE) is rejected immediately with HTTP 400.
  • System catalog tables (pg_catalog, information_schema) are strictly disallowed.
  • If the model omits a LIMIT clause, the server injects LIMIT 100 (capped at 1000) and marks limit_injected: true.
v1.0 · revised Oct 31, 2026