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

# Messages API

> Anthropic-compatible messages endpoint

# Messages API

Radium serves the Anthropic Messages endpoint at `POST /v1/messages`. The Anthropic SDK, Claude Code and PydanticAI can all point at Radium.

## Endpoint

```
POST https://api.radium.cloud/v1/messages
```

## Request format

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.radium.cloud/v1/messages \\
    -H "x-api-key: $RADIUM_API_KEY" \\
    -H "anthropic-version: 2023-06-01" \\
    -H "Content-Type: application/json" \\
    -d '{
      "model": "clarke-1.0",
      "max_tokens": 1024,
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```

  ```python Python theme={null}
  from anthropic import Anthropic
  client = Anthropic(
      api_key="YOUR_RADIUM_API_KEY",
      base_url="https://api.radium.cloud",
  )
  response = client.messages.create(
      model="clarke-1.0",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello"}],
  )
  print(response.content[-1].text)
  ```

  ```typescript TypeScript theme={null}
  import Anthropic from "@anthropic-ai/sdk";
  const client = new Anthropic({
    apiKey: process.env.RADIUM_API_KEY,
    baseURL: "https://api.radium.cloud",
  });
  const response = await client.messages.create({
    model: "clarke-1.0",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello" }],
  });
  console.log(response.content.at(-1)?.text);
  ```
</CodeGroup>

## Response format

```json theme={null}
{
  "id": "msg_01AbC",
  "type": "message",
  "role": "assistant",
  "model": "clarke-1.0",
  "content": [
    {"type": "text", "text": "Hello! How can I help you today?"}
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 10,
    "output_tokens": 9
  }
}
```

## Reading the response

When reasoning is enabled, a `thinking` block precedes the `text` block. Read the last block:

```python theme={null}
# Correct
print(response.content[-1].text)

# Incorrect: may return the thinking block
print(response.content[0].text)
```

## Limitations

The token count endpoint is available at `POST /v1/messages/count_tokens`.


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