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 分钟前
【LangGraph实战】LangGraph 学习笔记(三):Overwrite、输入输出模式与四大工作流模式
人工智能·笔记·学习·ai·langgraph
Query*10 小时前
深入浅出LangGraph【一】_基础篇
python·ai·langchain
张忠琳11 小时前
【hermes-agent】Hermes Agent 自我进化原理之一
ai·agent·hermes
Ai-_Man12 小时前
您您这可以把Grok的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。AI导出鸭
javascript·人工智能·ai·小程序·电脑
Harzerr12 小时前
AI行业日报|2026-10-04:5个热点事件
ai·行业动态·技术趋势
汤姆yu12 小时前
Gemini 4 Argon模型综述:技术、能力与实际使用指南
网络·安全·web安全·ai·大模型
搭贝12 小时前
上厕所的时间搭好一套系统:AI自动生成实测
开发语言·人工智能·低代码·ai·php·搭贝
老A的AI实验室13 小时前
Cyber Weekly #84
人工智能·ai·llm·agi·genai
lie..13 小时前
30天从零开始学AI应用开发(Day 18):文档切分与检索优化:RAG 效果好坏的分水岭
人工智能·ai·大模型
小此方13 小时前
LangChain/LangGraph(二)大模型接入篇一:API接入,从API Key到API请求报文,使用Apifox完成大模型接口调用
ai·langchain