Skip to main content

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:
apiKey
string
required
API key for the provider. Must not be empty or "REPLACE_ME".
baseUrl
string
Custom API endpoint URL. Use this for self-hosted instances or API proxies.

Supported Providers

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"
  }
}

Model Configuration

After configuring providers, specify which models to use:
ai.models.chat
string
required
Primary model for chat interactions. Format: provider:model-id
ai.models.vision
string
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:
ai.aliases
object
default:"{}"
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

  1. Start with one provider - Configure Anthropic or OpenAI first, add others as needed
  2. Use aliases - Create memorable shortcuts for frequently used models
  3. Configure vision models - Specify a vision-capable model if you need image understanding
  4. Secure your keys - Never commit API keys to version control
  5. Test configuration - Run babyclaw after configuration changes to validate

Getting API Keys

ProviderSign Up LinkFree Tier
Anthropicconsole.anthropic.com$5 credit
OpenAIplatform.openai.comLimited trial
Googlemakersuite.google.comFree quota
Mistralconsole.mistral.ai€5 credit
xAIconsole.x.aiLimited trial
OpenRouteropenrouter.aiFree credits

Build docs developers (and LLMs) love