#[openclaw] :warning: Agent failed before reply: No API key found for provider "anthropic".

1 messages · Page 1 of 1 (latest)

upbeat frigate
#

😩 I need help pleaseeee.

Goal : Trying to create an autoresponder for whatsapp messages but getting an error below.
Issue: [openclaw] ⚠️ Agent failed before reply: No API key found for provider "anthropic". Auth store: C:\Users\midni.openclaw\agents\main\agent\auth-profiles.json (agentDir: C:\Users\midni.openclaw\agents\main\agent). Configure auth for this agent (openclaw agents add <id>) or copy auth-profiles.json from the main agentDir.
Logs: openclaw logs --follow
From log file i got this details: 2026-02-15T13:24:00.052+05:30 Embedded agent failed before reply: No API key found for provider "anthropic". Auth store: C:\Users\midni.openclaw\agents\main\agent\auth-profiles.json (agentDir: C:\Users\midni.openclaw\agents\main\agent). Configure auth for this agent (openclaw agents add <id>) or copy auth-profiles.json from the main agentDir.

Fix taken: I have created API key under https://platform.claude.com/settings/keys
I had added the key under path > .openclaw\agents\main\agent

What iam doing wrong here?

royal falconBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

simple hornetBOT
#

OpenClaw isn’t looking for a “key file in that folder” — it’s looking for either:

  1. an env var ANTHROPIC_API_KEY (recommended), or
  2. a properly-written auth profile inside C:\Users\midni\.openclaw\agents\main\agent\auth-profiles.json (usually created by the CLI, not by hand).

Easiest fix (Windows)

  1. Create/edit this file (note: NOT inside agents\main\agent):
  • C:\Users\midni\.openclaw\.env
  1. Put this in it (no quotes):
ANTHROPIC_API_KEY=sk-ant-...
  1. Restart the Gateway so it actually picks up the new env:
#
openclaw gateway restart

(or stop/start whichever way you run it)

  1. Verify:
openclaw models status

Alternative (CLI-managed auth profile)

Run:

openclaw models auth login --provider anthropic

(or openclaw onboard) and paste your API key when prompted — this will write the correct auth-profiles.json for you.

upbeat frigate
#

While running openclaw models status i see this

seems something wrong there
Config : ~.openclaw\openclaw.json
Agent dir : ~.openclaw\agents\main\agent
Default : anthropic/claude-opus-4-6
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (0) : -
Configured models (0): all

Auth overview
Auth store : ~.openclaw\agents\main\agent\auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): -

simple hornetBOT
#

Yep — that models status output is telling you OpenClaw currently sees zero Anthropic credentials for the main agent:

  • Providers w/ OAuth/tokens (0) = auth-profiles.json has no usable credentials
  • Shell env : off = the Gateway is not importing your PowerShell/CMD environment automatically (so setting env vars “in your terminal” often won’t reach the Gateway if it’s running as a service/background process)

Fix (recommended): put the key in the global OpenClaw .env

On Windows create/edit this exact file:

C:\Users\midni\.openclaw\.env (not inside agents\main\agent\)

Add one line:

ANTHROPIC_API_KEY=sk-ant-...

Important Windows gotchas:

#
  • make sure the file is literally named .env (not .env.txt)
  • no quotes, no extra spaces

Then restart the Gateway, and re-run:

openclaw models status

Alternative: let OpenClaw write auth-profiles.json for you

Run the interactive helper and choose Anthropic, then paste the API key:

openclaw models auth add

Quick check question

#

How are you running the Gateway on Windows — as a background service/daemon, or just in a terminal window? (It matters for env vars.)

Also paste openclaw --version (and don’t paste any keys).

upbeat frigate
#

how to create .env file since its showing off

simple hornetBOT
#

Shell env: off does not mean you can’t use a .env file — it just means OpenClaw isn’t auto-importing variables from your login shell. A .env file is the easiest fix.

Create the file on Windows (recommended)

You want this exact path:

C:\Users\midni\.openclaw\.env

Option A: PowerShell (easy + reliable)

Open PowerShell and run:

notepad $env:USERPROFILE\.openclaw\.env

Notepad will ask to create it → click Yes.

#

Then paste this line into the file (replace with your key):

ANTHROPIC_API_KEY=sk-ant-...

Save, close.

Option B: Create it via command (PowerShell)

New-Item -Force -ItemType File $env:USERPROFILE\.openclaw\.env
Add-Content $env:USERPROFILE\.openclaw\.env "ANTHROPIC_API_KEY=sk-ant-..."

IMPORTANT: make sure it’s not “.env.txt”

In File Explorer, enable:
View → Show → File name extensions

#

The filename must be exactly .env (no .txt).

Then restart the Gateway + verify

Restart whatever is running OpenClaw (or run):

openclaw gateway restart

Then check:

openclaw models status

If you tell me how you started the gateway (terminal window vs installed service), I can tell you the exact restart step for your setup.

upbeat frigate
#

midni@MidnightGhost MINGW64 ~/.openclaw
$ openclaw models status
Config : ~.openclaw\openclaw.json
Agent dir : ~.openclaw\agents\main\agent
Default : anthropic/claude-opus-4-6
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (0) : -
Configured models (0): all

Auth overview
Auth store : ~.openclaw\agents\main\agent\auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): -

  • anthropic effective=env:s A | env=s A | source=env: ANTHROPIC_API_KEY

OAuth/token status

  • none

What i see

simple hornetBOT
#

That output actually means the CLI can see an Anthropic key now:

  • - anthropic ... source=env: ANTHROPIC_API_KEY ✅ = ANTHROPIC_API_KEY is present for the openclaw models status command you just ran
  • Providers w/ OAuth/tokens (0) is fine if you’re using an env var (it just means auth-profiles.json doesn’t contain stored tokens)

What usually still causes the agent to say “No API key found…” is: the Gateway process didn’t reload the env var yet (or it’s running in a different environment).

Do this next

  1. Make sure the key is in the global env file (recommended):
  • File: C:\Users\midni\.openclaw\.env
  • Line inside:
ANTHROPIC_API_KEY=sk-ant-...
  1. Restart the Gateway (this is the important part):
#
openclaw gateway restart

(or if you started the gateway in a terminal window: stop it with Ctrl+C and start it again)

  1. Then re-test by sending a WhatsApp message again.

If it still fails, tell me how you start the gateway

  • Do you run openclaw gateway start in a terminal?
  • Or did you install it as a Windows service/background daemon?

That determines the exact restart/env behavior.

upbeat frigate
#

how to check .env file using command?

simple hornetBOT
#

On Windows you can print/check your OpenClaw .env like this:

PowerShell

type $env:USERPROFILE\.openclaw\.env

Or (same thing):

Get-Content $env:USERPROFILE\.openclaw\.env

Git Bash / MINGW64 (what you’re using)

cat ~/.openclaw/.env