How to Add Models in OpenClaw (Every Provider, 5 Minutes)

Add cloud, local, and custom models in OpenClaw. Covers API keys, OAuth, Ollama, LM Studio, OpenRouter, fallbacks, and per-agent routing.

8 min read

OpenClaw add models setup showing the mascot connected to multiple AI provider icons including Claude, GPT, Ollama, and DeepSeek

TL;DR: OpenClaw supports five methods to add models: built-in providers, OAuth login, Ollama, LM Studio, and custom OpenAI-compatible APIs. Every model uses the provider/model-name format. For built-in providers, set the API key and run openclaw models set provider/model. For local models, add the provider to models.providers in openclaw.json. Verify with openclaw models list.

I wasted an hour on my first model swap. Typo in the model string. Forgot to reload the gateway. Classic.

It's actually a 5-minute job once you know the pattern. Five methods, every provider, nothing extra. If you're also setting up agents to use these models, see how to add agents in OpenClaw — but models first.

The model reference format

Every model in OpenClaw follows one pattern: provider/model-name.

anthropic/claude-sonnet-4-5. openai/gpt-4o. ollama/llama3.3. OpenClaw splits on the first forward slash to separate provider from model ID. That's what goes in your config, your CLI commands, everywhere.

Get this wrong and nothing works. Get it right and everything else is just plugging in keys.

Five methods to add models in OpenClaw: built in providers, OAuth login, Ollama local, LM Studio, and custom providers

Method 1: built-in providers (fastest)

OpenClaw ships with a catalog of pre-configured providers. Anthropic, OpenAI, Google Gemini, DeepSeek, xAI, Groq, Mistral, OpenRouter. For these, you don't touch any config files. Just set a key and pick the model.

Set your API key:

export ANTHROPIC_API_KEY=sk-ant-your-key-here

Add it to .bashrc or .zshrc so it sticks. Then:

openclaw models set anthropic/claude-sonnet-4-5

Done. That's your default model for all agents. Verify:

openclaw models list

You should see the model listed with status "available." If it says "unavailable," your key is wrong or the env var didn't load. Run echo $ANTHROPIC_API_KEY to check.

Here's every built-in provider and the env var it needs:

ProviderEnv variableExample model
AnthropicANTHROPIC_API_KEYanthropic/claude-sonnet-4-5
OpenAIOPENAI_API_KEYopenai/gpt-4o
GoogleGEMINI_API_KEYgoogle/gemini-3-flash
DeepSeekDEEPSEEK_API_KEYdeepseek/deepseek-chat
xAIXAI_API_KEYxai/grok-3
GroqGROQ_API_KEYgroq/llama-3.3-70b
MistralMISTRAL_API_KEYmistral/mistral-large
OpenRouterOPENROUTER_API_KEYopenrouter/meta/llama-3.3

This flexibility with model choice is one of OpenClaw's key advantages. For alternatives and comparisons to other AI platforms, see the full breakdown.

OpenClaw add models terminal workflow showing three steps: export API key, run openclaw models set, and verify with openclaw models list

Multiple keys? Use the plural form with commas:

export ANTHROPIC_API_KEYS=sk-ant-key1,sk-ant-key2,sk-ant-key3

OpenClaw rotates between them when one hits a rate limit. Not round-robin. Only on 429 responses.

Skip the server setup. OpenclawVPS comes pre-configured with multi-model support. Add your API keys from the dashboard, pick your models, running in under a minute. See plans →

Method 2: OAuth login (use your existing subscription)

If you already pay for a Claude Pro/Max or ChatGPT Plus subscription, you can authenticate with your account directly instead of buying separate API credits.

For OpenAI:

openclaw models auth login --provider openai

This opens a browser window. Sign in with your OpenAI account. OpenClaw stores the token and uses your subscription for all OpenAI model requests.

For Anthropic, the flow uses a setup token:

openclaw models auth paste-token --provider anthropic

You generate the token from the Claude CLI or the Anthropic console, then paste it in.

The catch. Anthropic cracked down on this in early 2026. OAuth tokens from Pro/Max subscriptions now return 401 errors in third-party tools. So for Anthropic specifically, API keys are your only reliable option right now. OpenAI OAuth still works fine.

Bottom line: OAuth saves money if your provider supports it. But don't count on it for Anthropic models. Use API keys there.

Method 3: Ollama (local, free)

Ollama runs open-source models on your machine. No API costs. No data leaving your network. (This works on Android phones too, though performance is limited to CPU-only inference.)

Install it:

curl -fsSL https://ollama.com/install.sh | sh

Pull a model:

ollama pull llama3.3

Add Ollama as a provider in ~/.openclaw/openclaw.json:

{
  "models": {
    "providers": {
      "ollama": {
        "baseUrl": "http://127.0.0.1:11434",
        "api": "ollama-chat"
      }
    }
  }
}

Stop. Read that baseUrl. It's http://127.0.0.1:11434. Not http://127.0.0.1:11434/v1. That trailing /v1 is the number one Ollama mistake. It forces OpenAI compatibility mode and breaks tool calling. I burned 45 minutes on this.

Set it as your model:

openclaw models set ollama/llama3.3

Verify:

openclaw models list --local

Every model you've pulled shows up automatically. No need to define them individually in the config.

Method 4: LM Studio (local, GUI-based)

LM Studio is the other local option. Different from Ollama in one way: it exposes an OpenAI-compatible API. So the config uses /v1.

Start the LM Studio server, then add it:

{
  "models": {
    "providers": {
      "lmstudio": {
        "baseUrl": "http://127.0.0.1:1234/v1",
        "api": "openai-completions",
        "models": [
          {
            "id": "your-model-id",
            "name": "Model Display Name",
            "contextWindow": 8000,
            "maxTokens": 2000
          }
        ]
      }
    }
  }
}

Notice you have to define model metadata manually here: context window and max tokens. Ollama reads these from the Modelfile automatically. LM Studio's OpenAI layer doesn't report them, so you tell OpenClaw yourself.

openclaw models list --provider lmstudio

Method 5: custom providers (any OpenAI-compatible API)

Got a provider that's not built-in? If it speaks the OpenAI API format, OpenClaw can use it.

Two steps. Define the provider in models.providers, then add the model to your allowlist.

{
  "models": {
    "providers": {
      "myhost": {
        "baseUrl": "https://api.myhost.com/v1",
        "apiKey": "env:MYHOST_API_KEY",
        "api": "openai-completions",
        "models": [
          {
            "id": "myhost-model-70b",
            "name": "MyHost 70B",
            "contextWindow": 32000,
            "maxTokens": 4096
          }
        ]
      }
    },
    "allowlist": ["myhost/myhost-model-70b"]
  }
}

The allowlist key needs the fully-qualified name: myhost/myhost-model-70b, not just myhost-model-70b. Miss this and the model won't show up in openclaw models list.

The id field has to match exactly what the provider's API expects. Check their docs. Wrong ID means failed requests or hitting a different model than you intended.

Add fallbacks

Don't run a single model with no backup. When your primary hits rate limits or the provider goes down, your agents just stop.

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-5",
        "fallbacks": ["anthropic/claude-haiku-4-5", "openai/gpt-4o"]
      }
    }
  }
}

Sonnet goes down? OpenClaw tries Haiku. Haiku down? Falls back to GPT-4o. This saved me during the Anthropic outage in February. Agents kept running while everyone else's were dead.

Route different models per agent

Once you have multiple models configured, you can assign each agent its own. Put the expensive model where it matters, cheap ones everywhere else.

{
  "agents": {
    "list": [
      {
        "id": "coding",
        "workspace": "~/.openclaw/workspace-coding",
        "model": {
          "primary": "anthropic/claude-sonnet-4-5"
        }
      },
      {
        "id": "chat",
        "workspace": "~/.openclaw/workspace-chat",
        "model": {
          "primary": "deepseek/deepseek-chat"
        }
      },
      {
        "id": "personal",
        "workspace": "~/.openclaw/workspace-personal",
        "model": {
          "primary": "ollama/llama3.3"
        }
      }
    ]
  }
}

Coding agent gets Sonnet. Chat gets DeepSeek at $0.27/million tokens. Personal stuff runs on Ollama for free. Same OpenClaw instance, three different models matched to three different jobs.

Troubleshooting

"Model not found" means the model string is wrong. Run openclaw models list --all to see exact strings. It's anthropic/claude-sonnet-4-5, not claude-sonnet-4.5 or anthropic/sonnet.

Ollama "connection refused" means the server isn't running. Start with ollama serve. On macOS it runs as a background service automatically. On Linux you might need to start it manually or set up systemd.

Config changes not showing up. Model provider changes sometimes need a gateway restart:

openclaw gateway restart

"Rate limit exceeded" with no fallback. Add fallback models. OpenClaw only rotates on 429 responses. No fallbacks configured = dead agent.

Run openclaw doctor if anything feels off. It validates your entire config, checks API keys, and flags issues before they break something.

Don't want to manage configs and restarts? OpenclawVPS handles the infrastructure. Pick your models from a dashboard, bring your own API keys, and your agents stay online 24/7. No config files to edit. See plans →

Quick reference

OpenClaw add models quick reference showing seven steps: built in provider, OAuth, Ollama, LM Studio, custom provider, verify, and add fallbacks

  1. Built-in provider: Set env var → openclaw models set provider/model
  2. OAuth: openclaw models auth login --provider <name>
  3. Ollama: Install → pull model → add provider to openclaw.json with ollama-chat API
  4. LM Studio: Start server → add provider with /v1 and openai-completions API
  5. Custom: Define in models.providers → add to allowlist → set with CLI
  6. Always verify: openclaw models list
  7. Always add fallbacks. Your future self will thank you.

Check the OpenClaw model docs for the full model catalog and the provider reference for advanced provider config.

Once your models are set up, the next step is adding agents. From there, extend what your agents can do with skills and MCP servers, or connect them to Telegram so you can message them from your phone.

Ready to run OpenClaw without the server headaches? OpenclawVPS gives you a managed instance with dashboard model config, 24/7 uptime, and zero maintenance. Get started →


Frequently asked questions

What do I do when OpenClaw says 'Model not found'?
The model string is wrong. Run 'openclaw models list --all' to see exact strings. Use the provider/model-name format, for example 'anthropic/claude-sonnet-4-5', not 'claude-sonnet-4.5' or 'anthropic/sonnet'.
Why does Ollama show 'connection refused' in OpenClaw?
The Ollama server isn't running. Start it with 'ollama serve'. On macOS it runs as a background service automatically. On Linux you may need to start it manually or set up systemd.
Do I need to restart the gateway after changing model config?
Yes, model provider changes sometimes need a gateway restart. Run 'openclaw gateway restart' to apply changes.
How do I add fallback models in OpenClaw?
Add a fallbacks array in agents.defaults.model in openclaw.json. For example, set 'anthropic/claude-sonnet-4-5' as primary with fallbacks to 'anthropic/claude-haiku-4-5' and 'openai/gpt-4o'. OpenClaw tries each one on 429 rate limit errors.

Keep reading