> ## 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.

# Conversational prompt assistant (streaming)

> Conversational prompt assistant that streams assistant reply deltas and may emit a draft prompt update. Classifies the user turn into chat, clarify, or draft mode, then streams a series of newline-delimited JSON events (mode, status, assistant-delta, reasoning-delta, draft-ready, done, error). Response uses application/x-ndjson; treat each line as a discrete event.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/ai/prompt-assistant/stream
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/prompt-assistant/stream:
    post:
      tags:
        - AI
      summary: Conversational prompt assistant (streaming)
      description: >-
        Conversational prompt assistant that streams assistant reply deltas and
        may emit a draft prompt update. Classifies the user turn into chat,
        clarify, or draft mode, then streams a series of newline-delimited JSON
        events (mode, status, assistant-delta, reasoning-delta, draft-ready,
        done, error). Response uses application/x-ndjson; treat each line as a
        discrete event.
      operationId: post_ai_prompt_assistant_stream
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIPromptAssistantStreamRequest'
      responses:
        '200':
          description: >-
            NDJSON event stream of assistant reply deltas and optional draft
            prompt
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/AIPromptAssistantStreamEvent'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/AIPromptAssistantStreamEvent'
        '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 process prompt assistant request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    AIPromptAssistantStreamRequest:
      type: object
      properties:
        instruction:
          type: string
          description: >-
            Latest user turn in the assistant conversation. Classified into
            chat/clarify/draft mode before any prompt edit is attempted.
        currentPrompt:
          type: string
          description: >-
            The prompt XML currently in the editor; used as read-only grounding
            for chat/clarify and as the basis for diff when drafting.
        conversationHistory:
          type: array
          description: >-
            Prior assistant turns in this editor session, replayed so the model
            can carry context. Empty or malformed entries are dropped
            server-side.
          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; the assistant only
            references `@variables` that appear here and never invents new ones.
        assistedMode:
          type: boolean
          description: >-
            When true, the assistant clarifies ambiguity instead of drafting
            directly, and any draft uses the stronger XML architecture system
            prompt.
        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: Tighten the tone — make it more concise and less salesy.
        currentPrompt: >-
          <prompt><role>Leasing assistant</role><goal>Convert leads into
          tours.</goal></prompt>
        conversationHistory:
          - role: user
            content: It feels a bit pushy.
          - role: assistant
            content: Got it — what tone would you like instead?
        assistedMode: true
        modelOverride:
          provider: anthropic
          model: claude-sonnet-4-6
    AIPromptAssistantStreamEvent:
      type: object
      description: >-
        One newline-delimited JSON event from the prompt-assistant stream.
        Possible types: mode, status, assistant-delta, reasoning-delta,
        draft-ready, ai-setup-required, error, done.
      properties:
        type:
          type: string
          enum:
            - mode
            - status
            - assistant-delta
            - reasoning-delta
            - draft-ready
            - ai-setup-required
            - error
            - done
        mode:
          type: string
          enum:
            - chat
            - clarify
            - draft
        label:
          type: string
        delta:
          type: string
        prompt:
          type: string
        code:
          type: string
        reason:
          type: string
        section:
          type: string
        provider:
          type: string
        message:
          type: string
        error:
          type: string
      required:
        - type
      additionalProperties: true
      example:
        type: assistant-delta
        delta: Sure — I can tighten that up for you.
    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

````