BuilderIO / BuilderIO/micro-agent

"401 Incorrect API key provided" even if it has the correct OPENAI_KEY (even after a API key update)

Open
#82 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.3k
Forks
380
PR merge metrics
No merged PRs in 30d

Description

Hi all,
first of all, I'm sure my OpenAI API Key works because I'm using it on a WSL2 machine (Ubuntu 22.04) on the same Windows 11 machine.

On a Windows 11 command prompt window (cmd.exe) I executed `micro-agent` (after installing it through `npm`).
The output was the following:
>C:\Users\edoardo.molinatti>micro-agent
>(node:25320) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
>(Use `node --trace-deprecation ...` to show where the warning was created)
>
>┌ 🦾 Micro Agent
>│
>◇ Welcome newcomer! What is your OpenAI key? (this is kept private)
>│ sk-proj-*******************************************************************************************************************************************************qikA
>│
>◇ What would you like to do?
>│ A function that checks the disk used space telling me a list of the "heaviest" folders on the root filesystem, with a customizable depth level
>which should be 3 by default (this is the recursive depth of the folder to visualize, calculated from the root)
>│
>◓
>✖ 401 Incorrect API key provided: sk-proj-*******************************************************************************************************************************************************qikA. You can find your API key at https://platform.openai.com/account/api-keys.
> at APIError.generate (file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/node_modules/openai/error.mjs:44:20)
> at OpenAI.makeStatusError (file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/node_modules/openai/core.mjs:286:25)
> at OpenAI.makeRequest (file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/node_modules/openai/core.mjs:330:30)
> at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
> at async getFileSuggestion (file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/dist/cli.mjs:967:22)
> at async interactiveMode (file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/dist/cli.mjs:735:33)
> at async file:///C:/Users/edoardo.molinatti/AppData/Roaming/npm/node_modules/@builder.io/micro-agent/dist/cli.mjs:1776:11
>
> micro-agent v0.1.4
>
> Please open a Bug report with the information above:
> https://github.com/BuilderIO/micro-agent/issues/new

As you can see I specified my OpenAI API key as requested, but it didn't work.
If I run `micro-agent config` I see that the key is correct, but I tried to update it re-pasting it after a double-check (using the command `micro-agent config set OPENAI_KEY=`).
It still doesn't work (with the same error output).

Can you please tell me what could be wrong and/or what to check?

Thank you very much for any help

Contributor guide

Open the contributing guide

Research direction

Reproduce the Windows command-prompt flow described in the issue, then start at dist/cli.mjs around interactiveMode and getFileSuggestion, where the reported stack trace reaches the OpenAI request. Compare the configured key and request behavior with the working WSL2 setup; done means identifying and fixing or documenting the cause of the 401 for a valid key.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.