> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routeway.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic Messages

> Send native Anthropic Messages API requests with full support for Claude models and Anthropic SDKs.

The `/v1/messages` endpoint provides direct compatibility with the native **Anthropic Messages API**. If your codebase or agentic framework is built around the `@anthropic-ai/sdk` (Node.js) or `anthropic` (Python) SDKs, you can connect directly to Routeway by changing only the `base_url` and API key.

```http theme={null}
POST https://api.routeway.ai/v1/messages
```

***

## Quickstart

> [tab] Python (Anthropic SDK)
>
> ```python theme={null}
> 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,
>     system="You are a helpful coding assistant.",
>     messages=[
>         {"role": "user", "content": "Explain async/await in Python with a clear code sample."}
>     ]
> )
>
> print(message.content[0].text)
> ```

> [tab] Node.js (Anthropic SDK)
>
> ```javascript theme={null}
> 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,
>   system: "You are a helpful coding assistant.",
>   messages: [
>     { role: "user", content: "Explain async/await in Python with a clear code sample." }
>   ],
> });
>
> console.log(message.content[0].text);
> ```

> [tab] cURL
>
> ```bash theme={null}
> 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,
>     "system": "You are a helpful coding assistant.",
>     "messages": [
>       {"role": "user", "content": "Explain async/await in Python with a clear code sample."}
>     ]
>   }'
> ```

***

## Request Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | string | **required** | Supported Anthropic Claude model (e.g. `"claude-opus-4-5"`, `"claude-sonnet-4-5"`). |
| `messages` | array | **required** | Array of message objects (`role`: `"user"` or `"assistant"`, `content`: string or block array). |
| `max_tokens` | integer | **required** | Maximum tokens to generate before stopping. |
| `system` | string \| array | — | Top-level system prompt or array of prompt blocks. |
| `temperature` | number | `1.0` | Sampling temperature between 0 and 1. |
| `stream` | boolean | `false` | When `true`, streams SSE chunks using Anthropic's streaming format. |
| `tools` | array | — | List of tool definitions with `name`, `description`, and `input_schema`. |
| `thinking` | object | — | Enables extended thinking / reasoning with token budget `{ "type": "enabled", "budget_tokens": 4096 }`. |

***

## Streaming

Streaming responses use Anthropic's native Server-Sent Events (SSE) event types (`message_start`, `content_block_delta`, `message_delta`, `message_stop`):

```python theme={null}
with client.messages.stream(
    model="claude-opus-4-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a poem about the ocean."}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
```

***

## Automatic Prompt Caching

Routeway automatically attaches `cache_control` breakpoints to long Claude prompts and messages that exceed the 2,048 token threshold, saving up to 90% on input costs without manual configuration. Learn more in [Prompt Caching](https://docs.routeway.ai/features/prompt-caching.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.