Change OpenClaw Model — Set Your AI Model and Provider (2026)

Clawpedia · For Humans

How to change the OpenClaw model and provider: switch between GPT, Claude, Gemini and local open-source LLMs, set API keys, and pick the right model per task.

Overview

OpenClaw supports a wide range of AI providers and models. Choosing the right combination directly impacts your agent's intelligence, speed, cost, and capabilities. This guide explains how to configure your preferred provider, switch between models, and optimize settings for different use cases.

Supported Providers

OpenClaw works with all major AI providers out of the box:

ProviderModelsStrengths
OpenAIGPT-4o, GPT-4o-mini, GPT-4-turbo, o1, o1-miniStrongest general reasoning, function calling
AnthropicClaude 3.5 Sonnet, Claude 3 Opus, Claude 3 HaikuLong context, nuanced writing, safety
GoogleGemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 FlashMultimodal, large context window
MistralMistral Large, Mixtral 8x22B, Mistral SmallOpen-weight, fast, EU-hosted
OllamaLlama 3, Phi-3, Gemma 2, Qwen 2.5Fully local, no API key needed

Setting the Provider and Model

Via CLI

OpenRouter100+ modelsSingle API key for multiple providers

The fastest way to switch your model:


# Set provider and model separately
openclaw config set model.provider openai
openclaw config set model.name gpt-4o

# Or use the combined format
openclaw config set model openai/gpt-4o

# Apply immediately with restart
openclaw config set model openai/gpt-4o --restart

Via Config File

Edit ~/.openclaw/config.yaml:


model:
  provider: openai
  name: gpt-4o
  temperature: 0.7
  max_tokens: 4096
  top_p: 1.0

Via Environment Variable


export OPENCLAW_MODEL=anthropic/claude-3-5-sonnet
export OPENCLAW_API_KEY=sk-ant-...
openclaw start

API Key Configuration

Each provider requires its own API key:


# Set API keys per provider
openclaw config set providers.openai.api_key sk-...
openclaw config set providers.anthropic.api_key sk-ant-...
openclaw config set providers.google.api_key AIza...

# Or use environment variables
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...

In config.yaml:


providers:
  openai:
    api_key: sk-...
  anthropic:
    api_key: sk-ant-...
  google:
    api_key: AIza...
  ollama:
    base_url: http://localhost:11434

Security Tip: Never commit API keys to version control. Use environment variables or a .env file that is listed in .gitignore.

Model Parameters

Fine-tune how the model generates responses:

ParameterDefaultRangeDescription
temperature0.70.0–2.0Creativity vs. determinism. Lower = more focused.
max_tokens40961–model limitMaximum response length
top_p1.00.0–1.0Nucleus sampling. Alternative to temperature.
frequency_penalty0.0-2.0–2.0Penalize repeated tokens

model:
  provider: openai
  name: gpt-4o
  temperature: 0.3      # More precise answers
  max_tokens: 8192      # Longer responses allowed
  frequency_penalty: 0.2 # Reduce repetition

Choosing the Right Model

presence_penalty0.0-2.0–2.0Encourage topic diversity

Different tasks benefit from different models:

Use CaseRecommended ModelWhy
General assistantopenai/gpt-4oBest all-round performance
Writing and contentanthropic/claude-3-5-sonnetNuanced, long-form writing
Quick responsesopenai/gpt-4o-miniFast, cost-effective
Code generationanthropic/claude-3-5-sonnetStrong coding ability
Privacy-sensitiveollama/llama3Runs entirely locally
Large documentsgoogle/gemini-1.5-pro1M+ token context window
Complex reasoningopenai/o1Chain-of-thought reasoning

Using Local Models with Ollama

Budget-friendlymistral/mistral-smallLow cost, decent quality

For complete privacy or offline use, run models locally with Ollama:


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

# Pull a model
ollama pull llama3

# Configure OpenClaw to use it
openclaw config set model.provider ollama
openclaw config set model.name llama3
openclaw config set providers.ollama.base_url http://localhost:11434

Hardware Requirements for Local Models

ModelParametersRAM RequiredGPU Recommended
Llama 3 8B8B8 GBOptional
Llama 3 70B70B48 GB24 GB+ VRAM
Phi-3 Mini3.8B4 GBNot needed

Using OpenRouter

Mixtral 8x7B46.7B32 GB16 GB+ VRAM

OpenRouter provides access to 100+ models through a single API key:


model:
  provider: openrouter
  name: anthropic/claude-3-5-sonnet

providers:
  openrouter:
    api_key: sk-or-...

This is particularly useful if you want to experiment with different models without managing multiple API keys.

Model Fallbacks

Configure fallback models in case your primary model is unavailable:


model:
  provider: openai
  name: gpt-4o
  fallbacks:
    - openai/gpt-4o-mini
    - anthropic/claude-3-haiku

When the primary model fails (rate limit, downtime), OpenClaw automatically tries the next model in the fallback chain.

Per-Skill Model Overrides

Different skills can use different models:


skills:
  code-review:
    model: anthropic/claude-3-5-sonnet  # Best for code
  quick-answer:
    model: openai/gpt-4o-mini           # Fast and cheap
  research:
    model: google/gemini-1.5-pro        # Large context

Cost Management

Track and control your API spending:


# View usage statistics
openclaw usage stats

# Set a monthly spending limit
openclaw config set budget.monthly_limit 50.00
openclaw config set budget.currency USD

# Get notified at 80% of the limit
openclaw config set budget.warning_threshold 0.8

Troubleshooting

"Invalid API Key" Error

Model Responds Slowly

"Model Not Found" Error

Model names vary by provider. Use the exact model identifier:


# List available models for a provider
openclaw models list --provider openai

Responses Are Too Random or Too Rigid

Adjust the temperature:

Next Steps

Related Articles