Reputation: 1
Even after using the correct parameter for OPENAI_API_KEY= yet keep getting the error:
{ "status": "error", "message": "An error occurred: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details." }
Code: enter image description here enter image description here
Error: enter image description here
Have used the current openai==1.6.0 and langchain=0.0346
The API keys are correct and present in the .env file. Have printed the API keys and other credentials as debugging step to ensure.
Help with this will be much appreciated. It's dragging since 2-3 days now. Thank You.
I tried changing the version of the libraries. Tried using openai==0.28.0 and langchain=0.0341 and openai==0.27.0 and langchain=0.0341 yet facing this error.
Expectations was that the Azure OpenAI key will work and we'll receive the result.
Upvotes: 0
Views: 895
Reputation: 894
This is my solution.
os.environ["OPENAI_API_KEY"]="your-openai-key"
And you don't need add OPENAI_API_KEY on AzureChatOpenAI, this's because it's defined on the environment.
Hope it useful for you. I will support you until you solve your problem.
Upvotes: 0