Antbase/Documentation

REST API Integration

Make direct HTTP requests to ANT using curl, Postman, or any HTTP client.

Base URL

https://antbase.ai

OpenAI-compatible endpoints are under /v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer your-ant-api-key

Chat Completions

The main endpoint for sending prompts and receiving responses.

Basic Request

curl -X POST https://antbase.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ant:auto",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  }'

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1708123456,
  "model": "anthropic/claude-haiku-4-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21
  }
}

With Streaming

curl -X POST https://antbase.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ant:auto",
    "messages": [{"role": "user", "content": "Tell me a joke"}],
    "stream": true
  }'

Anthropic Messages API

ANT also supports the Anthropic Messages format at /v1/messages. Use this if your client expects Anthropic-style requests and responses.

Basic Request

curl -X POST https://antbase.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "ant:auto",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Response

{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "model": "anthropic/claude-haiku-4-5",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 9
  }
}

With Streaming

curl -X POST https://antbase.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "ant:best",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
      {"role": "user", "content": "Explain quantum computing briefly"}
    ]
  }'

Streaming uses Anthropic SSE format with event types: message_start, content_block_delta, message_stop.

With Vision

curl -X POST https://antbase.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "ant:best",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/jpeg",
              "data": "BASE64_IMAGE_DATA"
            }
          },
          {
            "type": "text",
            "text": "What is in this image?"
          }
        ]
      }
    ]
  }'

With Tool Use

curl -X POST https://antbase.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "ant:best",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get current weather for a location",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": {"type": "string", "description": "City name"}
          },
          "required": ["location"]
        }
      }
    ],
    "messages": [
      {"role": "user", "content": "What is the weather in Tokyo?"}
    ]
  }'

Authentication: The Messages API accepts both x-api-key: YOUR_KEY (Anthropic style) and Authorization: Bearer YOUR_KEY (OpenAI style).

Which API Should I Use?

FeatureChat Completions (/v1/chat/completions)Messages (/v1/messages)
FormatOpenAIAnthropic
Auth headerAuthorization: Bearerx-api-key or Authorization: Bearer
Streamingdata: {...} / data: [DONE]event: type / data: {...}
Visionimage_url in content arrayimage source with base64/url
ToolsOpenAI function formatAnthropic tool format
Best forMost clients, OpenAI SDKs, LangChainAnthropic SDK, OpenClaw

Both endpoints support all virtual models (ant:auto, ant:best, etc.) and route to the same models. Choose based on which format your client expects.

ANT Response Headers

ANT adds custom headers to show what happened during routing:

X-Antbase-Model: anthropic/claude-haiku-4-5
X-Antbase-Virtual-Model: ant:auto
X-Antbase-Task-Type: chat
X-Antbase-Complexity: simple
X-Antbase-Tokens-Saved: 0

Use -i or -v with curl to see headers.

List Models

curl https://antbase.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Returns available virtual models and (if enabled) real models.

Health Check

curl https://antbase.ai/healthz

Returns { "status": "ok" } if the service is healthy.

Optional Request Headers

HeaderDescription
X-Antbase-SourceIdentify your client for analytics (e.g., "my-bot-v1")
X-Antbase-Skip-RoutingSet to "true" to bypass routing (use model as-is)

Error Responses

Errors follow a consistent format:

{
  "error": {
    "code": "INSUFFICIENT_CREDITS",
    "message": "Your workspace has insufficient credits",
    "retryable": false
  }
}
StatusMeaning
400Bad request (invalid model, missing fields)
401Invalid or missing API key
402Insufficient credits
429Rate limited
500Internal server error
502Upstream provider error