# Switch from OpenAI or Anthropic

Code written for the OpenAI Chat Completions API or the Anthropic Messages API runs on Claudech after three changes: the base URL, the API key and the model id. Request and response shapes stay the same, so the rest of your code does not change.

## Before you start

- **A Claudech API key** from [API keys](https://claudech.com/api-keys). API access unlocks after your first purchase.
- Store it as an environment variable, for example `CLAUDECH_API_KEY`, rather than in code.

## From the OpenAI API

| Setting | Before | After |
| --- | --- | --- |
| Base URL | `https://api.openai.com/v1` | `https://api.claudech.com/v1` |
| API key | Your OpenAI key | Your Claudech `sk-...` key |
| Model | An OpenAI model name | A Claudech model id, e.g. `claude-opus-5-5` |

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CLAUDECH_API_KEY"],
    base_url="https://api.claudech.com/v1",
)
res = client.chat.completions.create(
    model="claude-opus-5-5",
    messages=[{"role": "user", "content": "Hello"}],
)
```

**JavaScript**

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.CLAUDECH_API_KEY,
  baseURL: 'https://api.claudech.com/v1',
});
const res = await client.chat.completions.create({
  model: 'claude-opus-5-5',
  messages: [{ role: 'user', content: 'Hello' }],
});
```

Many tools read the standard environment variables, so you can often switch without touching code:

```bash
export OPENAI_BASE_URL=https://api.claudech.com/v1
export OPENAI_API_KEY=sk-...
```

### What works the same

Streaming, tool calling, JSON mode, image input, `system` and `developer` messages, `max_completion_tokens` and `reasoning_effort` all behave as in the OpenAI API. See [Streaming](https://claudech.com/docs/streaming) and [Tool calling & JSON](https://claudech.com/docs/tools).

### What is different

| Area | Claudech behaviour |
| --- | --- |
| Endpoints | Only `/v1/chat/completions` and `/v1/models` follow the OpenAI shape. The Responses API, embeddings, images, audio and files are not offered. |
| `n` | Only `1` is supported. |
| `response_format.json_schema` | Treated as `json_object`; validate the output yourself. |
| `logprobs` | Accepted; always returns `null`. |
| Unknown parameters | Ignored rather than rejected. |
| `usage` | Adds `claud_tokens_debited` and `claud_cost_usd` with the exact charge. |

If your app also uses embeddings, keep them on your current provider and move only the chat calls.

## From the Anthropic API

| Setting | Before | After |
| --- | --- | --- |
| Base URL | `https://api.anthropic.com` | `https://api.claudech.com` (no `/v1`) |
| API key | Your Anthropic key | Your Claudech `sk-...` key, sent as `x-api-key` |
| Model | An Anthropic model name | A Claudech model id, e.g. `claude-opus-5-5` |

**Python**

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["CLAUDECH_API_KEY"],
    base_url="https://api.claudech.com",
)
msg = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
```

**JavaScript**

```javascript
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.CLAUDECH_API_KEY,
  baseURL: 'https://api.claudech.com',
});
const msg = await client.messages.create({
  model: 'claude-opus-5-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello' }],
});
```

Tool use, `system` prompts, image blocks, `stop_sequences`, streaming events and `thinking` blocks are supported. See [Messages (Anthropic format)](https://claudech.com/docs/api/messages). For Claude Code, follow [Claude Code setup](https://claudech.com/docs/integrations/claude-code).

## Choose a model

Every Claudech model has a 1M-token context window, supports tool calling and image input, and costs the same per token. Pick by task rather than price:

- `claude-opus-5-5` for most work.
- `claude-fable-5-1` or `claude-opus-5` for long outputs and hard reasoning.
- `claude-sonnet-5` for fast, simple tasks such as titles, classification and autocomplete.

The full list with output limits is on [Models](https://claudech.com/docs/models).

## Check the switch

1. Send one request and confirm the `x-claud-model` response header names the model you asked for.
2. Compare the `usage` fields with the request on your [Usage](https://claudech.com/usage) page.
3. Run your existing tests. If something fails, the [Errors](https://claudech.com/docs/errors) page lists every error code.

## Things to know

- **Rate limits** depend on your plan. See [Rate limits](https://claudech.com/docs/rate-limits) before moving high-volume traffic.
- **Billing** is per token from a prepaid balance. See [Tokens & billing](https://claudech.com/docs/billing).
- **Fallbacks.** If a model is temporarily unavailable, Claudech can serve the request from a fallback model of equal or greater capability and says so in the response. See [Fallbacks](https://claudech.com/docs/models#fallbacks).

Claudech is an independent service and is not affiliated with OpenAI or Anthropic. It implements their public request formats so existing code keeps working.

---

Source: https://claudech.com/docs/migration
