Skip to content
InfercomInfercomInfercom Documentation

Features

Implement Anthropic-Compatible Features - Developer Guide

Use the Anthropic SDK and Messages API with the Infercom API. Drop-in compatible - just change the base URL and API key to switch to EU sovereign inference.

The Infercom API supports Anthropic’s Messages API format (/v1/messages), enabling you to use the Anthropic Python SDK and compatible tooling with Infercom’s models. This is useful for applications and frameworks built around the Anthropic API, such as Claude Code, LangChain’s Anthropic provider, or custom agentic workflows.

Terminal window
pip install anthropic

Set the base_url to Infercom’s API and provide your Infercom API key.

import anthropic
client = anthropic.Anthropic(
base_url="https://api.infercom.ai",
api_key="your-infercom-api-key"
)
import anthropic
client = anthropic.Anthropic(
base_url="https://api.infercom.ai",
api_key="your-infercom-api-key"
)
message = client.messages.create(
model="gpt-oss-120b",
max_tokens=1024,
messages=[
{"role": "user", "content": "What is the capital of Germany?"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
base_url="https://api.infercom.ai",
api_key="your-infercom-api-key"
)
with client.messages.stream(
model="gpt-oss-120b",
max_tokens=1024,
messages=[
{"role": "user", "content": "Write a haiku about AI."}
]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)

Use the system parameter to provide instructions to the model.

message = client.messages.create(
model="gpt-oss-120b",
max_tokens=1024,
system="You are a helpful assistant that speaks like a pirate.",
messages=[
{"role": "user", "content": "Hello!"}
]
)
message = client.messages.create(
model="gpt-oss-120b",
max_tokens=1024,
messages=[
{"role": "user", "content": "My name is Thomas."},
{"role": "assistant", "content": "Nice to meet you, Thomas!"},
{"role": "user", "content": "What is my name?"}
]
)

The Anthropic Messages API supports tool use for models that have function calling capabilities.

import anthropic
client = anthropic.Anthropic(
base_url="https://api.infercom.ai",
api_key="your-infercom-api-key"
)
message = client.messages.create(
model="gpt-oss-120b",
max_tokens=200,
tools=[
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and country, e.g. Munich, Germany"
}
},
"required": ["location"]
}
}
],
messages=[
{"role": "user", "content": "What's the weather in Munich?"}
]
)
print(message.content)

If the model decides to use the tool, the response will include a tool_use content block:

[
{
"type": "tool_use",
"id": "call_abc123",
"name": "get_weather",
"input": {"location": "Munich, Germany"}
}
]

After executing the tool, send the result back to continue the conversation:

message = client.messages.create(
model="gpt-oss-120b",
max_tokens=200,
tools=[
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
],
messages=[
{"role": "user", "content": "What's the weather in Munich?"},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "call_abc123",
"name": "get_weather",
"input": {"location": "Munich, Germany"}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "call_abc123",
"content": "Sunny, 22°C"
}
]
}
]
)
print(message.content[0].text)
import anthropic
import asyncio
async def main():
client = anthropic.AsyncAnthropic(
base_url="https://api.infercom.ai",
api_key="your-infercom-api-key"
)
message = await client.messages.create(
model="gpt-oss-120b",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(message.content[0].text)
asyncio.run(main())

You can also call the Messages API directly with curl:

Terminal window
curl https://api.infercom.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: your-infercom-api-key" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gpt-oss-120b",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
Parameter Type Description
model string Required. The model to use (e.g., gpt-oss-120b)
messages array Required. Array of message objects with role and content
max_tokens integer Required. Maximum tokens to generate
system string System prompt for the model
temperature number Sampling temperature (0.0-2.0). No default, unlike the Anthropic API, which defaults to 1.0.
top_p number Nucleus sampling parameter
top_k integer Top-k sampling parameter
stop_sequences array Custom stop sequences
stream boolean Enable streaming responses
tools array Tool definitions for function calling
tool_choice object Control tool usage (auto, any, or specific tool)

The following Anthropic-specific features are not supported:

  • Extended thinking (thinking parameter)
  • Prompt caching (cache_control)
  • Vision/image inputs
  • PDF file inputs
  • Citations
  • Server-side tools (web search, code execution)
  • Batch API
  • repetition_penalty (accepted and ignored on this endpoint, and an upcoming platform release will reject it; use /v1/chat/completions)
Aspect Anthropic Infercom
Models Claude (Opus, Sonnet, Haiku) Open-source models (gpt-oss, Gemma, DeepSeek, Llama)
Base URL https://api.anthropic.com https://api.infercom.ai
API key header x-api-key x-api-key (same)
Version header Required: anthropic-version Supported but optional
Error shape Anthropic error format Anthropic error format (see below)

/v1/messages returns errors in the Anthropic shape, not the OpenAI envelope used by Infercom’s other endpoints. The body carries a top-level "type": "error", and the error object holds message and type only:

{
"type": "error",
"error": {
"type": "not_found_error",
"message": "The model `nonexistent-model` does not exist or you do not have access to it."
},
"request_id": "req_6313f64378ad4a89b6005ab233a3f2a9"
}
Field Notes
type (top level) Always error
error.type authentication_error, invalid_request_error or not_found_error
error.message Human-readable explanation
error.param / error.code Not returned. The OpenAI-compatible endpoints provide these; /v1/messages does not
request_id Present on every status. Most carry a req_ prefix; the 401 does not

This shape is returned for every error status, including 400, 401, 404, 410 and 422. See API error codes for the shapes the other endpoints use.

When to use Anthropic vs OpenAI compatibility

Section titled “When to use Anthropic vs OpenAI compatibility”
Use case Recommended API
Existing Anthropic SDK code Anthropic Messages API (/v1/messages)
Claude Code, LangChain Anthropic Anthropic Messages API (/v1/messages)
OpenAI SDK code OpenAI Chat Completions API (/v1/chat/completions)
Agentic workflows, coding tools Responses API (/v1/responses)
New projects Any - all three APIs work with the same models