# Anthropic SDK

Source: https://staging-docs.aiand.com/sdks/anthropic/

ai& exposes Anthropic-compatible endpoints alongside its OpenAI surface. Use the official `anthropic` SDKs by overriding the base URL.

## Setup

<Tabs>
<TabItem label="Python">

```bash
pip install anthropic
```

```python
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.aiand.com",
    api_key="sk-your-aiand-api-key",
)
```

</TabItem>
<TabItem label="Node.js">

```bash
npm install @anthropic-ai/sdk
```

```ts

const client = new Anthropic({
  baseURL: "https://api.aiand.com",
  apiKey: "sk-your-aiand-api-key",
});
```

</TabItem>
</Tabs>

## Messages

```python
response = client.messages.create(
    model="...",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.content[0].text)
```

## Streaming

```python
with client.messages.stream(
    model="...",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="")
```

## Files

The Anthropic Files API works too — selected by the SDK's `anthropic-version` header:

```python
file = client.beta.files.upload(file=open("cat.png", "rb"))
```

See [OpenAI vs Anthropic shape](/api/file-shapes/) for how the dual-emit works.

<Aside type="tip">
  You can use both `openai` and `anthropic` SDKs in the same project against ai& — same API key, same org, same billing.
</Aside>
