Overview
BabyClaw supports multiple AI providers through a unified configuration system. You can configure multiple providers simultaneously and reference models using the provider:model format.
Provider Configuration
All providers are configured in the ai.providers section of your config file:
{
"ai": {
"providers": {
"anthropic": {
"apiKey": "sk-ant-xxxxxxxxxxxxx"
},
"openai": {
"apiKey": "sk-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "anthropic:claude-sonnet-4-20250514"
}
}
}
Provider Schema
Each provider requires at minimum an API key:
API key for the provider. Must not be empty or "REPLACE_ME".
Custom API endpoint URL. Use this for self-hosted instances or API proxies.
Supported Providers
Anthropic
OpenAI
Google
Mistral
xAI
OpenRouter
Vercel Gateway
Anthropic (Claude)
Provider ID: anthropicGet your API key: Anthropic ConsoleExample models:
claude-sonnet-4-20250514 - Latest Sonnet model (recommended)
claude-opus-4-6 - Most capable model
claude-haiku-4-5 - Fast and efficient
claude-4.5-sonnet - Previous generation
claude-3.5-sonnet-20241022
claude-3.5-haiku-20241022
Configuration:{
"ai": {
"providers": {
"anthropic": {
"apiKey": "sk-ant-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "anthropic:claude-sonnet-4-20250514"
}
}
}
Custom base URL (for proxies):{
"anthropic": {
"apiKey": "sk-ant-xxxxxxxxxxxxx",
"baseUrl": "https://api.anthropic.example.com"
}
}
OpenAI
Provider ID: openaiGet your API key: OpenAI PlatformExample models:
gpt-4o - GPT-4 Optimized
gpt-4o-mini - Fast and cost-effective
gpt-4.1 - Latest GPT-4.1
gpt-4.1-mini - GPT-4.1 Mini
gpt-4.1-nano - Smallest GPT-4.1
o3 - Reasoning model
o3-mini - Fast reasoning
o4-mini - Latest mini model
Configuration:{
"ai": {
"providers": {
"openai": {
"apiKey": "sk-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "openai:gpt-4o",
"vision": "openai:gpt-4o"
}
}
}
Azure OpenAI:{
"openai": {
"apiKey": "your-azure-api-key",
"baseUrl": "https://your-resource.openai.azure.com/openai/deployments"
}
}
Google Generative AI
Provider ID: googleGet your API key: Google AI StudioExample models:
gemini-2.5-pro - Most capable Gemini model
gemini-2.5-flash - Fast Gemini
gemini-2.0-flash - Previous generation flash
gemini-2.0-flash-lite - Lightweight model
Configuration:{
"ai": {
"providers": {
"google": {
"apiKey": "AIzaSyxxxxxxxxxxxxx"
}
},
"models": {
"chat": "google:gemini-2.5-pro",
"vision": "google:gemini-2.5-pro"
}
}
}
Mistral AI
Provider ID: mistralGet your API key: Mistral ConsoleExample models:
mistral-large-latest - Most capable model
mistral-medium-latest - Balanced performance
mistral-small-latest - Fast and efficient
codestral-latest - Code-specialized model
pixtral-large-latest - Vision model
Configuration:{
"ai": {
"providers": {
"mistral": {
"apiKey": "xxxxxxxxxxxxx"
}
},
"models": {
"chat": "mistral:mistral-large-latest"
}
}
}
xAI (Grok)
Provider ID: xaiGet your API key: xAI ConsoleExample models:
grok-3 - Latest Grok model
grok-3-fast - Faster Grok
grok-3-mini - Smaller Grok
grok-3-mini-fast - Fast mini model
Configuration:{
"ai": {
"providers": {
"xai": {
"apiKey": "xai-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "xai:grok-3"
}
}
}
OpenRouter
Provider ID: openrouterGet your API key: OpenRouterOpenRouter provides unified access to many AI models from different providers.Example models:
anthropic/claude-sonnet-4
anthropic/claude-opus-4
anthropic/claude-4.5-sonnet
openai/gpt-4o
openai/gpt-4.1
openai/o3
openai/o4-mini
google/gemini-2.5-pro
google/gemini-2.5-flash
deepseek/deepseek-r1
deepseek/deepseek-chat-v3
meta-llama/llama-4-maverick
meta-llama/llama-4-scout
Configuration:{
"ai": {
"providers": {
"openrouter": {
"apiKey": "sk-or-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "openrouter:anthropic/claude-sonnet-4"
}
}
}
OpenRouter uses a different model naming format: provider/model-name within the OpenRouter namespace.
Vercel AI Gateway
Provider ID: gatewayGet your API key: Vercel DashboardVercel AI Gateway provides unified access, caching, and analytics.Example models:
anthropic/claude-sonnet-4-20250514
anthropic/claude-opus-4-6
openai/gpt-4o
openai/gpt-4.1
google/gemini-2.5-pro
Configuration:{
"ai": {
"providers": {
"gateway": {
"apiKey": "your-gateway-api-key",
"baseUrl": "https://your-gateway.vercel.app/api"
}
},
"models": {
"chat": "gateway:anthropic/claude-sonnet-4-20250514"
}
}
}
Model Configuration
After configuring providers, specify which models to use:
Primary model for chat interactions. Format: provider:model-id
Model for vision/image understanding tasks. Format: provider:model-idIf not specified, falls back to the chat model.
Example
{
"ai": {
"models": {
"chat": "anthropic:claude-sonnet-4-20250514",
"vision": "google:gemini-2.5-pro"
}
}
}
Model Aliases
Create shortcuts for commonly used models:
Dictionary mapping alias names to full model references.Alias names must match the pattern: /^[a-z0-9_-]+$/
Example
{
"ai": {
"providers": {
"anthropic": { "apiKey": "..." },
"openai": { "apiKey": "..." }
},
"models": {
"chat": "smart"
},
"aliases": {
"smart": "anthropic:claude-opus-4-6",
"fast": "openai:gpt-4o-mini",
"vision": "google:gemini-2.5-pro"
}
}
}
You can then reference models by alias in your configuration or when switching models.
Multi-Provider Setup
Configure multiple providers to switch between them easily:
{
"ai": {
"providers": {
"anthropic": {
"apiKey": "sk-ant-xxxxxxxxxxxxx"
},
"openai": {
"apiKey": "sk-xxxxxxxxxxxxx"
},
"google": {
"apiKey": "AIzaSyxxxxxxxxxxxxx"
},
"openrouter": {
"apiKey": "sk-or-xxxxxxxxxxxxx"
}
},
"models": {
"chat": "anthropic:claude-sonnet-4-20250514",
"vision": "google:gemini-2.5-pro"
},
"aliases": {
"fast": "openai:gpt-4o-mini",
"smart": "anthropic:claude-opus-4-6",
"deepthink": "openai:o3",
"backup": "openrouter:anthropic/claude-sonnet-4"
}
}
}
Environment Variables
While API keys must be configured in babyclaw.json, you can override the config file location:
export BABYCLAW_CONFIG_PATH=/path/to/config.json
Do not commit your configuration file with API keys to version control. Keep it secure and local.
Legacy Configuration
If you’re upgrading from an older version that used ai.gatewayApiKey, you’ll see an error:
Legacy configuration detected.
The 'ai.gatewayApiKey' field has been replaced by 'ai.providers'.
Run 'babyclaw model configure' to migrate.
The new multi-provider system is more flexible and allows you to use multiple AI providers simultaneously.
Validation
Common configuration errors:
- Missing API key: Ensure
apiKey is present and not "REPLACE_ME"
- Invalid provider: Provider ID must be one of:
anthropic, openai, google, mistral, xai, openrouter, gateway
- Invalid model reference: Must use format
provider:model-id
- No providers configured: At least one provider must be configured
- Invalid base URL: Must be a valid HTTP/HTTPS URL
Best Practices
- Start with one provider - Configure Anthropic or OpenAI first, add others as needed
- Use aliases - Create memorable shortcuts for frequently used models
- Configure vision models - Specify a vision-capable model if you need image understanding
- Secure your keys - Never commit API keys to version control
- Test configuration - Run
babyclaw after configuration changes to validate
Getting API Keys
| Provider | Sign Up Link | Free Tier |
|---|
| Anthropic | console.anthropic.com | $5 credit |
| OpenAI | platform.openai.com | Limited trial |
| Google | makersuite.google.com | Free quota |
| Mistral | console.mistral.ai | €5 credit |
| xAI | console.x.ai | Limited trial |
| OpenRouter | openrouter.ai | Free credits |