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

# Anthropic SDK

> Use the official Anthropic Python or TypeScript SDK with RedPill's Messages API

The Anthropic SDK can call RedPill's compatible [`/v1/messages`](/api-reference/messages) endpoint
directly. Set the RedPill host without `/v1` because the SDK appends `/v1/messages`.

<Warning>
  Use `auth_token` in Python or `authToken` in TypeScript. The `api_key` option sends `x-api-key`,
  while RedPill expects `Authorization: Bearer`.
</Warning>

## Install

<CodeGroup>
  ```bash Python theme={null}
  pip install anthropic
  ```

  ```bash TypeScript theme={null}
  npm install @anthropic-ai/sdk
  ```
</CodeGroup>

## Send a message

<CodeGroup>
  ```python Python theme={null}
  import os

  from anthropic import Anthropic

  client = Anthropic(
      auth_token=os.environ["REDPILL_AI_API_KEY"],
      base_url="https://api.redpill.ai",
  )

  message = client.messages.create(
      model="anthropic/claude-sonnet-5",
      max_tokens=128,
      messages=[{"role": "user", "content": "Explain attestation in one sentence."}],
  )

  for block in message.content:
      if block.type == "text":
          print(block.text)
  ```

  ```typescript TypeScript theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const authToken = process.env.REDPILL_AI_API_KEY;
  if (!authToken) throw new Error('REDPILL_AI_API_KEY is required');

  const client = new Anthropic({
    authToken,
    baseURL: 'https://api.redpill.ai',
  });

  const message = await client.messages.create({
    model: 'anthropic/claude-sonnet-5',
    max_tokens: 128,
    messages: [{ role: 'user', content: 'Explain attestation in one sentence.' }],
  });

  for (const block of message.content) {
    if (block.type === 'text') console.log(block.text);
  }
  ```
</CodeGroup>

## Choose a model

Use an exact Anthropic model ID from the live catalog:

```bash theme={null}
curl -s https://api.redpill.ai/v1/models \
  | jq -r '.data[] | select(.id | startswith("anthropic/")) | .id'
```

Model availability and supported fields change. Test streaming or tool use with the selected model
before depending on it in production.

## Privacy boundary

Every request enters through RedPill's attested gateway. Check the model's `is_tee` value and the
response [receipt](/confidential-ai/receipts) to determine whether the upstream model provider was
also verified. Do not use the TEE-only base URL with a model whose catalog entry has
`is_tee: false`.

## Troubleshooting

| Symptom                                 | Check                                                                            |
| --------------------------------------- | -------------------------------------------------------------------------------- |
| `401` authentication error              | Pass the RedPill key as `auth_token` or `authToken`, not `api_key` or `apiKey`.  |
| Request path contains `/v1/v1/messages` | Set the base URL to `https://api.redpill.ai`, without `/v1`.                     |
| Model not found                         | Refresh `GET /v1/models` and use the full `anthropic/...` ID.                    |
| Unsupported field returns `400`         | Update the SDK, then remove beta-only fields not accepted by the selected model. |

## References

* [Anthropic Python SDK](https://github.com/anthropics/anthropic-sdk-python)
* [Anthropic TypeScript SDK](https://github.com/anthropics/anthropic-sdk-typescript)
* [RedPill Messages API](/api-reference/messages)
