import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.routeway.ai",
api_key=os.getenv("ROUTEWAY_API_KEY")
)
message = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude!"}
]
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.routeway.ai",
apiKey: process.env.ROUTEWAY_API_KEY,
});
const message = await client.messages.create({
model: "claude-opus-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude!" }],
});
console.log(message.content[0].text);
curl https://api.routeway.ai/v1/messages \
-H "Authorization: Bearer $ROUTEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'
{
"id": "<string>",
"model": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"cache_control": {}
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
},
"service_tier": "standard"
},
"type": "message",
"role": "assistant",
"stop_sequence": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}API Reference
Anthropic Messages
Send a message to the Anthropic models. Supports streaming and non-streaming responses.
POST
/
v1
/
messages
import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.routeway.ai",
api_key=os.getenv("ROUTEWAY_API_KEY")
)
message = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude!"}
]
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.routeway.ai",
apiKey: process.env.ROUTEWAY_API_KEY,
});
const message = await client.messages.create({
model: "claude-opus-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude!" }],
});
console.log(message.content[0].text);
curl https://api.routeway.ai/v1/messages \
-H "Authorization: Bearer $ROUTEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'
{
"id": "<string>",
"model": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"cache_control": {}
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
},
"service_tier": "standard"
},
"type": "message",
"role": "assistant",
"stop_sequence": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"status_code": 123,
"id": "<string>",
"param": "<string>",
"code": "<string>",
"tip": "<string>",
"docs": "https://docs.routeway.ai",
"support": "https://discord.gg/RjX2CpdPpd",
"community": {}
}
}Send a message to Anthropic models using the native Anthropic Messages API format. Supports streaming and non-streaming responses.
Create Anthropic Message
To create an Anthropic message, use the following endpoint:POST /v1/messages
This endpoint is compatible with the Anthropic SDK (
anthropic Python/Node.js package). Point
your SDK at https://api.routeway.ai and replace your Anthropic API key with your Routeway
key — no other changes needed.Request Body
string
required
The Anthropic model ID to use (e.g.
"claude-opus-4-5", "claude-sonnet-4-5"). See
Models for the full list of supported Anthropic models.array
required
An array of message objects forming the conversation. Each object must have a
role
("user" or "assistant") and a content field (string or array of content blocks).integer
required
The maximum number of tokens to generate before stopping.
string | array
A system prompt that provides context and instructions to the model. Can be a plain string
or an array of content blocks.
number
Sampling temperature between 0 and 1. Higher values produce more varied outputs.
boolean
Whether to stream the response as Server-Sent Events (SSE).
array
Custom text sequences that will cause the model to stop generating.
array
A list of tools the model may call. Each tool must have a
name, optional description,
and an input_schema (JSON Schema object).object
Controls tool use. Can be
{"type": "auto"}, {"type": "any"}, or
{"type": "tool", "name": "..."}.number
Nucleus sampling parameter. Use
temperature or top_p, but not both.integer
Only sample from the top K options for each subsequent token.
import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.routeway.ai",
api_key=os.getenv("ROUTEWAY_API_KEY")
)
message = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude!"}
]
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.routeway.ai",
apiKey: process.env.ROUTEWAY_API_KEY,
});
const message = await client.messages.create({
model: "claude-opus-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude!" }],
});
console.log(message.content[0].text);
curl https://api.routeway.ai/v1/messages \
-H "Authorization: Bearer $ROUTEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
application/json
Show child attributes
Show child attributes
system
string(TextBlock · object | ImageBlock · object | DocumentBlock · object | ToolUseBlock · object | ToolResultBlock · object)[]
Required range:
0 <= x <= 2Required range:
0 <= x <= 1Required range:
x >= 0Show child attributes
Show child attributes
- ToolChoiceAuto
- ToolChoiceNone
- ToolChoiceAny
- ToolChoiceSpecific
Show child attributes
Show child attributes
- ThinkingConfigEnabled
- ThinkingConfigDisabled
- ThinkingConfigAdaptive
Show child attributes
Show child attributes
Response
Successful Response
content
(TextBlock · object | ImageBlock · object | DocumentBlock · object | ToolUseBlock · object | ToolResultBlock · object)[]
required
- TextBlock
- ImageBlock
- DocumentBlock
- ToolUseBlock
- ToolResultBlock
Show child attributes
Show child attributes
Available options:
end_turn, max_tokens, stop_sequence, tool_use, content_filter Show child attributes
Show child attributes
Allowed value:
"message"Allowed value:
"assistant"Was this page helpful?