Migrate Python Apps from Azure OpenAI Chat Completions to Responses API
AUTHORITATIVE GUIDANCE — FOLLOW EXACTLY
Dis skill dey migrate Python code wey dey use Azure OpenAI Chat Completions
come use di unified Responses API. Abeg follow dis instructions sharply.
No try do your own mapping of parameters or create new API shapes.
Triggers
Activate dis skill wen user want:
- Migrate a Python app from Azure OpenAI Chat Completions to Responses API
- Upgrade Python OpenAI SDK usage to di latest API shape for Azure OpenAI
- Prepare Python code for GPT-5 or newer models wey need Responses on Azure
- Switch from
AzureOpenAI/AsyncAzureOpenAIgo standardOpenAI/AsyncOpenAIclient with di v1 endpoint - Fix deprecation warnings wey concern
AzureOpenAIconstructors orapi_version
⚠️ Model Compatibility — CHECK FIRST
Before you migrate, make sure say your Azure OpenAI deployment support 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_tokensget minimum 16 for Azure OpenAI. If value less than 16, e go return 400 error. Use 50+ for smoke tests.
If e return 404, e mean say di deployment model no de support Responses yet — check di reference down or redeploy with correct model.
2. Check models wey dey your region (recommended)
Run di built-in model compatibility tool to see wetin dey available with Responses API support for your region:
python migrate.py models --subscription YOUR_SUB_ID --location YOUR_REGION
Dis one dey query Azure ARM live and show compatibility matrix — which models dey 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 am above — region-specific, always updated) - Browse availability: Model summary table and region availability
- Quickstart & guidance: https://aka.ms/openai/start
⚠️ Older model limitations
WARNING: Older models (before
gpt-4.1) fit no fit support all Responses API features fully.
Known limitations with older models:
-
reasoningparameter: No support for many non-reasoning models. Only migratereasoningif e already dey for original code.
-
seedparameter: No dey support at all for Responses API — remove from all requests.
- Structured output via
text.format: Older models no sure to enforcestrict: trueJSON schemas well.
- Tool orchestration: GPT-5+ dey manage tool calls as part of internal reasoning. Older models for Responses still dey work but dem no get dis deep integration.
- Temperature constraints: Wen you dey migrate to
gpt-5, temperature gats be blank or set to1. Older models no get dis kind limit.
O-series reasoning models (o1, o3-mini, o3, o4-mini)
O-series models get them own special parameter limits. If your app dey target o-series models during migration:
temperature: Gats be1(or no include am). O-series no fit take other values.max_completion_tokens→max_output_tokens: Apps wey dey use Azure-specificmax_completion_tokensmust switch gomax_output_tokens. Set am high (4096+) because reasoning tokens dey count against limit.reasoning_effort: If app dey usereasoning_effort(low/medium/high), keep am — Responses API support this for o-series models.- Streaming behavior: O-series models fit hold output till reasoning finish before e dey send text delta events. Streaming still work, but first
response.output_text.deltafit show late than GPT models. top_p: No support for o-series — remove if e dey.- Tool use: O-series models support tools via Responses API same as GPT, but tool call orchestration quality depend on model.
Action — proactive model advisory: During scan, check which model app dey target (deployment names, env vars, config). If model before gpt-4.1 (no be gpt-4.1+), tell user beforehand:
- Migration go work for basic text, chat, streaming, and tools for their current model.
- Newer models (
gpt-5.1,gpt-5.2) get better tool orchestration, structured output enforcement, reasoning, and cross-region availability. - Dem suppose think about upgrading deployment when dem ready — e no go block migration.
No block or refuse migrate based on model version. Dis advisory be just info.
GitHub Models no support Responses API
GitHub Models (
models.github.ai,models.inference.ai.azure.com) no support Responses API.
If codebase get GitHub Models path (look for base_url wey point to models.github.ai or models.inference.ai.azure.com), remove am completely during migration. Responses API need Azure OpenAI, OpenAI, or compatible local endpoint (e.g., Ollama with Responses support).
Action during scan:
- Flag any GitHub Models code paths for removal.
Framework Migration
Plenty apps dey use higher-level frameworks on top of OpenAI. When you dey migrate dem, the framework own API go change — no be only the underlying OpenAI calls.
Microsoft Agent Framework (MAF)
Check your MAF version first — migration depends on whether you dey on MAF 1.0.0+ or before 1.0.0 beta/rc.
MAF 1.0.0+ (agent-framework-openai >= 1.0.0)
OpenAIChatClient dey use Responses API already — no migration needed. If codebase dey use old OpenAIChatCompletionClient (we dey use chat.completions.create), switch am to OpenAIChatClient.
| Before | After |
|--------|-------|
| from agent_framework.openai import OpenAIChatCompletionClient | from agent_framework.openai import OpenAIChatClient |
| OpenAIChatCompletionClient(...) | OpenAIChatClient(...) |
To check your version: python -c "import agent_framework_openai; print(agent_framework_openai.__version__)"
MAF pre-1.0.0 (beta/rc releases)
For pre-1.0.0 MAF, OpenAIChatClient dey use Chat Completions. Upgrade to agent-framework-openai>=1.0.0 so that OpenAIChatClient go use Responses API by default.
No other changes dey needed — Agent and tools API still the same.
LangChain (`langchain-openai`)
Add use_responses_api=True to ChatOpenAI(). Change response access from .content to .text.
| Before | After |
|--------|-------|
| ChatOpenAI(model=..., base_url=..., api_key=...) | ChatOpenAI(model=..., base_url=..., api_key=..., use_responses_api=True) |
| result['messages'][-1].content | result['messages'][-1].text |
For complete before/after code examples, see cheat-sheet.md.
Frontend Migration Guidance
Responses API na server-side matter. Migrate your Python backend; frontend HTTP contract suppose no change unless your backend na thin pass-through — if na so, consider use Responses request shape to drop translation layer. If frontend dey call OpenAI directly with client-side key, make dem move those calls to backend first.
`@microsoft/ai-chat-protocol` deprecation
The @microsoft/ai-chat-protocol npm package don deprecate, make you replace am with