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函数。

相关推荐
何以解忧唯有撸码15 分钟前
玩转控件:封装个带图片的Label控件
c#·winform·自定义控件·封装控件·控件扩展
xiaoshuaishuai823 分钟前
C# 实现百度搜索算法逆向
开发语言·windows·c#·dubbo
慕峯29 分钟前
反蒸馏 Skill 安装使用教程
ai
深兰科技31 分钟前
深兰科技与淡水河谷合作推进:矿区示范加速落地
java·人工智能·python·c#·scala·symfony·深兰科技
垚森2 小时前
我用AI写了一个颜值拉满的桌面媒体播放器,全程没动一行代码,这就是AI编程新范式
ai·electron·react·opencode
Java小白笔记2 小时前
什么是 Token?2026 年主流大模型计费规则、价格与性能全面对比
人工智能·ai·ai编程·ai写作
Java小白笔记3 小时前
Claude-Code 完全指南
人工智能·ai·全文检索·ai编程·ai写作
岳小哥AI3 小时前
5. WorkBuddy: 小龙虾的灵魂三件套,让你的小龙虾不只是工具
ai·openclaw·workbuddy
我是唐青枫4 小时前
C#.NET ObjectPool 深入解析:对象复用、池化策略与使用边界
c#·.net
lgcgkCQ4 小时前
Trae使用教程:从入门到精通
ai·ai编程·trae·ai ide