> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infercom.ai/llms.txt
> Use this file to discover all available pages before exploring further.

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

<Note>
  The Anthropic SDK was designed for Claude models. When using it with Infercom, you're accessing open-source models (like MiniMax, DeepSeek, Llama) through an Anthropic-compatible interface - not Claude itself.
</Note>

## Install the Anthropic SDK

```bash theme={null}
pip install anthropic
```

## Configure the client

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

<Note>
  Don't have an Infercom API key? Get yours from the [API keys and URLs](/en/get-started/api-keys-urls) page.
</Note>

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.infercom.ai",
    api_key="your-infercom-api-key"
)
```

## Basic usage

### Non-streaming example

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.infercom.ai",
    api_key="your-infercom-api-key"
)

message = client.messages.create(
    model="MiniMax-M2.7",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "What is the capital of Germany?"}
    ]
)

print(message.content[0].text)
```

### Streaming example

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.infercom.ai",
    api_key="your-infercom-api-key"
)

with client.messages.stream(
    model="MiniMax-M2.7",
    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)
```

### System prompts

Use the `system` parameter to provide instructions to the model.

```python theme={null}
message = client.messages.create(
    model="MiniMax-M2.7",
    max_tokens=1024,
    system="You are a helpful assistant that speaks like a pirate.",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)
```

### Multi-turn conversations

```python theme={null}
message = client.messages.create(
    model="MiniMax-M2.7",
    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?"}
    ]
)
```

## Tool use (function calling)

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

<Note>
  Tool use works with `MiniMax-M2.7`, `MiniMax-M2.5`, and `gpt-oss-120b`. Other models may not reliably call tools. See [Function calling](/en/features/function-calling) for model-specific guidance.
</Note>

### Defining tools

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.infercom.ai",
    api_key="your-infercom-api-key"
)

message = client.messages.create(
    model="MiniMax-M2.7",
    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:

```json theme={null}
[
  {
    "type": "tool_use",
    "id": "call_abc123",
    "name": "get_weather",
    "input": {"location": "Munich, Germany"}
  }
]
```

### Providing tool results

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

```python theme={null}
message = client.messages.create(
    model="MiniMax-M2.7",
    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)
```

## Async usage

```python theme={null}
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="MiniMax-M2.7",
        max_tokens=1024,
        messages=[
            {"role": "user", "content": "Hello!"}
        ]
    )
    print(message.content[0].text)

asyncio.run(main())
```

## Using curl

You can also call the Messages API directly with curl:

```bash theme={null}
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": "MiniMax-M2.7",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'
```

## Supported parameters

| Parameter        | Type    | Description                                                  |
| ---------------- | ------- | ------------------------------------------------------------ |
| `model`          | string  | Required. The model to use (e.g., `MiniMax-M2.7`)            |
| `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-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)         |

## Unsupported features

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

## Differences from Anthropic's API

| Aspect         | Anthropic                     | Infercom                                             |
| -------------- | ----------------------------- | ---------------------------------------------------- |
| Models         | Claude (Opus, Sonnet, Haiku)  | Open-source models (MiniMax, DeepSeek, Llama, Gemma) |
| 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                               |

## 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](/en/features/responses-api) (`/v1/responses`) |
| New projects                     | Any - all three APIs work with the same models                |

## Related documentation

* [OpenAI compatibility](/en/features/openai-compatibility) - Using the OpenAI SDK
* [Function calling](/en/features/function-calling) - Detailed guide on tool use
* [Responses API](/en/features/responses-api) - Agentic workflows with structured outputs
* [Supported models](/en/models/infercomcloud-models) - Available models and capabilities
