v52

OpenAPI 3.1.0raw.githubusercontent.com2026-07-311,1941,9384.1 MB
Anthropic Messages

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

post/ai/anthropic/v1/messages

Request body

api_key_refstring

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 for your API key, pass the secret's identifier in this field.

billing_group_idstring uuid

The billing group ID to associate with this request.

fallback_configobject

Configuration for model fallback behavior when the primary model is unavailable.

max_retriesinteger

Maximum number of retries for the request.

max_tokensinteger required

The maximum number of tokens to generate in the response.

mcp_serversobject[]

List of MCP (Model Context Protocol) servers to make available to the model.

messagesobject[] required

The messages to send to the model, following the Anthropic Messages API format.

metadataobject

An object describing metadata about the request.

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

service_tierstring

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.

stop_sequencesstring[]

Custom sequences that will cause the model to stop generating.

streamboolean

Whether to stream the response as Anthropic-format Server-Sent Events.

temperaturenumber

Amount of randomness injected into the response. Ranges from 0 to 1.

thinkingobject

Extended thinking configuration for models that support it. Set type to enabled to turn on extended thinking.

timeoutnumber

Request timeout in seconds.

tool_choiceobject

Controls how the model uses tools, following the Anthropic API format.

toolsobject[]

Definitions of tools that the model may use, following the Anthropic API format.

top_kinteger

Top-k sampling parameter. Only sample from the top K options for each subsequent token.

top_pnumber

Nucleus sampling parameter. Use temperature or top_p, but not both.

Response

Successful Response

object required

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.