-
Notifications
You must be signed in to change notification settings - Fork 4.8k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: AuthenticationError when using OpenAI Embedding API in llama_index #6920
Comments
Answer generated by a 🤖 AnswerI understand that you're encountering an In your code, you've set the OpenAI API key using the line To address this issue, I suggest setting the openai.api_key = 'xxx' Please replace If you're using custom embeddings, ensure that the model is correctly initialized and the embeddings are correctly generated. In case you're using Azure OpenAI, you need to set the openai.api_type = "azure"
openai.api_base = "https://<foo-bar>.openai.azure.com"
openai.api_version = "2022-12-01"
os.environ["OPENAI_API_KEY"] = "youcannottellanyone"
openai.api_key = os.getenv("OPENAI_API_KEY") And initialize the llm = AzureOpenAI(
engine="<foo-bar-deployment>",
temperature=0,
openai_api_version=openai.api_version,
model_kwargs={
"api_key": openai.api_key,
"api_base": openai.api_base,
"api_type": openai.api_type,
"api_version": openai.api_version,
},
) Please replace This solution should help resolve the Sources
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
The way llama-index is implemented forces you to set the environment variable before importing the VectorStoreIndex. So, put |
If this is the case, then the documentation needs to be updated here. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Question Validation
Question
I'm encountering an AuthenticationError when trying to generate embeddings using the OpenAI API in my application that uses the llama_index library. Here's a snippet of the code where the issue occurs:
And the error message I get is:
The error is raised when trying to create an embedding using the OpenAI's service, but it fails due to an authentication issue. It seems like the tenacity library is trying to retry the operation, but it fails every time due to the same error.
Any help on how to resolve this would be much appreciated.
The text was updated successfully, but these errors were encountered: