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

# Generate XML prompt from natural language

> Generates a full XML prompt from a natural language instruction, or iteratively refines an existing prompt when conversationHistory and existingPrompt are supplied. Does not persist anything; the returned prompt text is meant to be saved by the caller.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/ai/nl-create
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/ai/nl-create:
    post:
      tags:
        - AI
      summary: Generate XML prompt from natural language
      description: >-
        Generates a full XML prompt from a natural language instruction, or
        iteratively refines an existing prompt when conversationHistory and
        existingPrompt are supplied. Does not persist anything; the returned
        prompt text is meant to be saved by the caller.
      operationId: post_ai_nl_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AINLCreateRequest'
      responses:
        '200':
          description: Prompt drafted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AINLCreateResponse'
        '400':
          description: instruction is required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
        '500':
          description: Failed to generate prompt
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    AINLCreateRequest:
      type: object
      properties:
        instruction:
          type: string
          description: Natural-language ask describing what the prompt should accomplish.
        existingPrompt:
          type: string
          description: >-
            Optional current prompt XML to iteratively refine; absent for
            first-draft generation.
        conversationHistory:
          type: array
          description: >-
            Prior turns in this prompt-drafting session, replayed so the model
            can continue an iterative refinement thread.
          items:
            type: object
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
              content:
                type: string
            required:
              - role
              - content
        variableContext:
          type: object
          additionalProperties: true
          description: >-
            Available runtime variables and field scopes (grouped) the editor
            exposes; constrains the model to real `@variables` instead of
            inventing placeholders.
        assistedMode:
          type: boolean
          description: >-
            When true, drafting uses the stronger battle-tested XML architecture
            system prompt; otherwise stays closer to the user request with
            lighter guardrails.
        modelOverride:
          $ref: '#/components/schemas/AiModelOverride'
          description: >-
            Pin to a specific provider/model (e.g. `{ provider: 'anthropic',
            model: 'claude-sonnet-4-6' }`) overriding the org's default
            assignment.
      required:
        - instruction
      additionalProperties: true
      example:
        instruction: >-
          Draft a friendly follow-up agent that re-engages leads 24h after the
          last reply.
        existingPrompt: ''
        conversationHistory: []
        variableContext:
          firstName: Alex
          propertyName: Maple Court
        assistedMode: true
        modelOverride:
          provider: anthropic
          model: claude-sonnet-4-6
    AINLCreateResponse:
      type: object
      properties:
        success:
          type: boolean
        prompt:
          type: string
          description: Generated XML prompt
      required:
        - success
        - prompt
      additionalProperties: true
      example:
        success: true
        prompt: >-
          <prompt><role>Friendly leasing follow-up agent</role><goal>Re-engage
          leads 24h after their last reply.</goal></prompt>
    AIErrorResponse:
      type: object
      description: >-
        Error envelope used across AI endpoints. The `error` field is a stable
        machine-readable code on approval-related failures
        (`approval_owner_mismatch`, `approval_org_mismatch`, `approval_expired`,
        `approval_service_unavailable`) and a human-readable string elsewhere.
        `message` is set alongside on the approval paths so the UI can render
        both.
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
        message:
          type: string
      required:
        - error
      additionalProperties: true
      example:
        success: false
        error: approval_expired
        message: >-
          This approval request has expired or was already handled. Please send
          a new playground message to retry.
    AiModelOverride:
      type: object
      properties:
        provider:
          type: string
          enum:
            - anthropic
            - openai
            - google
        model:
          type: string
      required:
        - provider
        - model
      additionalProperties: false
      example:
        provider: anthropic
        model: claude-sonnet-4-6
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````