API Connection Error

I keep getting this error:
Retrying llama_index.llms.openai.base.OpenAI._chat in xxx seconds as it raised APIConnectionError: Connection error…

Not sure why. I am able to access openai using langchain but get this error when using llama_index.llm per this course.

Have you tried the following:
import openai
openai.api_key = OPENAI_API_KEY

Yes, the issue persists

did you get your OpenAI API keys?? from the website openai?

I mean yes! I have no issues when using langchain but somehow I get this issue when using llamaindex

can you share a screenshot of the error sujit

regards
dp

you have to create a .txt file in the root of the project directory. and save it as .env.txt in which the api key should be stored as OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. You might also have to add it in you system’s local environment variables.