> ## 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 AI response for conversation

> Generates an AI reply for an existing conversation and writes the message back into the conversation. Caller must own the conversation, be assigned to it, or be an ADMIN/SUPERADMIN. Supports optional mergeContextPrompt, followUpProcess, and enableTools overrides.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/ai/process
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/process:
    post:
      tags:
        - AI
      summary: Generate AI response for conversation
      description: >-
        Generates an AI reply for an existing conversation and writes the
        message back into the conversation. Caller must own the conversation, be
        assigned to it, or be an ADMIN/SUPERADMIN. Supports optional
        mergeContextPrompt, followUpProcess, and enableTools overrides.
      operationId: post_ai_process
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIProcessRequest'
      responses:
        '200':
          description: AI response generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIProcessResponse'
        '400':
          description: Invalid conversation id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
        '403':
          description: Not authorized for conversation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
        '404':
          description: Conversation or context not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
        '500':
          description: Failed to process chat request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    AIProcessRequest:
      type: object
      properties:
        conversationId:
          type: string
          description: >-
            Target conversation to generate a reply for. Caller must own it, be
            assigned, or be ADMIN/SUPERADMIN. The literal value `new-sms` is
            rejected.
        mergeContextPrompt:
          type: string
          description: >-
            Free-form context to splice into the system prompt for this single
            turn (e.g. tour notes, lead status) without modifying the saved
            prompt.
      required:
        - conversationId
      additionalProperties: true
      example:
        conversationId: 64d2f9c5e8a1d4e001a0b1c2
        mergeContextPrompt: The lead just toured the property and is comparing two units.
    AIProcessResponse:
      type: object
      description: >-
        Returned by `/api/ai/process` after the AI reply has been generated and
        persisted into the conversation.
      properties:
        message:
          type: string
          description: >-
            The generated assistant message text that was appended to the
            conversation.
      required:
        - message
      additionalProperties: true
      example:
        message: >-
          Hi Alex — thanks for reaching out! Are you still interested in the
          Maple Court corner unit?
    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.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````