> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datris.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Natural-language query (AI)

> Ask a question in plain English against a PostgreSQL table. The server reads the table's columns, uses AI to generate a SQL SELECT, executes it, and returns both the SQL and the results.



## OpenAPI

````yaml /openapi.yaml post /api/v1/query/natural
openapi: 3.0.3
info:
  title: Datris API
  description: >
    REST API for the Datris AI Data Platform. Ingest, validate, transform,
    store, and retrieve data.


    For AI agent integration, use the [MCP
    Server](https://docs.datris.ai/mcp-server) instead.
  version: 1.11.3
  contact:
    name: Datris
    url: https://datris.ai
  license:
    name: Apache 2.0
servers:
  - url: http://localhost:8080
    description: Local development
security:
  - ApiKeyAuth: []
paths:
  /api/v1/query/natural:
    post:
      tags:
        - Query
      summary: Natural-language query (AI)
      description: >-
        Ask a question in plain English against a PostgreSQL table. The server
        reads the table's columns, uses AI to generate a SQL SELECT, executes
        it, and returns both the SQL and the results.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - question
                - table
              properties:
                question:
                  type: string
                  description: Plain-English question to answer
                table:
                  type: string
                  description: PostgreSQL table to query
                database:
                  type: string
                  default: datris
                  description: PostgreSQL database name
                schema:
                  type: string
                  default: public
                  description: PostgreSQL schema
                limit:
                  type: integer
                  default: 100
                  description: Maximum rows to return
      responses:
        '200':
          description: Generated SQL and query results
          content:
            application/json:
              schema:
                type: object
                properties:
                  question:
                    type: string
                  sql:
                    type: string
                  results:
                    type: array
                    items:
                      type: object
                  count:
                    type: integer
        '500':
          description: Error (including table not found)
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Optional API key for authentication (enabled via application.yaml)

````