Remote OpenClaw

Remote OpenClaw Blog

OpenClaw API Key Setup: Complete Guide for Every Provider [2026]

Published: ·Last Updated:
What changed

This post was reviewed and updated to reflect current deployment, security hardening, and operations guidance.

What should operators know about OpenClaw API Key Setup: Complete Guide for Every Provider [2026]?

Answer: OpenClaw is an AI agent platform — it orchestrates tasks, manages conversations, handles integrations, and runs automations. But it does not contain an AI model itself. It connects to external AI model providers through their APIs, and each provider requires an API key for authentication. This guide covers practical deployment decisions, security controls, and operations steps to run.

Updated: · Author: Zac Frulloni

How to get and configure API keys for OpenClaw. Step-by-step instructions for Anthropic Claude, OpenAI, Google Gemini, DeepSeek, xAI Grok, and Mistral. Free tiers, billing setup, and .env configuration.

Marketplace

Free skills and AI personas for OpenClaw — deploy a pre-built agent in 15 minutes.

Browse the Marketplace →

Join the Community

Join 500+ OpenClaw operators sharing deployment guides, security configs, and workflow automations.

API Keys Overview

OpenClaw is an AI agent platform — it orchestrates tasks, manages conversations, handles integrations, and runs automations. But it does not contain an AI model itself. It connects to external AI model providers through their APIs, and each provider requires an API key for authentication.

Think of API keys like login credentials for AI services. When OpenClaw needs to process a message, generate a response, or analyze data, it sends a request to the model provider's API using your key. The provider processes the request, sends back a response, and charges your account based on usage.

You need a minimum of one API key to use OpenClaw. However, configuring multiple providers is recommended for reliability (if one provider goes down, OpenClaw can fall back to another) and cost optimization (route expensive tasks to capable models and cheap tasks to efficient ones).

Here is a quick comparison of the major providers:

ProviderBest ModelFree TierStarting CostBest For
AnthropicClaude Sonnet 4Limited credits~$3/M input tokensReasoning, analysis, coding
OpenAIGPT-4oLimited credits~$2.50/M input tokensGeneral purpose, vision
GoogleGemini 2.0 FlashGenerous (15 RPM)Free for light useCost-sensitive, high volume
DeepSeekDeepSeek V3None~$0.27/M input tokensBudget-friendly, coding
xAIGrok 3Limited~$3/M input tokensReal-time data, X integration
MistralMistral LargeLimited~$2/M input tokensEuropean hosting, multilingual

Anthropic (Claude) API Key

Anthropic's Claude models are the most popular choice for OpenClaw operators. Claude excels at reasoning, following complex instructions, and generating high-quality content.

Step 1: Go to console.anthropic.com and create an account.

Step 2: Navigate to "API Keys" in the left sidebar.

Step 3: Click "Create Key." Give it a descriptive name like "OpenClaw Agent."

Step 4: Copy the key immediately — it starts with sk-ant- and is only shown once. If you lose it, you will need to create a new one.

Step 5: Add billing information. Go to "Plans and Billing" and add a payment method. Without billing, you are limited to the free tier which has very low rate limits (5 requests per minute).

Available models:

  • Claude Opus 4: Most capable, best for complex reasoning. Higher cost.
  • Claude Sonnet 4: Excellent balance of capability and cost. Recommended default.
  • Claude Haiku 3.5: Fastest and cheapest. Good for simple tasks, classification, and summarization.

Cost estimate: A personal agent making 50-100 requests per day with Claude Sonnet typically costs $5-15 per month.


OpenAI (GPT) API Key

OpenAI's GPT models are widely used and well-supported in the AI ecosystem. They are a solid alternative or complement to Claude.

Step 1: Go to platform.openai.com and sign up or log in.

Step 2: Navigate to "API keys" in the left sidebar (under your profile).

Step 3: Click "Create new secret key." Name it "OpenClaw."

Step 4: Copy the key — it starts with sk-. Store it securely.

Step 5: Go to "Billing" and add a payment method. Set a usage limit to avoid surprise charges.

Available models:

  • GPT-4o: Multimodal (text, images, audio). Strong general purpose model.
  • GPT-4o-mini: Cheaper and faster. Great for bulk tasks.
  • GPT-5.4: Latest flagship model. Most capable but most expensive.
  • o3-mini: Reasoning-optimized model. Excellent for complex logic tasks.

Cost estimate: GPT-4o-mini is extremely affordable at approximately $0.15/M input tokens. GPT-4o runs about $2.50/M input tokens. For a typical personal agent, expect $3-10 per month.


Google (Gemini) API Key

Google's Gemini models offer the most generous free tier of any major provider. If you want to experiment with OpenClaw at zero cost, start here.

Step 1: Go to aistudio.google.com and sign in with your Google account.

Step 2: Click "Get API key" in the top navigation.

Step 3: Click "Create API key." Select or create a Google Cloud project.

Step 4: Copy the generated key.

Free tier limits: 15 requests per minute, 1 million tokens per minute, 1,500 requests per day. This is remarkably generous and sufficient for many personal agents.

Available models:

  • Gemini 2.0 Flash: Fast, capable, and free for light usage. Recommended starting point.
  • Gemini 2.0 Pro: More capable, better at complex tasks. Paid tier.
  • Gemini 1.5 Pro: 1M+ token context window. Useful for processing very long documents.

Cost estimate: Free for light usage. Paid tier starts at approximately $1.25/M input tokens for Gemini 2.0 Flash.


DeepSeek API Key

DeepSeek offers high-quality models at very competitive prices. It is an excellent choice for budget-conscious operators or high-volume tasks.

Step 1: Go to platform.deepseek.com and create an account.

Step 2: Navigate to API Keys and generate a new key.

Step 3: Add credits to your account (minimum $5).

Available models:

  • DeepSeek V3: Strong general-purpose model. Competitive with GPT-4o at a fraction of the cost.
  • DeepSeek R1: Reasoning-focused model. Comparable to Claude Opus for analytical tasks.

Cost estimate: DeepSeek V3 costs approximately $0.27/M input tokens — roughly 10x cheaper than Claude Sonnet. A heavy-usage personal agent might cost $1-3 per month.

Note: DeepSeek is a Chinese company. Some operators prefer to avoid routing sensitive data through Chinese-hosted APIs. DeepSeek does offer API endpoints in multiple regions.


xAI (Grok) API Key

xAI's Grok models are built by Elon Musk's AI company. They have unique access to real-time X (Twitter) data, which can be valuable for social media monitoring and trend analysis.

Step 1: Go to console.x.ai and sign up.

Step 2: Navigate to API Keys and create a new key.

Step 3: Add billing information.

Available models:

  • Grok 3: Flagship model with real-time data access.
  • Grok 3 Mini: Lighter, faster version for simpler tasks.

Cost estimate: Approximately $3/M input tokens for Grok 3. $0.30/M for Grok 3 Mini.


Mistral API Key

Mistral is a French AI company offering models hosted in the EU. This makes it the preferred choice for operators with European data residency requirements.

Step 1: Go to console.mistral.ai and create an account.

Step 2: Navigate to API Keys and generate a key.

Step 3: Add billing information.

Available models:

  • Mistral Large: Most capable model. Strong at multilingual tasks.
  • Mistral Small: Efficient model for everyday tasks.
  • Codestral: Specialized for code generation.

Cost estimate: Mistral Large costs approximately $2/M input tokens. Mistral Small is about $0.20/M.


Configuring Your .env File

Once you have your API keys, add them to your OpenClaw .env file. This file lives in your OpenClaw installation directory.

# Navigate to your OpenClaw directory
cd ~/openclaw

# Edit the .env file
nano .env

Add your keys in this format:

# ── AI Model Provider Keys ──────────────────────
# At least one is required. Add as many as you like.

# Anthropic (Claude)
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here

# OpenAI (GPT)
OPENAI_API_KEY=sk-your-key-here

# Google (Gemini)
GOOGLE_API_KEY=AIza-your-key-here

# DeepSeek
DEEPSEEK_API_KEY=sk-your-key-here

# xAI (Grok)
XAI_API_KEY=xai-your-key-here

# Mistral
MISTRAL_API_KEY=your-key-here

# ── OpenClaw Configuration ──────────────────────
OPENCLAW_PORT=18789
OPENCLAW_DEFAULT_MODEL=anthropic/claude-sonnet-4-20250514

Important: After editing the .env file, restart OpenClaw for the changes to take effect:

# Docker
docker compose restart

# systemd
sudo systemctl restart openclaw

# npm
openclaw restart

Billing and Cost Management

API costs are pay-as-you-go for most providers. You are charged based on the number of tokens (roughly words) processed in each request. Here are tips for managing costs:

Set spending limits. Most providers let you set monthly spending caps. Set these immediately after adding billing information. A $20/month cap is a reasonable starting point for personal use.

Monitor usage daily for the first week. Check your provider dashboard to understand your actual usage patterns. You may find that certain skills or cron jobs consume more tokens than expected.

Use the right model for each task. Don't send simple tasks to expensive models. Route email summarization and classification to GPT-4o-mini or Gemini Flash. Reserve Claude Sonnet or GPT-4o for complex reasoning tasks.

Reduce context length. Long conversations that send the full history with each request consume tokens rapidly. Configure OpenClaw to limit conversation context to the last 10-20 messages instead of the full history.

Typical monthly budgets:

  • Minimal use (personal assistant, occasional queries): $3-10/month
  • Moderate use (daily automation, email processing, scheduling): $10-30/month
  • Heavy use (high-volume processing, content generation, multi-channel): $30-100/month
  • Business use (multiple agents, complex workflows): $100-500+/month

API Key Security Best Practices

Your API keys are essentially credit cards for AI services. Anyone who has your key can make API calls that charge your account. Protect them accordingly:

  • Never share keys publicly. Do not paste keys in chat messages, forum posts, GitHub issues, or screenshots. If you accidentally expose a key, revoke it immediately and create a new one.
  • Never commit .env files to Git. Add .env to your .gitignore file. If you accidentally committed a .env file, the key should be considered compromised — revoke and regenerate.
  • Set file permissions. On Linux/Mac, restrict access to your .env file: chmod 600 ~/openclaw/.env
  • Use separate keys for separate environments. Create different API keys for development and production. This lets you revoke one without affecting the other.
  • Rotate keys periodically. Every 3-6 months, create new keys and revoke old ones. This limits the damage window if a key is compromised without your knowledge.
  • Set spending limits. Even with good security practices, set billing limits as a safety net. If a key is compromised, the damage is capped at your spending limit.

Setting Up Multi-Provider Routing

Once you have keys for multiple providers, configure OpenClaw to route requests intelligently across them:

{
  "routing": {
    "default": "anthropic/claude-sonnet-4-20250514",
    "fallback": ["openai/gpt-4o", "google/gemini-2.0-flash"],
    "rules": [
      {
        "match": "skill:email-*",
        "model": "openai/gpt-4o-mini"
      },
      {
        "match": "skill:research-*",
        "model": "anthropic/claude-sonnet-4-20250514"
      },
      {
        "match": "cron:*",
        "model": "google/gemini-2.0-flash"
      }
    ]
  }
}

This configuration sends research tasks to Claude (best reasoning), email tasks to GPT-4o-mini (cheapest), and cron jobs to Gemini Flash (free tier). If any provider is down or rate-limited, requests fall back to the next available provider. This approach optimizes both cost and reliability.