How to Configure Model Providers in OpenClaw
I’ve spent too much time manually editing config files just to try out a new model. It’s a common headache when you’re juggling different API formats and environment variables across multiple projects. I want to show you how OpenClaw handles this so you can switch providers without the usual friction.
What You’ll Need
Section titled “What You’ll Need”- OpenClaw installed on your machine.
- API keys for your chosen providers (e.g.,
OPENAI_API_KEY,ANTHROPIC_API_KEY). - For local models, a running instance of Ollama or LM Studio.
Quick Start
Section titled “Quick Start”The fastest way to get your models running is to use the built-in CLI helpers. I recommend these two steps to get started in under five minutes:
- Run the onboarder: Use
openclaw onboardand follow the prompts to pick your provider and auth method. - Set your model: Run
openclaw models set <provider/model>(for example,openclaw models set opencode/claude-opus-4-6) to define your primary model.
If you want to see what is already available, run openclaw models list.
Built-in Providers
Section titled “Built-in Providers”OpenClaw includes the pi‑ai catalog by default. This means you don’t need to write complex provider configurations; you just need to provide the auth and pick a model ref using the provider/model format.
OpenAI and Anthropic
Section titled “OpenAI and Anthropic”For OpenAI, set your OPENAI_API_KEY and use a ref like openai/gpt-5.1-codex. If you prefer Anthropic, you can use the ANTHROPIC_API_KEY or a setup token.
{ agents: { defaults: { model: { primary: "anthropic/claude-opus-4-6" } } },}OpenCode Zen and Z.AI
Section titled “OpenCode Zen and Z.AI”OpenCode Zen uses the opencode provider prefix. If you are using Z.AI (GLM), use the zai prefix. Note that z.ai/* and z-ai/* will automatically normalize to zai/*.
Google Gemini and Vertex
Section titled “Google Gemini and Vertex”You can use standard Gemini API keys with the google provider. For Vertex AI or the Gemini CLI, you’ll need to enable specific plugins first:
openclaw plugins enable google-antigravity-authopenclaw models auth login --provider google-antigravity --set-defaultCustom Providers and Local Models
Section titled “Custom Providers and Local Models”If you need to use a provider that isn’t in the built-in catalog, or if you want to point to a local proxy, you use the models.providers section in your config.
Moonshot AI (Kimi)
Section titled “Moonshot AI (Kimi)”Moonshot uses OpenAI-compatible endpoints. Here is how I configure it in openclaw.json:
{ agents: { defaults: { model: { primary: "moonshot/kimi-k2.5" } }, }, models: { mode: "merge", providers: { moonshot: { baseUrl: "https://api.moonshot.ai/v1", apiKey: "${MOONSHOT_API_KEY}", api: "openai-completions", models: [{ id: "kimi-k2.5", name: "Kimi K2.5" }], }, }, },}Ollama (Local)
Section titled “Ollama (Local)”Ollama is great because it is automatically detected if it’s running at http://127.0.0.1:11434/v1. You just need to pull the model and reference it.
ollama pull llama3.3{ agents: { defaults: { model: { primary: "ollama/llama3.3" } }, },}Local Proxies (LM Studio / vLLM)
Section titled “Local Proxies (LM Studio / vLLM)”When using local proxies like LM Studio, you should provide explicit values for the model limits to ensure things run smoothly.
{ agents: { defaults: { model: { primary: "lmstudio/minimax-m2.1-gs32" }, }, }, models: { providers: { lmstudio: { baseUrl: "http://localhost:1234/v1", apiKey: "LMSTUDIO_KEY", api: "openai-completions", models: [ { id: "minimax-m2.1-gs32", name: "MiniMax M2.1", contextWindow: 200000, maxTokens: 8192, }, ], }, }, },}Troubleshooting
Section titled “Troubleshooting”Plugin Authentication
Section titled “Plugin Authentication”If you are trying to use google-antigravity or google-gemini-cli, remember that these plugins are disabled by default. You must run openclaw plugins enable <plugin-name> before the auth commands will work.
Missing Client IDs
Section titled “Missing Client IDs”For Google Gemini CLI or Antigravity, you do not need to paste a client ID or secret into your openclaw.json. The CLI login flow handles this and stores tokens in auth profiles on your gateway host.
Anthropic Token Errors
Section titled “Anthropic Token Errors”When using the CLI for Anthropic, if you aren’t using an environment variable, ensure you use openclaw models auth paste-token --provider anthropic to correctly save your setup token.
If you run into other configuration hurdles, check out the AI Setup Assistant.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.