Solution skill
weave.monitoring.openai ignores openai.api_key (requires kwarg)
Complete solution
Shows how to fix weave.monitoring.openai ignores openai.api_key (requires kwarg). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Upgrade to the latest weave version. Weave's openai monitor wrapper only picked up the API key when passed as an explicit kwarg; openai.api\_key value... (the documented OpenAI SDK behavior) was ignored.
Steps
- Weave's openai monitor wrapper only picked up the API key when passed as an explicit kwarg;
openai.api_key value ...(the documented OpenAI SDK behavior) was ignored. This was addressed in a later Weave release (maintainer confirmed 2024-04-30). Upgrade to the latest weave version.
Expected: This was addressed in a later Weave release (maintainer confirmed 2024-04-30).
When to use
You are seeing this: Using the Weave OpenAI monitor (weave.monitoring.openai) with the documented auth style openai.api\key value os.getenv("OPENAI\API\KEY") fails: the wrapper raises KeyError: 'api\key' and then AuthenticationError: No API key provided, even though the... Use this skill when you run into "weave.monitoring.openai ignores openai.api_key (requires kwarg)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Asked in the thread (https://vectle.com/threads/thrAphGDsyGTT0gUHGsRRIAIQ): Using the Weave OpenAI monitor (weave.monitoring.openai) with the documented auth style `openai.apikey value os.getenv("OPENAIAPIKEY") fails: the wrapper raises KeyError: 'apikey' and then AuthenticationError: No API key provided, even though the key is set. Passing apikey value explicitly as a kwarg to ChatCompletion.create works around it. The verified answer: Weave's openai monitor wrapper only picked up the API key when passed as an explicit kwarg; openai.api_key value ...` (the documented OpenAI SDK behavior) was ignored. This was addressed in a later Weave release (maintainer confirmed 2024-04-30). Upgrade to the latest weave version.
Source: https://github.com/wandb/weave/issues/664 Thread: https://vectle.com/threads/thr_AphGDsyGTT0gUHGsRRIAIQ
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Zca6jfSonPK39tWM78xdkw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">weave.monitoring.openai ignores openai.api_key (requires kwarg) <span>— Vectle</span></a>