agentleFS
MicrosoftKnown publishermicrosoft/generative-ai-for-beginners/.github/skills/azure-openai-to-responses/SKILL.md

azure-openai-to-responses

Skill121k starsChanged 5 months agoMITView on GitHub

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: building new apps from scratch (start with responses directly), Node/TypeScript/C#/Java/Go migrations (this skill is Python-only), Azure infrastructure setup (use azure-prepare), deploying models (use microsoft-foundry).

  • Reads credentials

2 other projects use a version of this, 2 of them edited; 2 of 2 edited versions we compared changed its rules.

How people change it

2 of 2 edited versions changed its rules, and some changes recur.

Of the 2 edited versions we compared: 2 made changes of their own.

Rules people drop

  1. Verify the deployed model supports the Responses API before migrating. GPT-4o and GPT-4 support Responses for basic text/chat/streaming/tools but not all features. Newer models (gpt-4.1+, gpt-5.x) have full support. …dropped by 2 of 2
  2. No top-level response_format; structured output uses text={"format": {...}}dropped by 2 of 2

Rules people add

  1. If this returns a 404, the deployment's model doesn't support Responses yet — check the reference below or redeploy with a supported model.added by 2 of 2
  2. Run the built-in model compatibility tool to see what's available with Responses API support in your specific region:added by 2 of 2
  3. temperature: Must be 1 (or omitted). O-series models do not accept other values.added by 2 of 2
  4. reasoning_effort: If the app uses reasoning_effort (low/medium/high), keep it — the Responses API supports this parameter for o-series models.added by 2 of 2
  5. top_p: Not supported on o-series — remove if present.added by 2 of 2
  6. Do not block or refuse to migrate based on model version. The advisory is informational.added by 2 of 2
  7. If the codebase has a GitHub Models code path (look for base_url pointing to models.github.ai or models.inference.ai.azure.com), remove it entirely during migration. …added by 2 of 2
  8. No other changes needed — the Agent and tool APIs remain the same.added by 2 of 2

We split this file and each edited version into the rules they give an agent and match them by wording. A version that adds no rule of its own and has not changed since this file last did reads as an older text, so what it lacks is not counted as dropped. We keep no past texts of a file, so that is inferred, and an edited version that started from an older text still counts its gaps as drops.

Trending

More talk lately.about the whole repository

Dec 2025: 1 mentionJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 2 mentionsJun 2026: 8 mentionsJul 2026: 3 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 2 mentionsNov 2026: 13 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/generative-ai-for-beginners repository that our weekly crawl found. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about microsoft/generative-ai-for-beginners

The biggest 5 of 94 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 94

Talked about on Bluesky, GitHub and Hacker News (94 times).

On Bluesky · 44

39 more on Bluesky

On GitHub · 43

38 more on GitHub

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verify the deployed model supports the Responses API before migrating.

    line 65
  2. Very specific:

    No top-level response_format.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.

Installed from Azure-Samples/azure-openai-to-responses (MIT).

Triggers

Activate this skill when the 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/AsyncAzureOpenAI to standard OpenAI/AsyncOpenAI client with the v1 endpoint
  • Fix deprecation warnings related to AzureOpenAI constructors or api_version

Why migrate

GPT-5 and newer models require the Responses API. The new /openai/v1/ endpoint uses the standard OpenAI() client instead of AzureOpenAI(), requires no api_version parameter, and works identically across OpenAI and Azure OpenAI.

What changes

Chat Completions (before)Responses API (after)
AzureOpenAI() / AsyncAzureOpenAI()OpenAI(base_url=...) / AsyncOpenAI(base_url=...)
azure_endpoint=...base_url=f"{endpoint.rstrip('/')}/openai/v1/"
api_version="2024-..."Remove entirely — /openai/v1/ is stable
azure_ad_token_provider=...api_key=token_provider
client.chat.completions.create(messages=...)client.responses.create(input=...)
resp.choices[0].message.contentresp.output_text
max_tokensmax_output_tokens (min 16 on Azure)
response_formattext={"format": {...}}
seedRemove (not supported)
tools nested {"type":"function","function":{...}}flat {"type":"function","name":...}
tool result {"role":"tool","tool_call_id":...}{"type":"function_call_output","call_id":...,"output":...}
content[].type: "text"content[].type: "input_text"
content[].type: "image_url" + {"url": "..."}content[].type: "input_image" + flat "image_url": "..."
streaming chunk.choices[0].delta.contentevent.type == "response.output_text.delta" → event.delta

Model compatibility — CHECK FIRST

Verify the deployed model supports the Responses API before migrating. GPT-4o and GPT-4 support Responses for basic text/chat/streaming/tools but not all features. Newer models (gpt-4.1+, gpt-5.x) have full support. GitHub Models (models.github.ai, models.inference.ai.azure.com) do NOT support the Responses API — remove those code paths and switch to Azure OpenAI, OpenAI, or a compatible local endpoint.

Smoke test:

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/",
)
resp = client.responses.create(
    model=os.environ["AZURE_OPENAI_DEPLOYMENT"],
    input="ping",
    max_output_tokens=50,
    store=False,
)
print(resp.output_text)

Step 0: Client migration (prerequisite)

AzureOpenAI/AsyncAzureOpenAI constructors are deprecated in openai>=1.108.1.

Before:

from openai import AzureOpenAI
client = AzureOpenAI(
    api_version=os.environ["AZURE_OPENAI_API_VERSION"],
    azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    api_key=os.environ["AZURE_OPENAI_API_KEY"],
)

After:

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/",
)

Cleanup: remove api_version args, remove AZURE_OPENAI_API_VERSION / AZURE_OPENAI_VERSION from .env/infra, rename AZURE_OPENAI_CLIENT_ID → AZURE_CLIENT_ID, ensure openai>=1.108.1.

Step 1: Detect legacy call sites

rg "chat\.completions\.create"        # legacy API calls
rg "ChatCompletion\.create|Completion\.create"
rg "AzureOpenAI\(|AsyncAzureOpenAI\("  # deprecated constructors
rg "choices\[0\]\.message\.content"    # response access
rg "choices\[0\]\.delta\.content"      # streaming access
rg "max_tokens\b"                      # rename to max_output_tokens
rg "['\"]seed['\"]"                    # remove entirely
rg "response_format"                   # → text.format
rg "AZURE_OPENAI_API_VERSION|AZURE_OPENAI_VERSION"
rg "models\.github\.ai|models\.inference\.ai\.azure"  # GitHub Models: remove

Step 2: Apply migration

  • client.chat.completions.create(messages=...) → client.responses.create(input=...)
  • resp.choices[0].message.content → resp.output_text
  • max_tokens → max_output_tokens (min 16); remove seed
  • response_format → text={"format": {"type": "json_schema", "name": "Output", "strict": True, "schema": {...}}}
  • Set store=False on every request (client-managed state)
  • Streaming: iterate events, handle event.type == "response.output_text.delta" (use event.delta) and response.completed
  • Tools: flat format, tool_choice, return results as function_call_output items; append response.output items for round-trips
  • Multi-turn: maintain conversation in an input array, or use previous_response_id (requires store=True)
  • Reasoning models (o-series, GPT-5): max_completion_tokens → max_output_tokens (4096+), reasoning_effort → reasoning={"effort": ...}, omit temperature/top_p (GPT-5 rejects temperature outright; to vary output use a non-reasoning model like Llama-3.3-70B-Instruct via Foundry Models)

Acceptance criteria (all must pass)

  • Zero matches for chat.completions.create|ChatCompletion.create|Completion.create
  • Zero matches for AzureOpenAI(|AsyncAzureOpenAI( — all use OpenAI/AsyncOpenAI + v1 endpoint
  • Zero matches for models.github.ai|models.inference.ai.azure
  • Zero matches for choices[0] — all access uses resp.output_text / Responses schema
  • No top-level response_format; structured output uses text={"format": {...}}
  • openai>=1.108.1 in requirements; store=False on every call; no api_version in client construction
  • Tests updated (mocks use kwargs.get("input"), snapshots use Responses shape); pytest passes

See references/cheat-sheet.md for complete before/after code examples.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.