The first question everyone asks after installing OpenClaw: where do I get an API key?
It’s a fair question because OpenClaw doesn’t have its own key. It’s an agent framework that connects to LLM providers. You bring the keys, OpenClaw does the routing.
Here’s how to get set up with every major provider, including which ones to start with if you’re new.
The fast path
If you just want to get running:
openclaw onboard
The setup wizard walks you through picking a provider and entering your API key. It handles the config file for you. If you’re new to this, start here.
Getting API keys
Anthropic (Claude)
- Go to console.anthropic.com
- Create an account and add a payment method
- Navigate to API Keys and create one
- New accounts get $5 in free credits
Claude Sonnet 4 is the recommended default for most OpenClaw users. Good balance of capability and cost.
OpenAI (GPT)
- Go to platform.openai.com
- Create an account
- Go to API Keys and generate one
- Add billing (pay-as-you-go, no subscription needed)
GPT-4o and GPT-4o-mini are the most commonly used models. Mini is good for high-volume simple tasks.
Google (Gemini)
- Go to aistudio.google.com
- Sign in with your Google account
- Get an API key from the API Keys section
- Free tier includes a generous amount of requests
Gemini 3 Pro’s million-token context window makes it the go-to for document analysis.
xAI (Grok)
- Go to console.x.ai
- Create an account
- Generate an API key
- New accounts receive free credits
Grok 4.1 Fast is cheap ($0.20/$0.50 per M tokens) with a 2M token context window. See our Grok guide for details.
Haimaker (open-source models)
- Go to app.haimaker.ai/sign-up
- Create an account
- Generate an API key from the dashboard
Haimaker gives you access to Llama, Qwen, MiniMax, and other open-source models through a single API key. Pricing is 5% below market rate. The API is OpenAI-compatible, so configuration is straightforward.
Ollama (local, no key needed)
curl -fsSL https://ollama.com/install.sh | sh
ollama pull qwen3.5:32b
Ollama runs locally. No API key, no costs, no data leaving your machine. See our Ollama models guide for which models to use.
Adding keys to OpenClaw
Method 1: The config file
Your config lives at ~/.openclaw/openclaw.json. Here’s what a multi-provider setup looks like:
{
"models": {
"mode": "merge",
"providers": {
"haimaker": {
"baseUrl": "https://api.haimaker.ai/v1",
"apiKey": "sk-your-haimaker-key",
"api": "openai-completions",
"models": [
{ "id": "llama-3.3-70b", "name": "Llama 3.3 70B" },
{ "id": "minimax/minimax-m2.5", "name": "MiniMax M2.5" }
]
},
"ollama": {
"baseUrl": "http://localhost:11434/v1",
"apiKey": "ollama",
"api": "openai-completions",
"models": [
{ "id": "qwen3.5:32b", "name": "Qwen 3.5 32B" }
]
}
}
},
"agents": {
"defaults": {
"models": {
"haimaker/llama-3.3-70b": { "alias": "llama" },
"haimaker/minimax/minimax-m2.5": { "alias": "minimax" },
"ollama/qwen3.5:32b": { "alias": "qwen" }
}
}
}
}
Apply with:
openclaw gateway config.apply --file ~/.openclaw/openclaw.json
For built-in providers like Anthropic and OpenAI, you don’t need to define them in models.providers. OpenClaw picks them up from environment variables or the onboard wizard.
Method 2: Environment variables
You can set API keys as environment variables instead of putting them in the config:
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="AI..."
OpenClaw checks for these automatically. Add them to your shell profile (~/.zshrc or ~/.bashrc) to persist across sessions.
Method 3: SecretRef (for teams)
If you’re running OpenClaw in a shared environment, use the SecretRef system instead of hardcoding keys:
{
"models": {
"providers": {
"haimaker": {
"apiKey": { "$secretRef": { "provider": "env", "key": "HAIMAKER_API_KEY" } }
}
}
}
}
SecretRef supports env (environment variables), file (read from a file), and exec (run a command to fetch the secret). This keeps credentials out of your config file, which matters if you’re checking configs into version control.
Keeping keys safe
A few things worth doing:
Don’t commit keys to git. If your openclaw.json has API keys in it, add it to .gitignore. Better yet, use environment variables or SecretRef.
Set spending limits. Most providers let you set monthly caps. Do this before you forget. OpenClaw agent loops can burn through tokens fast if something goes wrong.
Use separate keys for separate purposes. If you’re running OpenClaw for personal use and for work, use different API keys. Makes billing easier and limits blast radius if a key leaks.
Rotate keys periodically. If you suspect a key has been exposed, regenerate it immediately from the provider’s console.
Which provider to start with
If you’re new and want a single recommendation: sign up for Haimaker. One API key gets you access to multiple model families (Llama, Qwen, MiniMax, GPT-OSS), and the pricing is competitive. You can always add Anthropic or OpenAI later when you want Claude or GPT directly.
If you want the best coding experience and don’t mind paying more, go with Anthropic. Claude Sonnet 4 is the most reliable model for OpenClaw agent workflows.
If you want to keep everything local and private, install Ollama and skip the API keys entirely.
Most experienced users end up with two or three providers configured and switch between them depending on the task.
For detailed provider configuration including troubleshooting, see our custom providers guide. For model comparisons across all providers, see our complete models guide.