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

相关推荐
TDengine (老段)25 分钟前
TDengine IDMP 工业数据建模 —— 数据标准化
大数据·数据库·物联网·ai·时序数据库·tdengine·涛思数据
Thomas.Sir43 分钟前
第三章:RAG知识库开发之【RAG系统工作流程详细解析:从数据源到智能问答的全链路实战指南】
人工智能·ai·rag·离线处理·在线查询
Agent产品评测局2 小时前
物流供应链自动化解决方案选型,全链路提效指南:从硬件集成到AI Agent的演进路径
运维·人工智能·ai·chatgpt·自动化
学术头条2 小时前
清华、智谱团队提出Vision2Web:基于Agent验证评估视觉网站开发
人工智能·科技·ai
zzb15803 小时前
Agent记忆与检索
java·人工智能·python·学习·ai
领尚3 小时前
OpenClaw 2026.3.28 使用model qwen 无法统计tokens使用量及费用的解决过程
ai
种时光的人3 小时前
Java+AI 无缝衔接:Spring AI 聊天模型入门到精通
java·人工智能·spring·ai·spring ai
2501_948114244 小时前
OpenClaw数据采集实战:用星链4SAPI给AI采集装上“稳定引擎”
服务器·人工智能·ai·openclaw
实在智能RPA4 小时前
Agent上线后有专人运营支持吗?深度解析AI Agent的全生命周期运维保障体系
运维·人工智能·ai