← Back to Blog

Anthropic Just Cut You Off. Here's How to Keep Your OpenClaw Running With Your Own API Key

Anthropic Just Cut You Off. Here's How to Keep Your OpenClaw Running With Your Own API Key

On April 4, 2026, Anthropic ended Claude Pro and Claude Max subscription coverage for third-party applications—including OpenClaw. If you built an OpenClaw agent expecting those flat-rate plans to cover API costs, you now have seven days before billing switches to pay-as-you-go rates. The good news: switching to your own API key takes 10 minutes and costs less than the old subscription pricing for most use cases.

This guide walks through exactly what changed, why it matters, and the three-step process to keep your agent running without disruption.

What Actually Changed (April 4, 2026)

Anthropic's official announcement was minimal: Claude subscription plans no longer cover API calls from third-party integrations. This includes:

  • OpenClaw agents (all versions)
  • LangChain integrations
  • API clients using Anthropic's Python SDK
  • Enterprise integrations (GitHub Copilot, Zapier, Make, n8n)

In plain terms: if your OpenClaw agent was calling Claude using a shared Anthropic subscription under the hood, that ended April 11. After that date, API calls route to pay-as-you-go billing at standard rates (~$0.003 per 1K input tokens, $0.015 per 1K output tokens for Claude 3.5 Sonnet).

The six-day buffer (April 4 announcement, April 11 cutoff) was designed to give hosted platforms time to migrate. If you self-hosted OpenClaw with a subscription, you got the same notice as everyone else.

Why This Happened (And Why It Matters)

Anthropic's rationale: subscription plans are designed for direct API usage patterns, not indirect consumption through third-party layers. When you use Claude via OpenClaw, Anthropic has less visibility into billing and user intent. Grouping all third-party traffic under pay-as-you-go ensures accurate cost attribution and prevents arbitrary increases from uncontrolled agent behavior (a 24-hour runaway loop can cost hundreds without rate limits).

For OpenClaw builders, this is actually a safety feature in disguise. Pay-as-you-go forces you to set cost controls—exactly the kind of guardrails your agent needs. Agents running under flat-rate subscription felt "free" to loop and retry without consequence. Now you'll see the cost immediately, and you'll be motivated to debug and optimize.

The Real Cost: Is It More Expensive?

Short answer: depends on your agent's workload, but probably not.

Claude Pro: EUR 20/month (~270 API calls per day at average token usage) Pay-as-you-go: EUR 0.003 per 1K input + EUR 0.015 per 1K output

For a typical agent that makes 20-50 API calls per day with moderate context windows (5K tokens average), you're looking at EUR 5-15 per month. Even high-volume agents (500 calls/day) hit about EUR 50-100 monthly.

The catch: if your agent is misconfigured and loops infinitely, costs spike fast. That's why step three (cost guards) is mandatory.

Step 1: Generate Your Anthropic API Key

This takes two minutes.

  1. Go to https://console.anthropic.com/
  2. Sign in with your Anthropic account (use the same account that held the subscription)
  3. Click API Keys in the left sidebar
  4. Click Create Key
  5. Copy the key immediately (Anthropic only shows it once)
  6. Keep it safe—treat it like a password. Don't paste it into Discord, GitHub, or anywhere public.

Your API key starts with sk-ant- and is ~90 characters long.

If you don't have an Anthropic account yet, create one at https://console.anthropic.com/signup. You'll need a valid credit card on file to use pay-as-you-go billing.

Security Guardrails

  • Never commit your API key to Git or version control. Use environment variables or .env files (and add .env to .gitignore).
  • Never share your API key in logs, Slack, or support threads. Anthropic can rotate it if leaked, but assume the worst.
  • Set up billing alerts in the Anthropic console: click BillingUsage & Limits → set a monthly hard limit so agents can't burn through your budget.

Step 2: Update Your OpenClaw Agent Config (AGENTS.md)

Open your agent's AGENTS.md file and locate the API authentication section. It typically looks like this:

# AGENTS.md - Before (using subscription)
api_provider: anthropic
api_auth_method: subscription
model: claude-3-5-sonnet

Change it to use your API key:

# AGENTS.md - After (using pay-as-you-go)
api_provider: anthropic
api_auth_method: api_key
api_key: ${ANTHROPIC_API_KEY}
model: claude-3-5-sonnet

The ${ANTHROPIC_API_KEY} syntax tells OpenClaw to read your API key from an environment variable instead of storing it in the file. This is the secure approach.

Now, set the environment variable on your OpenClaw server:

export ANTHROPIC_API_KEY="sk-ant-..."

If you're running OpenClaw in a Docker container or systemd service, add this to your .env file:

ANTHROPIC_API_KEY=sk-ant-...

Or directly in your OpenClaw systemd unit file:

[Service]
Environment="ANTHROPIC_API_KEY=sk-ant-..."

Test the connection by restarting your agent:

openclaw agent restart your-agent-name

If the agent starts without errors, you're connected.

Step 3: Set Cost Guards (Critical)

This is the difference between paying EUR 10/month and EUR 300+/month.

Open your AGENTS.md and add cost limits:

# Cost guards
max_api_calls_per_session: 50
max_tokens_per_session: 100000
max_tokens_per_request: 15000
cost_limit_monthly: 50.00

Explanation:

  • max_api_calls_per_session: Stops runaway loops after 50 API calls in one conversation
  • max_tokens_per_session: Hard cap on total tokens used in one session (100K ≈ EUR 1.50)
  • max_tokens_per_request: Prevents a single API call from loading massive context windows
  • cost_limit_monthly: OpenClaw will refuse API calls if you exceed EUR 50 this month

These are conservative defaults. Tune them based on your agent's actual usage. If you run a daily report generator, 50 calls per session might be too low. If you're building a Q&A bot, it's plenty.

Monitor your usage in the Anthropic console. Go to BillingUsage & Limits and check how much you're actually spending per week.

What If You Want to Switch Providers?

The same config change works for other API providers. If you're concerned about Anthropic's pricing, you can switch to:

  • Google Gemini: EUR 0.00075 per 1K input, EUR 0.003 per 1K output (cheaper)
  • OpenAI GPT-4o: EUR 0.005 per 1K input, EUR 0.015 per 1K output (same tier as Claude)
  • Open-weight models (Ollama): Free, runs locally, no API key needed

To switch, update your AGENTS.md:

api_provider: google  # or openai, ollama, etc
api_key: ${GOOGLE_API_KEY}
model: gemini-2.0-pro

The beauty of file-based OpenClaw agents is that the config is portable. Your SOUL.md, memory files, and tool configs stay the same—only the backend model changes. This is why OpenAgents.mom bundles give you model-agnostic workspace structure from the start.

Common Mistakes

Common Mistakes

  • Hardcoding the API key in AGENTS.md. If you paste api_key: sk-ant-... directly into the file and commit it to Git, you've leaked your credentials. Always use environment variables.
  • Forgetting to set cost limits. Without monthly caps, a single misconfigured agent loop can bill you EUR 300-500 in hours. Set cost_limit_monthly as your first config step.
  • Using the wrong API endpoint. Anthropic has separate endpoints for direct API calls vs. third-party integrations. OpenClaw automatically routes to the correct one, but if you're manually configuring, double-check the endpoint URL in the Anthropic console.
  • Not rotating your API key after a leak. If you accidentally shared your key in a GitHub commit, Slack message, or forum post, go to the Anthropic console and regenerate it immediately. The old key becomes invalid within minutes.
  • Leaving billing alerts disabled. Set a monthly hard limit so you get a warning before charges spike. You can adjust the limit anytime.

Next: Make Your Agent Cost-Efficient

Now that you're on pay-as-you-go, every token counts. Check out Your OpenClaw Agent Can Burn $300/Day Without These Cost Guards for deeper strategies on reducing token usage through context pruning, short-form instructions, and tool optimization.

You should also review your AGENTS.md configuration to ensure your agent is scoped tightly—unnecessary tools bloat context windows and increase per-call costs.

The transition from subscription to pay-as-you-go is painful only if you skip cost controls. With limits in place, your agent will be cheaper and safer than before.

Generate a Cost-Guard Hardened Agent Bundle

Our wizard generates OpenClaw workspace bundles pre-wired with API key authentication and cost controls built in. Answer a guided interview (5 minutes), download your bundle, and deploy an agent that respects billing limits from day one.

Create Your Hardened Agent Bundle Now

Share