Antbase/Documentation

Messages (Anthropic-Compatible)

Anthropic-compatible endpoint for sending messages. Use this with the Anthropic SDK or Claude-style API clients.

POST/v1/messages

Create a message completion with automatic model routing (Anthropic format).

Request

Headers

HeaderRequiredDescription
x-api-keyYes*Your API key (Anthropic SDK style)
AuthorizationYes*Bearer token (OpenAI style alternative)
Content-TypeYesapplication/json

*Either x-api-key or Authorization: Bearer is required.

Body Parameters

ParameterTypeRequiredDescription
modelstringYesVirtual model (ant:auto) or real model name
messagesarrayYesArray of message objects (user/assistant roles)
max_tokensintegerYesMaximum tokens to generate
systemstringNoSystem prompt
streambooleanNoStream response as SSE events
temperaturenumberNoSampling temperature (0-1)
toolsarrayNoTool definitions (Anthropic format)

Example Request

curl -X POST https://antbase.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ant:auto",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain recursion in programming."}
    ]
  }'

Response

Response Body

{
  "id": "msg_abc123xyz",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-haiku-4-5",
  "content": [
    {
      "type": "text",
      "text": "Recursion is a programming technique where a function calls itself..."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 25,
    "output_tokens": 150
  }
}

Response Headers

HeaderDescription
X-Antbase-ClassifierHow the model was selected (auto, virtual, passthrough)

Streaming

Set "stream": true to receive Server-Sent Events with Anthropic event types.

event: message_start
data: {"type":"message_start","message":{"id":"msg_123","type":"message","role":"assistant","model":"ant:auto","content":[],"stop_reason":null,"usage":{"input_tokens":25,"output_tokens":0}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" world!"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":15}}

event: message_stop
data: {"type":"message_stop"}

Tool Use

Define tools using Anthropic's format. ANT converts these internally.

{
  "model": "ant:auto",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "What's the weather in Paris?"}],
  "tools": [
    {
      "name": "get_weather",
      "description": "Get current weather for a location",
      "input_schema": {
        "type": "object",
        "properties": {
          "location": { "type": "string", "description": "City name" }
        },
        "required": ["location"]
      }
    }
  ]
}

SDK Usage

Use the official Anthropic SDK with a custom base URL:

# Python
import anthropic

client = anthropic.Anthropic(
    base_url="https://antbase.ai",  # No /v1 suffix
    api_key="ant_your-api-key",
)

message = client.messages.create(
    model="ant:auto",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)
// TypeScript
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  baseURL: 'https://antbase.ai',
  apiKey: process.env.ANT_API_KEY,
});

const message = await client.messages.create({
  model: 'ant:auto',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(message.content[0].text);

OpenAI vs Anthropic Format

ANT supports both API formats. Choose based on your SDK preference:

FeatureOpenAI (/v1/chat/completions)Anthropic (/v1/messages)
Auth headerAuthorization: Bearerx-api-key (or Bearer)
System promptIn messages arraySeparate "system" field
max_tokensOptionalRequired
Response contentStringContent blocks array
Stream eventsdata: onlyevent: + data: