← Back to OpenClaw DocsComponent

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

AliasModel IDBest for
sonnetanthropic/claude-sonnet-4-6Best balance of speed and capability. Default for most workloads.
opusanthropic/claude-opus-4-8Anthropic's most capable model. Use for complex reasoning and long tasks.
haikuanthropic/claude-haiku-4-5Fastest Claude model. Great for quick lookups and high-frequency tasks.
gptopenai/gpt-5.4OpenAI's flagship. Use when you want a second opinion or GPT-specific behaviour.
Grokxai/grok-4.3Grok from xAI. Strong at real-time web knowledge and reasoning.
fableanthropic/claude-fable-5Latest Anthropic model for creative and generative tasks.

CLI commands

Minimum version:openclaw 2026.6.0+

Set a model for the current workspace

openclaw config set model sonnet

Switch model mid-session (in chat)

/model opus

List available model aliases

openclaw models

Set 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.4

Tips

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.