Message: Failed to invoke function `genai.vector.encode`: Caused by: com.neo4j.genai.util.GenAIProcedureException: Not authorized to make API request; check your credentials

as per the lesson 5 I am trying to make search call using genai.vector.encode as per below code, but in my case I don’t have the “OpenAiKey” inestade I am using “AzureOpenAiKey” is there any changes required to make it runable.

kg.query(“”"
MATCH (chunk:Chunk) WHERE chunk.textEmbedding IS NULL
WITH chunk, genai.vector.encode(
chunk.text,
“OpenAI”,
{
token: $openAiApiKey,
endpoint: $openAiEndpoint
}) AS vector
CALL db.create.setNodeVectorProperty(chunk, “textEmbedding”, vector)
“”",
params={“openAiApiKey”:OPENAI_API_KEY, “openAiEndpoint”: OPENAI_ENDPOINT})

with this code i am getting error:
message: Failed to invoke function genai.vector.encode: Caused by: com.neo4j.genai.util.GenAIProcedureException: Not authorized to make API request; check your credentials.

Hi @sunil.kushwaha97

Can you share the screenshot of the Message you are getting, did you check into the utils file?

The reason probably it is not working because the authentication for Azure openai API key would be solely from openai, so if you have metadata access to the codes you are working, you can probably look for changing the api key in utils file. if utils file is not available then you need to get an openai api key for the api keys to be authorised.

Regards
DP

Hi @Deepti_Prasad , Thanks for your reply.
Actually I am executing the code from my Jupyter Notebook,
And also I verifyed that the AzureOpenAIkey is correct. But here the main difference is while calling Azure OpenAI the EndPoint URL is different as it must include Deployment Name and API Version so may be my EndPoint Is not correctlly formed, I have used like below
“https://{AzureResourceName}.openai.azure.com/openai/deployments/{MyDeploymentName}” Also I am not sure if i cam pass API version too with this code.

Adding snaps of the Error Screen1:


Error Screen2:

By Using same key I am getting response from llm:

@sunil.kushwaha97

This seems neo client don’t authorise to use your own openai api keys.

I also came across a thread in the same course category where you probably need to address the Neo environment rather than changing the api key. You can check once

Regards
DP

Hi @Deepti_Prasad, I also ran beloew query within my DB and can see there are no proc named “genai.vector.encode”, I already copied the jar file neo4j-genai-plugin-5.20.0.jar from product folder to pluging folder, do you have any idea from where I can install the missing procedures?

Did you download all the metadata files which comes with assignment lesson in short course?

Didn’t get which matadata file to download, can you share the link or Image from where to download the matadate file,

One more question did you completed the Course “Knowledge Graphs for RAG” without any Error or issue as described in course?

Thanks,

@sunil.kushwaha97

The client error could also be related to Coursera platform as we encountering some issues with external links.

I am tagging L.T so he is notified of this issue and can give his input, but as per the error image, I can see because you don’t have access to all the metadata, you are running into issue to run it locally.

@Mubsi Please have a look here. Another client error report but here the learner is running the codes locally in his Jupyter notebook.

Hi @Mubsi,
Could you please help me here.

Hi @sunil.kushwaha97

It is very hard to provide assistance when something is not part of the course material, given that you are running things locally. There could be a number of things wrong here. I’d start first by using Open AI Key to see the issue is with Azure Open AI Key authentication.

I encourage you to find the solution to this on your own and share it with the community!

Best,
Mubsi

Hi @Mubsi , Thanks for reply.
As already communicated in previous chat with @Deepti_Prasad That I tried to find the Function on my DB by running the query(See Attached Image) within my DB and can see there are no proc named “genai.vector.encode”,
From Availabe info on internet, I already copied the jar file neo4j-genai-plugin-5.20.0.jar from product folder to pluging folder to enable genai proc, but issue not resolved, do you have any idea from where I can install the missing genai procedures?
Few peoples are suggesting that only “enterprise edition” of neo4j is having function genai.vector.encode, if its true how can I Install enterprise edition of neo4j.

so issue is with neo4j Database, Can you help me here,

I don’t think copying plugins wil allow access to database.

Issue is not with neo4jbase, it is the access issue which copying will ofcourse not allow.

However I did find something relative to your issue

Regards
DP

Hi @Deepti_Prasad, The Stackoverflow link that you Shared above is also saying my both the points that I mentioned in previous Communication.

  1. You should have “Enterprise Edition”
  2. you have to Copy the requird JAR file from product to pluging folder

it also mentions neo4j database version!!!

check if your version and the assignment codes version match

having access to an enterprise version cannot be just by copying jar file, it should be more than that, the other link mentions the same issue where copying didn’t resolve the issue.

Thank you for your suggestions. I’ve already tried various permutations and combinations available online.

The core issue is that the procedure “genai.vector.encode” is not available in my Neo4j database. Until this procedure is installed or made available in my database, the issue will remain unresolved.

Do you have your own openai api key authorised??

from the codes mentioned in the assignment lesson, the vectors are being used from the token generated from openai api keys.

Regards
DP

Yes I have authorized AzureOpenAI
API key, and is tested too.

Thanks and Regards
Sunil

I suppose because the codes use OpenAI api key and not Azure OpenAI api key, you might be encountering this issue. They surely do use same language model. The one provided directly by OpenAI is the OpenAI API, while the one provided by Microsoft is Microsoft Azure OpenAI.

Regards
DP

I ran into the same issue. Were you able to solve it?
@sunil.kushwaha97

Hi Rohan,
The issue is not resolved yet, may be its required enterprise edition to work properly.

But at the same time i have found one workaround and its working fine for me, i have use my Azure OpenAi model of GPT turbo 3.5 to to create embedding inestad of “genai.vector.encode” method of neo4j database, and saved them back to neo4j database. For that you have to change the code a bit and exact code provided in course will not work.

By using your own model you may be able to create complete RAG.

Thanks,
Sunil