Skip to main content
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)
{
  "id": "<string>",
  "model": "<string>",
  "content": [
    {
      "text": "<string>",
      "type": "text",
      "cache_control": {}
    }
  ],
  "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>"
}
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

model
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.
messages
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).
max_tokens
integer
required
The maximum number of tokens to generate before stopping.
system
string | array
A system prompt that provides context and instructions to the model. Can be a plain string or an array of content blocks.
temperature
number
Sampling temperature between 0 and 1. Higher values produce more varied outputs.
stream
boolean
Whether to stream the response as Server-Sent Events (SSE).
stop_sequences
array
Custom text sequences that will cause the model to stop generating.
tools
array
A list of tools the model may call. Each tool must have a name, optional description, and an input_schema (JSON Schema object).
tool_choice
object
Controls tool use. Can be {"type": "auto"}, {"type": "any"}, or {"type": "tool", "name": "..."}.
top_p
number
Nucleus sampling parameter. Use temperature or top_p, but not both.
top_k
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)

Authorizations

Authorization
string
header
required

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

Headers

x-api-key
string

Body

application/json
model
string
required
max_tokens
integer
required
messages
Message · object[]
required
system
stream
boolean | null
default:false
temperature
number | null
Required range: 0 <= x <= 2
top_p
number | null
Required range: 0 <= x <= 1
top_k
integer | null
Required range: x >= 0
stop_sequences
string[] | null
tools
ToolDefinition · object[] | null
tool_choice
ToolChoiceAuto · object
disable_parallel_tool_use
boolean | null
thinking
ThinkingConfigEnabled · object
metadata
Metadata · object

Response

Successful Response

id
string
required
model
string
required
content
(TextBlock · object | ImageBlock · object | DocumentBlock · object | ToolUseBlock · object | ToolResultBlock · object)[]
required
stop_reason
enum<string>
required
Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
content_filter
usage
Usage · object
required
type
string
default:message
Allowed value: "message"
role
string
default:assistant
Allowed value: "assistant"
stop_sequence
string | null