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

# Anthropic Integration

> Choose Anthropic Admin API sync for visibility or proxy routing for runtime controls

Anthropic has two valid CostHawk integration modes.

## Mode A: Admin API Sync (Recommended start)

Use an Anthropic Admin key (`sk-ant-admin-...`) for organization-level reporting with minimal setup.

* Endpoint coverage:
  * `/v1/organizations/usage_report/messages`
  * `/v1/organizations/cost_report`
  * `/v1/organizations/usage_report/claude_code`
* No app code changes required
* Best for baseline visibility and reporting

<Card title="Admin API Setup" icon="key" href="/integrations/admin-api">
  Use this if your priority is fast org-level visibility.
</Card>

## Mode B: Proxy + Wrapped Key (Advanced controls)

Use wrapped keys when you need runtime enforcement (hard limits, attribution, policy controls).

<Warning>
  A wrapped key only works against the CostHawk proxy. Do not send `ch_sk_...` directly to `api.anthropic.com`.
</Warning>

<Info>
  If you are not sure whether you have a wrapped key or a CostHawk access token, read <a href="/integrations/wrapped-keys">Wrapped Keys</a> first.
</Info>

### Proxy URL

```
POST https://costhawk.ai/api/proxy/anthropic
```

This replaces `https://api.anthropic.com/v1/messages`.

### Python (Anthropic SDK)

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    api_key="ch_sk_your_wrapped_key_here",
    base_url="https://costhawk.ai/api/proxy/anthropic",
)

message = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude!"}],
)

print(message.content[0].text)
```

### Node.js (Anthropic SDK)

```javascript theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: "ch_sk_your_wrapped_key_here",
  baseURL: "https://costhawk.ai/api/proxy/anthropic",
});

const message = await client.messages.create({
  model: "claude-sonnet-4-5-20250929",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude!" }],
});

console.log(message.content[0].text);
```

### curl

```bash theme={null}
curl -X POST https://costhawk.ai/api/proxy/anthropic \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ch_sk_your_wrapped_key_here" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, Claude!"}]
  }'
```

<Note>
  When calling proxy directly, always use `Authorization: Bearer ch_sk_...`.
</Note>

## Recommended Pattern

1. Start with Admin API sync for immediate reporting coverage.
2. Keep MCP enabled for assistant-native analytics workflows.
3. Add proxy routing only for workloads that need enforcement controls.
