AgentGPT icon indicating copy to clipboard operation
AgentGPT copied to clipboard

Invalid API Key

Open taia-source opened this issue 1 year ago • 9 comments
trafficstars

Please check that this issue hasn't been reported before.

  • [X] I searched previous Bug Reports didn't find any similar reports.

Expected Behavior

Should accept OpenAI API Key.

Current behaviour

git clone https://github.com/reworkd/AgentGPT.git cd AgentGPT ./setup.bat

I did this, cmd couldn't understand .setup.bat so I had to run setup.bat only. Asks me to choose between Docker and Manual. I choose Docker. Asks me for OpenAPI Key. I input API Key with no success.

Steps to reproduce

No idea.

Possible solution

I'm doing something wrong clearly as no one have reported this bug. I followed the instructions to get started but this is where i am at.

Which Operating Systems are you using?

  • [ ] Android
  • [ ] iPhone/iPad
  • [ ] Linux
  • [ ] macOS
  • [X] Windows

Acknowledgements

  • [X] My issue title is concise, descriptive, and in title casing.
  • [X] I have searched the existing issues to make sure this bug has not been reported yet.
  • [X] I am using the latest version of AgentGPT.
  • [X] I have provided enough information for the maintainers to reproduce and diagnose the issue.

taia-source avatar Sep 12 '24 09:09 taia-source

No you are not doing anythig wrong. I just landed here super exited about how strateforeword all this looks anb bam~ Invalid api key. Please try again.

I'm on linux Ubuntu 24.04.1 LTS x86_64

bogdan-marian avatar Sep 13 '24 11:09 bogdan-marian

Yea, something's weird. Also happening to me.

The issue stems from this line: https://github.com/reworkd/AgentGPT/blame/main/cli/src/questions/newEnvQuestions.js#L15

The regex is incorrect and should be changed from /^sk-[a-zA-Z0-9]{48}$/ to /^sk-[a-zA-Z0-9\-\_]{92}$/ as OpenAI API secrets have 92 characters after the 'sk-' prefix, and also have underscores & dashes. Unless I'm missing something

Edit: The above only accounts for User API Secret Keys and not 'Project' API Secret Keys which seem to have a different length

Edit 2: Testing the change now, will probably create a PR tomorrow if all is ok

jarodsmk avatar Sep 17 '24 17:09 jarodsmk

Same happened for me on Ubuntu 24.04.1 LTS x86_64

elhenro avatar Sep 23 '24 19:09 elhenro

same for me...

twobeass avatar Sep 30 '24 10:09 twobeass

Any workaround? Running it on Mac M1 Ok, 48 key work but not 92

Molnfront avatar Oct 15 '24 08:10 Molnfront

also having this issue

AlexVanDyne avatar Oct 25 '24 16:10 AlexVanDyne

I personally use a project api key. Mine begins with sk-proj- and is 164 chars long.

Once the regexp modified like /^sk(-proj)?-[a-zA-Z0-9\-\_]+$/, AgentGPT works like a charm with it

jclaveau avatar Nov 01 '24 15:11 jclaveau

I personally use a project api key. Mine begins with sk-proj- and is 164 chars long.

Once the regexp modified like /^sk(-proj)?-[a-zA-Z0-9\-\_]+$/, AgentGPT works like a charm with it

The PR I put up accounts for all 3 OpenAI SK variants - though I see there's another PR that's been up for months without a review... 😞

jarodsmk avatar Nov 01 '24 19:11 jarodsmk

Looks like this project is dead? Still no resolution available which I could find.

viktorrudi avatar Feb 10 '25 11:02 viktorrudi