Find answers from the community

Updated 2 years ago

I am facing Authorization error when I

At a glance

The community member is facing an Authorization error when trying to import llama_index.AuthenticationError. The error occurs in the get_embeddings function from the llama_index.embeddings.openai module. The comment suggests that the issue may be related to the OpenAI API key not being set correctly, and recommends setting the openai.api_key directly using the environment variable OPENAI_API_KEY.

I am facing Authorization error when I try to do import llama_index.
AuthenticationError Traceback (most recent call last)
File ~\AppData\Local\anaconda3\Lib\site-packages\tenacity__init.py:382, in Retrying.call__(self, fn, args, **kwargs) 381 try:--> 382 result = fn(args, kwargs) 383 except BaseException: # noqa: B902File C:\experiments\llama_index\llama_index\embeddings\openai.py:185, in get_embeddings(list_of_text, engine, kwargs)
183 list_of_text = [text.replace("\n", " ") for text in list_of_text]
--> 185 data = openai.Embedding.create(input=list_of_text, model=engine, **kwargs).data
186 return [d["embedding"] for d in data]
L
1 comment
Try setting the openai key directly on the module, this usually happens in notebooks or threaded applications

Plain Text
import openai

openai.api_key = os.environ["OPENAI_API_KEY"]
Add a reply
Sign up and join the conversation on Discord