","error":{"type":"image_generation_user_error","message":"imagegen deployment m...
错误信息
=== API RESPONSE ===
Timestamp: 2026-07-15T22:06:42.050612153+08:00
{"type":"error","error":{"type":"image_generation_user_error","message":"imagegen deployment must be provided through header: x-ms-oai-image-generation-deployment"}}
AI 解决方案
🔍 报错分析
1. 🌐 错误翻译
原文:imagegen deployment must be provided through header: x-ms-oai-image-generation-deployment
译文:imagegen 部署必须通过请求头 x-ms-oai-image-generation-deployment 提供
2. 🎯 原因分析
该错误表明当前请求缺少必要的部署标识信息。平台要求在进行图像生成操作时,必须通过HTTP请求头
x-ms-oai-image-generation-deployment 明确指定所使用的图像生成部署名称,但当前请求未提供该请求头,导致API验证失败。3. 💡 解决方案
在发送API请求时,添加正确的请求头字段,指定已部署的图像生成模型:
``代码语言Python 示例 - 使用正确的请求头
import requests
headers = {
"x-ms-oai-image-generation-deployment": "your-deployment-name", # 替换为实际的部署名称
"Content-Type": "application/json",
# 其他必要请求头...
}
response = requests.post(
"https://your-api-endpoint/v1/images/generations",
headers=headers,
json={
"prompt": "A beautiful landscape",
# 其他参数...
}
)
`
> 注意:your-deployment-name` 需要替换为你在平台上创建的实际图像生成部署名称,具体可在平台部署管理页面查看。