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

# Generate semantic model

> Submit a task to automatically generate semantic models using AI.

**Required roles**: `nx1_semantic_modeller` or `nx1_semantic_admin`

The domain_urn in the request specifies which DataHub domain to scan.
The AI will only analyze datasets within that domain.

Use GET /semantic-models/tasks/{task_id} to check progress.



## OpenAPI

````yaml post /api/semantic-models/generate
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/semantic-models/generate:
    post:
      tags:
        - Semantic models
      summary: Generate semantic model
      description: |-
        Submit a task to automatically generate semantic models using AI.

        **Required roles**: `nx1_semantic_modeller` or `nx1_semantic_admin`

        The domain_urn in the request specifies which DataHub domain to scan.
        The AI will only analyze datasets within that domain.

        Use GET /semantic-models/tasks/{task_id} to check progress.
      operationId: generate_semantic_models_api_semantic_models_generate_post
      parameters:
        - name: x-correlation-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Correlation-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateSemanticModelRequest'
      responses:
        '200':
          description: Generation task submitted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerationTaskResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    GenerateSemanticModelRequest:
      properties:
        domain_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Domain Name
          description: >-
            Domain name. For example, `Finance`. Either `domain_name` or
            `domain_urn` is required.
        domain_urn:
          anyOf:
            - type: string
            - type: 'null'
          title: Domain Urn
          description: >-
            DataHub domain URN. For example, `urn:li:domain:Finance`. Either
            `domain_name` or `domain_urn` is required.
        user_prompt:
          anyOf:
            - type: string
            - type: 'null'
          title: User Prompt
          description: Optional description of what kind of models to generate.
        include_tables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Include Tables
          description: 'Specific tables to include. Default: All tables in a domain'
        exclude_tables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Exclude Tables
          description: Tables to exclude from generation.
        target_catalog:
          type: string
          title: Target Catalog
          description: Target Trino catalog for views.
          default: iceberg
        target_schema:
          anyOf:
            - type: string
            - type: 'null'
          title: Target Schema
          description: 'Target schema. Default: domain name'
        auto_submit_for_review:
          type: boolean
          title: Auto Submit For Review
          description: Automatically submit generated models for review.
          default: true
      type: object
      title: GenerateSemanticModelRequest
      description: Request to generate semantic models using AI.
    GenerationTaskResponse:
      properties:
        task_id:
          type: string
          format: uuid
          title: Task Id
          description: Internal task ID.
        celery_task_id:
          type: string
          title: Celery Task Id
          description: Celery task ID. Empty if synchronous.
        domain_urn:
          type: string
          title: Domain Urn
        status:
          type: string
          title: Status
        submitted_by:
          type: string
          title: Submitted By
        submitted_at:
          type: string
          format: date-time
          title: Submitted At
        message:
          type: string
          title: Message
          default: Task submitted successfully.
        models_generated:
          anyOf:
            - type: integer
            - type: 'null'
          title: Models Generated
          description: Number of models generated if completed.
        result_model_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Result Model Ids
          description: IDs of generated models if completed.
      type: object
      required:
        - task_id
        - celery_task_id
        - domain_urn
        - status
        - submitted_by
        - submitted_at
      title: GenerationTaskResponse
      description: Response for a generation task submission.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````