Provider Abstraction: Why OpenClaw Can Use Different Models
If OpenClaw could only use one model, it would be a client for that model.
Provider abstraction is what makes it a platform.
The question is:
If model APIs differ, how can one OpenClaw agent loop call all of them?
The Key Idea: Providers Contain Model Differences
Providers handle differences such as:
authentication
model catalog
request protocol
tool schema cleanup
stream wrapping
usage reporting
reasoning / thinking parameters
error classification
failover decisions
The Agent Runtime should not depend on every provider's raw fields. It should see stable concepts:
messages / context
tool schemas
assistant text
tool call
tool result
usage
finish reason
error
A provider plugin translates the external model world into those internal concepts.
Provider and Model Are Different
OpenClaw model refs usually look like:
provider/model
openai/gpt-5.5
anthropic/claude-opus-4-6
google/gemini-*
provider is the integration route. model is the concrete model under that provider.
This means:
you can change models without changing the agent architecture
One provider can also support many models, auth profiles, and fallbacks.
What Provider Plugins Own
The docs describe provider plugins as owning onboarding, model catalogs, auth env-var mapping, transport/config normalization, tool-schema cleanup, failover classification, OAuth refresh, usage reporting, and reasoning profiles.
Think in four layers:
configuration
model refs, defaults, context window, max tokens
authentication
API key, OAuth, CLI reuse, auth profiles
request
provider-specific payload, stream, transport
recovery
usage, error, retry, failover, cooldown
Why Not Hard-Code OpenAI, Claude, and Gemini?
Agent systems evolve.
Models change:
API shape
tool call format
context length
pricing
reasoning controls
streaming protocol
If these details live inside the agent loop, the core runtime becomes fragile.
Provider abstraction keeps change at the boundary:
external provider changes
↓
provider plugin updates
↓
agent loop still sees unified events
A Real Scenario
You use:
openai/gpt-5.5
Then long-context tasks move to:
google/gemini-*
Code review uses:
anthropic/claude-*
Gateway, sessions, tool loop, and workspace do not need to be rewritten. Model selection and provider plugins handle the mapping.
Common Misunderstandings
Misunderstanding 1: Provider Means API Key
No. API key is only one part of authentication.
Misunderstanding 2: Providers Have Identical Capabilities
They do not. Tool calls, context, reasoning, streaming, and media capabilities differ.
Misunderstanding 3: OpenAI Compatible Means OpenAI
Not exactly. The interface may look similar, but capability, errors, usage, and tool details can differ.
Final Summary
Provider abstraction lets OpenClaw connect different models to one Agent Runtime.
In one sentence:
Providers adapt differences; the runtime executes a stable loop.
Lesson Homework
- Write three
provider/modelrefs. - Distinguish Provider, Model, and Auth Profile.
- List the minimum errors a provider plugin must classify.
- Explain why tool schema cleanup belongs near the provider boundary.
Next Lesson Preview
Next: connecting OpenAI, Claude, Gemini, and OpenAI-compatible providers.
References
- OpenClaw Docs: Model providers
- OpenClaw Docs: Provider directory
- OpenClaw Docs: Agent runtimes
- OpenClaw Docs: Building provider plugins
Original link: Provider Abstraction: Why OpenClaw Can Use Different Models
评论
0分享你对这一章的想法