AI Models
OpenClaw is provider-agnostic. Swap between Claude, GPT, Grok, and others per workspace or mid-session. Short aliases keep config concise — no long provider strings to memorise.
Use Claude Code with ANY AI Model — GPT, Gemini, DeepSeek, and local Ollama models
Description
OpenClaw is provider-agnostic: it doesn't tie you to a single AI vendor. You can run Claude, GPT, Grok, Gemini, local Ollama models, or anything accessible via an OpenAI-compatible API — and switch between them per workspace, per session, or even mid-conversation.
Model configuration is done via aliases — short names like sonnet or gpt that map to full provider/model strings. Aliases keep your config readable and let you change the underlying model version in one place without hunting through every workspace config.
API keys are read from environment variables by default ( ANTHROPIC_API_KEY, OPENAI_API_KEY, XAI_API_KEY etc.). You can also set them via openclaw config set, in which case they're stored encrypted in your local config — never in plaintext logs or workspace files.
Switching models doesn't change the session's context window or transcript. Use /model <alias> mid-session to compare how different models handle the same conversation — useful when debugging or exploring which provider works best for a specific task.
Built-in model aliases
| Alias | Model ID | Best for |
|---|---|---|
sonnet | anthropic/claude-sonnet-4-6 | Best balance of speed and capability. Default for most workloads. |
opus | anthropic/claude-opus-4-8 | Anthropic's most capable model. Use for complex reasoning and long tasks. |
haiku | anthropic/claude-haiku-4-5 | Fastest Claude model. Great for quick lookups and high-frequency tasks. |
gpt | openai/gpt-5.4 | OpenAI's flagship. Use when you want a second opinion or GPT-specific behaviour. |
Grok | xai/grok-4.3 | Grok from xAI. Strong at real-time web knowledge and reasoning. |
fable | anthropic/claude-fable-5 | Latest Anthropic model for creative and generative tasks. |
CLI commands
Set a model for the current workspace
openclaw config set model sonnetSwitch model mid-session (in chat)
/model opusList available model aliases
openclaw modelsSet a custom API key for a provider
openclaw config set anthropic.apiKey sk-ant-...Use a full model ID directly
openclaw config set model openai/gpt-5.4Tips
Pin a model per workspace
Set the model in the workspace config rather than switching per-message. Consistency is better for daily use and costs.
Use env vars for API keys
Set ANTHROPIC_API_KEY, OPENAI_API_KEY, or XAI_API_KEY as environment variables. OpenClaw picks them up automatically and never logs them.
Switch mid-session without losing context
Typing /model <alias> mid-conversation swaps the provider but keeps the full session history intact.
Local models via Ollama
OpenClaw supports Ollama for fully offline usage. Set model to ollama/<model-name> and point the API base to your Ollama server.