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

when i run the scripts code, I alwys got the following:No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. #29

Open
xiaohai-AI opened this issue Jul 3, 2024 · 2 comments

Comments

@xiaohai-AI
Copy link

No description provided.

@xiaohai-AI xiaohai-AI changed the title when i run the scripts code, I alwys got the following: when i run the scripts code, I alwys got the following:No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. Jul 3, 2024
@xiaohai-AI
Copy link
Author

but Actually I already set the enviroment variable and echo$OPENAI_API_KEY output the right value sk-XXXXXXXXXXXXXXXXXXX

@ZixuanWang1210
Copy link

Hi @xiaohai-AI,

I encountered the same issue and found the reason behind it. In the LLM.py file, the script retrieves the API key using the following line:

openai.api_key = os.getenv("OPENAI_KEY")

This means the script is designed to use the OPENAI_KEY environment variable, not the commonly used OPENAI_API_KEY. If you have set the API key as OPENAI_API_KEY, it won't work with the current script configuration.

To resolve this, you can either:

  • Set your API key using the OPENAI_KEY environment variable, or
  • Modify the script to retrieve the key using os.getenv("OPENAI_API_KEY").

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