Change AI Models in OpenClaw: Claude, GPT-4o, or Local LLMs
Change AI Models in OpenClaw: Claude, GPT-4o, or Local LLMs

Let's cut to it: one of the best features of OpenClaw is that you're not married to a single AI provider. You can swap between Claude, GPT-4o, Llama 3, Mistral, or whatever model you want β sometimes even within the same workflow. But the documentation on how to actually do this is scattered, and most people end up confused, stuck on a default model they didn't choose, or burning money on GPT-4o calls when a local model would've been fine.
This post walks you through exactly how to change AI models in OpenClaw, why you'd want to, and how to set up multi-model workflows that use the right brain for the right job.
Why This Matters More Than You Think
Here's the dirty secret of AI agent frameworks: most of them are built with OpenAI's API as the assumed default, and everything else is an afterthought. Try to use a local model? Half the features break. Want to use Claude for writing and GPT-4o for reasoning? You're looking at a weekend of hacky workarounds.
OpenClaw was designed differently. It's model-agnostic at its core, which means swapping providers isn't a config hack β it's a first-class feature. The framework doesn't care where the intelligence comes from. It cares about getting the task done.
This matters for three practical reasons:
-
Cost control. GPT-4o is powerful but expensive. If your agent is doing simple classification or validation steps, you're lighting money on fire using a frontier model for every single call.
-
Performance optimization. Different models are genuinely better at different things. Claude tends to produce cleaner long-form writing. GPT-4o is often sharper at multi-step reasoning. Local models like Llama 3 are fast and free once you've got the hardware. Matching the model to the task isn't just smart β it's the difference between an agent that works and one that kind of works.
-
Privacy and data control. Some workflows involve sensitive data that shouldn't leave your network. Running a local LLM through Ollama or LM Studio means nothing hits an external API. OpenClaw makes this seamless rather than painful.
The Basics: Changing Your Default Model
The simplest change is swapping the default model your OpenClaw agent uses. This is a one-line configuration change.
from openclaw import OpenClawAgent
# Default: uses whatever model is configured in your environment
agent = OpenClawAgent(
objective="Analyze this dataset and generate a report"
)
# Explicit: specify exactly which model you want
agent = OpenClawAgent(
model="claude-sonnet-4-20250514",
objective="Analyze this dataset and generate a report"
)
OpenClaw supports a straightforward naming convention for models:
# OpenAI models
model="gpt-4o"
model="gpt-4o-mini"
model="gpt-3.5-turbo"
# Anthropic models
model="claude-sonnet-4-20250514"
model="claude-3-haiku"
# Local models via Ollama
model="ollama:llama3"
model="ollama:mistral"
model="ollama:codellama"
# Local models via LM Studio
model="lm-studio:mixtral-8x7b"
For this to work, you need the appropriate API keys set in your environment (or in your OpenClaw config file):
# .env file or environment variables
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here
# For local models, just make sure Ollama or LM Studio is running
OLLAMA_HOST=http://localhost:11434
That's it for the basic swap. Change the model string, make sure your credentials are in place, and OpenClaw handles the rest β including adjusting prompt formats for different providers.
The Good Stuff: Multi-Model Workflows
This is where OpenClaw actually shines compared to other frameworks. Instead of one model doing everything, you can assign different models to different roles within the same agent workflow.
Think of it like staffing a project. You wouldn't hire a senior architect to do data entry. Same logic applies here.
agent = OpenClawAgent(
planner_model="gpt-4o", # Strategic thinking
executor_model="claude-sonnet-4-20250514", # Implementation and writing
critic_model="gpt-4o-mini", # Validation and checking
objective="Research competitor pricing and write an analysis report"
)
In this setup:
- GPT-4o handles the planning phase β breaking the objective into steps, deciding which tools to use, sequencing actions. This is where strong reasoning matters most.
- Claude Sonnet handles execution β actually writing the report, synthesizing research, producing the final output. Claude tends to write more naturally and follow complex formatting instructions better.
- GPT-4o Mini handles the critic role β reviewing outputs, checking for errors, validating that the plan was followed. This doesn't require a frontier model, so you save money.
The cost difference is significant. If your agent takes 20 steps to complete a task, and only 4 of those steps need frontier-model reasoning, you've just cut your API costs by roughly 60-70% without sacrificing quality where it counts.
Setting Up Local Models (The Right Way)
Running local models with OpenClaw is one of the most underrated setups. Zero API costs, full data privacy, and surprisingly good performance for many common tasks.
Option 1: Ollama (Recommended for Most People)
Ollama is the easiest path. Install it, pull a model, and point OpenClaw at it.
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull the models you want
ollama pull llama3
ollama pull codellama
ollama pull mistral
Then in your OpenClaw config:
agent = OpenClawAgent(
model="ollama:llama3",
optimize_for_local=True, # Enables batching, reduces round-trips
objective="Process these log files and extract error patterns"
)
The optimize_for_local=True flag is important. It tells OpenClaw to batch operations where possible, reduce the number of inference calls, and adjust prompt lengths to work within local model context windows. Without it, you might see performance issues because OpenClaw would treat it like calling a cloud API β lots of small, frequent calls that tank local throughput.
Option 2: LM Studio
If you prefer a GUI and want to browse/download models visually, LM Studio works great. Start the local server in LM Studio, then:
agent = OpenClawAgent(
model="lm-studio:mixtral-8x7b",
optimize_for_local=True,
objective="Summarize these customer support tickets"
)
When to Use Local vs. Cloud
Here's my honest take after running both extensively:
| Task | Best Model Choice | Why |
|---|---|---|
| Complex multi-step reasoning | GPT-4o | Best at planning and tool orchestration |
| Long-form writing/reports | Claude Sonnet | More natural prose, better formatting |
| Code generation | Claude Sonnet or CodeLlama (local) | Both excellent, local is free |
| Simple classification/routing | Local Llama 3 or GPT-4o Mini | Don't overpay for simple tasks |
| Data processing/extraction | Local Mistral or GPT-4o Mini | Speed matters more than brilliance |
| Sensitive data handling | Any local model | Nothing leaves your machine |
Automatic Model Selection
If you don't want to manually assign models, OpenClaw can make the choice for you:
agent = OpenClawAgent(
auto_select=True,
available_models=["gpt-4o", "gpt-4o-mini", "ollama:llama3"],
objective="Handle this customer inquiry"
)
With auto_select=True, OpenClaw analyzes each step in the workflow and picks the most appropriate model from your available list. Planning steps get routed to stronger models. Simple validation steps get routed to cheaper or local ones. It's not perfect β sometimes it's overly conservative and uses the expensive model when it doesn't need to β but it's a solid starting point that you can tune over time.
Fallback Chains: Because APIs Go Down
One of the pain points that drives people crazy with other frameworks: your agent is mid-task, the API returns a rate limit error, and everything crashes. No recovery. No fallback. Just a stack trace and wasted money.
OpenClaw handles this with fallback chains:
agent = OpenClawAgent(
model="gpt-4o",
fallback_chain=["claude-sonnet-4-20250514", "gpt-4o-mini", "ollama:llama3"],
token_budget=50000,
objective="Generate weekly analytics report"
)
If GPT-4o hits a rate limit or errors out, OpenClaw automatically falls to Claude Sonnet. If that fails too, it drops to GPT-4o Mini. Last resort: it runs locally on Llama 3. Your agent keeps working instead of dying.
The token_budget parameter also ties into this. If your budget is running low, OpenClaw can proactively step down to a cheaper model before you hit the limit, rather than just stopping mid-task.
agent = OpenClawAgent(
model="gpt-4o",
token_budget=50000,
cost_tracking=True,
fallback_model="gpt-4o-mini", # Switch when budget gets tight
objective="Process these 200 support tickets"
)
This is the kind of defensive execution that separates a framework you can actually rely on from one that works great in demos and crumbles in production.
Prompt Adaptation: The Hidden Complexity
Here's something most people don't realize: when you swap models, the prompts need to change too. GPT-4o and Claude interpret instructions differently. Local models have different prompt templates (ChatML vs. Llama format vs. Alpaca format). If you just swap the model string and send the same prompt, you'll get degraded results.
OpenClaw handles this automatically. When you specify a model, the framework adjusts:
- System prompt formatting to match the model's preferred structure
- Tool-use syntax (OpenAI function calling vs. Claude tool use vs. manual tool prompting for local models)
- Output parsing to account for different response formats
- Token estimation based on the model's specific tokenizer
# You write this once:
agent = OpenClawAgent(
objective="Analyze code for security issues",
tools=[code_scanner, vulnerability_db, report_generator]
)
# OpenClaw internally generates different prompts for:
# - GPT-4o (uses native function calling)
# - Claude (uses Claude's tool_use format)
# - Llama 3 (uses structured prompting with examples)
This is why the "30 prompt rewrites" problem from other frameworks doesn't apply here. You define your intent. OpenClaw handles the prompt engineering per model. It's not magic β it's pre-tested templates and adaptation logic β but it saves you an enormous amount of time.
A Real Example: Research Agent with Model Mixing
Let me walk through a concrete workflow that uses multiple models effectively:
from openclaw import OpenClawAgent, tools
agent = OpenClawAgent(
planner_model="gpt-4o",
executor_model="claude-sonnet-4-20250514",
critic_model="gpt-4o-mini",
max_steps=15,
token_budget=30000,
loop_detection=True,
tools=[tools.search, tools.fetch_page, tools.summarize],
objective="Research the current state of vector databases and write a technical summary"
)
result = agent.execute(debug_mode=True)
Here's what happens under the hood:
- GPT-4o (Planner): "I need to search for recent vector database comparisons, fetch the top 3-5 most relevant articles, then synthesize findings."
- Claude Sonnet (Executor): Runs the search, fetches pages, reads content. Because
loop_detection=True, it doesn't spiral into fetching 50 articles β it grabs the top-ranked ones and moves on. - GPT-4o Mini (Critic): Reviews the fetched content. "Article 3 is from 2022, too outdated. Articles 1, 2, and 4 are sufficient and current."
- Claude Sonnet (Executor): Writes the technical summary using the validated sources.
- GPT-4o Mini (Critic): Checks the summary for accuracy against source material. Approves.
Total cost: roughly $1.50-2.00. Total time: about 3 minutes. Compare that to a single-model approach that might burn $15 and take 30 minutes because it's using GPT-4o for every step including the ones that don't need it.
Testing Your Model Configuration
Before you deploy a multi-model workflow, test it. OpenClaw makes this actually possible (unlike most frameworks where testing is basically "run it and hope"):
def test_model_fallback():
agent = OpenClawAgent(
model="gpt-4o",
fallback_chain=["claude-sonnet-4-20250514", "ollama:llama3"],
deterministic=True,
seed=42
)
# Simulate primary model failure
with mock_model("gpt-4o", raises=RateLimitError):
result = agent.execute("Summarize this document")
assert result.model_used == "claude-sonnet-4-20250514"
assert result.fallback_triggered == True
assert result.status == "completed"
The deterministic=True flag with a seed makes runs reproducible. Mock model responses let you test failure scenarios without actually hitting APIs. This is how you build agent workflows you can actually trust in production.
The Fastest Way to Get Running
If you've read this far and you're thinking "this is great but I don't want to configure all of this from scratch" β I get it. Setting up model configs, fallback chains, tool integrations, and testing all takes time.
Felix's OpenClaw Starter Pack on Claw Mart is honestly the fastest way to get a properly configured multi-model setup running. For $29, you get pre-configured skills with model routing already dialed in β the fallback chains, the cost optimization settings, the prompt templates for different providers. It's the kind of thing that would take you a weekend to set up manually, and Felix has clearly spent a lot of time testing the configurations across different model combinations. If you're serious about using OpenClaw in production and don't want to reinvent the wheel on the model configuration side, it's a no-brainer starting point.
My Recommendations
After months of running various configurations, here's what I'd suggest:
If you're just starting out: Use claude-sonnet-4-20250514 as your default. It's the best all-around model for agent tasks right now β good at reasoning, great at writing, solid tool use. Switch to GPT-4o if you find specific planning tasks where Claude struggles.
If you're cost-conscious: Set up a multi-model workflow with GPT-4o for planning, GPT-4o Mini for execution and validation. You'll get 80% of the quality at 20% of the cost.
If you're privacy-focused: Go local with Ollama and Llama 3. Use optimize_for_local=True and be patient with the initial setup. Once it's running, you've got zero ongoing costs and complete data control.
If you want maximum reliability: Set up fallback chains. Always. Cloud APIs go down, rate limits hit at the worst times, and your agent shouldn't just die when that happens. Even if your primary is a cloud model, having a local fallback means your workflow survives outages.
The whole point of OpenClaw being model-agnostic is that you're never locked in. Start with whatever model you have access to. Optimize later. The framework makes switching trivially easy, so there's no penalty for changing your mind once you see real performance data from your specific use cases.
Now go swap some models. Your wallet (and your workflows) will thank you.
Recommended for this post

