# Migrating from Anthropic (/en/docs/cookbook/migration/from-anthropic)



Keep the Anthropic SDK and Messages request structure. Replace the URL, key, and model ID, then validate your prompts against the new model.

```diff
 client = Anthropic(
-    base_url="https://api.anthropic.com",
-    api_key=os.environ["ANTHROPIC_API_KEY"],
+    base_url="https://api.deepraxis.com/anthropic",
+    api_key=os.environ["PRAXIS_API_KEY"],
 )
-model = "claude-sonnet-4-5"
+model = "deepseek-flash"
```

## 1. Prepare [#1-prepare]

You need Python 3.10+, [uv](https://docs.astral.sh/uv/getting-started/installation/), and a Praxis key. Create one in [Console → API Keys](https://console.deepraxis.ai/keys) and securely inject it into the current terminal as `PRAXIS_API_KEY`. Never put the key in code or logs. Keep your original service configuration and key for rollback. Run the commands below in Bash on macOS or Linux.

```bash
test -n "${PRAXIS_API_KEY:-}"
```

Expected: exit code 0. Exit code 1 means the variable is missing; set it before continuing.

## 2. Choose a model [#2-choose-a-model]

| Original choice                                    | Praxis choice                                           | Check                                                                                                     |
| -------------------------------------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| An official Claude ID, such as `claude-sonnet-4-5` | `deepseek-flash` for this example                       | A different model, not a Claude alias; reevaluate quality and tool behavior                               |
| A Claude model is required                         | Copy an available Claude ID from `/anthropic/v1/models` | `claude-opus-5` appeared in the catalog on October 12, 2026; verify your required capabilities before use |

The SDK base URL ends at `/anthropic`, without `/v1`: the SDK adds `/v1/messages`. The catalog lists models available through the Anthropic protocol. It is separate from `/openai/v1/models` and `/google/v1beta/models`.

Expected: your exact model ID is present in `client.models.list()`; do not carry over an official ID without checking.

## Behavior differences [#behavior-differences]

* `thinking` supports `enabled`, `adaptive`, and `disabled`; `output_config.effort` is available. Some models cannot disable thinking and return `400` with `cannot disable thinking`. See [Messages field support](/en/docs/api/compatible/anthropic/createMessage) before combining options.
* Read text blocks from `content`, rather than assuming the first block is text. A reasoning model can return a thinking block first.
* `count_tokens` returns a calibrated estimate with `x-praxis-token-count: estimated`, not an exact billing measurement. See [Count tokens](/en/docs/api/compatible/anthropic/countTokens).
* Chat's `usage.cost` is the amount charged; Responses and Messages currently omit it. When `X-Praxis-Generation-Id` is present, use `GET /model/v1/generation?id=GENERATION_ID` as described in the [generation record API](/en/docs/api/native/model/getGeneration). Records may take a few seconds to appear. If the header is absent, check [Console → Usage and costs](https://console.deepraxis.ai/usage). Neither the response body's `id` nor `X-Request-Id` is a substitute for a generation ID. Missing cost does not mean zero cost.

## Unsupported operations and alternatives [#unsupported-operations-and-alternatives]

The compatible model API provides Messages, token counting, model listing, and file operations with the limits in the [Anthropic API reference](/en/docs/api/compatible/anthropic). Message Batches (`/anthropic/v1/messages/batches`) is not provided; send individual Messages requests with application-controlled concurrency or keep batch processing on the original service. Official model IDs and file IDs are not automatically mapped; select a catalog model and re-upload needed source files.

## 3. Verify one request [#3-verify-one-request]

```bash
unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy
uv run -q --no-project --with openai --with anthropic python - <<'PY'
import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.deepraxis.com/anthropic",
    api_key=os.environ["PRAXIS_API_KEY"],
    timeout=90.0,
    max_retries=0,
)
models = client.models.list()
assert "deepseek-flash" in {m.id for m in models.data}
raw = client.messages.with_raw_response.create(
    model="deepseek-flash",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Reply OK."}],
)
reply = raw.parse()
text = "".join(block.text for block in reply.content if block.type == "text")
print("HTTP", raw.status_code)
print("X-Request-Id:", raw.headers.get("x-request-id"))
print("X-Praxis-Generation-Id:", raw.headers.get("x-praxis-generation-id"))
print(text)
assert raw.status_code == 200 and text and text.strip()
assert raw.headers.get("x-request-id")
PY
```

Expected: exit code 0, `HTTP 200`, nonempty text (usually `OK.`), and an `X-Request-Id`. Assertions check both model availability and a real reply, not just connectivity. Keep the request ID for troubleshooting, never the key. The example incurs a small usage charge.

## Failures [#failures]

| Observed error                                       | Action                                                                                        |
| ---------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `400` with `cannot disable thinking`                 | Remove the request to disable thinking, or choose a model whose catalog capabilities allow it |
| `404` with `anthropic.messages is not offered for …` | Choose an ID listed for the Anthropic protocol and the operation you need                     |
| `404 Not Found` for Message Batches                  | Use individual Messages calls or retain the original batch service                            |

## 4. Roll back [#4-roll-back]

Restore `https://api.anthropic.com`, the key from `ANTHROPIC_API_KEY`, and your original Claude model ID. Restore the original thinking options and file references. Restart the client, run your previous Messages smoke test, and retain its request ID.

Expected: the original service returns usable text. Changing configuration does not move files or previous conversation state, nor reverse charges already incurred.

[API reference →](/en/docs/api/compatible/anthropic) · [Compatibility guide →](/en/docs/developers/model/guides/anthropic-compatible)
