error reading API key #2

Open
opened 2026-02-15 23:17:30 -05:00 by yindo · 5 comments
Owner

Originally created by @NickCassab on GitHub (Jul 27, 2023).

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

Originally created by @NickCassab on GitHub (Jul 27, 2023). 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
Author
Owner

@jeremyarbid commented on GitHub (Jul 27, 2023):

Do you have your api keys in the environment variable?

@jeremyarbid commented on GitHub (Jul 27, 2023): Do you have your api keys in the environment variable?
Author
Owner

@NickCassab commented on GitHub (Jul 27, 2023):

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

@NickCassab commented on GitHub (Jul 27, 2023): 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](https://github.com/langchain-ai/web-explorer/assets/5970253/f7bb5ce5-2c21-4d6c-b63a-3249f2ca3fa0)
Author
Owner

@shashankdeshpande commented on GitHub (Jul 27, 2023):

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

import os
os.environ["OPENAI_API_KEY"] = "{your-key}"
@shashankdeshpande commented on GitHub (Jul 27, 2023): You can configure those as environment variables in script. For example - ```python import os os.environ["OPENAI_API_KEY"] = "{your-key}" ```
Author
Owner

@jeremyarbid commented on GitHub (Jul 28, 2023):

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...

@jeremyarbid commented on GitHub (Jul 28, 2023): 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...
Author
Owner

@NickCassab commented on GitHub (Jul 28, 2023):

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

@NickCassab commented on GitHub (Jul 28, 2023): thank you everyone, i got it working using environment variables, with a .env file
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/web-explorer#2