自定义渠道报错 No API key found:用 agent auth-profiles 定位并修复
问题/场景:自定义渠道插件收消息后,代理在回复前失败并提示 `No API key found for provider "anthropic"`。前置:可访问 agent 目录与 CLI。实施步骤:先确认当前会话绑定的 agent,再为该 agent 写入 provider 凭据并重启 gateway,最后做渠道回测。关键命令:`openclaw logs --follow`、`openclaw agents add`。验证:同一渠道消息可正常返回。风险:把凭据写到错误 agentDir 会导致“看似已配置但仍报错”。来源:GitHub issue + CLI 文档交叉整理。
GITHUBDiscovered 2026-02-20Author yukilnw
Prerequisites
- You can run OpenClaw CLI on the host and inspect agent directories.
- Provider credentials (Anthropic/OpenAI/etc.) are available for the target agent.
Steps
- Reproduce once and capture exact failing provider from logs (`openclaw logs --follow`).
- Identify which agentDir is serving the channel (avoid assuming main agent).
- Configure auth for that specific agent using interactive CLI (`openclaw agents add`) or equivalent profile write.
- Restart gateway and resend a real channel message to verify round trip.
Commands
openclaw logs --followopenclaw agents addopenclaw gateway restartopenclaw gateway statusVerify
The previous provider-key error disappears and channel messages receive normal replies.
Caveats
- Do not copy credentials between unrelated agents without scope review.
- Exact command flow may differ by CLI version; confirm with `openclaw help`(需验证).
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗