# Anthropic Style

Use the Anthropic Messages API format

SilentAPI provides an endpoint compatible with the Anthropic Messages API at `/v1/messages`. Point the Anthropic SDK at SilentAPI and send your API key.

## Endpoint

| Method | Path | Description |
| --- | --- | --- |
| POST | `/v1/messages` | Create a message (Anthropic Messages API) |

## Basic Request

```
curl https://api.silentapi.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-5.5",
    "max_tokens": 1024,
    "messages": [{"role":"user","content":"What is zero data retention (ZDR)?"}]
  }'
```

Response:

```
{
  "id": "msg_1719584000",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5.5",
  "content": [{
    "type": "text",
    "text": "Zero data retention means no prompts or outputs are kept."
  }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 7,
    "output_tokens": 89
  },
  "silentapi": {
    "cost": 0.000084,
    "fallback": null
  }
}
```

## Using the Anthropic SDK

### Python

```
import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://api.silentapi.com"
)

message = client.messages.create(
    model="claude-sonnet-5.5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain quantum computing"}
    ]
)
print(message.content[0].text)
```

### TypeScript

```
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
    apiKey: "YOUR_API_KEY",
    baseURL: "https://api.silentapi.com"
});

const message = await client.messages.create({
    model: "claude-sonnet-5.5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Explain quantum computing" }]
});
const responseText = message.content[0].text;
```

## Supported Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| model | string | A supported text or multimodal model ID |
| messages | array | Multi-turn conversation messages |
| system | string | System instruction |
| max_tokens | integer | Maximum output tokens (required by Anthropic API) |
| temperature | number | Sampling temperature |
| top_p | number | Nucleus sampling parameter |
| stop_sequences | array | Sequences that stop generation |
| tools | array | Function definitions with name and input_schema |
| tool_choice | object | Select auto, any, none, or a named tool |
| thinking | object | Thinking configuration. See [Reasoning](#reasoning). |
| stream | boolean | Enable SSE streaming (see [Streaming](https://silentapi.com/docs/streaming)) |

## Reasoning

Send `thinking` with `type: "enabled"`. SilentAPI changes `budget_tokens` to a reasoning level:

| budget_tokens | Reasoning level |
| --- | --- |
| Absent | `medium` |
| 1 to 2,048 | `low` |
| 2,049 to 8,192 | `medium` |
| 8,193 to 32,768 | `high` |
| 32,769 to 65,536 | `xhigh` |
| More than 65,536 | `max` |

Each model supports its own set of levels, and SilentAPI changes an unsupported level to the closest supported one. See [Reasoning](https://silentapi.com/docs/openai#reasoning) for the rules.

### Parameter Handling

| Request | Handling |
| --- | --- |
| `thinking.type: "disabled"` | Level `none`. Reasoning is off on models that can turn it off. Other models use their lowest level. |
| `thinking.type: "adaptive"` without `budget_tokens` | Level `medium` |
| `output_config.effort` | Used as the level: `low`, `medium`, `high`, `xhigh`, or `max`. It wins over `budget_tokens`. `thinking.type: "disabled"` wins over it. |
| `budget_tokens` on any model | Changed to a level with the table above, then to the closest level the model supports |
| `temperature` above 2 | Limited to 2. See [Parameter Handling](https://silentapi.com/docs/openai#parameter-handling). |

```
curl https://api.silentapi.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "model": "claude-sonnet-5.5",
    "max_tokens": 4096,
    "thinking": {"type": "enabled", "budget_tokens": 4096},
    "messages": [{"role":"user","content":"Compare two sorting algorithms."}]
  }'
```

## Cross-Style Usage

Use any supported text or multimodal model with the Anthropic Messages API. The response uses the Anthropic Messages format.

## Streaming

Set `stream: true` to receive server-sent events (SSE) in the Anthropic Messages API format. See [Streaming](https://silentapi.com/docs/streaming) for the event sequence.

Source: https://silentapi.com/docs/anthropic
