Error when using vector_index=VectorStoreIndex(nodes)

I get below error, can some body kindly give me a solution for this?

WARNING:llama_index.embeddings.openai.utils:Retrying llama_index.embeddings.openai.base.get_embeddings in 0.8607730008289738 seconds as it raised APIConnectionError: Connection error…


LocalProtocolError Traceback (most recent call last)

/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py in map_httpcore_exceptions()
68 try:
—> 69 yield
70 except Exception as exc:

61 frames

LocalProtocolError: Illegal header value b’Bearer ’

The above exception was the direct cause of the following exception:

LocalProtocolError Traceback (most recent call last)

LocalProtocolError: Illegal header value b’Bearer ’

The above exception was the direct cause of the following exception:

APIConnectionError Traceback (most recent call last)

/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
984
985 log.debug(“Raising connection error”)
→ 986 raise APIConnectionError(request=request) from err
987
988 log.debug(

APIConnectionError: Connection error.

Hi @Dushan_Jalath,

You are getting this error in which lesson of the course ?

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.

anybody found a solution for this issue?
swass solution does not work for me