Generate Query
Answer a natural language question by generating and executing SQL.
Uses pgvector similarity search to retrieve relevant schema chunks, generates a validated SQL statement via Claude Sonnet (AWS Bedrock), executes it against the customer database, and returns the results formatted as markdown.
The response includes:
- markdown_output: query results as a markdown table (primary consumer field)
- The generated SQL and confidence score
- Schema context used for generation
- Structured error details when generation or execution fails
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Request Body required
Section titled “Request Body required ”object
Natural language description of the query to generate.
Maximum number of schema chunks to retrieve via vector similarity search.
Maximum number of document chunks to include as business context.
Responses
Section titled “ Responses ”Successful Response
Response envelope for POST /queries/generate.
object
Whether the request succeeded.
object
ID of the connection the query was generated for.
The original natural language query, echoed back.
Generated PostgreSQL SQL statement.
LLM confidence score (0.0–1.0) based on schema coverage.
LLM explanation of table/column selection and any assumptions.
Tables referenced in the generated SQL.
Warnings about schema gaps or ambiguities.
Whether the generated SQL passed pglast parse and schema validation.
Table names in the SQL that were not found in the retrieved schema context.
Qualified column references (table.column) in the SQL that were not found in the retrieved schema context.
Number of schema chunks retrieved and included in the LLM prompt.
Number of document chunks retrieved and included as business context.
Primary output for callers: query results formatted as a markdown table on success, or an error summary when generation or execution failed.
Validation Error