eliza
eliza copied to clipboard
Error when sending message without `ANTHROPIC_API_KEY`: "x-api-key header is required"
Error when sending message without ANTHROPIC_API_KEY: "x-api-key header is required"
Description
When installing Eliza from source and running bun start, attempts to send a message to the agent fail with an AI_APICallError: x-api-key header is required error if the ANTHROPIC_API_KEY environment variable is not set. This occurs regardless of whether an OPENAI_API_KEY is present.
Steps to Reproduce
- Clone the Eliza repository and install dependencies.
- Ensure only the
OPENAI_API_KEY(or no API keys) is set in your environment; do not setANTHROPIC_API_KEY. - From the project root, run:
bun start - Attempt to send a message to the “Eliza” agent (e.g., via an HTTP request or CLI).
- Observe the error in logs.
Expected Behavior
- If
ANTHROPIC_API_KEYis unset, Eliza should either:- Fall back to OpenAI if
OPENAI_API_KEYis provided, or - Emit a warning about missing Anthropic functionality without throwing an error when handling messages.
- Fall back to OpenAI if
Actual Behavior
Eliza logs warnings about missing instrumentation and missing ANTHROPIC_API_KEY, then errors out on any message send with:
(AI_APICallError) x-api-key header is required
at new _AISDKError (/eliza/node_modules/@ai-sdk/provider/dist/index.mjs:19:5)
...
Relevant Logs
[2025-04-23 22:20:42] WARN: ANTHROPIC_API_KEY is not set in environment - Anthropic functionality will be limited
[2025-04-23 22:20:47] WARN: Service instrumentation not found
agentName: "Eliza"
agentId: "b850bc30-45f8-0041-a00a-83df46d8555d"
[2025-04-23 22:20:47] WARN: [getTracer] Service instrumentation not found in runtime.
[2025-04-23 22:20:48] ERROR: Error during emitEvent for MESSAGE_RECEIVED (handler execution):
agentName: "Eliza"
agentId: "b850bc30-45f8-0041-a00a-83df46d8555d"
message: "(AI_APICallError) x-api-key header is required"
stack: [
"AI_APICallError: x-api-key header is required",
"at new _AISDKError (/eliza/node_modules/@ai-sdk/provider/dist/index.mjs:19:5)",
"at new APICallError (/eliza/node_modules/@ai-sdk/provider/dist/index.mjs:61:5)",
"at <anonymous> (/eliza/node_modules/@ai-sdk/provider-utils/dist/index.mjs:667:18)",
"at processTicksAndRejections (native:7:39)"
]
Environment
- OS: Ubuntu 22.04 LTS
- Runtime: Bun v0.x
- Eliza Version: Source checkout as of April 23, 2025
- Env Vars:
-
OPENAI_API_KEY: set or unset -
ANTHROPIC_API_KEY: not set
-
Additional Context
This issue blocks users who wish to run Eliza exclusively with OpenAI credentials. A fallback or clearer error message would improve usability.