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:
| Provider | Models | Strengths |
|---|
| OpenAI | GPT-4o, GPT-4o-mini, GPT-4-turbo, o1, o1-mini | Strongest general reasoning, function calling |
|---|
| Anthropic | Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku | Long context, nuanced writing, safety |
|---|
| Gemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 Flash | Multimodal, large context window |
|---|
| Mistral | Mistral Large, Mixtral 8x22B, Mistral Small | Open-weight, fast, EU-hosted |
|---|
| Ollama | Llama 3, Phi-3, Gemma 2, Qwen 2.5 | Fully local, no API key needed |
|---|
| OpenRouter | 100+ models | Single 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
.envfile that is listed in.gitignore.
Model Parameters
Fine-tune how the model generates responses:
| Parameter | Default | Range | Description |
|---|
temperature | 0.7 | 0.0–2.0 | Creativity vs. determinism. Lower = more focused. |
|---|
max_tokens | 4096 | 1–model limit | Maximum response length |
|---|
top_p | 1.0 | 0.0–1.0 | Nucleus sampling. Alternative to temperature. |
|---|
frequency_penalty | 0.0 | -2.0–2.0 | Penalize repeated tokens |
|---|
presence_penalty | 0.0 | -2.0–2.0 | Encourage topic diversity |
|---|
Different tasks benefit from different models:
| Use Case | Recommended Model | Why |
|---|
| General assistant | openai/gpt-4o | Best all-round performance |
|---|
| Writing and content | anthropic/claude-3-5-sonnet | Nuanced, long-form writing |
|---|
| Quick responses | openai/gpt-4o-mini | Fast, cost-effective |
|---|
| Code generation | anthropic/claude-3-5-sonnet | Strong coding ability |
|---|
| Privacy-sensitive | ollama/llama3 | Runs entirely locally |
|---|
| Large documents | google/gemini-1.5-pro | 1M+ token context window |
|---|
| Complex reasoning | openai/o1 | Chain-of-thought reasoning |
|---|
| Budget-friendly | mistral/mistral-small | Low 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
| Model | Parameters | RAM Required | GPU Recommended |
|---|
| Llama 3 8B | 8B | 8 GB | Optional |
|---|
| Llama 3 70B | 70B | 48 GB | 24 GB+ VRAM |
|---|
| Phi-3 Mini | 3.8B | 4 GB | Not needed |
|---|
| Mixtral 8x7B | 46.7B | 32 GB | 16 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
- Verify the key is correct:
openclaw config get providers.<name>.api_key - Check that the key has the right permissions on the provider's dashboard.
- Ensure you're using the correct provider name.
Model Responds Slowly
- Switch to a faster model (e.g.,
gpt-4o-miniormistral-small). - Reduce
max_tokensto limit response length. - Check your internet connection latency to the provider.
"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:
- Too creative / off-topic: Lower temperature to 0.2–0.4.
- Too repetitive / boring: Raise temperature to 0.8–1.0.
Next Steps
- Learn prompt techniques in Prompt Engineering 101.
- Set up platform connections in Connecting OpenClaw to Multiple Chat Platforms.
- Explore local models in OpenClaw System Requirements and Dependencies.
Related Articles
- Building a Custom Model Provider for OpenClaw — Create a custom LLM provider integration to use any AI model with your OpenClaw agent.
- Why does OpenClaw say "Model not allowed" or "Unknown model"? — Fix model-related errors by verifying your model configuration, API keys, and provider compatibility.
- Open-Source vs Proprietary LLMs — Which Should You Choose in 2026? — An honest comparison of open-source and proprietary LLMs in 2026: cost, performance, privacy, and when each one wins.
- How to Build a RAG Pipeline with Open-Source Tools in 2026 — Build a powerful RAG pipeline in 2026 using cutting-edge open-source tools for enhanced AI applications.
- AI Safety in 2026: What You Need to Know — Stay ahead on AI safety in 2026: threats, regulations, and practical controls for GPT-5, Claude 4, and Gemini 3 deployments. Reduce risk and ship with confidence.