Antbase/Documentation
Back to Agents

OpenClaw

A terminal-based AI coding assistant. Connect it to ANT for intelligent routing across all your coding tasks — with automatic model selection, fallback chains, and cost optimization.

Quick Install

Run this command in your terminal. It will create an Antbase account (or log you in), generate an API key, and configure OpenClaw automatically.

curl -fsSL https://antbase.ai/install.sh | bash

Done!

The installer will detect your openclaw.json and add ANT as a provider.

Manual Configuration

If you prefer to configure OpenClaw manually, add ANT to your ~/.openclaw/openclaw.json:

{
  "providers": {
    "antbase": {
      "baseUrl": "https://antbase.ai",
      "apiKey": "${ANT_API_KEY}",
      "api": "anthropic-messages",
      "models": [
        { "id": "auto", "name": "ANT Auto", "reasoning": true, "input": ["text"], "contextWindow": 200000, "maxTokens": 8192 },
        { "id": "best", "name": "ANT Best", "reasoning": true, "input": ["text"], "contextWindow": 200000, "maxTokens": 16384 },
        { "id": "fast", "name": "ANT Fast", "reasoning": false, "input": ["text"], "contextWindow": 128000, "maxTokens": 4096 },
        { "id": "free", "name": "ANT Free", "reasoning": false, "input": ["text"], "contextWindow": 131072, "maxTokens": 8192 },
        { "id": "reasoning", "name": "ANT Reasoning", "reasoning": true, "input": ["text"], "contextWindow": 200000, "maxTokens": 16384 },
        { "id": "coder", "name": "ANT Coder", "reasoning": true, "input": ["text"], "contextWindow": 200000, "maxTokens": 16384 },
        { "id": "creative", "name": "ANT Creative", "reasoning": false, "input": ["text"], "contextWindow": 200000, "maxTokens": 16384 },
        { "id": "vision", "name": "ANT Vision", "reasoning": false, "input": ["text", "image"], "contextWindow": 128000, "maxTokens": 8192 }
      ]
    }
  }
}

Get your API key from the dashboard and set it in your environment:

export ANT_API_KEY="ant_your-api-key-here"

How Routing Works

When OpenClaw sends a request through ANT, it passes through a multi-stage pipeline before reaching a model:

┌──────────┐   ┌─────────────┐   ┌──────────────┐   ┌──────────┐   ┌──────────┐
│ OpenClaw │──▶│ Classify LLM│──▶│ Optimize LLM │──▶│ Route AI │──▶│   LLM    │
└──────────┘   └─────────────┘   └──────────────┘   └──────────┘   └──────────┘
                Task type &        Compress           Score &        2,500+ models
                complexity         (optional)         select         30+ providers
  1. Classify — ANT's custom classifier tags the request by task type (coding, reasoning, creative, etc.), complexity (simple/medium/complex), and required capabilities (vision, tools, reasoning)
  2. Optimize — Optional prompt compression removes redundant tokens, saving 20-40% on token costs
  3. Route — Scores all available models using preference weights (speed, quality, cost) combined with task classification
  4. Execute — Forwards to the highest-scoring model. If the provider fails, ANT re-scores and falls back to the next-best model from a different provider

The full pipeline adds ~100-200ms of overhead. For detailed scoring formula and configuration, see How It Works.

Virtual Models

Virtual models are routing presets. Instead of picking a specific model, you tell ANT what you care about and it selects the real model for each request. Use different virtual models for different use cases:

antbase/auto

Balanced routing — ANT picks the best model for each prompt

antbase/fast

Optimized for speed — quick queries, autocomplete

antbase/best

Maximum quality — complex reasoning, architecture

antbase/free

Zero-cost — uses free-tier provider models only

antbase/reasoning

Thinking models — o-series, Claude extended thinking, DeepSeek R1

antbase/coder

Code-optimized — favors high-quality code generation models

antbase/creative

Writing & dialogue — expressive models with good prose quality

antbase/vision

Image-capable — guaranteed to handle screenshots and visual content

For the full list of virtual models, weight configurations, and usage examples, see Virtual Models.

Custom Routing with Nests

Nests let you create custom routing groups that restrict which models ANT can select from. Assign a nest to an API key, and all requests using that key route exclusively through the nest's model set — with your custom preference weights.

Compliance Nest

Only approved providers/regions

Budget Nest

Only free-tier or low-cost models

Speed Nest

Only sub-200ms latency models

Provider-Specific Nest

Only models from one provider

Create and manage nests in the dashboard under Models > Nests. See Nests documentation for full setup instructions.

Usage

Once configured, OpenClaw works exactly as before. ANT handles routing transparently:

# Your existing OpenClaw commands work as before
openclaw chat "How do I implement a binary search?"

# ANT will:
# 1. Classify the prompt (coding, medium complexity)
# 2. Select the optimal model (e.g., DeepSeek V3 for code)
# 3. Stream the response back with routing info in headers

# Switch models per-request:
openclaw -m antbase/free "explain what this regex does"
openclaw -m antbase/best "design the database schema for a multi-tenant SaaS"
openclaw -m antbase/reasoning "prove that sqrt(2) is irrational"

ANT returns routing metadata in response headers: X-Antbase-Model (actual model used), X-Antbase-Task-Type (detected task), X-Antbase-Complexity (simple/medium/complex).

Automatic Failover

If the selected provider returns an error or times out, ANT automatically fails over to the next-best scored model from a different provider. Circuit breakers track provider health in real-time and temporarily remove unhealthy providers from the scoring pool.

Retry logic: Up to 3 attempts, each targeting a different provider. ANT re-scores remaining healthy models between retries.

ant:free behavior: If the entire free pool is exhausted, you get a clear error rather than a surprise charge. With ant:auto, free providers are tried first, then paid models if needed.

Troubleshooting

Install script fails

Make sure you have curl installed and can reach antbase.ai. The script will open your browser for authentication.

401 Unauthorized errors

Check that your API key is correct in openclaw.json. You can regenerate keys in the dashboard.

OpenClaw not using ANT

Ensure "defaultProvider": "antbase" is set in your config, or use the -p antbase flag when running commands.

Model not recognized

Make sure the model ID in your config matches a valid virtual model (e.g., auto, free, best). The provider prefix is added automatically by OpenClaw (e.g., antbase/auto).

Slow responses

The routing pipeline adds ~100-200ms. If responses are significantly slower, check your network connection to antbase.ai. Use antbase/fast to prioritize speed over quality.

Provider errors / 429 rate limits

ANT handles provider failures automatically via circuit breakers. If you see persistent errors, check the request logs in the dashboard for details on which providers are failing and why.