Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Embeddings API in Azure OpenAI

When I use embeddings with Azure OpenAI I am getting 404 (resource not found):

    EmbeddingsOptions embdOptions = new EmbeddingsOptions(text);
    Azure.AI.OpenAI.Embeddings response = Task.Run(() => mOpenAiClient.GetEmbeddingsAsync(mWebSvc.AzureOpenAI.DeploymentID, embdOptions)).Result;

The text is the input text to be used to create the vector. Also, mWebSvc.AzureOpenAI.DeploymentID is a Deployment ID or Deployment Name, which is "ada2" - this is how I named the text-embedding-ada-002 model. Also, while I created mOpenAiClient I used the URL:

"https://AzureOpenAIExperiment.openai.azure.com/openai/deployments/ada2/embeddings?api-version=2023-05-15"

Any ideas? Microsoft is quite silent on these things and no documentation is provided in Azure OpenAI part of Azure SDK.

like image 417
Leon Avatar asked Sep 17 '25 05:09

Leon


2 Answers

Apparently, the URL that I used before, although correct for normal HttpClient calls is not what Azure Open AI API is expecting. It expects this:

https://{resourceName}.openai.azure.com

Where {resourceName} is a placeholder - it is the name of the resource you created on Azure. The Type Of Resource is: "Azure OpenAI". This is the resource that you deployed the model (in my case text-embedding-ada-002 that I named "ada2". This "ada2" goes as a parameter into GetEmbeddingsAsync function.

like image 199
Leon Avatar answered Sep 19 '25 11:09

Leon


Check your Deployment Id, if 'ada2' is correct. You can sure, verify by sending a GET request to the URL:

https://AzureOpenAIExperiment.openai.azure.com/openai/deployments?api-version=2023-05-15

enter image description here

After, include the ID in your URL

https://AzureOpenAIExperiment.openai.azure.com/openai/deployments/{{ID}}/embeddings?api-version=2023-05-15

My test

My ID = text-embedding-ada-002

https://estudoopenai.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15

{    
    "input":"test"
}

enter image description here

like image 25
Shai Pinho Avatar answered Sep 19 '25 11:09

Shai Pinho