Skip to main content

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.

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

Install the Anthropic SDK

pip install anthropic

Configure the client

Set the base_url to Infercom’s API and provide your Infercom API key.
Don’t have an Infercom API key? Get yours from the API keys and URLs page.
import anthropic

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

Basic usage

Non-streaming example

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

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

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.
Tool use works with MiniMax-M2.7, MiniMax-M2.5, and gpt-oss-120b. Other models may not reliably call tools. See Function calling for model-specific guidance.

Defining tools

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:
[
  {
    "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:
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

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

ParameterTypeDescription
modelstringRequired. The model to use (e.g., MiniMax-M2.7)
messagesarrayRequired. Array of message objects with role and content
max_tokensintegerRequired. Maximum tokens to generate
systemstringSystem prompt for the model
temperaturenumberSampling temperature (0.0-1.0)
top_pnumberNucleus sampling parameter
top_kintegerTop-k sampling parameter
stop_sequencesarrayCustom stop sequences
streambooleanEnable streaming responses
toolsarrayTool definitions for function calling
tool_choiceobjectControl 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

AspectAnthropicInfercom
ModelsClaude (Opus, Sonnet, Haiku)Open-source models (MiniMax, DeepSeek, Llama, Gemma)
Base URLhttps://api.anthropic.comhttps://api.infercom.ai
API key headerx-api-keyx-api-key (same)
Version headerRequired: anthropic-versionSupported but optional

When to use Anthropic vs OpenAI compatibility

Use caseRecommended API
Existing Anthropic SDK codeAnthropic Messages API (/v1/messages)
Claude Code, LangChain AnthropicAnthropic Messages API (/v1/messages)
OpenAI SDK codeOpenAI Chat Completions API (/v1/chat/completions)
Agentic workflows, coding toolsResponses API (/v1/responses)
New projectsAny - all three APIs work with the same models