OpenClaw API Keys Setup: Anthropic Claude & OpenAI GPT Complete Guide
Complete guide to obtaining and configuring API keys for your OpenClaw instance. Step-by-step instructions for getting Anthropic Claude and OpenAI GPT API keys, plus security best practices.
Your OpenClaw instance needs an API key to communicate with AI providers. This guide walks you through obtaining keys from Anthropic (Claude) and OpenAI (GPT), plus security best practices for keeping them safe.
What Is an API Key?
An API key is a unique identifier that authenticates your requests to an AI provider. Think of it as a password that lets your OpenClaw instance communicate with Claude or GPT on your behalf.
When you send a message to your AI assistant, here’s what happens:
- Your message reaches your OpenClaw instance
- The instance uses your API key to send the message to the AI provider
- The AI provider processes it and returns a response
- Your instance delivers the response back to you
You only need one API key — either Anthropic or OpenAI, depending on which models you want to use.
Getting an Anthropic API Key (Claude)
Step 1: Create an Anthropic Account
- Go to console.anthropic.com
- Click “Sign Up” and create your account
- Verify your email address
Step 2: Add Billing
- Navigate to Settings → Billing in the Anthropic Console
- Add a payment method (credit card)
- Add credits to your account (you can start with as little as $5)
Tip: Anthropic sometimes offers free credits for new accounts. Check their documentation for current offers.
Step 3: Generate Your API Key
- Go to Settings → API Keys in the Console
- Click “Create Key”
- Give it a descriptive name (e.g., “OpenClaw Instance”)
- Copy the key immediately — it’s only shown once
Anthropic API keys start with sk-ant-.
Step 4: Add to OpenClaw
- Go to your OpenClaw dashboard
- Navigate to API Keys
- Paste your Anthropic key and click Save
Getting an OpenAI API Key (GPT)
Step 1: Create an OpenAI Account
- Go to platform.openai.com
- Sign up or log in with your existing OpenAI/ChatGPT account
Step 2: Add Billing
- Navigate to Settings → Billing
- Add a payment method
- Set up auto-recharge or add prepaid credits
Important: The free tier of ChatGPT does not include API access. You need a separate API billing setup at platform.openai.com.
Step 3: Generate Your API Key
- Go to platform.openai.com/api-keys
- Click “Create new secret key”
- Name it (e.g., “OpenClaw”)
- Copy the key immediately — it won’t be shown again
OpenAI API keys start with sk-.
Step 4: Add to OpenClaw
- Go to your OpenClaw dashboard
- Navigate to API Keys
- Paste your OpenAI key and click Save
API Key Security Best Practices
Your API key is linked to your billing account, so keeping it secure is essential:
How OpenClaw Protects Your Keys
- AES-256 encryption — All keys are encrypted at rest in the database
- Isolated instances — Your key is only accessible to your container
- No logging — Keys are never logged or exposed in error messages
- HTTPS only — All communication uses TLS encryption in transit
What You Should Do
- Use a dedicated key — Create a separate API key just for OpenClaw
- Set spending limits — Both Anthropic and OpenAI let you set monthly spending caps
- Rotate keys periodically — Every 90 days is a good practice
- Never share your key — Don’t paste it in public chats, forums, or code repositories
- Enable 2FA — Protect your Anthropic/OpenAI accounts with two-factor authentication
How Much Does It Cost?
AI API pricing is based on tokens (roughly 4 characters = 1 token). Here’s a rough guide for typical conversational use:
| Model | Casual Use (/month) | Heavy Use (/month) |
|---|---|---|
| Claude Haiku 4.5 | $1–$5 | $10–$30 |
| Claude Sonnet 4.5 | $5–$15 | $30–$80 |
| Claude Opus 4.6 | $15–$40 | $80–$200+ |
| GPT-4.1 Mini | $1–$5 | $10–$25 |
| GPT-4.1 | $5–$15 | $30–$80 |
Tip: Start with $5–$10 in credits on a fast model like Haiku to get a feel for your usage patterns before committing to more.
Troubleshooting
“Invalid API Key” Error
- Make sure you copied the entire key (no extra spaces or missing characters)
- Verify you’re using an API key, not your account password
- Check that the key hasn’t been revoked in your provider’s dashboard
“Insufficient Credits” Error
- Add more credits to your Anthropic or OpenAI account
- Check if you’ve hit a spending limit you set previously
Need More Help?
Visit our detailed API key documentation or reach out via the contact page.