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 reading API key #3

Open
NickCassab opened this issue Jul 27, 2023 · 5 comments
Open

error reading API key #3

NickCassab opened this issue Jul 27, 2023 · 5 comments

Comments

@NickCassab
Copy link

i tried running this streamlit app but I keep running into a validation error related to finding my openAI API key:

ValidationError: 1 validation error for OpenAIEmbeddings root Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error)

i'm hoping this is just user error, and someone may be able to help me out? thank you

@jeremyarbid
Copy link

Do you have your api keys in the environment variable?

@NickCassab
Copy link
Author

yes, i've tried setting my api keys as the environment variable using python, i've tried using a secrets.toml file, and i've tried setting the variables in the script directly. neither method seems to work. Where in the script are the API keys being set and sent to the streamlet app?

image

@shashankdeshpande
Copy link

You can configure those as environment variables in script.
For example -

import os
os.environ["OPENAI_API_KEY"] = "{your-key}"

@jeremyarbid
Copy link

You have a paid OpenAI api, or have quota to use? Are you running the command "streamlit run web_explorer.py" from command terminal? I set my api keys in the secret.toml and it's working for me...

@NickCassab
Copy link
Author

thank you everyone, i got it working using environment variables, with a .env file

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

3 participants