REST API Integration
Make direct HTTP requests to ANT using curl, Postman, or any HTTP client.
Base URL
https://antbase.aiOpenAI-compatible endpoints are under /v1
Authentication
Include your API key in the Authorization header:
Authorization: Bearer your-ant-api-keyChat 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?
| Feature | Chat Completions (/v1/chat/completions) | Messages (/v1/messages) |
|---|---|---|
| Format | OpenAI | Anthropic |
| Auth header | Authorization: Bearer | x-api-key or Authorization: Bearer |
| Streaming | data: {...} / data: [DONE] | event: type / data: {...} |
| Vision | image_url in content array | image source with base64/url |
| Tools | OpenAI function format | Anthropic tool format |
| Best for | Most clients, OpenAI SDKs, LangChain | Anthropic 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: 0Use -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/healthzReturns { "status": "ok" } if the service is healthy.
Optional Request Headers
| Header | Description |
|---|---|
X-Antbase-Source | Identify your client for analytics (e.g., "my-bot-v1") |
X-Antbase-Skip-Routing | Set 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
}
}| Status | Meaning |
|---|---|
400 | Bad request (invalid model, missing fields) |
401 | Invalid or missing API key |
402 | Insufficient credits |
429 | Rate limited |
500 | Internal server error |
502 | Upstream provider error |