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

# Create a message (Anthropic-compatible)

> Send a message to a language model using the Anthropic Messages API format. This endpoint is compatible with the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) and may be used with the Anthropic JS or Python SDK by setting the base URL to `https://api.telnyx.com/v2/ai/anthropic`.

The endpoint translates Anthropic-format requests into Telnyx's inference internals, then translates the response back to the Anthropic message shape. Streaming responses use Anthropic SSE event types (`message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, `message_stop`).



## OpenAPI

````yaml /openapi/source/external/inference/inference-embedding.json post /ai/anthropic/v1/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/anthropic/v1/messages:
    post:
      tags:
        - Anthropic Messages
      summary: Create a message (Anthropic-compatible)
      description: >-
        Send a message to a language model using the Anthropic Messages API
        format. This endpoint is compatible with the [Anthropic Messages
        API](https://docs.anthropic.com/en/api/messages) and may be used with
        the Anthropic JS or Python SDK by setting the base URL to
        `https://api.telnyx.com/v2/ai/anthropic`.


        The endpoint translates Anthropic-format requests into Telnyx's
        inference internals, then translates the response back to the Anthropic
        message shape. Streaming responses use Anthropic SSE event types
        (`message_start`, `content_block_start`, `content_block_delta`,
        `content_block_stop`, `message_delta`, `message_stop`).
      operationId: create_anthropic_message
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessageRequest'
            example:
              model: zai-org/GLM-5.3-Flash
              system: You are a friendly chatbot.
              messages:
                - role: user
                  content: Hello, world!
              max_tokens: 1024
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                description: >-
                  An Anthropic-format message response with `type: "message"`,
                  `role`, `content`, `stop_reason`, `stop_sequence`, and
                  `usage`. When `stream` is true, the response is a
                  text/event-stream of Anthropic SSE events.
              example:
                id: msg_01B8b1f2a3c9d4e5f6a
                type: message
                role: assistant
                model: zai-org/GLM-5.3-Flash
                content:
                  - type: text
                    text: >-
                      Telnyx provides carrier-grade voice, messaging, and AI
                      inference through one API.
                stop_reason: end_turn
                stop_sequence: null
                usage:
                  input_tokens: 24
                  output_tokens: 18
            text/event-stream:
              schema:
                type: string
                description: Anthropic-format Server-Sent Events stream.
        '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.anthropic.v1.messages({
              max_tokens: 0,
              messages: [],
              model: 'model',
            });

            console.log(response.data);
        - 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.anthropic.v1.messages(
                max_tokens=0,
                messages=[],
                model="model",
            )
            print(response.data)
        - 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.Anthropic.V1.Messages(\n\t\tcontext.TODO(),\n\t\ttelnyx.AIAnthropicV1MessagesParams{\n\t\t\tMaxTokens: 1,\n\t\t\tMessages:  \"messages\",\n\t\t\tModel:     \"model\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\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.anthropic.v1.V1MessagesParams;
            import java.util.List;

            public final class Main {
                private Main() {}

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

                    V1MessagesParams params = V1MessagesParams.builder()
                        .maxTokens(0)
                        .messages(List.of())
                        .model("model")
                        .build();
                    var response = client.ai().anthropic().v1().messages(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            response = telnyx.ai.anthropic.v1.messages(max_tokens: 0, messages:
            [], model: "model")


            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->anthropic->v1->messages(
                max_tokens: 0,
                messages: [],
                model: 'model',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:anthropic:v1 messages \
              --api-key 'My API Key' \
              --model model \
              --messages messages \
              --max-tokens 0
components:
  schemas:
    AnthropicMessageRequest:
      properties:
        model:
          type: string
          description: >-
            The model to use for generating the response, for example
            `zai-org/GLM-5.3-Flash` or another model available from the Telnyx
            models endpoint.
        messages:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            The messages to send to the model, following the [Anthropic Messages
            API](https://docs.anthropic.com/en/api/messages) format.
        max_tokens:
          type: integer
          description: The maximum number of tokens to generate in the response.
        system:
          description: >-
            System prompt. Can be a string or an array of content blocks
            following the Anthropic API format.
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: true
        stream:
          type: boolean
          default: false
          description: >-
            Whether to stream the response as Anthropic-format Server-Sent
            Events.
        temperature:
          type: number
          description: Amount of randomness injected into the response. Ranges from 0 to 1.
        top_p:
          type: number
          description: Nucleus sampling parameter. Use temperature or top_p, but not both.
        top_k:
          type: integer
          description: >-
            Top-k sampling parameter. Only sample from the top K options for
            each subsequent token.
        stop_sequences:
          type: array
          items:
            type: string
          description: Custom sequences that will cause the model to stop generating.
        metadata:
          type: object
          additionalProperties: true
          description: An object describing metadata about the request.
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Definitions of tools that the model may use, following the Anthropic
            API format.
        tool_choice:
          type: object
          additionalProperties: true
          description: >-
            Controls how the model uses tools, following the Anthropic API
            format.
        thinking:
          type: object
          additionalProperties: true
          description: >-
            Extended thinking configuration for models that support it. Set
            `type` to `enabled` to turn on extended thinking.
        api_key_ref:
          type: string
          description: >-
            If you are using an external inference provider, this field allows
            you to pass along a reference to your API key. After creating an
            [integration
            secret](https://developers.telnyx.com/api-reference/integration-secrets/create-a-secret)
            for your API key, pass the secret's `identifier` in this field.
        mcp_servers:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            List of MCP (Model Context Protocol) servers to make available to
            the model.
        fallback_config:
          type: object
          additionalProperties: true
          description: >-
            Configuration for model fallback behavior when the primary model is
            unavailable.
        billing_group_id:
          type: string
          format: uuid
          description: The billing group ID to associate with this request.
        timeout:
          type: number
          default: 300
          description: Request timeout in seconds.
        max_retries:
          type: integer
          description: Maximum number of retries for the request.
        service_tier:
          type: string
          description: >-
            The service tier to use for this request. Supported values vary by
            model; use the Telnyx models endpoint and inspect the model's
            `service_tiers` field. If omitted, Telnyx-hosted models use
            `default`.
        region:
          type: string
          enum:
            - USA
            - EU
            - AUS
            - UAE
          description: >-
            Optional data-residency region the request should be served from,
            using the same vocabulary as your account's Data Locality setting.
            Behavior depends on `mode`. Supported for Telnyx-hosted models only:
            a request routed to an external provider never passes through Telnyx
            model routing, so a region cannot be enforced for it. Omit for
            today's latency-based routing.
        mode:
          type: string
          enum:
            - preferred
            - strict
          default: preferred
          description: >-
            How strictly `region` is applied. `preferred` (the default when
            `region` is set) tries that region first and falls back to another
            when the model cannot be served there, so a request that would have
            succeeded still succeeds. `strict` pins the request: it is served
            from that region or it fails with a 422, never redirected to another
            region. Requires `region`.
      type: object
      required:
        - model
        - messages
        - max_tokens
      title: AnthropicMessageRequest
      additionalProperties: true
      description: Anthropic Messages-compatible request with Telnyx extensions.
    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

````