> ## Documentation Index
> Fetch the complete documentation index at: https://domoinc-openapi-sync-dataflows.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Text-to-SQL

> Generate SQL based on the given text input and schemas.



## OpenAPI

````yaml /openapi/product/aiservices.yaml post /api/ai/v1/text/sql
openapi: 3.0.0
info:
  title: AI Services API
  version: v1
  description: >-
    API for Domo's AI services, including Text Generation, Text-to-SQL, and
    Summarization.
servers:
  - url: https://{instance}.domo.com
    description: Domo Instance
    variables:
      instance:
        default: api
        description: Your specific Domo instance name (e.g., mycompany)
security:
  - developerToken: []
tags:
  - name: AI Services
    description: Endpoints for AI-powered text operations.
paths:
  /api/ai/v1/text/sql:
    post:
      tags:
        - AI Services
      summary: Text-to-SQL
      description: Generate SQL based on the given text input and schemas.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSQLRequest'
            example:
              input: What are my total sales by region?
              dataSourceSchemas:
                - dataSourceName: Store Sales
                  description: ''
                  columns:
                    - type: STRING
                      name: product
                      description: ''
                    - type: LONG
                      name: store
                      description: ''
                    - type: LONG
                      name: amount
                      description: ''
                    - type: DATETIME
                      name: timestamp
                      description: ''
                    - type: STRING
                      name: region
                      description: ''
      responses:
        '200':
          description: The generated SQL query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIResponse'
              example:
                output: >-
                  SELECT region, SUM(amount) AS total_sales FROM `Store Sales`
                  GROUP BY region
                modelId: domo.domo_ai.domogpt-sql-v1:anthropic
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TextToSQLRequest:
      type: object
      required:
        - input
        - dataSourceSchemas
      properties:
        input:
          type: string
          description: The input text to send to the model.
        dataSourceSchemas:
          type: array
          items:
            $ref: '#/components/schemas/DataSourceSchema'
        model:
          type: string
          description: The ID of the model to use.
        modelConfiguration:
          $ref: '#/components/schemas/ModelConfiguration'
        promptTemplate:
          $ref: '#/components/schemas/PromptTemplate'
        parameters:
          $ref: '#/components/schemas/ModelParameters'
        system:
          type: string
          description: The system message to use.
    AIResponse:
      type: object
      description: Standard successful AI response.
      properties:
        output:
          type: string
        modelId:
          type: string
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: A human-readable error message.
    DataSourceSchema:
      type: object
      properties:
        dataSourceName:
          type: string
        description:
          type: string
          nullable: true
        columns:
          type: array
          items:
            $ref: '#/components/schemas/DataSourceColumn'
    ModelConfiguration:
      type: object
      description: >-
        Additional model-specific configuration key-value pairs (e.g.,
        temperature).
      additionalProperties: true
      example:
        temperature: 0.7
        max_tokens: 1024
    PromptTemplate:
      type: object
      description: >-
        A prompt template object. The 'template' string should contain
        placeholders.
      properties:
        template:
          type: string
          example: 'Respond to the following in ${language}: ${input}'
    ModelParameters:
      type: object
      description: Custom parameters to inject into the prompt template.
      additionalProperties: true
      example:
        language: Japanese
    DataSourceColumn:
      type: object
      properties:
        type:
          type: string
          enum:
            - STRING
            - LONG
            - DECIMAL
            - DOUBLE
            - DATE
            - DATETIME
        name:
          type: string
        description:
          type: string
          nullable: true
  securitySchemes:
    developerToken:
      type: apiKey
      in: header
      name: X-DOMO-Developer-Token
      description: Domo Developer Token for authentication.

````