---
title: "Anthropic SDK with EU-hosted models · Base URL setup"
description: "Point the official Anthropic Python or TypeScript SDK at inference.eu and call open-weight models processed in the EU through the Messages API."
canonical: "https://inference.eu/integrations/anthropic-sdk/"
language: "en"
---

SDKs · Anthropic SDK (Python and TypeScript)

# Use the Anthropic SDK with open-source models hosted in the EU

inference.eu accepts the Anthropic Messages format as well as the OpenAI format. If your application is built on the official Anthropic SDK, you can keep that code, change the base URL and key, and run it on open-weight models processed in European data centres.

[Contact sales](https://inference.eu/contact/)[Setup](#setup)

1.  01API format: Anthropic Messages
2.  02EU data centres
3.  03Covered by one DPA

## Set it up in a few minutes

1.  1

    Create an API key in your inference.eu account and store it as `INFERENCE_EU_API_KEY`.

2.  2

    Install the SDK with `pip install anthropic` or `npm install @anthropic-ai/sdk`.

3.  3

    Create the client with `base_url` (Python) or `baseURL` (TypeScript) set to the inference.eu host without the trailing `/v1`.

4.  4

    Pass your key as `api_key` and replace the model name with an inference.eu model id such as `kimi-k3`.

5.  5

    Send a short `messages.create` request to confirm the connection, then add streaming or tools.

python

```
import os
from anthropic import Anthropic

# The Anthropic SDK adds /v1/messages itself, so drop the trailing /v1.
client = Anthropic(
    base_url="https://api.inference.eu/v1".removesuffix("/v1"),
    api_key=os.environ["INFERENCE_EU_API_KEY"],
)

message = client.messages.create(
    model="kimi-k3",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Summarise GDPR Article 28 in two sentences."}],
)
print(message.content[0].text)

# TypeScript:
# const client = new Anthropic({ baseURL: "https://api.inference.eu/v1".replace(/\/v1$/, ""), apiKey: process.env.INFERENCE_EU_API_KEY });
```

## Why use the Anthropic SDK with inference.eu

Many teams first built their applications on the Anthropic Messages API, with its content blocks, system prompt field and tool use format. Rewriting that code for another API takes time and introduces risk. Because inference.eu speaks the Messages format directly, you can move the same code to open-weight models without changing how you build requests or read responses.

The official SDKs keep handling retries, timeouts, streaming events and typed errors. Only the endpoint, the key and the model name change, which keeps the switch small and easy to review.

## How the configuration works

The Anthropic SDK appends `/v1/messages` to the base URL itself. Set `base_url` to the inference.eu host without the trailing `/v1`; the snippet strips it with `removesuffix`. In TypeScript the option is called `baseURL`.

Pass your key as `api_key`. The SDK sends it in the `x-api-key` header, which inference.eu accepts. Both SDKs also read `ANTHROPIC_BASE_URL` and `ANTHROPIC_API_KEY` from the environment when you pass nothing, which helps with tools you cannot edit. In your own code, explicit arguments with `INFERENCE_EU_API_KEY` make the provider obvious and avoid sending the wrong key.

## Which models to choose

Use the model id from inference.eu in the `model` field. `kimi-k3` and `glm-5.3` are good general choices for applications written against the Messages API: they handle long system prompts, multi-turn conversations and tool use well.

For code generation or agents that edit files, `qwen3-coder-480b-a35b-instruct` is a strong option. For fast classification, extraction or high-volume tasks, `gpt-oss-120b` keeps latency low. Since only the `model` string changes, you can run the same request against several models and compare the results on your own data.

## Troubleshooting

A 404 error almost always means the base URL still ends in `/v1`, so the SDK calls `/v1/v1/messages`. Remove the suffix. A 401 `AuthenticationError` means the key is missing or wrong; check you are not reading an old `ANTHROPIC_API_KEY`.

"Model not found" means the `model` value is a Claude model name rather than an inference.eu id. `max_tokens` is required by the Messages API, so keep it in every request. Features specific to Claude, such as certain beta headers or server-side tools, may not apply to open-weight models; remove them if a request is rejected.

## Keeping data in the EU

With the base URL set to inference.eu, every request your application sends through the SDK is processed in EU data centres. Prompts and completions are never used for training. We sign a data processing agreement under Article 28 GDPR, publish our subprocessor list and bill in euros.

The SDK only talks to the base URL you configure. Check that every client in your code uses it, including clients created by libraries that read `ANTHROPIC_BASE_URL`. Logging, tracing and evaluation services in your stack may also store prompts, so review where they keep their data.

## Anthropic SDK (Python and TypeScript)

Category

SDKs

Maker

Anthropic

API format

Anthropic Messages

Processing

EU data centres

Website

[github.com](https://github.com/anthropics/anthropic-sdk-python)

Documentation

[platform.claude.com](https://platform.claude.com/docs/en/api/sdks/python)

## Anthropic SDK (Python and TypeScript): common questions

The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.

Yes. Pass \`base\_url\` and \`api\_key\` when you create the client and the SDK sends all requests there. inference.eu implements the Messages API, so \`messages.create\`, streaming and tool use work with the same code and response types.

The base URL most likely still ends in \`/v1\`. The SDK adds \`/v1/messages\` itself, so the result is \`/v1/v1/messages\`. Set \`base\_url\` to the host without the trailing \`/v1\` and the request will reach the right path.

Yes. The Python and TypeScript SDKs read \`ANTHROPIC\_BASE\_URL\` and \`ANTHROPIC\_API\_KEY\` when no explicit values are passed. Set the base URL without \`/v1\`. In your own code, explicit arguments make it clearer which provider each client is talking to.

Kimi K3 and GLM-5.3 are good general replacements for applications built on the Messages API. Qwen3 Coder 480B suits code-heavy tasks, and gpt-oss-120b is a quick choice for classification and extraction. Test on your own prompts before switching production traffic.

Yes, for models that support tool calling. Define \`tools\` with \`input\_schema\` as usual and read \`tool\_use\` content blocks from the response. Return results as \`tool\_result\` blocks in the next message, exactly as you would with Claude.

Yes. Use \`client.messages.stream(...)\` or pass \`stream=True\` and handle the standard Messages events such as \`content\_block\_delta\` and \`message\_stop\`. Token usage arrives in the \`message\_delta\` event at the end of the stream.

The core Messages API works: system prompts, multi-turn messages, streaming and tool use. Features tied to Claude models, such as some beta headers or server-side tools, may not apply. Remove them if a request is rejected.

The Anthropic SDK sends \`api\_key\` in the \`x-api-key\` header, and inference.eu accepts it. If you pass \`auth\_token\` instead, the SDK sends an \`Authorization\` bearer header, which also works. Use one of the two, not both.

Use whichever your code already depends on. Both reach the same models. The OpenAI format is supported by more third-party tools, so new projects often start there, but there is no need to rewrite working Anthropic SDK code.

No. The SDK only sends requests to the base URL you configure and has no built-in telemetry. Make sure no other part of your code creates a client with the default Anthropic URL, for example through an unset environment variable.

[Ask a question](https://inference.eu/contact/)

## Related

[All integrations](https://inference.eu/integrations/)

-   [OpenAI SDK (Python and JavaScript)Point the official OpenAI Python or JavaScript SDK at inference.eu with base\_url and an API key, and call open-weight models processed in the EU.SDKs](https://inference.eu/integrations/openai-sdk/)
-   [Claude CodePoint Claude Code at inference.eu with ANTHROPIC\_BASE\_URL and run it on open-weight models processed in EU data centres. No Anthropic account needed.Coding agents](https://inference.eu/integrations/claude-code/)
-   [LiteLLMAdd inference.eu to the LiteLLM proxy or Python SDK with the openai/ prefix and route your team's requests to open-weight models processed in the EU.Gateways](https://inference.eu/integrations/litellm/)

## Move your AI workloads to EU infrastructure

Tell us which models you use and roughly how much traffic you have. We reply within one working day with pricing and next steps.

-   Reply within one working day
-   Pricing for your volume
-   DPA ready to sign
