---
title: "Anthropic Messages API compatible endpoint · hosted in the EU"
description: "Call open-weight models with the Anthropic Messages format on inference.eu. Works with Anthropic SDKs and Claude Code, processed in EU data centres."
canonical: "https://inference.eu/api/messages/"
language: "en"
---

POST /v1/messages

# Messages API: Anthropic-compatible requests, processed in the EU

The inference.eu API also speaks the Anthropic Messages format. Tools and SDKs built for Anthropic, including coding agents such as Claude Code, can send their requests to open-weight models in European data centres without a translation layer. You keep the same request body, headers and streaming events, and change only the base URL, the key and the model name.

[Contact sales](https://inference.eu/contact/)[Example request](#example)

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

POST /v1/messages

```
curl https://api.inference.eu/v1/messages \
  -H "x-api-key: $INFERENCE_EU_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-oss-120b",
    "max_tokens": 1024,
    "system": "You review pull requests for a Python codebase. Be specific and brief.",
    "messages": [
      {"role": "user", "content": "Is it safe to use a mutable default argument like def add(item, items=[])?"}
    ]
  }'
```

## What the endpoint does

`POST /v1/messages` takes a list of `messages` that alternate between `user` and `assistant`, plus an optional top-level `system` prompt, and returns the next assistant turn. Unlike the OpenAI format, the system prompt is not a message but its own field, and `max_tokens` is required on every request.

Authentication uses the `x-api-key` header with your inference.eu key, and the `anthropic-version` header is accepted as Anthropic clients send it. Because the endpoint follows the Anthropic shape, the official Python and TypeScript SDKs work once you set their base URL to the API host. Note that those SDKs add `/v1/messages` themselves, so give them the host without the `/v1` suffix.

## Content blocks and the response shape

Message `content` can be a string or a list of content blocks: `text`, `image` (base64 or URL) for vision models, `tool_use` and `tool_result`. The response is a message object with `id`, `role: "assistant"`, the `model`, and a `content` array of blocks. Plain answers contain one `text` block; reasoning models can add a `thinking` block first.

`stop_reason` is `end_turn` when the model finished, `max_tokens` when it ran out of room, `stop_sequence` when it hit one of your `stop_sequences`, and `tool_use` when it wants you to run a tool. `usage` reports `input_tokens` and `output_tokens`.

## Tools and agents in the Anthropic format

Define tools in a top-level `tools` array, each with `name`, `description` and an `input_schema` written as JSON Schema. When the model wants to use one, the response ends with `stop_reason: "tool_use"` and contains a `tool_use` block with an `id` and `input`. Run the tool, then send a `user` message containing a `tool_result` block that references the same `tool_use_id`.

This is the loop coding agents run all day: read a file, edit, run tests, repeat. Pointing such an agent at inference.eu keeps source code inside European data centres. Pick a model that handles long tool loops well, and set `max_tokens` generously so edits are not cut off mid-file.

## Errors and edge cases

Errors follow the Anthropic shape: `{"type": "error", "error": {"type": "...", "message": "..."}}` with an HTTP status. Expect `invalid_request_error` (400) for a missing `max_tokens` or messages that do not alternate correctly, `authentication_error` (401) for a bad key, `not_found_error` (404) for an unknown model, and `rate_limit_error` (429) when you reach a limit for your plan.

Anthropic model names such as Claude are not available here; send an open model id instead. Most clients let you override the model with an environment variable or setting. Features tied to Anthropic's own models may be accepted but have no effect.

## Messages (Anthropic format)

Endpoint

POST /v1/messages

Category

Endpoints

API format

Anthropic Messages

Base URL

api.inference.eu/v1

Processing

EU data centres

Training on your data

Never

## Messages (Anthropic format): common questions

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

Yes. Create the client with your inference.eu key and set \`base\_url\` (Python) or \`baseURL\` (TypeScript) to the API host without the trailing \`/v1\`, because the SDK adds the path itself. Then call \`messages.create\` with an open model id such as \`gpt-oss-120b\`.

Claude Code reads \`ANTHROPIC\_BASE\_URL\` and \`ANTHROPIC\_AUTH\_TOKEN\` or \`ANTHROPIC\_API\_KEY\` from the environment. Set them to the inference.eu host and your key, and set the model to an open model id. Requests, including your source code, are then processed in EU data centres.

No. The endpoint accepts the Anthropic request format, but the models behind it are open-weight models that we run in European data centres. Choose a model id from \`GET /v1/models\`. Code that hard-codes a Claude model name needs that one string changed.

The Anthropic format makes \`max\_tokens\` mandatory, and we keep that rule so that clients behave the same here as elsewhere. Set it high enough for the longest answer you expect. For reasoning models, leave room for the thinking as well as the visible answer.

Yes. Set \`stream\` to \`true\` to receive the Anthropic event sequence: \`message\_start\`, \`content\_block\_start\`, \`content\_block\_delta\` with text or tool input, \`content\_block\_stop\`, \`message\_delta\` with the stop reason and usage, and \`message\_stop\`. The Anthropic SDKs handle these events for you.

Send your inference.eu key in the \`x-api-key\` header, as Anthropic clients do. Include \`anthropic-version: 2023-06-01\` if your client sends it; it is accepted and does not change model behaviour. Never put the key in client-side code that runs in a browser.

Yes. \`POST /v1/messages/count\_tokens\` takes the same \`model\`, \`system\`, \`messages\` and \`tools\` as a Messages request and returns \`input\_tokens\` without generating anything. Use it to check that a long prompt fits the context window or to estimate costs before a batch run.

In the same European data centres as every other request to the inference.eu API. The format is Anthropic's; the processing is ours, in the EU. Prompts, code and responses are used only to answer the request and are never used to train models.

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

## Related

[API overview](https://inference.eu/api/)

-   [Count tokensCount the input tokens of a Messages request before you send it. Anthropic-compatible count\_tokens endpoint on inference.eu, processed in the EU.Endpoints](https://inference.eu/api/count-tokens/)
-   [Tool callingLet open models call your functions and APIs with OpenAI-compatible tool calling. Define tools, run the loop, handle arguments, processed in the EU.Guides](https://inference.eu/api/tool-calling/)
-   [StreamingStream tokens from open models as they are generated, with OpenAI and Anthropic server-sent events. Examples, chunk format and error handling.Guides](https://inference.eu/api/streaming/)
-   [Chat completionsSend chat messages to open-weight models with the OpenAI chat completions format. Requests are processed in EU data centres and never used for training.Endpoints](https://inference.eu/api/chat-completions/)

## 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
