#Cannot locate anthropic key

1 messages · Page 1 of 1 (latest)

surreal acorn
#

Ive just added my anthropic api key to enable opus and sonnet but. I did this through Openclaw config wizrd.
Something went wrong and my key appears to be missing in the config.
Please see error after running openclaw doctor -- fix
Failed to read config at /Users/homesafeinspections/.openclaw/openclaw.json MissingEnvVarError: Missing env var "ANTHROPIC_API_KEY" referenced at config path: models.providers.anthropic.apiKey
at substituteString (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2523:61)
at substituteAny (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2563:41)
at substituteAny (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2567:67)
at substituteAny (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2567:67)
at substituteAny (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2567:67)
at substituteAny (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2567:67)
at resolveConfigEnvVars (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:2581:10)
at resolveConfigForRead (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:5233:24)
at Object.loadConfig (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:5255:53)
at loadConfig (/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/config-BWkAE3kO.js:5641:21) {
varName: 'ANTHROPIC_API_KEY',
configPath: 'models.providers.anthropic.apiKey'

vernal sailBOT
#

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

soft drumBOT
#

That error means your openclaw.json doesn’t contain the key — it contains a reference to an env var (ANTHROPIC_API_KEY) and OpenClaw can’t find that env var at runtime:

  • models.providers.anthropic.apiKey → references ANTHROPIC_API_KEY
  • but ANTHROPIC_API_KEY is not set anywhere (shell / service / .env)

Fix (recommended): put the key in ~/.openclaw/.env

On macOS, especially if you run the Gateway as a LaunchAgent/service, your shell env usually won’t be inherited, so .env is the most reliable.

  1. Create/edit this file:
    /Users/homesafeinspections/.openclaw/.env

  2. Add:

ANTHROPIC_API_KEY=sk-ant-...your key...
  1. Restart + re-run checks:
#
openclaw gateway restart
openclaw models status
openclaw doctor

Alternative: store it in config (also fine)

Docs-recommended config pattern is:

{
env: { ANTHROPIC_API_KEY: "sk-ant-..." }
}

(Then you can keep models.providers.anthropic.apiKey pointing at the env var, or the wizard may do it automatically.)

If you’re still stuck

Please paste (no secrets) the output of:

surreal acorn
#

ok so i found the .env file and added the api in, i currently have moonshot and minimax but i dont see their api keys in that file. Why is it only anthropic?

soft drumBOT
#

Totally normal: ~/.openclaw/.env is not “the place where all provider keys live” — it’s just one of several places OpenClaw can load env vars from.

In your case, your config explicitly references an env var here:

  • models.providers.anthropic.apiKey${ANTHROPIC_API_KEY}

So when openclaw doctor reads the config, it must be able to resolve ANTHROPIC_API_KEY, otherwise config loading fails immediately (which is the error you hit).

Moonshot / MiniMax keys might not be in ~/.openclaw/.env because they’re likely coming from one of these other sources:

  1. Inline env block in ~/.openclaw/openclaw.json (wizard often does this)
{ env: { MINIMAX_API_KEY: "...", MOONSHOT_API_KEY: "..." } }
  1. Auth profiles (per-agent) — this is very common, especially for OAuth-style setups
    Stored in something like: