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.
- 01API format: Anthropic Messages
- 02EU data centres
- 03Covered by one DPA
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): common questions
The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.
Related
- 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
- 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
- StreamingStream tokens from open models as they are generated, with OpenAI and Anthropic server-sent events. Examples, chunk format and error handling.Guides
- 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
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