OpenClaw Model Configuration

OpenClaw is model-agnostic and supports auth profile rotation and fallback chains. This chapter explains how to connect and configure models.


Supported Providers

TypeProviderAccess
CloudAnthropic (Claude)API key
CloudOpenAI (GPT)API key
CloudGoogle (Gemini)API key
LocalOllamaLocal endpoint
LocalLM Studio / other OpenAI-compatibleLocal endpoint

Models are configured in openclaw.json, with support for auth profile rotation and fallback chains — when the primary model is unavailable, it automatically switches to a backup.


Context Window & Local Model Requirements

For reliable operation, the project recommends:

  • Context window ≥ 64K tokens
  • For local models: 32B+ parameters and 24GB VRAM minimum

The agent must fit memory, tool descriptions, skills, and conversation history into context — too small a window leads to unstable behavior.


Configuring in openclaw.json

Model configuration lives in the main config file openclaw.json (under ~/.openclaw/). Key areas include:

  • Provider settings and auth
  • Model routing preferences: primary model, fallback chain
  • Tool policies and approval gates
  • Autonomy level settings

An illustrative snippet (exact fields defer to your version):

{
  // Model routing: prefer Claude, fall back to GPT on failure
  "model": {
    "primary": "anthropic:claude-...",
    "fallback": ["openai:gpt-...", "ollama:llama3.1:70b"]
  }
}

Credentials & Environment Variables

Keep secrets like API keys in environment variables or a separate config, out of files that might be shared/committed:

ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=...

Relevant paths can be overridden via environment variables:

VariablePurpose
OPENCLAW_HOMEBase directory
OPENCLAW_CONFIG_PATHPoint to a config file

Security tip: never commit keys to Git; keep ~/.openclaw/ private.


Three Typical Setups

1) Cloud frontier models (most reliable)

Use strong Anthropic / OpenAI / Google models directly — best tool calling and long-task performance, ideal for stable everyday use.

2) Local models (most private)

Run open models with Ollama or LM Studio so data never leaves your network. Meet the 32B+ / 24GB VRAM recommendation, or complex tasks may be unstable.

3) Hybrid + fallback chain (cost and reliability)

Use a cheap/local model for simple tasks and fall back to a strong cloud model when complex or failing:

simple tasks → local Ollama (cheap)
failure/complex → fall back to Claude / GPT (quality)

Cost Notes

Rough monthly API spend by usage intensity:

IntensityEstimate (indicative)
Light use$18–36 / month
Active agents with frequent heartbeats$50–150 / month
Unoptimized deploymentspotentially thousands / month

Strongly recommended: set spending alerts at the provider level. Shorter heartbeat intervals and pricier models grow the bill faster — see CLI & Automation.


Next Steps