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

**URL:** <https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046>\
**Category:** Knowledge Graphs for RAG\
**Created:** [August 6, 2024, 3:05pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046 "2024-08-06T15:05:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 6, 2024, 3:05pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/1 "2024-08-06T15:05:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 6, 2024, 3:57pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/2 "2024-08-06T15:57:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 7, 2024, 4:57am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/3 "2024-08-07T04:57:50Z")

</div>

> [@sunil.kushwaha97](#):
>
> 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.

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:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/4/7/47d44af4e4dcb4fbeda0a12b69b2320d97cac899.png)  
Error Screen2:  
 ![image](https://global.discourse-cdn.com/dlai/original/3X/3/7/379a347d6f524275572c5d03941e4a8e3d6ea73c.png)

By Using same key I am getting response from llm:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/4/b/4b1980c339152fef2161e0a6cf1e3d0335181b19.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 7, 2024, 9:11am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/4 "2024-08-07T09:11:51Z")

</div>

@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

> [@Setting up Neo4j locally](https://community.deeplearning.ai/t/setting-up-neo4j-locally/593016/10):
>
> I had the same error, and I managed to use the solution of @pol_avec 1 - copy the docker-compose.yml in a local folder 2 - using terminal get to that folder and run : echo -e “FROM neo4j:5.4” \> Dockerfile 3 - then run : docker compose up 4 - Restart Neo4J …and you are good to go!

Regards  
DP

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 7, 2024, 11:05am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/5 "2024-08-07T11:05:15Z")

</div>

> [@sunil.kushwaha97](#):
>
> openai/

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?

 ![image](https://global.discourse-cdn.com/dlai/original/3X/d/c/dcca49274c6ac9212b897baf1191f6eb760b1443.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 7, 2024, 11:23am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/6 "2024-08-07T11:23:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 7, 2024, 11:38am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/7 "2024-08-07T11:38:39Z")

</div>

> [@Deepti\_Prasad](#):
>
> e to use your own openai api keys.

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,

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 7, 2024, 12:00pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/9 "2024-08-07T12:00:26Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 8, 2024, 10:47am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/10 "2024-08-08T10:47:54Z")

</div>

> [@Deepti\_Prasad](#):
>
> @Mubsi

Hi @Mubsi,  
Could you please help me here.

---

<div class="post-metadata">

**Author:** ![Mubsi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/mubsi/32/94983_2.png) [@Mubsi](https://community.deeplearning.ai/u/Mubsi)\
**Post date:** [August 12, 2024, 11:20am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/11 "2024-08-12T11:20:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 12, 2024, 11:55am UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/12 "2024-08-12T11:55:51Z")

</div>

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,

 ![image](https://global.discourse-cdn.com/dlai/original/3X/d/c/dcca49274c6ac9212b897baf1191f6eb760b1443.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 12, 2024, 12:15pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/13 "2024-08-12T12:15:27Z")

</div>

> [@sunil.kushwaha97](#):
>
> I already copied the jar file neo4j-genai-plugin-5.20.0.jar

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

> **[Install plugins in dockerized neo4j](https://community.neo4j.com/t/install-plugins-in-dockerized-neo4j/13644)**
>
> Hi community, I'm trying to install Neo4j Graph Algorithms plugin in a dockerized neo4j. I'm using Ubuntu and all install buttons are disabled in Neo4j Desktop. I have downloaded the neo4j-graph-algorithms-3.5.14.0-standalone.jar and I have...

> <https://stackoverflow.com/questions/78189201/unknown-function-genai-vector-encode>

Regards  
DP

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 12, 2024, 12:36pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/14 "2024-08-12T12:36:10Z")

</div>

> [@Deepti\_Prasad](#):
>
> I did find something relative to your issue

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

 ![image](https://global.discourse-cdn.com/dlai/original/3X/c/6/c6898aa7c9e863ceea7ca9450489c451ec12336b.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 12, 2024, 12:41pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/15 "2024-08-12T12:41:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 12, 2024, 12:47pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/16 "2024-08-12T12:47:14Z")

</div>

> [@Deepti\_Prasad](#):
>
> [Install plugins in dockerized neo4j - Newbie Questions - Neo4j Online Community](https://community.neo4j.com/t/install-plugins-in-dockerized-neo4j/13644)

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.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 12, 2024, 4:49pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/17 "2024-08-12T16:49:21Z")

</div>

> [@sunil.kushwaha97](#):
>
> **genai.vector.encode** ” i

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

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 12, 2024, 5:35pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/18 "2024-08-12T17:35:51Z")

</div>

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

Thanks and Regards  
Sunil

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [August 12, 2024, 5:45pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/19 "2024-08-12T17:45:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rohanazad94](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rohanazad94](https://community.deeplearning.ai/u/rohanazad94)\
**Post date:** [August 18, 2024, 1:09pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/20 "2024-08-18T13:09:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sunil.kushwaha97](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/sunil.kushwaha97/32/93019_2.png) [@sunil.kushwaha97](https://community.deeplearning.ai/u/sunil.kushwaha97)\
**Post date:** [August 18, 2024, 3:54pm UTC](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046/21 "2024-08-18T15:54:03Z")

</div>

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

[Next page](https://community.deeplearning.ai/t/message-failed-to-invoke-function-genai-vector-encode-caused-by-com-neo4j-genai-util-genaiprocedureexception-not-authorized-to-make-api-request-check-your-credentials/674046.md?page=2)
