---
title: "Create a message (Anthropic-compatible)"
method: POST
path: "/ai/anthropic/v1/messages"
tags: ["Anthropic Messages"]
---

# Create a message (Anthropic-compatible)

`POST /ai/anthropic/v1/messages`

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`).

## Request body

- AnthropicMessageRequest — Anthropic Messages-compatible request with Telnyx extensions.
  - `model` string, required — The model to use for generating the response, for example `zai-org/GLM-5.2` or another model available from the Telnyx models endpoint.
  - `messages` object[], required — The messages to send to the model, following the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) format.
  - `max_tokens` integer, required — The maximum number of tokens to generate in the response.
  - `system` union — System prompt. Can be a string or an array of content blocks following the Anthropic API format.
    - string
    - object[]
  - `stream` boolean — Whether to stream the response as Anthropic-format Server-Sent Events.
  - `temperature` number — Amount of randomness injected into the response. Ranges from 0 to 1.
  - `top_p` number — Nucleus sampling parameter. Use temperature or top_p, but not both.
  - `top_k` integer — Top-k sampling parameter. Only sample from the top K options for each subsequent token.
  - `stop_sequences` string[] — Custom sequences that will cause the model to stop generating.
  - `metadata` object — An object describing metadata about the request.
  - `tools` object[] — Definitions of tools that the model may use, following the Anthropic API format.
  - `tool_choice` object — Controls how the model uses tools, following the Anthropic API format.
  - `thinking` object — Extended thinking configuration for models that support it. Set `type` to `enabled` to turn on extended thinking.
  - `api_key_ref` string — 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` object[] — List of MCP (Model Context Protocol) servers to make available to the model.
  - `fallback_config` object — Configuration for model fallback behavior when the primary model is unavailable.
  - `billing_group_id` string, uuid — The billing group ID to associate with this request.
  - `timeout` number — Request timeout in seconds.
  - `max_retries` integer — Maximum number of retries for the request.
  - `service_tier` string — 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`.

## Response `200`

Successful Response

- object — 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.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/team-telnyx/apis/telnyx-api-2.md) · [All operations](https://skmtc.net/team-telnyx/apis/telnyx-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/team-telnyx/telnyx-api-2/revisions/8f5f4e537994/schema)
