browser-agent icon indicating copy to clipboard operation
browser-agent copied to clipboard

API Key Error.

Open george4n opened this issue 2 years ago • 4 comments

I provided the api key in the .env file but the following error is thrown.

Error: invalid_request_error: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.

george4n avatar Mar 29 '23 08:03 george4n

If you did change .env.example to .env and provided the OPENAI_API_KEY that should be ok. Can you give more context like

  • your OS
  • the command you ran

0ex-d avatar Mar 30 '23 05:03 0ex-d

Running into the same issue.

  1. Installed browser-agent via cargo install browser-agent
  2. I have a .env file in the current folder with my key
  3. Running browser-agent --visual visit google

SebastianSzturo avatar Mar 30 '23 10:03 SebastianSzturo

Building the package myself via cargo build and then cargo run did the trick 👍🏻

SebastianSzturo avatar Mar 30 '23 10:03 SebastianSzturo

Yes, this would work because it would take the variable from your .env file when been run as build. If you are running browser-agent as a CLI (after cargo install), it would make sense to add it as an environment variable (i.e OPENAI_API_KEY=sk-blahblah browser-agent dostuff )

0ex-d avatar Mar 30 '23 10:03 0ex-d