azure-openai-to-responses
它能做什么
这项技能指导将使用 Azure OpenAI 的 Python 应用迁移到较新的 Responses API。适合希望更新旧代码,或为更新的模型做准备的开发者。
适用场景
- ✓当你有一个使用 Azure OpenAI 的 Python 应用,并想切换到 Responses API 时。
- ✓当你为需要 Azure 上 Responses API 的新模型准备代码时。
- ✓当你看到关于 AzureOpenAI 客户端的弃用警告,并想修复它们时。
技能链接
https://github.com/microsoft/ai-agents-for-beginners/blob/main/.agents/skills/azure-openai-to-responses/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我的 Python 聊天机器人从 Azure OpenAI 的 chat completions 迁移到 Responses API。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体首先用一个小测试检查你的 Azure 模型是否支持新的 API。然后它把客户端设置、流式输出和工具调用更新为新格式。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Migrate Python Apps from Azure OpenAI Chat Completions to Responses API
AUTHORITATIVE GUIDANCE — FOLLOW EXACTLY
This skill migrates Python codebases using Azure OpenAI Chat Completions to the unified Responses API. Follow these instructions precisely. Do not improvise parameter mappings or invent API shapes.
Triggers
Activate this skill when user wants to:
- Migrate a Python app from Azure OpenAI Chat Completions to Responses API
- Upgrade Python OpenAI SDK usage to the latest API shape against Azure OpenAI
- Prepare Python code for GPT-5 or newer models that require Responses on Azure
- Switch from
AzureOpenAI/AsyncAzureOpenAIto standardOpenAI/AsyncOpenAIclient with the v1 endpoint - Fix deprecation warnings related to
AzureOpenAIconstructors orapi_version
⚠️ Model Compatibility — CHECK FIRST
Before migrating, verify your Azure OpenAI deployment supports the Responses API.
1. Smoke-test your deployment (fastest)
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AZURE_OPENAI_API_KEY"],
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT'].rstrip('/')}/openai/v1/",
)
try:
resp = client.responses.create(
model=os.environ["AZURE_OPENAI_DEPLOYMENT"],
input="ping",
max_output_tokens=50,
store=False,
)
print(f"✅ Deployment supports Responses API: {resp.output_text}")
except Exception as e:
print(f"❌ Deployment does NOT support Responses API: {e}")
Note:
max_output_tokenshas a minimum of 16 on Azure OpenAI. Values below 16 return a 400 error. Use 50+ for smoke tests.
If this returns a 404, the deployment's model doesn't support Responses yet — check the reference below or redeploy with a supported model.
2. Check available models in your region (recommended)
Run the built-in model compatibility tool to see what's available with Responses API support in your specific region:
python migrate.py models --subscription YOUR_SUB_ID --location YOUR_REGION
This queries Azure ARM live and shows a compatibility matrix — which models support Responses, structured output, tools, etc. Use --filter gpt-5.1,gpt-5.2 to narrow results or --json for scripting.
3. Full model support reference
- Live query:
python migrate.py models(see above — region-specific, always up to date) - Browse availability: Model summary table and region availability
- Quickstart & guidance: https://aka.ms/openai/start
⚠️ Older model limitations
WARNING: Older models (those predating
gpt-4.1) may not support all Responses API features fully.Known limitations with older models:
reasoningparameter: Not supported on many non-reasoning models. Only migratereasoningif it was already present in the original code.seedparameter: Not supported in Responses API at all — remove from all requests.- Structured output via
text.format: Older models may not enforcestrict: trueJSON schemas reliably.- Tool orchestration: GPT-5+ orchestrates tool calls as part of internal reasoning. Older models on Responses still work but lack this deep integration.
- Temperature constraints: When migrating to
gpt-5, temperature must be omitted or set to1. Older models have no such constraint.
O-series reasoning models (o1, o3-mini, o3, o4-mini)
O-series models have unique parameter constraints. When migrating apps that target o-series models:
temperature: Must be1(or omitted). O-series models do not accept other values.max_completion_tokens→max_output_tokens: Apps using the Azure-specificmax_completion_tokensmust switch tomax_output_tokens. Set high values (4096+) because reasoning tokens count against the limit.reasoning_effort: If the app usesreasoning_effort(low/medium/high), keep it — the Responses API supports this parameter for o-series models.- Streaming behavior: O-series models may buffer output until reasoning completes before emitting text delta events. Streaming still works, but the first
response.output_text.deltamay arrive after a longer delay than with GPT models. top_p: Not supported on o-series — remove if present.
常见问题
我需要先检查模型吗?
需要。技能说明,迁移之前应先测试你的部署,因为并非每个模型都支持 Responses API。
它适用于其他 AI 服务提供商吗?
不适用。它针对的是使用 Azure OpenAI 的 Python 代码。
它涵盖 Entra ID 登录吗?
涵盖。它在迁移步骤中包括 EntraID 身份验证。
详情
作者的原始描述
Migrate Python apps from Azure OpenAI Chat Completions to the Responses API. Covers AzureOpenAI/AsyncAzureOpenAI client migration to the v1 endpoint, streaming, tools, structured output, multi-turn, EntraID auth, and model compatibility checks. Python-focused, Azure OpenAI-specific. USE FOR: migrate to responses API, switch from chat completions, openai responses, upgrade openai SDK, responses API migration, move from completions to responses, gpt-5 migration, azure openai python migration, chat completions to responses, AzureOpenAI to OpenAI client, python azure openai upgrade. DO NOT USE FOR
热度
- GitHub 星标
- 79k
- 排名
- #1723
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …