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

Error when using OPEN AI API #278

Closed
tstanek390 opened this issue Nov 29, 2023 · 4 comments
Closed

Error when using OPEN AI API #278

tstanek390 opened this issue Nov 29, 2023 · 4 comments

Comments

@tstanek390
Copy link

I have an issue with running the client with open ai API, tried to export the key as shown and stated in docs, tried to create .env file, reinstalled the whole repo and deps several times, but I'm still getting this:

File "/Users/admin/miniforge3/envs/research/lib/python3.11/site-packages/openai/_base_client.py", line 885, in _request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: {sk-IvWw*****************************************gl9}. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

The API key is working with all other services and tasks, but GPT-researcher, tried a dozen of newly generated keys too, with different companies. All without a success.
What could cause the issue?
Cheers

@tstanek390 tstanek390 changed the title Error Error when using OPEN AI API Nov 29, 2023
@assafelovic
Copy link
Owner

Hi @tstanek390 thanks for raising this. Did you try doing like so export OPENAI_API_KEY=sk-... within the root directory?

@assafelovic
Copy link
Owner

Also you can test if it exists by adding these lines to the main.py file:

import os
env_variable_value = os.getenv('OPENAI_API_KEY')
print(env_variable_value)

@tstanek390
Copy link
Author

thanks for the answer, stupid me, i put brackets on the api key itself, and that was the reason behing the error. Now its working perfectly, thanks a lot for great project, big ups! :)

@assafelovic
Copy link
Owner

Great to hear!

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

2 participants