openapi: 3.2.0 info: version: 2.0.0 x-latency-category: responsive x-endpoint-cost: light title: Telnyx Anthropic Messages API 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: Anthropic Messages 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 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' 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: title: ValidationError required: - loc - msg - type type: object properties: loc: title: Location type: array items: anyOf: - type: string - type: integer msg: title: Message type: string type: title: Error Type type: string securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: API key description: 'Telnyx API key supplied as `Authorization: Bearer `. In production, auth may be validated by the API gateway and forwarded via Telnyx auth headers.' Payment: type: apiKey in: header name: Authorization description: 'Machine Payment Protocol credential used on paid retries, sent as `Authorization: Payment ...`. Obtained by paying a challenge returned in the `WWW-Authenticate` header of a 402 response. This is not a Telnyx API key; initial challenge requests use standard bearer authentication instead.' agent-memory_bearerAuth: type: http scheme: bearer description: Telnyx API key bearerAuth: type: http scheme: bearer branded-calling_bearerAuth: type: http scheme: bearer description: Telnyx API key. Generate one at https://portal.telnyx.com/#/app/api-keys. collections_bearerAuth: type: http scheme: bearer description: Telnyx API key. Collections and results are automatically scoped to the authenticated user's organization. number-reputation_bearerAuth: type: http scheme: bearer description: Telnyx API key. Generate one at https://portal.telnyx.com/#/app/api-keys. oauthClientAuth: type: oauth2 flows: clientCredentials: tokenUrl: https://api.telnyx.com/v2/oauth/token scopes: admin: Administrative access to Telnyx resources authorizationCode: authorizationUrl: https://api.telnyx.com/v2/oauth/authorize tokenUrl: https://api.telnyx.com/v2/oauth/token refreshUrl: https://api.telnyx.com/v2/oauth/token scopes: admin: Administrative access to Telnyx resources description: OAuth 2.0 authentication for Telnyx API and MCP integrations outbound-voice-profiles_bearerAuth: type: http scheme: bearer bearerFormat: JWT pronunciation-dicts_bearerAuth: type: http scheme: bearer description: Telnyx API v2 key. Obtain from https://portal.telnyx.com rcs-registration_bearerAuth: type: http scheme: bearer bearerFormat: API key stored-payment-transactions_bearerAuth: type: http scheme: bearer bearerFormat: JWT transcriptions-search_bearerAuth: type: http scheme: bearer description: Telnyx API key. Results are automatically scoped to the authenticated user's organization. web-search_bearerAuth: type: http scheme: bearer description: Telnyx API key x-service-info: categories: - communication - developer-tools docs: apiReference: https://developers.telnyx.com homepage: https://telnyx.com llms: https://telnyx.com/llms.txt