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

# Get conversation messages

> Retrieve messages for a specific conversation, including tool calls made by the assistant.



## OpenAPI

````yaml /openapi/source/external/inference/inference-embedding.json get /ai/conversations/{conversation_id}/messages
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/conversations/{conversation_id}/messages:
    get:
      tags:
        - Conversations
      summary: Get conversation messages
      description: >-
        Retrieve messages for a specific conversation, including tool calls made
        by the assistant.
      operationId: get_conversations_public__conversation_id__messages_get
      parameters:
        - name: conversation_id
          in: path
          description: Unique identifier of the conversation.
          required: true
          schema:
            type: string
        - name: page[size]
          in: query
          description: The number of messages to return per page.
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 1
            default: 20
        - name: page[number]
          in: query
          description: The page number to retrieve.
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationMessageListData'
        '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
            });


            // Automatically fetches more pages as needed.

            for await (const messageListResponse of
            client.ai.conversations.messages.list('conversation_id')) {
              console.log(messageListResponse.role);
            }
        - 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
            )
            page = client.ai.conversations.messages.list(
                conversation_id="conversation_id",
            )
            page = page.data[0]
            print(page.role)
        - 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\tpage, err := client.AI.Conversations.Messages.List(\n\t\tcontext.TODO(),\n\t\t\"conversation_id\",\n\t\ttelnyx.AIConversationMessageListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\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.conversations.messages.MessageListPage;

            import
            com.telnyx.sdk.models.ai.conversations.messages.MessageListParams;


            public final class Main {
                private Main() {}

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

                    MessageListPage page = client.ai().conversations().messages().list("conversation_id");
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            page = telnyx.ai.conversations.messages.list("conversation_id")

            puts(page)
        - 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 {
              $page = $client->ai->conversations->messages->list(
                'conversation_id', pageNumber: 1, pageSize: 1
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:conversations:messages list \
              --api-key 'My API Key' \
              --conversation-id conversation_id
components:
  schemas:
    ConversationMessageListData:
      properties:
        data:
          items:
            $ref: '#/components/schemas/ConversationMessage'
          type: array
          title: Data
        meta:
          $ref: '#/components/schemas/Meta'
      type: object
      required:
        - data
        - meta
      title: ConversationMessageListData
    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
    ConversationMessage:
      type: object
      required:
        - role
        - text
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - tool
          description: The role of the message sender.
        text:
          type: string
          description: The message content. Can be null for tool calls.
        tool_calls:
          type: array
          description: Optional tool calls made by the assistant.
          items:
            type: object
            properties:
              id:
                type: string
                description: Unique identifier for the tool call.
              type:
                type: string
                enum:
                  - function
                description: Type of the tool call.
              function:
                type: object
                properties:
                  name:
                    type: string
                    description: Name of the function to call.
                  arguments:
                    type: string
                    description: JSON-formatted arguments to pass to the function.
                required:
                  - name
                  - arguments
            required:
              - id
              - type
              - function
        created_at:
          type: string
          description: >-
            The datetime the message was created on the conversation. This does
            not necesarily correspond to the time the message was sent. The best
            field to use to determine the time the end user experienced the
            message is `sent_at`.
          format: date-time
          example: '2025-04-15T13:07:28.764Z'
        sent_at:
          type: string
          description: The datetime the message was sent to the end user.
          format: date-time
          example: '2025-04-15T13:07:28.764Z'
    Meta:
      properties:
        total_pages:
          type: integer
        total_results:
          type: integer
        page_number:
          type: integer
        page_size:
          type: integer
      type: object
      required:
        - total_pages
        - total_results
        - page_number
        - page_size
      title: Meta
    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

````