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

# Anthropic SDK

> Use Kyma with the Anthropic Python/JS SDK — drop-in compatible.

Kyma supports the **Anthropic Messages API** format. If your app uses the Anthropic SDK, just change the base URL and API key.

## Python

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://kymaapi.com",
    api_key="ky-your-api-key",
)

message = client.messages.create(
    model="llama-3.3-70b",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello! What can you do?"}
    ],
)

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

## JavaScript / TypeScript

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

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

const message = await client.messages.create({
  model: "qwen-3-32b",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "Write a haiku about coding" },
  ],
});

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

## With system prompt

```python theme={null}
message = client.messages.create(
    model="llama-3.3-70b",
    max_tokens=1024,
    system="You are a helpful coding assistant.",
    messages=[
        {"role": "user", "content": "Write a Python fibonacci function"}
    ],
)
```

## Streaming

```python theme={null}
with client.messages.stream(
    model="llama-3.3-70b",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tell me a story"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
```

## Switching from Claude to Kyma

If you're already using Claude, the only changes needed are:

```python theme={null}
# Before (Claude)
client = anthropic.Anthropic()  # uses ANTHROPIC_API_KEY

# After (Kyma)
client = anthropic.Anthropic(
    base_url="https://kymaapi.com",
    api_key="ky-your-api-key",
)
```

Then change the model name:

| Claude Model     | Kyma Equivalent | Notes                |
| ---------------- | --------------- | -------------------- |
| claude-sonnet-4  | `llama-3.3-70b` | Balanced all-rounder |
| claude-haiku-3.5 | `qwen-3-32b`    | Fast active model    |
| claude-opus-4    | `qwen-3.6-plus` | Highest quality      |

<Info>
  Kyma models are open-source/open-weight alternatives. They're different from Claude and use Kyma credits after signup bonus.
</Info>

## Prompt Caching

Prompt caching is automatic. Your system prompt and tool definitions are cached for 5 minutes, reducing costs by up to 90% on subsequent requests. No code changes needed. See [Prompt Caching](/guides/prompt-caching) for details.
