Azure AI Projects Python SDK
microsoft/skills
Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.
Migrasi aplikasi Python dari Azure OpenAI Chat Completions ke Responses API.
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responses --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .claude/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .claude/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .claude/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responsesType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responses --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .agents/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .agents/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .agents/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responses --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .cursor/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .cursor/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/microsoft/ai-agents-for-beginners.git --path translations/ms/.agents/skills/azure-openai-to-responses--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responses --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .gemini/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .gemini/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responsesInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .github/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .github/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .github/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install microsoft/ai-agents-for-beginners azure-openai-to-responses --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/microsoft/ai-agents-for-beginners.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/translations/ms/.agents/skills/azure-openai-to-responses .opencode/skills/azure-openai-to-responses && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "azure-openai-to-responses" agent skill from https://github.com/microsoft/ai-agents-for-beginners/tree/main/translations/ms/.agents/skills/azure-openai-to-responses into .opencode/skills/azure-openai-to-responses/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "azure-openai-to-responses", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
azure-openai-to-responsesMigrasi aplikasi Python dari Azure OpenAI Chat Completions ke Responses API.
Azure Openai To Responses is an agent skill from microsoft/ai-agents-for-beginners, published by the product's own GitHub organization. Migrasi aplikasi Python dari Azure OpenAI Chat Completions ke Responses API. Meliputi migrasi klien AzureOpenAI/AsyncAzureOpenAI ke endpoint v1, penstriman, alat, output berstruktur, multi-sesi, pengesahan EntraID, dan pemeriksaan keserasian model. Berfokus pada Python dan khusus untuk Azure OpenAI. GUNA UNTUK: migrasi ke responses API, bertukar dari chat completions, openai responses, peningkatan openai SDK, migrasi responses API, berpindah dari completions ke responses, migrasi gpt-5, migrasi python azure…
Its SKILL.md is about 6.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/cheat-sheet.md`, `references/test-migration.md` and `references/troubleshooting.md`).
It sits in AI & LLM Engineering, covering LLM API integration. It works with OpenAI, Azure OpenAI, Microsoft Azure and Python. The repository describes itself as: 18 Lessons to Get Started Building AI Agents. The licence is MIT.
3 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit ff2ba66. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
rgpythongitFrom the folder's file list and the shell code blocks in SKILL.md.
Hosts in commands or code, which the agent is likely to contact:
cdn.jsdelivr.netAlso links to:
learn.microsoft.comaka.msnpmjs.complatform.openai.comgithub.comFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
AZURE_OPENAI_API_KEYFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Azure Openai To Responses loads about 6.5k tokens when it runs, and up to ~20k if it reads all its reference files. Until then it costs about 223 tokens; SKILL.md has 2,222 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check noted patterns worth knowing about, such as sudo or a known installer.
SION` / `AZURE_OPENAI_API_VERSION` dari `.env`, tetapan aplikasi, dan fail Bicep/infra.AI_CLIENT_ID` → `AZURE_CLIENT_ID` dalam `.env`, tetapan aplikasi, Bicep/infra, dan fixtur ujian (konvensyen SDK IdentitiAutomated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from microsoft/ai-agents-for-beginners at commit ff2ba66, republished under its MIT licence (© microsoft). 2,222 words, ~6,523 tokens.
.claude/skills/azure-openai-to-responses/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.PANDUAN BERWIBAWA — IKUTI DENGAN TEPAT
Kemahiran ini memindahkan pangkalan kod Python yang menggunakan Azure OpenAI Chat Completions ke Responses API yang bersatu. Ikuti arahan ini dengan tepat. Jangan mengubah suai pemetaan parameter atau mencipta bentuk API baru.
Aktifkan kemahiran ini apabila pengguna ingin:
AzureOpenAI/AsyncAzureOpenAI ke klien standard OpenAI/AsyncOpenAI dengan titik akhir v1AzureOpenAI atau api_versionSebelum migrasi, sahkan penyebaran Azure OpenAI anda menyokong Responses API.
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}")Nota:
max_output_tokensmempunyai minimum 16 di Azure OpenAI. Nilai di bawah 16 akan menghasilkan ralat 400. Gunakan 50+ untuk ujian ringkas.
Jika ini mengembalikan 404, model penyebaran tidak menyokong Responses lagi — semak rujukan di bawah atau lakukan penyebaran semula dengan model yang disokong.
Jalankan alat keserasian model terbina dalam untuk melihat apa yang tersedia dengan sokongan Responses API di rantau anda:
python migrate.py models --subscription YOUR_SUB_ID --location YOUR_REGIONIni mengquery ARM Azure secara langsung dan menunjukkan matriks keserasian — model mana yang menyokong Responses, output berstruktur, alat, dan lain-lain. Gunakan --filter gpt-5.1,gpt-5.2 untuk mengehadkan hasil atau --json untuk skrip.
python migrate.py models (lihat di atas — khusus rantau, sentiasa terkini)AMARAN: Model lama (yang lebih tua daripada
gpt-4.1) mungkin tidak menyokong semua ciri Responses API sepenuhnya.Had yang diketahui dengan model lama:
- Parameter
reasoning: Tidak disokong oleh banyak model bukan beralasan. Hanya migrasireasoningjika sudah wujud dalam kod asal.- Parameter
seed: Tidak disokong langsung dalam Responses API — keluarkan dari semua permintaan.- Output berstruktur melalui
text.format: Model lama mungkin tidak menguatkuasakan skema JSONstrict: truedengan stabil.- Pengurusan alat: GPT-5+ menguruskan panggilan alat sebagai sebahagian daripada alasan dalaman. Model lama pada Responses masih berfungsi tetapi tiada integrasi mendalam ini.
- Had suhu: Apabila migrasi ke
gpt-5, suhu mesti tidak dimasukkan atau ditetapkan kepada1. Model lama tiada had sebegini.
Model siri O mempunyai had parameter unik. Apabila migrasi aplikasi yang mensasarkan model siri O:
temperature: Mesti 1 (atau tidak dimasukkan). Model siri O tidak menerima nilai lain.max_completion_tokens → max_output_tokens: Aplikasi yang menggunakan max_completion_tokens khusus Azure mesti bertukar ke max_output_tokens. Tetapkan nilai tinggi (4096+) kerana token beralasan dikira dalam had.reasoning_effort: Jika aplikasi menggunakan reasoning_effort (rendah/sederhana/tinggi), kekalkan — Responses API menyokong parameter ini untuk model siri O.response.output_text.delta pertama mungkin tiba lewat berbanding model GPT.top_p: Tidak disokong pada siri O — keluarkan jika ada.Tindakan — nasihat model proaktif: Semasa fasa imbasan, periksa model yang dituju aplikasi (nama penyebaran, pembolehubah persekitaran, konfigurasi). Jika model lebih tua daripada gpt-4.1 (bukan gpt-4.1+), beritahu pengguna secara proaktif:
gpt-5.1, gpt-5.2) menawarkan pengurusan alat lebih baik, penguatkuasaan output berstruktur, beralasan, dan ketersediaan merentas rantau.Jangan halang atau tolak migrasi berdasarkan versi model. Nasihat adalah untuk maklumat sahaja.
GitHub Models (
models.github.ai,models.inference.ai.azure.com) tidak menyokong Responses API.
Jika pangkalan kod ada laluan kod GitHub Models (cari base_url yang menunjuk ke models.github.ai atau models.inference.ai.azure.com), buang sepenuhnya semasa migrasi. Responses API memerlukan Azure OpenAI, OpenAI, atau titik akhir tempatan yang serasi (contohnya, Ollama dengan sokongan Responses).
Tindakan semasa imbasan:
Banyak aplikasi menggunakan kerangka kerja peringkat tinggi di atas OpenAI. Apabila memigrasi ini, perubahan API kerangka kerja sendiri — bukan hanya panggilan OpenAI asas.
Periksa versi MAF anda dahulu — migrasi bergantung sama ada anda pada MAF 1.0.0+ atau beta/rc sebelum 1.0.0.
OpenAIChatClient sudah menggunakan Responses API — tiada migrasi diperlukan. Jika pangkalan kod menggunakan OpenAIChatCompletionClient warisan (yang menggunakan chat.completions.create), gantikan dengan OpenAIChatClient.
| Sebelum | Selepas |
|---|---|
from agent_framework.openai import OpenAIChatCompletionClient | from agent_framework.openai import OpenAIChatClient |
OpenAIChatCompletionClient(...) | OpenAIChatClient(...) |
Untuk periksa versi anda: python -c "import agent_framework_openai; print(agent_framework_openai.__version__)"
Pada MAF sebelum 1.0.0, OpenAIChatClient menggunakan Chat Completions. Tingkatkan ke agent-framework-openai>=1.0.0 di mana OpenAIChatClient menggunakan Responses API secara lalai.
Tiada perubahan lain diperlukan — API Agent dan alat kekal sama.
langchain-openai)Tambah use_responses_api=True ke ChatOpenAI(). Juga kemas kini akses respons daripada .content ke .text.
| Sebelum | Selepas |
|---|---|
ChatOpenAI(model=..., base_url=..., api_key=...) | ChatOpenAI(model=..., base_url=..., api_key=..., use_responses_api=True) |
result['messages'][-1].content | result['messages'][-1].text |
Untuk contoh kod lengkap sebelum/selepas, lihat cheat-sheet.md.
Responses API adalah perkara sisi pelayan. Migrasikan backend Python anda; kontrak HTTP frontend harus kekal tidak berubah kecuali backend anda hanya laluan nipis — dalam kes itu, pertimbangkan menggunakan bentuk permintaan Responses untuk menghapuskan lapisan terjemahan. Jika frontend memanggil OpenAI secara langsung dengan kunci sisi klien, alihkan panggilan itu ke backend terlebih dahulu.
@microsoft/ai-chat-protocolPakej npm @microsoft/ai-chat-protocol sudah usang dan perlu digantikan dengan ndjson-readablestream. Jika anda menjumpainya di frontend:
<!-- Before -->
<script src="https://cdn.jsdelivr.net/npm/@microsoft/ai-chat-protocol@.../dist/iife/index.js"></script>
<!-- After -->
<script src="https://cdn.jsdelivr.net/npm/ndjson-readablestream@1.0.7/dist/ndjson-readablestream.umd.js"></script>AIChatProtocolClient (new ChatProtocol.AIChatProtocolClient("/chat")).client.getStreamedCompletion(messages) dengan panggilan fetch() terus ke titik akhir streaming backend.for await (const response of result) dengan for await (const chunk of readNDJSONStream(response.body)).response.delta.content / response.error ke chunk.delta.content / chunk.error.git add/git commit/git push; hasilkan suntingan pokok kerja sahaja.Jika pangkalan kod menggunakan konstruktor AzureOpenAI atau AsyncAzureOpenAI, migrasi ke konstruktor standard OpenAI / AsyncOpenAI terlebih dahulu. Konstruktor khusus Azure ini sudah usang dalam openai>=1.108.1.
Titik akhir baru /openai/v1 menggunakan klien standard OpenAI() dan bukan AzureOpenAI(), tidak memerlukan parameter api_version, dan berfungsi sama rata di OpenAI dan Azure OpenAI. Kod klien yang sama ini tahan masa depan — tiada pengurusan versi diperlukan.
| Sebelum | Selepas |
|---|---|
AzureOpenAI | OpenAI |
AsyncAzureOpenAI | AsyncOpenAI |
azure_endpoint | base_url |
azure_ad_token_provider | api_key |
api_version=... | Keluarkan sepenuhnya |
api_version daripada konstruktor klien.AZURE_OPENAI_VERSION / AZURE_OPENAI_API_VERSION dari .env, tetapan aplikasi, dan fail Bicep/infra.AZURE_OPENAI_CLIENT_ID → AZURE_CLIENT_ID dalam .env, tetapan aplikasi, Bicep/infra, dan fixtur ujian (konvensyen SDK Identiti Azure standard).openai>=1.108.1 dalam requirements.txt atau pyproject.toml.| Pembolehubah lama | Tindakan | Nota |
|---|---|---|
AZURE_OPENAI_VERSION | Keluarkan | Tiada api_version diperlukan dengan titik akhir v1 |
AZURE_OPENAI_API_VERSION | Keluarkan | Sama seperti di atas |
AZURE_OPENAI_CLIENT_ID | Namakan semula → AZURE_CLIENT_ID | Konvensyen SDK Identiti Azure standard untuk ManagedIdentityCredential(client_id=...) |
AZURE_OPENAI_ENDPOINT | Simpan | Masih diperlukan untuk pembinaan base_url |
AZURE_OPENAI_CHAT_DEPLOYMENT | Simpan | Digunakan sebagai parameter model dalam responses.create |
AZURE_OPENAI_API_KEY | Simpan | Digunakan sebagai api_key untuk pengesahan berasaskan kunci |
Untuk contoh kod penyediaan klien (sync, async, EntraID, kunci API, berbilang penyewa), lihat cheat-sheet.md.
Jalankan skrip detect_legacy.py untuk mencari semua tapak panggilan yang perlu dimigrasi:
python skills/azure-openai-to-responses/scripts/detect_legacy.py .Atau jalankan carian ini secara manual — setiap padanan adalah sasaran migrasi:
# Panggilan API Legacy (perlu tulis semula)
rg "chat\.completions\.create"
rg "ChatCompletion\.create"
rg "Completion\.create"
# Pembina klien Azure yang telah usang (perlu gantikan)
rg "AzureOpenAI\("
rg "AsyncAzureOpenAI\("
# Corak akses bentuk respons (perlu kemas kini)
rg "choices\[0\]\.message\.content"
rg "choices\[0\]\.delta\.content"
rg "choices\[0\]\.message\.function_call"
rg "choices\[0\]\.message\.tool_calls"
# Definisi alat dalam format bertingkat lama (perlu ratakan)
rg '"function":\s*{\s*"name"'
rg "pydantic_function_tool"
# Keputusan alat dalam format lama (perlu tukar kepada function_call_output)
rg '"role":\s*"tool"'
rg '"tool_call_id"'
# Parameter yang telah usang (perlu keluarkan atau tukar nama)
rg "response_format"
rg "max_tokens\b" # tukar nama kepada max_output_tokens
rg "['\"]seed['\"]" # remove entirely
# Pembolehubah persekitaran yang telah usang (bersihkan)
rg "AZURE_OPENAI_API_VERSION|AZURE_OPENAI_VERSION"
rg "AZURE_OPENAI_CLIENT_ID" # sepatutnya AZURE_CLIENT_ID
# Titik hujung Model GitHub (perlu keluarkan — API Respons tidak disokong)
rg "models\.github\.ai|models\.inference\.ai\.azure"
# Corak legacy tahap rangka kerja (perlu kemas kini)
rg "OpenAIChatCompletionClient" # MAF 1.0.0+: gantikan dengan OpenAIChatClient
rg "ChatOpenAI\(" | grep -v "use_responses_api" # LangChain: perlu use_responses_api=True
# Infrastruktur ujian (perlu kemas kini)
rg "ChatCompletionChunk|AsyncCompletions\.create" tests/
rg "_azure_ad_token_provider" tests/
rg "prompt_filter_results|content_filter_results" tests/
rg "choices\[0\]" tests/
# Akses badan ralat penapis kandungan (perlu kemas kini — struktur telah berubah)
rg 'innererror.*content_filter_result|error\.body\["innererror"\]'
rg "content_filter_result\[" # bentuk tunggal lama — sekarang content_filter_results (jamak) di dalam tatasusunan content_filters
# Panggilan HTTP mentah ke titik hujung Chat Completions (perlu kemas kini URL)
rg "/openai/deployments/.*/chat/completions"
rg "api-version="Klien Chat Completions: client.chat.completions.create → client.responses.create(...).
Pembina klien Azure: AzureOpenAI(...) → OpenAI(base_url=..., api_key=...).
Alat: tukar definisi alat panggilan fungsi daripada format bersarang ({"type": "function", "function": {"name": ...}}) ke format Respon rata ({"type": "function", "name": ...}); guna tool_choice; pulangkan hasil alat sebagai item {"type": "function_call_output", "call_id": ..., "output": ...} (bukan {"role": "tool", ...}).
Pusingan alat: apabila model memulangkan panggilan fungsi, tambah item response.output ke perbualan (bukan kamus manual {"role": "assistant", "tool_calls": [...]}), kemudian tambah item function_call_output untuk setiap hasil.
Contoh alat tembakan sedikit: jika perbualan termasuk contoh panggilan alat keras kod, tukar kepada item {"type": "function_call", "id": "fc_...", "call_id": "fc_...", ...} + {"type": "function_call_output", ...}. ID mesti bermula dengan fc_.
pydantic_function_tool(): pembantu ini masih menjana format bersarang lama dan tidak serasi dengan responses.create(). Gantikan dengan definisi alat manual atau pembungkus pemesejan.
Multi-pusingan: kekalkan sejarah perbualan dalam aplikasi; hantar pusingan sebelumnya melalui item input.
Pemformatan: ganti response_format peringkat atas Chat dengan text.format dalam Responses. Bentuk kanonik: text={"format": {"type": "json_schema", "name": "Output", "strict": True, "schema": {...}}}.
Item kandungan: ganti Chat content[].type: "text" dengan Responses content[].type: "input_text" untuk pusingan pengguna/sistem.
Item kandungan imej: ganti Chat content[].type: "image_url" dengan Responses content[].type: "input_image". Medan image_url berubah daripada objek bersarang {"url": "..."} menjadi rentetan rata. Lihat helaian cheat untuk contoh sebelum/selepas.
Usaha penalaran: hanya migrasikan reasoning jika ia sudah wujud dalam kod asal.
Pengendalian ralat penapis kandungan: struktur badan ralat berubah. Chat Completions menggunakan error.body["innererror"]["content_filter_result"] (tunggal); Respon API menggunakan error.body["content_filters"][0]["content_filter_results"] (jamak, dalam tatasusunan). Kod yang mengakses innererror akan menaikkan KeyError. Tulis semula untuk menggunakan laluan baru.
Panggilan HTTP mentah: jika aplikasi memanggil Azure OpenAI REST API secara langsung (melalui requests, httpx, dll.) menggunakan /openai/deployments/{name}/chat/completions?api-version=..., tulis semula kepada /openai/v1/responses. Badan permintaan berubah: messages → input, tambah max_output_tokens dan store: false, keluarkan param kueri api-version. Badan tindak balas berubah: choices[0].message.content → output[0].content[0].text (nota: output_text adalah sifat kemudahan SDK yang tiada dalam JSON REST mentah).
/openai/deployments/{name}/chat/completions kepada /openai/v1/responses.messages → input, max_tokens → max_output_tokens. temperature kekal.response_format → text.format dengan objek yang sesuai.content[].type: "text" dengan Responses content[].type: "input_text" untuk pusingan sistem/pengguna.content[].type: "image_url" dengan Responses content[].type: "input_image". Ratakan medan image_url daripada {"image_url": {"url": "..."}} kepada {"image_url": "..."} (rentetan biasa — sama ada URL HTTPS atau URI data data:image/...;base64,...).| Chat Completions | Responses API |
|---|---|
prompt | input |
messages | input (susunan item) |
max_tokens | max_output_tokens |
response_format | text.format (objek) |
temperature | temperature (tidak berubah) |
stop | stop (tidak berubah) |
frequency_penalty | frequency_penalty (tidak berubah) |
presence_penalty | presence_penalty (tidak berubah) |
tools / panggilan fungsi | tools (tidak berubah) |
seed | Buang (tidak disokong) |
store | store (tetapkan kepada false) |
content[].type: "text" | content[].type: "input_text" |
content[].type: "image_url" | content[].type: "input_image" |
"image_url": {"url": "..."} | "image_url": "..." (rentetan rata) |
Untuk contoh kod lengkap sebelum/selepas, lihat cheat-sheet.md.
Untuk migrasi infrastruktur ujian (mock, snapshot, penegasan), lihat test-migration.md.
Untuk penyelesaian masalah ralat dan masalah biasa, lihat troubleshooting.md.
store: false pada semua permintaan Responses.rg "chat\.completions\.create|ChatCompletion\.create|Completion\.create" dalam fail yang telah dimigrasi.rg "AzureOpenAI\(|AsyncAzureOpenAI\(" — semua pembina guna OpenAI/AsyncOpenAI dengan titik akhir v1.rg "models\.github\.ai|models\.inference\.ai\.azure" — laluan kod Model GitHub dibuang.rg "OpenAIChatCompletionClient" — kod MAF 1.0.0+ guna OpenAIChatClient (yang guna Responses API). Dalam pra-1.0.0, naik taraf kepada agent-framework-openai>=1.0.0.ChatOpenAI(...) sertakan use_responses_api=True.rg "choices\[0\]" — semua akses respons guna resp.output_text atau skema output Responses.response_format di peringkat atas; semua output berstruktur guna text={"format": {...}}.openai>=1.108.1 dan azure-identity dalam requirements.txt atau pyproject.toml; kebergantungan dipasang semula.store=False ditetapkan pada setiap panggilan responses.create.api_version dalam pembinaan klien; AZURE_OPENAI_API_VERSION dibuang dari fail persekitaran dan infrastruktur.rg "ChatCompletionChunk|AsyncCompletions\.create|chat\.completions" tests/.rg "_azure_ad_token_provider" tests/ — penegasan diubah untuk periksa isinstance(client, AsyncOpenAI) atau base_url.rg "prompt_filter_results|content_filter_results" tests/ — mock penapis khusus Azure dibuang.kwargs.get("input") bukan kwargs.get("messages").choices[0], function_call, logprobs, dll.).pytest lulus tanpa kegagalan selepas semua kemas kini ujian.responses.create tanpa penstriman pulangkan output_text tidak kosong.response.output_text.delta dengan delta tidak kosong.text.format dengan json_schema, json.loads(resp.output_text) berjaya dan padan dengan skema.output_text akhir (tiada gelung tanpa henti).AsyncAzureOpenAI digunakan, yang setara AsyncOpenAI berfungsi dengan await.| Pek | Versi Minimum |
|---|---|
openai | >=1.108.1 |
azure-identity | Terkini (untuk pengesahan EntraID) |
<!-- CO-OP TRANSLATOR DISCLAIMER START -->
Penafian: Dokumen ini telah diterjemahkan menggunakan perkhidmatan terjemahan AI Co-op Translator. Walaupun kami berusaha untuk ketepatan, sila ambil maklum bahawa terjemahan automatik mungkin mengandungi kesilapan atau ketidaktepatan. Dokumen asal dalam bahasa asalnya harus dianggap sebagai sumber yang sahih. Untuk maklumat penting, terjemahan oleh manusia profesional adalah disyorkan. Kami tidak bertanggungjawab terhadap sebarang salah faham atau salah tafsir yang timbul daripada penggunaan terjemahan ini.
<!-- CO-OP TRANSLATOR DISCLAIMER END -->
© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 3 other files (references) in translations/ms/.agents/skills/azure-openai-to-responses of microsoft/ai-agents-for-beginners.
Open the folder on GitHubat commit ff2ba66
Azure Openai To Responses next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Azure Openai To Responses this skillmicrosoft/ai-agents-for-beginners | 77k | — | ~6.5k | Automated safety check: Notes | MIT | |
| Azure AI Projects Python SDKmicrosoft/skills | 3.1k | — | ~2.8k | Automated safety check: Pass | MIT | |
| Azure AI Openai Dotnetmicrosoft/skills | 3.1k | 5 repos | ~3.4k | Automated safety check: Pass | MIT | |
| New Openai SDK Appsandgardenhq/sgai | 137 | — | ~3.9k | Automated safety check: Notes | Custom licence | |
| Add Example AgentGetBindu/Bindu | 10k | — | ~1.1k | Automated safety check: Notes | Custom licence | |
| Gemini API Devgoogle-gemini/gemini-skills | 4.3k | — | ~5.1k | Automated safety check: Pass | Apache-2.0 |
microsoft/skills
Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.
microsoft/skills
Azure OpenAI SDK for .NET. An agent skill from microsoft/skills.
sandgardenhq/sgai
Create and setup a new OpenAI Agents SDK application with interactive guidance for language choice, agent type selection (Basic, Voice, Realtime), project setup, and automatic verification.
GetBindu/Bindu
Add a new self-contained example agent under examples/. An agent skill from GetBindu/Bindu.
google-gemini/gemini-skills
A skill your agent uses when writing code that calls the Gemini API for text generation, multi-turn chat, multimodal understanding, image generation, video generation, speech generation (TTS), voice…
Kocoro-lab/Kocoro
Build apps with the Claude API or Anthropic SDK. An agent skill from Kocoro-lab/Kocoro.
microsoft/ai-agents-for-beginners
A skill your agent uses when the user asks to create, scaffold, or edit Jupyter notebooks (.ipynb) for experiments, explorations, or tutorials; prefer the bundled templates and run the helper script…
microsoft/ai-agents-for-beginners
Migrate Python apps from Azure OpenAI Chat Completions to the Responses API.
microsoft/ai-agents-for-beginners
Shift Python apps dem from Azure OpenAI Chat Completions go Responses API.
microsoft/ai-agents-for-beginners
Kasuta, kui kasutaja palub luua, üles ehitada või redigeerida Jupyteri märkmikke (.ipynb) katsetuste, uurimiste või juhendite jaoks; eelista kaasasolevaid malle ja käivita abiskript newnotebook.py…
microsoft/ai-agents-for-beginners
Käytetään, kun käyttäjä pyytää luomaan, alustamaan tai muokkaamaan Jupyter-muistikirjoja (.ipynb) kokeita, tutkimuksia tai opetusohjelmia varten; käytä mieluummin mukana olevia mallipohjia ja…
microsoft/ai-agents-for-beginners
À utiliser lorsque l'utilisateur demande de créer, structurer ou modifier des notebooks Jupyter (.ipynb) pour des expériences, explorations ou tutoriels ; privilégiez les modèles fournis et exécutez…
Categories
Migrasi aplikasi Python dari Azure OpenAI Chat Completions ke Responses API. Azure Openai To Responses is an agent skill from microsoft/ai-agents-for-beginners, published by the product's own GitHub organization. Migrasi aplikasi Python dari Azure OpenAI Chat Completions ke Responses API.
Azure Openai To Responses fits situations like: tasks that involve LLM API integration.
Run `npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a claude-code`. Or copy the skill folder (translations/ms/.agents/skills/azure-openai-to-responses in microsoft/ai-agents-for-beginners) into .claude/skills/azure-openai-to-responses in your project. Claude Code loads it when a task matches its description.
Run `npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a codex`. Or copy the skill folder (translations/ms/.agents/skills/azure-openai-to-responses in microsoft/ai-agents-for-beginners) into .agents/skills/azure-openai-to-responses in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/ai-agents-for-beginners --skill azure-openai-to-responses -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/azure-openai-to-responses, .gemini/skills/azure-openai-to-responses, .github/skills/azure-openai-to-responses and .opencode/skills/azure-openai-to-responses in your project.
Going by SKILL.md and its folder, Azure Openai To Responses needs the command-line tools its instructions call (rg, python and git) and credentials named AZURE_OPENAI_API_KEY. Our summary lists: Python 3; A credential in AZURE_OPENAI_API_KEY.
SKILL.md names 6 domains. In commands or code: cdn.jsdelivr.net; the agent is likely to contact it when it follows the instructions. As links in the text: learn.microsoft.com, aka.ms, npmjs.com, platform.openai.com and github.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.
Azure Openai To Responses is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 6.5k tokens (SKILL.md is roughly 26k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 13k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Azure Openai To Responses: Azure AI Projects Python SDK (microsoft/skills, 3.1k stars), Azure AI Openai Dotnet (microsoft/skills, 3.1k stars), New Openai SDK App (sandgardenhq/sgai, 137 stars) and Add Example Agent (GetBindu/Bindu, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
microsoft (a GitHub organization, an official publisher) maintains it in microsoft/ai-agents-for-beginners, which has 76,795 GitHub stars. The repository holds 122 skills in this directory. The repository was last updated on October 9, 2026.
Source: microsoft/ai-agents-for-beginners on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.