Skip to main content
POST
/
ai
/
anthropic
/
v1
/
messages
JavaScript
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);
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)
package main

import (
"context"
"fmt"

"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.AI.Anthropic.V1.Messages(
context.TODO(),
telnyx.AIAnthropicV1MessagesParams{,
MaxTokens: telnyx.String("max_tokens"),,
Messages: telnyx.String("messages"),,
Model: telnyx.String("model"),,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

public final class Main {
private Main() {}

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

Params params = Params.builder()
.maxTokens(0)
.messages(List.of())
.model("model")
.build();
Object response = client.ai()anthropic()v1()messages(params);
}
}
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)
<?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();
}
telnyx ai:anthropic:v1 messages \
--api-key 'My API Key' \
--model model \
--messages messages \
--max-tokens 0
curl --request POST \
--url https://api.telnyx.com/v2/ai/anthropic/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "zai-org/GLM-5.2",
"system": "You are a friendly chatbot.",
"messages": [
{
"role": "user",
"content": "Hello, world!"
}
],
"max_tokens": 1024
}
'
{}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

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

max_tokens
integer
required

The maximum number of tokens to generate in the response.

system

System prompt. Can be a string or an array of content blocks following the Anthropic API format.

stream
boolean
default:false

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 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
default:300

Request timeout in seconds.

max_retries
integer

Maximum number of retries for the request.

service_tier
string

Service tier for the request.

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.