You installed OpenClaw. Now you need an API key to actually make it work. Anthropic's Claude models are the most popular choice for OpenClaw users, and for good reason. This guide walks you through every step: creating your Anthropic account, generating your API key, connecting it to OpenClaw, picking the right model, and keeping your costs under control.
What's in this guide
How to Get Your Anthropic API Key
The whole process takes about 5 minutes. Here's exactly what to do:
- Go to console.anthropic.com and click "Sign up." You can use email or Google.
- Verify your phone number. Anthropic requires SMS verification. VoIP numbers usually get rejected, so use a real mobile number.
- Add billing credits. Anthropic uses a pre-purchase credit system. You buy credits upfront, then usage draws from that balance. Start with $5 or $10 to test things out.
- Navigate to API Keys. In the console sidebar, click "API Keys" then "Create Key." Give it a descriptive name like "openclaw-main."
- Copy and save immediately. Your key starts with
sk-ant-and is shown exactly once. Store it somewhere safe. A password manager is ideal.
Your API key is shown only once. If you lose it, you'll need to generate a new one. Copy it to a secure location before closing the page.
Connecting Your API Key to OpenClaw
Once you have your key, connecting it to OpenClaw takes one command.
Option 1: Interactive Setup
Run the onboard command and follow the prompts:
openclaw onboard
Select "Anthropic API key" when asked for your provider, then paste your key. Done.
Option 2: Non-Interactive (One Liner)
If you already have your key ready:
openclaw onboard --anthropic-api-key "sk-ant-your-key-here"
Option 3: Manual Config
Edit your OpenClaw config file at ~/.openclaw/openclaw.json:
{
"env": { "ANTHROPIC_API_KEY": "sk-ant-your-key-here" },
"agents": {
"defaults": {
"model": { "primary": "anthropic/claude-opus-4-6" }
}
}
}
Then restart OpenClaw for changes to take effect.
Pro tip: Use the interactive openclaw onboard if this is your first time. It handles config file creation, daemon setup, and channel connections all in one flow.
Need help getting OpenClaw installed first? Head to installopenclawnow.com for the fastest path from zero to running.
Which Claude Model Should You Use?
Anthropic offers several Claude models. Here's the honest breakdown for OpenClaw users:
| Model | Best For | Speed | Cost |
|---|---|---|---|
| Claude Opus 4.6 | Complex tasks, coding, research, multi-step agents | Slower | $5/$25 per MTok |
| Claude Sonnet 4.6 | Everyday tasks, balanced speed and quality | Fast | $3/$15 per MTok |
| Claude Haiku 4.5 | Simple tasks, quick lookups, high volume | Fastest | $1/$5 per MTok |
My recommendation: Start with anthropic/claude-sonnet-4-6 for general use. It's fast, capable, and significantly cheaper than Opus. Move to Opus for heavy coding sessions or complex research where quality matters more than cost.
I personally run Opus 4.6 for my main agent because I need it handling business operations, writing, and research simultaneously. But if you're just getting started, Sonnet is plenty.
Model naming in OpenClaw: Always prefix with anthropic/. So it's anthropic/claude-opus-4-6, not just claude-opus-4-6.
Anthropic API Pricing Breakdown
Let's talk real numbers. Anthropic prices by the million tokens (MTok). Here's what the current models cost, straight from Anthropic's pricing page:
| Model | Input (per MTok) | Output (per MTok) | Cache Hits (per MTok) |
|---|---|---|---|
| Claude Opus 4.6 | $5 | $25 | $0.50 |
| Claude Sonnet 4.6 | $3 | $15 | $0.30 |
| Claude Haiku 4.5 | $1 | $5 | $0.10 |
In practice, a typical OpenClaw session with Sonnet runs about $0.50 to $2.00 per day depending on how much you use it. Heavy Opus usage can hit $5 to $15 per day. That's still cheaper than a virtual assistant, and it works 24/7.
How to Keep Costs Low
Five things that actually make a difference:
- Use prompt caching. OpenClaw automatically enables 5-minute prompt caching with Anthropic API keys. Cache hits cost 90% less than fresh input tokens. For long conversations, this adds up fast.
- Match the model to the task. Use Haiku for simple lookups and notifications. Sonnet for everyday work. Opus only when you need maximum quality.
- Set spending limits in the Anthropic Console. Go to Settings and configure a monthly usage limit. Start at $50 and adjust from there.
- Enable long caching for heavy agents. In your OpenClaw config, set
cacheRetention: "long"for agents that process large contexts repeatedly. This extends cache from 5 minutes to 1 hour. - Monitor with /status. Run
/statusin any OpenClaw session to see your current token usage and estimated costs.
Cache config example: Add this to your openclaw.json to enable 1-hour caching:"models": { "anthropic/claude-opus-4-6": { "params": { "cacheRetention": "long" } } }
Setting Up OpenAI API Keys with OpenClaw
Prefer GPT models? Here's the OpenAI setup. Same process, different provider.
- Go to platform.openai.com and sign up or log in.
- Navigate to API Keys. Click your profile icon, then "API keys" from the dropdown.
- Create a new secret key. Name it "openclaw" and copy it immediately. It starts with
sk-and is shown only once. - Add billing. OpenAI requires a payment method. Add a credit card under Settings > Billing. Set a monthly limit to prevent surprises.
Connect it to OpenClaw:
openclaw onboard --openai-api-key "sk-your-key-here"
Or add to your config manually:
{
"env": { "OPENAI_API_KEY": "sk-your-key-here" },
"agents": {
"defaults": {
"model": { "primary": "openai/gpt-4o" }
}
}
}
OpenAI Model Options for OpenClaw
| Model | Best For | Input Cost (per MTok) | Output Cost (per MTok) |
|---|---|---|---|
| GPT-4o | General use, balanced | $2.50 | $10 |
| GPT-4o-mini | Budget-friendly, fast | $0.15 | $0.60 |
| o3 | Complex reasoning | $10 | $40 |
GPT-4o-mini is shockingly cheap. For simple tasks like email triage, calendar checks, or basic research, it works well at a fraction of the cost. I'd still use Claude for anything requiring nuance or long-form writing, but GPT-4o-mini is a great budget option for utility agents.
Setting Up Google Gemini API Keys with OpenClaw
Google offers a generous free tier for Gemini models. If you want to test OpenClaw without spending anything on API costs, this is the way.
- Go to aistudio.google.com (Google AI Studio).
- Click "Get API Key" in the top right.
- Create key in a new project or select an existing Google Cloud project.
- Copy the key. It starts with
AIzaand is visible in your API keys dashboard for later reference.
Connect to OpenClaw:
openclaw onboard --google-api-key "AIzaYourKeyHere"
Or manual config:
{
"env": { "GOOGLE_API_KEY": "AIzaYourKeyHere" },
"agents": {
"defaults": {
"model": { "primary": "google/gemini-2.5-pro" }
}
}
}
Google Gemini Pricing for OpenClaw
The free tier gives you 60 requests per minute for Gemini 2.0 Flash. For light personal use, this costs literally $0. The paid tier (Gemini 2.5 Pro) runs about $1.25/$10 per million tokens for input/output.
Multi-provider strategy: You can configure different agents to use different providers. Run your main conversational agent on Claude Opus for quality. Run utility agents (weather checks, simple lookups) on Gemini Flash for free. OpenClaw handles the routing automatically.
Bonus: OpenRouter for Maximum Flexibility
Don't want to manage multiple API keys? OpenRouter gives you access to Claude, GPT, Gemini, Llama, Mistral, and dozens more through a single API key. One key, all providers.
Setup:
- Go to openrouter.ai and create an account
- Add credits (pay-as-you-go)
- Generate an API key
openclaw onboard --openrouter-api-key "sk-or-your-key-here"
OpenRouter adds a small markup (~10-20%) on top of provider prices. Worth it for the convenience of one dashboard, one billing, and the ability to switch models without touching your config.
Common Setup Issues (and Fixes)
"Invalid API key" error
Double-check you copied the full key including the sk-ant- prefix. Make sure there are no trailing spaces. If the key was generated more than a few minutes ago and you didn't save it, generate a new one.
"Insufficient credits" error
Anthropic requires pre-purchased credits. Go to your Anthropic Console billing section and add credits. Even $5 is enough to start.
Model not found
Make sure you're using the correct model format: anthropic/claude-opus-4-6 (with the provider prefix and hyphens, not dots).
Rate limiting
New Anthropic accounts start at Tier 1 with lower rate limits. As you add credits and build usage history, you'll automatically move to higher tiers with increased limits. If you're hitting limits regularly, consider upgrading your tier by adding more credits.
Config changes not taking effect
After editing ~/.openclaw/openclaw.json manually, restart the OpenClaw gateway:
openclaw gateway restart
Alternative providers: Don't want to use Anthropic directly? OpenClaw also supports OpenRouter as a provider, which gives you access to Claude models plus dozens of others through a single API key. Check the OpenClaw docs for setup instructions.
Frequently Asked Questions
How do I get an Anthropic API key for OpenClaw?
Go to console.anthropic.com, create an account, navigate to API Keys, and generate a new key. Copy the key and paste it into your OpenClaw configuration during onboarding. You will need to add billing information to activate the key.
How much does the Anthropic API cost for OpenClaw?
Anthropic's Claude API costs $3/
Can I use OpenAI instead of Anthropic with OpenClaw?
Yes, OpenClaw supports multiple LLM providers including OpenAI, Anthropic, Google, OpenRouter, and local models via Ollama. You can switch providers by updating your API key and model configuration in the gateway settings.
What is the best API model to use with OpenClaw?
Claude Sonnet by Anthropic offers the best balance of capability and cost for most OpenClaw users. Claude Opus is more powerful but costs 5x more. For budget-conscious users, local models through Ollama are free but less capable.
How do I set spending limits on my Anthropic API key?
Log into console.anthropic.com, go to billing settings, and set a monthly spending limit. This prevents unexpected charges. Start with a $50 limit and increase as you understand your usage patterns with OpenClaw.
OpenClaw Lab is the #1 community for founders building AI agent systems. I share the exact playbooks, skill files, and workflows inside. Weekly lives, expert AMAs, and 260+ founders building real systems.
Join OpenClaw Lab →