Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not recognizing my OpenAI API #644

Closed
1 task done
timkite76 opened this issue Apr 10, 2023 · 21 comments
Closed
1 task done

Not recognizing my OpenAI API #644

timkite76 opened this issue Apr 10, 2023 · 21 comments

Comments

@timkite76
Copy link

Duplicates

  • I have searched the existing issues

Steps to reproduce 🕹

I input my OpenAI API key in the .env but when I run main.py, i can set up the agent, set 5 goals, but then it throws off the following error:

openai.error.AuthenticationError: Incorrect API key provided: sk-dLjLf***************************************PcFj. You can find your API key at https://platform.openai.com/account/api-keys.

I have tried several new openai api keys - all with the same result

Current behavior 😯

No response

Expected behavior 🤔

No response

Your prompt 📝

# Paste your prompt here
@richbeales
Copy link
Contributor

Have you set up billing on your OpenAI account?

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

I'd like to say that I'm having the same issue and I have set up billing.

@richbeales
Copy link
Contributor

Do you have quotes around the key in .env ? (If so try removing)

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

No quotes.

1311502041002

@DevangRadadiya
Copy link

try this command maybe it will help you to cache: pip cache purge

@aosan
Copy link

aosan commented Apr 10, 2023

a quick way to validate the API key you use in .env is by running:

curl -X GET https://api.openai.com/v1/models -H "Authorization: Bearer sk-kufw3eq_YOUR_API_KEY_asdqe23adg"

if successful, it will return what models are available to your subscription.

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

try this command maybe it will help you to cache: pip cache purge

I don't think this did anything for me, unfortunately.

a quick way to validate the API key you use in .env is by running:

curl -X GET https://api.openai.com/v1/models -H "Authorization: Bearer sk-kufw3eq_YOUR_API_KEY_asdqe23adg"

if successful, it will return what models are available to your subscription.

I put in the key I'm using in my .env and the command successfully returned with all of the models available to my account. This suggests that it may be an issue with the script.

Can other people with the same issue chime in?

@aosan
Copy link

aosan commented Apr 10, 2023

OK, we've established your API key is fine.

What version of Python are you running?

python3 --version

What version of openai is installed?

pip3 show openai

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

What version of Python are you running?

$ python3 --version
Python 3.10.10

What version of openai is installed?

$ pip3 show openai
Name: openai
Version: 0.27.2
Summary: Python client library for the OpenAI API
Home-page: https://github.com/openai/openai-python
Author: OpenAI
Author-email: [email protected]
License: 
Location: /home/****/.local/lib/python3.10/site-packages
Requires: aiohttp, requests, tqdm
Required-by:

@aosan
Copy link

aosan commented Apr 10, 2023

Fairly recent Python release, recent openai. Latest openai is 0.72.4, but I'm on 0.72.2 too, without any errors.
Did you try with the latest pull from master? Maybe try to install again to make sure you've pulled all dependencies? The app is not very modular at the moment, error handling is minimal.

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

I reran pip install -r requirements.txt after pulling the repo from master (no changes or updates from each command). I also tried rerunning the script after the fact and got the same error. Pretty illusive.

@aosan
Copy link

aosan commented Apr 10, 2023

see if you could jump on Discord https://discord.com/channels/1092243196446249134/1092243197117337677 and we can try a few ideas to get to the bottom of it

@aosan
Copy link

aosan commented Apr 10, 2023

@onekum try strace python scripts/main.py plus any other arguments you use and see what rabbit trails turn out ugly

@timkite76
Copy link
Author

Have you set up billing on your OpenAI account?

yeah - been set up for awhile.

@aosan
Copy link

aosan commented Apr 10, 2023

@onekum strace lets you see all the system calls made at execution, useful options can be found in the manual.

It appears only the pinecode API are read from .env in the strace and you've got an "write(2, "openai.error.AuthenticationError"..., 190) = 190" It worked when you tried calling the API with your API directly, so the app is not picking it up correctly.

just to rule out any environment issues, please try carefully with a git reset --hard origin/master and create .env again with only the minimal values like LLM_MODEL (try with both GPT-4 and 3.5), OPENAI and REDIS/PINECODE configurations. See if you get the same errors. If you do, try again but enable strace with:

strace -o strace_output.log -f -e trace=file -s 256 python scripts/main.py

Usually, it is not ideal to put strace logs in public, hence my suggestion to take it to Discord and then DM based ping-pong.
I'll come back in about 16h, best of luck until then 😉

@onekum
Copy link
Contributor

onekum commented Apr 10, 2023

Noted; I made sure there wasn't any personal information in the strace log. I'll do what you suggested, thanks.

@timkite76
Copy link
Author

This seems ot have resolved itself for me. My guess is it was some issue on the OpenAI key

@r3chn3r
Copy link

r3chn3r commented Apr 10, 2023

A lot of folks forget to rename the file and get the same error.

@aosan
Copy link

aosan commented Apr 11, 2023

@onekum strace lets you know see all the system calls made at execution, useful options can be found in the manual.

It appears only the pinecode API are read from .env in the strace and you've got an "write(2, "openai.error.AuthenticationError"..., 190) = 190" It worked when you tried calling the API with your API directly, so the app is not picking it up correctly.

just to rule out any environment issues, please try carefully with a git reset --hard origin/master and create .env again with only the minimal values like LLM_MODEL (try with both GPT-4 and 3.5), OPENAI and REDIS/PINECODE configurations. See if you get the same errors. If you do, try again but enable strace with:

strace -o strace_output.log -f -e trace=file -s 256 python scripts/main.py

Usually, it is not ideal to put strace logs in public, hence my suggestion to take it to Discord and then DM based ping-pong.
I'll come back in about 16h, best of luck until then 😉

Noted; I made sure there wasn't any personal information in the strace log. I'll do what you suggested, thanks.

@onekum got it working?

@onekum
Copy link
Contributor

onekum commented Apr 11, 2023

@onekum got it working?

Like timkite76, it seems to have resolve itself. I didn't do anything in particular on my system to resolve it, though, so I'd be hard pressed to tell what the issue was. I did do the hard git reset, but that was yesterday and it still didn't work after the fact, so I have no idea why it works now.

@Qoyyuum Qoyyuum closed this as completed Apr 16, 2023
@azapata13
Copy link

Check the .sourcery file and erase (.env) under :
ignore: # A list of paths or files which Sourcery will ignore.

:)

SquareandCompass pushed a commit to SquareandCompass/Auto-GPT that referenced this issue Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants