Using Embeddings API in Azure OpenAI

**题意:**当我在 Azure OpenAI 中使用嵌入功能时,我遇到了 404 错误(资源未找到)

问题背景:

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

当我在 Azure OpenAI 中使用嵌入功能时,我遇到了 404 错误(资源未找到)

cs 复制代码
    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:

该文本是用于创建向量的输入文本。同时,mWebSvc.AzureOpenAI.DeploymentID 是一个部署ID或部署名称,这里是 "ada2"------这是我给text-embedding-ada-002模型命名的名称。另外,在创建mOpenAiClient时,我使用了以下URL:

cs 复制代码
"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.

有什么想法吗?微软在这些事情上相当沉默,Azure SDK的Azure OpenAI部分也没有提供任何文档。

问题解决:

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:

显然,我之前使用的URL虽然对于正常的HttpClient调用是正确的,但并不是Azure OpenAI API所期望的。它期望的是这样的:

cs 复制代码
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.

其中{resourceName}是一个占位符,它是你在Azure上创建的资源的名称。资源类型是:"Azure OpenAI"。这是你部署模型的资源(在我的情况下,我命名为"ada2"的text-embedding-ada-002模型)。这个"ada2"作为参数传递给GetEmbeddingsAsync函数。

相关推荐
花生糖@1 小时前
ST-Raptor:无需微调,准确率超越 GPT-4o 的半结构化表格问答新范式
ai·gpt-4·st-raptor
William_cl1 小时前
C# MVC 修复DataTable时间排序以及中英文系统的时间筛选问题
开发语言·c#·mvc
c#上位机2 小时前
wpf之RelativeSource用法总结
c#·wpf
Dm_dotnet2 小时前
WPF应用最小化到系统托盘
c#
*长铗归来*4 小时前
ASP.NET Core Web API 中控制器操作的返回类型及Swagger
后端·c#·asp.net·.netcore
Damon小智4 小时前
玩转ClaudeCode:通过Excel-MCP实现数据清洗并写入Excel
ai·excel·ai编程·claude·chrome devtools·rpa·claude code
R-G-B7 小时前
【06】C#入门到精通——C# 多个 .cs文件项目 同一项目下添加多个 .cs文件
开发语言·c#·c# 多个 .cs文件项目
拆房老料13 小时前
Transformer推理优化全景:从模型架构到硬件底层的深度解析
深度学习·ai·自然语言处理·transformer
Learn Beyond Limits16 小时前
Mean Normalization|均值归一化
人工智能·神经网络·算法·机器学习·均值算法·ai·吴恩达
CoderJia程序员甲19 小时前
GitHub 热榜项目 - 日榜(2025-10-07)
ai·github·开源项目·github热榜