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

# Assistant Chat

> This endpoint allows a client to send a chat message to a specific AI Assistant. The assistant processes the message and returns a relevant reply based on the current conversation context. Refer to the Conversation API to [create a conversation](https://developers.telnyx.com/api-reference/conversations/create-a-conversation), [filter existing conversations](https://developers.telnyx.com/api-reference/conversations/list-conversations), [fetch messages for a conversation](https://developers.telnyx.com/api-reference/conversations/get-conversation-messages), and [manually add messages to a conversation](https://developers.telnyx.com/api-reference/conversations/create-message).



## OpenAPI

````yaml /openapi/source/external/inference/inference-embedding.json post /ai/assistants/{assistant_id}/chat
openapi: 3.1.0
info:
  version: 2.0.0
  title: Telnyx API
  x-latency-category: responsive
  x-endpoint-cost: light
  description: SIP trunking, SMS, MMS, Call Control and Telephony Data Services.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Version 2.0.0 of the Telnyx API
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Generate text with LLMs
  - name: Assistants
    description: Configure AI assistant specifications
  - name: Conversations
    description: Manage historical AI assistant conversations
  - name: File-based Text-to-Speech
    description: Turn audio into text or text into audio.
  - name: Embeddings
    description: Embed documents and perform text searches
  - name: Clusters
    description: Identify common themes and patterns in your embedded documents
  - name: Fine Tuning
    description: Customize LLMs for your unique needs
  - name: OpenAI Embeddings
    description: >-
      OpenAI-compatible embeddings endpoints for generating vector
      representations of text
paths:
  /ai/assistants/{assistant_id}/chat:
    post:
      tags:
        - Assistants
      summary: Assistant Chat
      description: >-
        This endpoint allows a client to send a chat message to a specific AI
        Assistant. The assistant processes the message and returns a relevant
        reply based on the current conversation context. Refer to the
        Conversation API to [create a
        conversation](https://developers.telnyx.com/api-reference/conversations/create-a-conversation),
        [filter existing
        conversations](https://developers.telnyx.com/api-reference/conversations/list-conversations),
        [fetch messages for a
        conversation](https://developers.telnyx.com/api-reference/conversations/get-conversation-messages),
        and [manually add messages to a
        conversation](https://developers.telnyx.com/api-reference/conversations/create-message).
      operationId: assistant_chat_public_assistants__assistant_id__chat_post
      parameters:
        - name: assistant_id
          in: path
          description: Unique identifier of the assistant.
          required: true
          schema:
            type: string
            title: Assistant Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssistantChatReq'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssistantChatResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.ai.assistants.chat('assistant_id', {
              content: 'Tell me a joke about cats',
              conversation_id: '42b20469-1215-4a9a-8964-c36f66b406f4',
            });

            console.log(response.content);
        - lang: Python
          source: |
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.ai.assistants.chat(
                assistant_id="assistant_id",
                content="Tell me a joke about cats",
                conversation_id="42b20469-1215-4a9a-8964-c36f66b406f4",
            )
            print(response.content)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.AI.Assistants.Chat(\n\t\tcontext.TODO(),\n\t\t\"assistant_id\",\n\t\ttelnyx.AIAssistantChatParams{\n\t\t\tContent:        \"Tell me a joke about cats\",\n\t\t\tConversationID: \"42b20469-1215-4a9a-8964-c36f66b406f4\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Content)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.ai.assistants.AssistantChatParams;
            import com.telnyx.sdk.models.ai.assistants.AssistantChatResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    AssistantChatParams params = AssistantChatParams.builder()
                        .assistantId("assistant_id")
                        .content("Tell me a joke about cats")
                        .conversationId("42b20469-1215-4a9a-8964-c36f66b406f4")
                        .build();
                    AssistantChatResponse response = client.ai().assistants().chat(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.ai.assistants.chat(
              "assistant_id",
              content: "Tell me a joke about cats",
              conversation_id: "42b20469-1215-4a9a-8964-c36f66b406f4"
            )

            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->ai->assistants->chat(
                'assistant_id',
                content: 'Tell me a joke about cats',
                conversationID: '42b20469-1215-4a9a-8964-c36f66b406f4',
                name: 'Charlie',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:assistants chat \
              --api-key 'My API Key' \
              --assistant-id assistant_id \
              --content 'Tell me a joke about cats' \
              --conversation-id 42b20469-1215-4a9a-8964-c36f66b406f4
components:
  schemas:
    AssistantChatReq:
      properties:
        content:
          type: string
          title: Content
          description: The message content sent by the client to the assistant
          example: Tell me a joke about cats
        name:
          type: string
          title: Name
          description: The optional display name of the user sending the message
          example: Charlie
        conversation_id:
          type: string
          title: Conversation Id
          description: >-
            A unique identifier for the conversation thread, used to maintain
            context
          example: 42b20469-1215-4a9a-8964-c36f66b406f4
        stream:
          type: boolean
          title: Stream
          description: >-
            When true, the response is streamed as Server-Sent Events
            (`text/event-stream`): `delta` events carry content fragments as
            they are generated, a final `done` event carries the full content
            plus `whatsapp_template`, and a terminal `error` event reports
            failures that happen after streaming started. When false (default),
            the response is a single JSON object.
          default: false
      type: object
      required:
        - content
        - conversation_id
      title: AssistantChatReq
    AssistantChatResponse:
      properties:
        content:
          type: string
          title: Content
          description: >-
            The assistant's generated response based on the input message and
            context.
          example: >-
            Why did the cat sit on the computer? Because it wanted to keep an
            eye on the mouse!
      type: object
      required:
        - content
      title: AssistantChatResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
      example:
        detail:
          - loc:
              - body
              - name
            msg: Field required
            type: missing
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````