Closed tituslhy closed 2 months ago
The OpenAI API key is not stored by Chainlit, it's stored either in your environment or on your machine at the system/user level. Chainlit will only load environment variables from a .env
file in your code's parent folder. See Chainlit's documentation on this.
Could you provide the following:
AsyncOpenAI
client.If your code is not providing the api_key
parameter to AsyncOpenAI()
, it's using the environment variable from your system or user with the name OPENAI_API_KEY.
Depending on your environment and how you installed python, your environment variables will be controlled differently. If you're on Windows, you can run echo %OPENAI_API_KEY%
from a command prompt or echo $Env:OPENAI_API_KEY
from powershell to see what key you are using. You will probably see your old key being printed out.
To change your environment variables, I recommend you just use the GUI in Windows like so:
If you are using conda for your Python, you can see your environment variables like so:
conda env config vars list
And you can set your new API key as follows:
conda env config vars set OPENAI_API_KEY="..."
You can just edit the activate.bat script to include:
set OPENAI_API_KEY=...
I've refreshed my openAI API key but when I run my application it keeps crashing because chainlit remembers only older version of the API key which doesn't work anymore.
I've tried
Can I check if there is any cached chainlit setting somewhere that is causing this issue?