OpenCode Integration
Use ANT as the backend for OpenCode to get intelligent model routing for your coding sessions.
Setup via Custom Provider
OpenCode supports adding custom OpenAI-compatible providers through its settings UI. Open OpenCode settings and add ANT as a custom provider with the following details:
antANThttps://antbase.ai/v1ant_...Your ANT API key from the dashboardAfter saving, select ANT as your provider in OpenCode and choose a model. For coding, we recommend ant:coder or ant:reasoning. All requests will route through ANT, which picks the best underlying model automatically.
Alternative: Environment Variables
You can also configure ANT via environment variables before launching OpenCode:
export OPENAI_API_BASE=https://antbase.ai/v1
export OPENAI_API_KEY=your-ant-api-key
opencodeConfiguration File
For a persistent setup, add ANT as a provider in your OpenCode config file (~/.opencode/config.json or opencode.json in your project root):
{
"provider": "openai-compatible",
"baseUrl": "https://antbase.ai/v1",
"apiKey": "${ANT_API_KEY}",
"model": "ant:coder"
}The ${ANT_API_KEY} syntax references an environment variable so you don't have to hardcode your key in the config file.
Best Models for Coding
ANT exposes virtual model names that automatically route to the best underlying provider. For coding with OpenCode, reasoning models are the best choice — they think step-by-step through complex logic, catch edge cases, and produce more reliable code.
Coding & Reasoning
ant:coderbest for codingOptimized for code generation, refactoring, and debugging. Routes to the highest-quality coding models available. Use this as your default model in OpenCode.
ant:reasoningdeep thinkingRoutes to thinking-capable models (DeepSeek-R1, Qwen3-Thinking, etc.) that reason through problems step-by-step. Excellent for algorithmic problems, complex debugging, and architecture decisions.
ant:reasoning-premiumMaximum quality reasoning. Only routes to the most capable thinking models (quality score 85+). Use for the hardest problems where correctness matters more than speed.
ant:reasoning-fastFast reasoning for quick iterations. Still uses thinking models but favors speed over depth. Good for simpler logic problems and rapid prototyping.
General Purpose
ant:bestHighest quality non-reasoning model. Great for complex tasks that don't need step-by-step thinking — documentation, code review, explanations.
ant:autoSmart routing based on prompt complexity. Simple questions get fast models, hard questions get powerful ones. Good if you want one model for everything.
ant:balancedBalance between quality, speed, and cost. Minimum quality score of 60.
ant:fastLowest latency. Ideal for inline completions, quick edits, and simple questions.
ant:freeZero-cost tier using free provider models. Good for experimentation and non-critical tasks.
Specialized
ant:visionVision-capable models for analyzing images, screenshots, diagrams, and UI mockups.
ant:creativeOptimized for creative writing, brainstorming, and content generation.
How to Test
Before launching OpenCode, verify that ANT is reachable and your key works:
Health Check
# Verify ANT is reachable
curl -s https://antbase.ai/healthzTest a Coding Request
curl -X POST https://antbase.ai/v1/chat/completions \
-H "Authorization: Bearer $ANT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ant:coder", "messages": [{"role": "user", "content": "Write a hello world in Rust"}], "max_tokens": 200}'You should get a JSON response with a Rust hello world program. Check the X-Antbase-Model response header to see which model ANT selected.
Troubleshooting
"Connection refused"
Check that the Base URL is set correctly and includes the
/v1suffix:https://antbase.ai/v1"401 Unauthorized"
Verify your API key is correct and starts with
ant_. You can find your API key in the ANT dashboard under API Keys."Model not found"
Use virtual model names like
ant:auto,ant:best, orant:fast. Raw provider model names (e.g.gpt-4o) are also supported if your plan includes direct routing.