Skip to content

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.

  • 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.

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:

  1. Run the onboarder: Use openclaw onboard and follow the prompts to pick your provider and auth method.
  2. 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.

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.

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 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/*.

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:

Terminal window
openclaw plugins enable google-antigravity-auth
openclaw models auth login --provider google-antigravity --set-default

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

Terminal window
ollama pull llama3.3
{
agents: {
defaults: { model: { primary: "ollama/llama3.3" } },
},
}

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,
},
],
},
},
},
}

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.

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.

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.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.