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).
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Anthropic Messages-compatible request with Telnyx extensions.
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.
The messages to send to the model, following the Anthropic Messages API format.
The maximum number of tokens to generate in the response.
System prompt. Can be a string or an array of content blocks following the Anthropic API format.
Whether to stream the response as Anthropic-format Server-Sent Events.
Amount of randomness injected into the response. Ranges from 0 to 1.
Nucleus sampling parameter. Use temperature or top_p, but not both.
Top-k sampling parameter. Only sample from the top K options for each subsequent token.
Custom sequences that will cause the model to stop generating.
An object describing metadata about the request.
Definitions of tools that the model may use, following the Anthropic API format.
Controls how the model uses tools, following the Anthropic API format.
Extended thinking configuration for models that support it. Set type to enabled to turn on extended thinking.
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.
List of MCP (Model Context Protocol) servers to make available to the model.
Configuration for model fallback behavior when the primary model is unavailable.
The billing group ID to associate with this request.
Request timeout in seconds.
Maximum number of retries for the request.
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.
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.
USA, EU, AUS, UAE 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.
preferred, strict Response
Successful Response
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.