# Anthropic Messages API

POST /anthropic/v1/messages: the Anthropic Messages format, for Claude Code and Anthropic SDKs.

The Anthropic Messages API, for Claude Code and Anthropic SDKs. Base URL `https://api.openscale.so/anthropic`.

## Endpoint

- [Create a message](#create-a-message): `POST https://api.openscale.so/anthropic/v1/messages`

### Create a message

`POST https://api.openscale.so/anthropic/v1/messages`

The Anthropic Messages API: system prompts, multi-turn messages with text, image, `tool_use` and `tool_result` blocks, client tools and `tool_choice`, extended thinking, `stop_sequences` and streaming with the standard event sequence. Any `claude-*` model name runs DeepSeek V4.1 Flash, and the reply echoes the name you sent. Thinking (`thinking.type` `enabled` or `adaptive`, or `output_config.effort`) turns reasoning on; it comes back as `thinking` blocks. Anthropic server tools are ignored. Usage reports `cache_read_input_tokens` for prompt tokens billed at the cached rate. Errors use the Anthropic shape.

#### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `model` | string | Yes | A model id from `GET /v1/models`, or any `claude-*` name. |
| `max_tokens` | integer | Yes |  |
| `system` | string or array of object | No |  |
| `messages` | array of object | Yes |  |
| `tools` | array of object | No |  |
| `tool_choice` | object | No |  |
| `thinking` | object | No |  |
| `temperature` | number | No |  |
| `stop_sequences` | array of string | No |  |
| `stream` | boolean | No | Default `false`. |

#### Example request

```bash
curl https://api.openscale.so/anthropic/v1/messages \
  -H "x-api-key: $OPENSCALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-sonnet-4-5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Hello from OpenScale"
    }
  ]
}'
```

#### Response

`200`: The message, or an SSE stream when `stream` is true: message_start, content_block_start, content_block_delta, content_block_stop, message_delta and message_stop.

```json
{
  "id": "msg_example",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-5",
  "content": [
    {
      "type": "text",
      "text": "Hello!"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 9,
    "cache_read_input_tokens": 0,
    "output_tokens": 3
  }
}
```

#### Errors

| Status | Meaning |
| --- | --- |
| 400 | Invalid request. A prompt that does not fit says `prompt is too long`. |
| 401 | Missing or invalid API key. |
| 402 | Empty balance, or the key reached its spend limit. |
| 429 | Rate limit crossed or model at capacity. |
| 529 | The model is temporarily overloaded. |

## More of the API reference

- [API reference](https://openscale.so/docs): base URLs, authentication and a first request.
- [Chat Completions](https://openscale.so/docs/chat-completions): POST /v1/chat/completions: the OpenAI Chat Completions format, streamed or not, with reasoning and tools.
- [Responses](https://openscale.so/docs/responses): POST /v1/responses: the OpenAI Responses format with stored state, background runs and enforced tool rules.
- [Conversations](https://openscale.so/docs/conversations): Keep the turns of a Responses conversation on our side and continue it by id.
- [Prompts](https://openscale.so/docs/prompts): Save instructions, messages and settings once, then use them by id in the Responses API.
- [Models and pricing](https://openscale.so/docs/models): Model ids, prices per 1M tokens, context windows, output limits, versions and the live catalog endpoint.
- [Batch](https://openscale.so/docs/batch): Upload a JSONL file of chat completions, create a batch and collect the results when it finishes.
- [Errors](https://openscale.so/docs/errors): The error shape, every status code and code, and which ones to retry.
- [Rate limits](https://openscale.so/docs/rate-limits): Requests and tokens per minute, how a 429 tells you when to retry, and how to get more.
- [Data retention](https://openscale.so/docs/data-retention): What is stored, for how long, how to delete it, and zero data retention.
- [Interactive reference](https://openscale.so/docs/reference): try every endpoint in the browser.
- [OpenAPI document](https://openscale.so/openapi.json): the whole API as OpenAPI 3.1.
