azure-openai-to-responses
Skill76k starsChanged 5 months agoMITView on GitHub
คำแนะนำอย่างเป็นทางการ — ทำตามอย่างเคร่งครัด ทักษะนี้จะย้ายฐานโค้ด Python ที่ใช้ Azure OpenAI Chat Completions ไปยัง Responses API แบบรวมศูนย์ โปรดทำตามคำแนะนำเหล่านี้อย่างแม่นยำ หลีกเลี่ยงการปรับแม็ปพารามิเตอร์เองหรือคิดค้นรูปแบบ API ใหม่ เปิดใช้งานทักษะนี้เมื่อผู้ใช้ต้องการ: - ย้ายแอป Python จาก Azure OpenAI Chat Completions ไปยัง Responses API - อัพเกรดการใช้งาน Python OpenAI SDK ไปยังรูปแบบ API ล่าสุดกับ Azure OpenAI - เตรียมโค้ด Python สำหรับโมเดล GPT-5 หรือใหม่กว่าที่ต้องการ Responses บน Azure - เปลี่ยนจากไคลเอนต์ AzureOpenAI/AsyncAzureOpenAI เป็น OpenAI/AsyncOpenAI แบบมาตรฐานที่ใช้ปลายทาง v1 - แก้ไขคำเตือนการเลิกใช้ที่เกี่ยวกับตัวสร้าง AzureOpenAI หรือ api_version ก่อนย้าย ตรวจสอบให้แน่ใจว่า deployment Azure OpenAI ของคุณรองรับ Responses API หมายเหตุ: บน Azure OpenAI max_output_tokens มีค่าขั้นต่ำ 16 ค่าที่ต่ำกว่า 16 จะส่งคืนข้อผิดพลาด 400…
- Reads credentials
- Commits and pushes
2 other projects use a version of this, 1 of them edited.
Adopted by
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Most recently taken up by
- microsoft/generative-ai-for-beginnerstheir own version, first seen Jul 14, 2026
- Azure-Samples/azure-openai-to-responsesedited, first seen Apr 6, 2026
Who's talking about microsoft/ai-agents-for-beginners
- @rodtrent.com“AI Agents for Beginners - 10 Lessons teaching everything you need to know to start building AI Agents …”Bluesky · Feb 14, 2025 · 25 likes
- A Hacker News story“Lessons to Get Started Building AI Agents”Hacker News · Jul 4, 2025 · 10 points
- @rdenadai.dev“Pô, parece legal a grade hein... Deixar na lista aqui pra estudar depois da certificação da AWS.”Bluesky · Sep 7, 2025 · 7 likes
- @alvinashcraft.com“AI Agents for Beginners - 10 Lessons to Get Started Building AI Agents. …”Bluesky · Feb 22, 2025 · 7 likes
- @ottorinobruni.bsky.social“🚨 Want to learn AI Agents from scratch? Microsoft’s free 18-lesson course covers frameworks, tools, RAG, …”Bluesky · Nov 20, 2026 · 4 likes
The biggest 5 of 88 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 88
Talked about on GitHub, Bluesky and Hacker News (88 times).
On GitHub · 50
- Oct 14, 2026"Lesson" is not being translated. (en→ja) — Azure/co-op-translator1 reaction
- Jul 25, 2026Previous and Next lessons have not been translated. (en→jp) — Azure/co-op-translator1 reaction · 1 comment
- Jul 4, 2026Translated the markdown header ## Summary to ## まとめ (en→jp) — Azure/co-op-translator1 reaction · 1 comment
- Mar 31, 2026"Join the [Microsoft Foundry Discord]~" has not been translated. (en→ja) — Azure/co-op-translator1 reaction · 3 comments
- Mar 17, 2026The headline has not been translated (en→ja) — Azure/co-op-translator1 reaction · 2 comments
45 more on GitHub
- Mar 15, 2026Code block before and after it has not been translated. (en→ja) — Azure/co-op-translatorsays it tested it1 reaction · 3 comments
- Nov 18, 2025README Structure — notoriousmic/github-copilot-workshop1 reaction
- Oct 2, 2025[KO] Translation improvement for "{days}" usage — Azure/co-op-translator1 reaction · 1 comment
- Oct 2, 2025[KO] Translation improvement for "{days}" usage — Azure/co-op-translator1 reaction
- Sep 15, 2025HTML tags (e.g., <a>) are stripped or lost during translation — Azure/co-op-translator1 reaction · 2 comments
- Sep 7, 2025``` not handled correctly (en→ja) — Azure/co-op-translator1 reaction · 3 comments
- May 7, 2025Correcting all misc errors found across code samples for Lessons 04, 06, 09. — jabari-max/Mohammadhadi-Jabari1 reaction
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T010: retrieval with source attribution — scenario assessment [05-agentic-rag] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T009: confidence-gated escalation — evaluation experiment [09-metacognition] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T008: allowlisted action policy — failure and recovery example [06-building-trustworthy-agents] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T007: dependency-plan validation — worked example with checks [07-planning-design] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T006: dependency-plan validation — refactor the teaching example [08-multi-agent] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T005: bounded agent loop — offline service adapter [01-intro-to-ai-agents] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T004: trace aggregation — invariant and state trace [10-ai-agents-production] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T003: agent-component routing — compare two approaches [03-agentic-design-patterns] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T002: retrieval with source attribution — boundary-case lesson extension [05-agentic-rag] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Jayesh Aher (261105B306021) — R17-T001: bounded agent loop — runnable concept example [01-intro-to-ai-agents] — S-AI-Final-Projects-SMRU/ai-agents-for-beginners0 reactions
- Nov 28, 2026Yatharth Ujwal (2601010406) — R17-T030: model-manifest selection — scenario assessment [17-creating-local-ai-agents] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Yatharth Ujwal (2601010406) — R17-T029: trace aggregation — evaluation experiment [16-deploying-scalable-agents] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Yatharth Ujwal (2601010406) — R17-T028: bounded agent loop — failure and recovery example [14-microsoft-agent-framework] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Yatharth Ujwal (2601010406) — R17-T033: retrieval with source attribution — invariant and state trace [05-agentic-rag] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Yatharth Ujwal (2601010406) — R17-T032: bounded agent loop — compare two approaches [14-microsoft-agent-framework] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Tanmay (2601010364) — R17-T038: prompt-template escaping — failure and recovery example [12-context-engineering] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Tanmay (2601010364) — R17-T037: typed tool dispatch — worked example with checks [04-tool-use] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Tanmay (2601010364) — R17-T036: bounded conversation memory — evaluation experiment [13-agent-memory] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Tanmay (2601010364) — R17-T035: bounded conversation memory — refactor the teaching example [11-agentic-protocols] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Tanmay (2601010364) — R17-T034: retrieval with source attribution — offline service adapter [05-agentic-rag] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Rudransh (2601010295) — R17-T040: confidence-gated escalation — scenario assessment [09-metacognition] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Rudransh (2601010295) — R17-T039: bounded conversation memory — boundary-case lesson extension [13-agent-memory] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Rudransh (2601010295) — R17-T044: bounded conversation memory — invariant and state trace [11-agentic-protocols] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Rudransh (2601010295) — R17-T043: agent-component routing — offline service adapter [03-agentic-design-patterns] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Rudransh (2601010295) — R17-T042: dependency-plan validation — compare two approaches [08-multi-agent] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Himanshi Gupta (2601010156) — R17-T049: tamper-evident action receipt — scenario assessment [18-securing-ai-agents] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Himanshi Gupta (2601010156) — R17-T048: prompt-template escaping — evaluation experiment [12-context-engineering] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Himanshi Gupta (2601010156) — R17-T047: agent-component routing — failure and recovery example [02-explore-agentic-frameworks] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Himanshi Gupta (2601010156) — R17-T046: trace aggregation — worked example with checks [10-ai-agents-production] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Hasrat Marwaha (2601010152) — R17-T050: confidence-gated escalation — runnable concept example [09-metacognition] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Hasrat Marwaha (2601010152) — R17-T055: confidence-gated escalation — offline service adapter [09-metacognition] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Hasrat Marwaha (2601010152) — R17-T052: agent-component routing — compare two approaches [02-explore-agentic-frameworks] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Avi Garg (2601010083) — R17-T057: dependency-plan validation — worked example with checks [08-multi-agent] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 28, 2026Avi Garg (2601010083) — R17-T056: agent-component routing — refactor the teaching example [03-agentic-design-patterns] — s-and-ai-ru-4/ai-agents-for-beginners0 reactions
- Nov 16, 2026agent-skills.github.microsoft.ai-agents-for-beginners: 0-unstable-2026-09-10 → 0-unstable-2026-11-07 — sudosubin/agents.nix0 reactions
- Oct 14, 2026agent-skills.github.microsoft.ai-agents-for-beginners: 0-unstable-2026-07-13 → 0-unstable-2026-09-10 — sudosubin/agents.nix0 reactions
- Sep 30, 2026agent-skills.github.microsoft.ai-agents-for-beginners: init at 0-unstable-2026-07-13 — sudosubin/agents.nix0 reactions
- Sep 6, 2026Batch 78: Claude usage-limit tips, n8n grounding technique, coding-agent CLIs, OSS-to-service ideas — dmavridi6478/business0 reactions
On Bluesky · 35
- Feb 14, 2025AI Agents for Beginners - 10 Lessons teaching everything you need to know to start building AI Agents github.com/microsoft/ai...… — @rodtrent.com25 likes and reposts · 1 reply
- Sep 7, 2025Pô, parece legal a grade hein... Deixar na lista aqui pra estudar depois da certificação da AWS. — @rdenadai.dev7 likes and reposts
- Feb 22, 2025AI Agents for Beginners - 10 Lessons to Get Started Building AI Agents. https://github.com/microsoft/ai-agents-for-beginners #ai #aiagents… — @alvinashcraft.com7 likes and reposts
- Nov 20, 2026🚨 Want to learn AI Agents from scratch? Microsoft’s free 18-lesson course covers frameworks, tools, RAG, multi-agents, production & more… — @ottorinobruni.bsky.social4 likes and reposts
- Apr 4, 202510 Lessons teaching everything you need to know to start building AI Agents github.com/microsoft/ai... — @asiermarques.com3 likes and reposts
30 more on Bluesky
- Mar 23, 2025📦 microsoft / ai-agents-for-beginners ⭐ 5,023 (+55) 🗒 Jupyter Notebook 10 Lessons to Get Started Building AI Agents — @github-trending.bsky.social3 likes and reposts
- Oct 20, 2026Stage 3: Agent fundamentals AI Agents for Beginners, Microsoft (18 lessons, 77k+ stars) github.com/microsoft/a... Hugging Face AI Agents… — @astrodevil1.bsky.social2 likes and reposts · 1 reply
- May 18, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 62,102 (+180) 🗒 Jupyter Notebook 12 Lessons to Get Started… — @github-trending.bsky.social2 likes and reposts
- Dec 17, 2025Microsoft AI agents for beginners resource 👀 #fyp #typescript #agent #coding #llm #viral #viralvideo github.com/microsoft/ai... — @krystalmess.bsky.social2 likes and reposts
- Nov 12, 2025🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 44,431 (+193) 🗒 Jupyter Notebook 12 Lessons to Get Started… — @github-trending.bsky.social2 likes and reposts
- Sep 7, 2025AI Agents for Beginners 11 Lessons to Get Started Building AI Agents. https://github.com/microsoft/ai-agents-for-beginners — @pythonhub.dev2 likes and reposts
- Jun 16, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 27,064 (+437) 🗒 Jupyter Notebook 11 Lessons to Get Started… — @github-trending.bsky.social2 likes and reposts
- Apr 26, 2025🚀 Dive into Microsoft’s “AI Agents for Beginners” a 10-lesson course designed to help you build AI agents using tools like Azure AI Agent… — @sean.techsnazzy.com2 likes and reposts
- Apr 21, 2025DesktopCommander MCP is trending on GitHub! Check it out alongside other amazing projects from: @microsoft github.com/microsoft/ai..., @n8n… — @desktopcommander.bsky.social2 likes and reposts
- Feb 14, 2025Microsoft’s #AI Agents for Beginners is a great hands-on resource for learning AI agents from scratch. Perfect for beginners and developers… — @mertyeter.bsky.social2 likes and reposts
- Jul 17, 2026微软开源了一套免费课程《AI Agents for Beginners》,GitHub 已封战 61k+ 星。 课程内容:什么是 AI Agent、怎么用 Tool/MCP、多代理人系统、Context 管理、让 AI 操作浏览器、安全部署——一路到完整实战。… — @anotherbug.com1 likes and repost
- Jun 8, 2026https://github.com/microsoft/ai-agents-for-beginners — @tom-doerr.bsky.social1 likes and repost
- May 3, 2026https://github.com/microsoft/ai-agents-for-beginners — @tom-doerr.bsky.social1 likes and repost
- Apr 21, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 57,227 (+131) 🗒 Jupyter Notebook 12 Lessons to Get Started… — @github-trending.bsky.social1 likes and repost
- Feb 14, 2026https://github.com/microsoft/ai-agents-for-beginners — @tom-doerr.bsky.social1 likes and repost
- Jan 10, 2026https://github.com/microsoft/ai-agents-for-beginners — @tom-doerr.bsky.social1 likes and repost
- Dec 5, 20254) ai-agents-for-beginners ↳ 11 Lessons teaching everything you need to know to start building AI Agents. GitHub: github.com/microsoft/ai... — @analyticalrohit.bsky.social1 likes and repost · 1 reply
- Sep 8, 2025AI Agent for Beginners: github.com/microsoft/ai... ---- 📌 Join 3,000+ ML enthusiasts and professionals from 100 countries. ✅ Learn AI for… — @analyticalrohit.bsky.social1 likes and repost · 1 reply
- Jul 23, 20254) ai-agents-for-beginners ↳ 11 Lessons teaching everything you need to know to start building AI Agents. GitHub: github.com/microsoft/ai... — @analyticalrohit.bsky.social1 likes and repost · 1 reply
- Jun 12, 2025🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 25,485 (+175) 🗒 Jupyter Notebook 11 Lessons to Get Started… — @github-trending.bsky.social1 likes and repost
- May 29, 2025🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 22,020 (+180) 🗒 Jupyter Notebook 11 Lessons to Get Started… — @github-trending.bsky.social1 likes and repost
- Apr 14, 2025🎉 Celebrating! 🎉 (500+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 14,149 (+688) 🗒 Jupyter Notebook 10 Lessons to Get Started… — @github-trending.bsky.social1 likes and repost · 1 reply
- Apr 10, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / ai-agents-for-beginners ⭐ 11,709 (+403) 🗒 Jupyter Notebook 10 Lessons to Get Started… — @github-trending.bsky.social1 likes and repost
- Mar 23, 2025Fundamentals of building AI Agents, a place to start. github.com/microsoft/ai... — @cloudnativeboy.bsky.social1 likes and repost
- Feb 22, 2025🤖 Include anche esempi di implementazione di workflow usando #Autogen. 🚀 È un contributo davvero interessante. Insieme al corso… — @alessiopomaro.it1 likes and repost · 1 reply
- Jul 1, 20261. Hugging Face — AI Agents Course huggingface.co/learn/agent... 2. Microsoft — AI Agents for Beginners github.com/microsoft/a... 3.… — @aipromptgirl.bsky.social0 likes and reposts · 1 reply
- Jan 3, 2026AI Agents for Beginners (Microsoft) A free, structured 11-lesson course to get started with AI agents the right way.… — @jackfusion.bsky.social0 likes and reposts · 1 reply
- Jul 20, 20252️⃣ AI Agents for Beginners Free 11-part intro course, build your first AI agents step-by-step. 🔗 github.com/microsoft/a... — @arindam-1729.bsky.social0 likes and reposts · 1 reply
- Jun 13, 2025GitHub repo → github.com/microsoft/a... — @arindam-1729.bsky.social0 likes and reposts · 1 reply
- Mar 24, 2025Microsoft's "AI Agents for Beginners," is designed to teach you everything you need to know to start building AI Agents. The course… — @kuanhoong.bsky.social0 likes and reposts · 1 reply
On Hacker News · 3
- Jul 4, 2025Lessons to Get Started Building AI Agents10 points
- Apr 14, 2025AI Agents for Beginners2 points
- Feb 14, 2025AI Agents for Beginners – A 10 Lesson Course2 points
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- Azure-Samples/azure-openai-to-responses★ 615% same
Wrote their own version · 1
- microsoft/generative-ai-for-beginners★ 121ksame name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository338 other files it gives its agents.
- AGENTS.mdAGENTS.md
- translations/ar/AGENTS.mdAGENTS.md
- translations/bg/AGENTS.mdAGENTS.md
- translations/bn/AGENTS.mdAGENTS.md
- translations/cs/AGENTS.mdAGENTS.md
- translations/da/AGENTS.mdAGENTS.md
- translations/de/AGENTS.mdAGENTS.md
- translations/el/AGENTS.mdAGENTS.md
- translations/en/AGENTS.mdAGENTS.md
- translations/es/AGENTS.mdAGENTS.md
- translations/et/AGENTS.mdAGENTS.md
- translations/fa/AGENTS.mdAGENTS.md
- translations/fi/AGENTS.mdAGENTS.md
- translations/fr/AGENTS.mdAGENTS.md
- translations/he/AGENTS.mdAGENTS.md
- translations/hi/AGENTS.mdAGENTS.md
- translations/hr/AGENTS.mdAGENTS.md
- translations/hu/AGENTS.mdAGENTS.md
- translations/id/AGENTS.mdAGENTS.md
- translations/it/AGENTS.mdAGENTS.md
- translations/ja/AGENTS.mdAGENTS.md
- translations/km/AGENTS.mdAGENTS.md
- translations/kn/AGENTS.mdAGENTS.md
- translations/ko/AGENTS.mdAGENTS.md
- translations/lt/AGENTS.mdAGENTS.md
- translations/ml/AGENTS.mdAGENTS.md
- translations/mr/AGENTS.mdAGENTS.md
- translations/ms/AGENTS.mdAGENTS.md
- translations/my/AGENTS.mdAGENTS.md
- translations/ne/AGENTS.mdAGENTS.md
- translations/nl/AGENTS.mdAGENTS.md
- translations/no/AGENTS.mdAGENTS.md
- translations/pa/AGENTS.mdAGENTS.md
- translations/pcm/AGENTS.mdAGENTS.md
- translations/pl/AGENTS.mdAGENTS.md
- translations/pt-BR/AGENTS.mdAGENTS.md
- translations/pt-PT/AGENTS.mdAGENTS.md
- translations/ro/AGENTS.mdAGENTS.md
- translations/ru/AGENTS.mdAGENTS.md
- translations/sk/AGENTS.mdAGENTS.md
- translations/sl/AGENTS.mdAGENTS.md
- translations/sr/AGENTS.mdAGENTS.md
- translations/sv/AGENTS.mdAGENTS.md
- translations/sw/AGENTS.mdAGENTS.md
- translations/ta/AGENTS.mdAGENTS.md
- translations/te/AGENTS.mdAGENTS.md
- translations/th/AGENTS.mdAGENTS.md
- translations/tl/AGENTS.mdAGENTS.md
- translations/tr/AGENTS.mdAGENTS.md
- translations/uk/AGENTS.mdAGENTS.md
- translations/ur/AGENTS.mdAGENTS.md
- translations/vi/AGENTS.mdAGENTS.md
- translations/zh-CN/AGENTS.mdAGENTS.md
- translations/zh-HK/AGENTS.mdAGENTS.md
- translations/zh-MO/AGENTS.mdAGENTS.md
- translations/zh-TW/AGENTS.mdAGENTS.md
- 15-browser-use/llms.txtllms.txt
- azure-openai-to-responsesSkill
- deploying-scalable-agentsSkill
- jupyter-notebookSkill
- The first 60 shown.
The file
Files
ย้ายแอป Python จาก Azure OpenAI Chat Completions ไปยัง Responses API
คำแนะนำอย่างเป็นทางการ — ทำตามอย่างเคร่งครัด
ทักษะนี้จะย้ายฐานโค้ด Python ที่ใช้ Azure OpenAI Chat Completions ไปยัง Responses API แบบรวมศูนย์ โปรดทำตามคำแนะนำเหล่านี้อย่างแม่นยำ หลีกเลี่ยงการปรับแม็ปพารามิเตอร์เองหรือคิดค้นรูปแบบ API ใหม่
ตัวจุดเริ่มต้น
เปิดใช้งานทักษะนี้เมื่อผู้ใช้ต้องการ:
- ย้ายแอป Python จาก Azure OpenAI Chat Completions ไปยัง Responses API
- อัพเกรดการใช้งาน Python OpenAI SDK ไปยังรูปแบบ API ล่าสุดกับ Azure OpenAI
- เตรียมโค้ด Python สำหรับโมเดล GPT-5 หรือใหม่กว่าที่ต้องการ Responses บน Azure
- เปลี่ยนจากไคลเอนต์
AzureOpenAI/AsyncAzureOpenAIเป็นOpenAI/AsyncOpenAIแบบมาตรฐานที่ใช้ปลายทาง v1 - แก้ไขคำเตือนการเลิกใช้ที่เกี่ยวกับตัวสร้าง
AzureOpenAIหรือapi_version
⚠️ ความเข้ากันได้ของโมเดล — ตรวจสอบก่อน
ก่อนย้าย ตรวจสอบให้แน่ใจว่า deployment Azure OpenAI ของคุณรองรับ Responses API
1. ทดสอบอย่างรวดเร็ว (เร็วที่สุด)
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}")หมายเหตุ: บน Azure OpenAI
max_output_tokensมีค่าขั้นต่ำ 16 ค่าที่ต่ำกว่า 16 จะส่งคืนข้อผิดพลาด 400 ใช้ค่า 50+ สำหรับการทดสอบแบบรวดเร็ว
หากส่งคืน 404 โมเดลใน deployment นี้ยังไม่รองรับ Responses — ตรวจสอบข้อมูลอ้างอิงด้านล่างหรือเปิดใช้งานใหม่ด้วยโมเดลที่รองรับ
2. ตรวจสอบโมเดลที่มีในภูมิภาคของคุณ (แนะนำ)
ใช้เครื่องมือรองรับโมเดลในตัวเพื่อดูว่ามีอะไรพร้อมใช้งานกับ Responses API ในภูมิภาคของคุณ:
python migrate.py models --subscription YOUR_SUB_ID --location YOUR_REGIONเครื่องมือนี้เรียก Azure ARM สดและแสดงแมทริกซ์ความเข้ากันได้ — โมเดลใดรองรับ Responses, การส่งออกแบบมีโครงสร้าง, เครื่องมือ ฯลฯ ใช้ --filter gpt-5.1,gpt-5.2 เพื่อลดผลลัพธ์หรือ --json สำหรับสคริปต์
3. อ้างอิงการรองรับโมเดลเต็มรูปแบบ
- การเรียกดูสด:
python migrate.py models(ดูด้านบน — เฉพาะภูมิภาค, อัปเดตเสมอ) - เรียกดูความพร้อมใช้งาน: ตารางสรุปโมเดลและความพร้อมใช้งานในภูมิภาค
- เริ่มต้นใช้งานและคำแนะนำ: https://aka.ms/openai/start
⚠️ ข้อจำกัดของโมเดลเก่า
คำเตือน: โมเดลเก่า (ก่อน
gpt-4.1) อาจไม่รองรับฟีเจอร์ Responses API ทุกอย่างอย่างเต็มที่จำกัดการใช้งานที่ทราบกับโมเดลเก่า:
- พารามิเตอร์
reasoning: ไม่รองรับในหลายโมเดลที่ไม่มี reasoning หากจะย้ายให้ย้ายเฉพาะกรณีที่มีreasoningอยู่แล้วในโค้ดต้นทาง- พารามิเตอร์
seed: ไม่รองรับใน Responses API เลย — ลบออกจากคำขอทั้งหมด- ผลลัพธ์แบบมีโครงสร้างผ่าน
text.format: โมเดลเก่าอาจไม่บังคับใช้สคีมา JSON แบบstrict: trueได้อย่างน่าเชื่อถือ- การประสานเครื่องมือ: GPT-5+ จัดการการเรียกเครื่องมือเป็นส่วนหนึ่งของ reasoning ภายใน โมเดลเก่าบน Responses ยังใช้งานได้แต่ไม่มีการรวมลึกนี้
- ข้อจำกัดอุณหภูมิ: เมื่อย้ายไป
gpt-5อุณหภูมิต้องไม่กำหนดหรือกำหนดเป็น1โมเดลเก่าไม่มีข้อจำกัดนี้
โมเดล reasoning ซีรีส์ O (o1, o3-mini, o3, o4-mini)
โมเดลซีรีส์ O มีข้อจำกัดพารามิเตอร์เฉพาะตัว เมื่อย้ายแอปที่มุ่งเป้าไปยังโมเดลซีรีส์ O:
temperature: ต้องเป็น1(หรือละเว้น) โมเดลซีรีส์ O ไม่รับค่าที่ต่างจากนี้max_completion_tokens→max_output_tokens: แอปที่ใช้max_completion_tokensเฉพาะ Azure ต้องเปลี่ยนเป็นmax_output_tokensตั้งค่าสูง (4096+) เพราะโทเค็น reasoning นับในขีดจำกัดนี้reasoning_effort: หากแอปใช้reasoning_effort(ต่ำ/กลาง/สูง) ให้เก็บไว้ — Responses API รองรับพารามิเตอร์นี้สำหรับโมเดลซีรีส์ O- พฤติกรรมการสตรีม: โมเดลซีรีส์ O อาจเก็บบัฟเฟอร์ผลลัพธ์จน reasoning เสร็จก่อนส่งเหตุการณ์ delta ข้อความ การสตรีมยังทำงาน แต่ delta แรกอาจช้ากว่าโมเดล GPT
top_p: ไม่รองรับในซีรีส์ O — ให้ลบออกหากมี- การใช้เครื่องมือ: โมเดลซีรีส์ O รองรับเครื่องมือผ่าน Responses API เช่นเดียวกับโมเดล GPT แต่คุณภาพการประสานการเรียกเครื่องมือขึ้นกับแต่ละโมเดล
คำแนะนำเชิงรุก — ระหว่างสแกน: ตรวจสอบว่าแอปใช้โมเดลใด (ชื่อ deployment, ตัวแปรสภาพแวดล้อม, การตั้งค่า) หากเป็นโมเดลก่อน gpt-4.1 (ไม่ใช่ gpt-4.1+) แจ้งผู้ใช้ล่วงหน้า:
- การย้ายจะทำงานกับข้อความพื้นฐาน แชท การสตรีม และเครื่องมือบนโมเดลปัจจุบันได้
- โมเดลใหม่กว่า (
gpt-5.1,gpt-5.2) ให้การประสานเครื่องมือที่ดีกว่า การบังคับใช้ผลลัพธ์แบบมีโครงสร้าง reasoning และความพร้อมใช้งานข้ามภูมิภาค - ควรพิจารณาอัปเกรด deployment เมื่อพร้อม — ไม่มีผลขัดขวางการย้ายตอนนี้
หลีกเลี่ยงการบล็อกหรือปฏิเสธให้ย้ายตามเวอร์ชันโมเดล คำแนะนำนี้เป็นข้อมูลเท่านั้น
GitHub Models ไม่รองรับ Responses API
GitHub Models (
models.github.ai,models.inference.ai.azure.com) ไม่รองรับ Responses API
หากฐานโค้ดมีเส้นทางโค้ด GitHub Models (ดูที่ base_url ชี้ไปยัง models.github.ai หรือ models.inference.ai.azure.com) ให้ลบออกทั้งหมด ในการย้าย Responses API ต้องใช้ Azure OpenAI, OpenAI หรือปลายทางในเครื่องที่เข้ากันได้ (เช่น Ollama ที่รองรับ Responses)
การดำเนินการระหว่างสแกน:
- ให้ติดธงเส้นทางโค้ด GitHub Models เพื่อการลบ
การย้ายเฟรมเวิร์ก
แอปหลายแอปใช้เฟรมเวิร์กระดับสูงบน OpenAI เมื่อย้ายเฟรมเวิร์กเหล่านี้ จะมีการเปลี่ยนแปลง API เฟรมเวิร์กเอง — ไม่ใช่แค่การเรียก OpenAI ขั้นต่ำ
Microsoft Agent Framework (MAF)
ตรวจสอบเวอร์ชัน MAF ของคุณก่อน — การย้ายขึ้นกับว่าคุณใช้ MAF 1.0.0+ หรือเบต้า/rc ก่อน 1.0.0
MAF 1.0.0+ (agent-framework-openai >= 1.0.0)
OpenAIChatClient ใช้ Responses API แล้ว — ไม่ต้องย้าย หากฐานโค้ดยังใช้ OpenAIChatCompletionClient แบบเก่า (ที่ใช้ chat.completions.create) ให้เปลี่ยนเป็น OpenAIChatClient
| ก่อน | หลัง |
from agent_framework.openai import OpenAIChatCompletionClient | from agent_framework.openai import OpenAIChatClient |
OpenAIChatCompletionClient(...) | OpenAIChatClient(...) |
ตรวจสอบเวอร์ชันของคุณด้วย: python -c "import agent_framework_openai; print(agent_framework_openai.__version__)"
MAF ก่อน 1.0.0 (รุ่นเบต้า/rc)
ใน MAF ก่อน 1.0.0 OpenAIChatClient ใช้ Chat Completions อัพเกรดเป็น agent-framework-openai>=1.0.0 ซึ่ง OpenAIChatClient ใช้ Responses API โดยดีฟอลต์
ไม่มีการเปลี่ยนแปลงอื่น — API ของ Agent และเครื่องมือเหมือนเดิม
LangChain (langchain-openai)
เพิ่ม use_responses_api=True ให้กับ ChatOpenAI() และอัพเดตการเข้าถึงผลลัพธ์จาก .content เป็น .text
| ก่อน | หลัง |
ChatOpenAI(model=..., base_url=..., api_key=...) | ChatOpenAI(model=..., base_url=..., api_key=..., use_responses_api=True) |
result['messages'][-1].content | result['messages'][-1].text |
ดูตัวอย่างโค้ดทั้งก่อนและหลังใน cheat-sheet.md
คำแนะนำการย้ายส่วนหน้า
Responses API เป็นเรื่องฝั่งเซิร์ฟเวอร์ ย้าย backend Python ของคุณ ส่วนหน้า (frontend) ควรยังคงตามสัญญา HTTP เดิมเว้นแต่ว่า backend เป็นเพียงชั้นผ่านบาง ๆ — กรณีนั้นให้พิจารณาใช้รูปแบบคำขอ Responses เพื่อกำจัดชั้นแปลง หาก frontend เรียก OpenAI โดยตรงด้วยคีย์ฝั่งไคลเอนต์ ให้ย้ายการเรียกเหล่านั้นไป backend ก่อน
การเลิกใช้งาน @microsoft/ai-chat-protocol
แพ็กเกจ npm @microsoft/ai-chat-protocol ถูกเลิกใช้และควรเปลี่ยนเป็น ndjson-readablestream หากพบในส่วนหน้า:
- แก้แท็กสคริปต์ CDN:
<!-- 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)เป็นเรียกfetch()ตรงไปยังจุดสตรีมของ backend - เปลี่ยน
for await (const response of result)เป็นfor await (const chunk of readNDJSONStream(response.body)) - ปรับเปลี่ยนการเข้าถึงคุณสมบัติจาก
response.delta.content/response.errorเป็นchunk.delta.content/chunk.error
เป้าหมาย
- ระบุทุกจุดเรียก Python ที่ใช้ Chat Completions หรือ Completions แบบเก่าที่เรียกกับ Azure OpenAI
- เสนอแผนการย้ายและลำดับขั้นสำหรับฐานโค้ด Python
- ใช้การแก้ไขอย่างปลอดภัยและน้อยที่สุดเพื่อสลับไป Responses API
- อัปเดตผู้เรียกเพื่อใช้สคีมาผลลัพธ์ของ Responses; ไม่มีหุ้มหลังความเข้ากันได้
- รันการทดสอบ/ตรวจสอบ; แก้ไขปัญหาเล็กน้อยที่เกิดจากการย้าย
- เตรียมชุดการเปลี่ยนแปลงที่เล็กและตรวจสอบได้ พร้อมสรุปสุดท้ายพร้อมการเปรียบเทียบ (ไม่ต้อง commit)
กฎข้อบังคับ
- แก้ไขเฉพาะไฟล์ในพื้นที่ git เท่านั้น ห้ามเขียนนอกพื้นที่นี้
- ไม่ต้องเก็บไว้ในช่องทางหลังความเข้ากันได้; ย้ายโค้ดไปยังรูปแบบ API ใหม่
- หลีกเลี่ยงการทิ้งคอมเมนต์รอยตาย/เปลี่ยนผ่านหรือไฟล์สำรอง
- รักษาลักษณะการสตรีมหากเคยใช้; มิฉะนั้นใช้แบบไม่สตรีม
- ขออนุมัติก่อนรันคำสั่งหรือเรียกเครือข่ายถ้าอยู่ในโหมดอนุมัติ
- หลีกเลี่ยงการรัน
git add/git commit/git push; ผลลัพธ์ต้องเป็นใน working-tree เท่านั้น
ขั้นตอนที่ 0: ย้ายไคลเอนต์ Azure OpenAI (เงื่อนไขเบื้องต้น)
หากฐานโค้ดใช้ตัวสร้าง AzureOpenAI หรือ AsyncAzureOpenAI ให้ย้ายไปใช้ตัวสร้าง OpenAI / AsyncOpenAI แบบมาตรฐานก่อน ตัวสร้างเฉพาะ Azure ถูกเลิกใช้ใน openai>=1.108.1
ทำไมต้องใช้ปลายทาง v1 API?
ปลายทางใหม่ /openai/v1 ใช้ไคลเอนต์ OpenAI() แบบมาตรฐานแทน AzureOpenAI() ไม่ต้องใช้พารามิเตอร์ api_version และทำงานเหมือนกันทั้ง OpenAI และ Azure OpenAI โค้ดไคลเอนต์เดียวกันนี้รองรับอนาคต — ไม่ต้องจัดการเวอร์ชัน
การเปลี่ยนแปลงสำคัญ
| ก่อน | หลัง |
AzureOpenAI | OpenAI |
AsyncAzureOpenAI | AsyncOpenAI |
azure_endpoint | base_url |
azure_ad_token_provider | api_key |
api_version=... | ลบทิ้งทั้งหมด |
รายการล้างข้อมูล
- ลบอาร์กิวเมนต์
api_versionจากการสร้างไคลเอนต์ - ลบตัวแปรสภาพแวดล้อม
AZURE_OPENAI_VERSION/AZURE_OPENAI_API_VERSIONจาก.env, การตั้งค่าแอป และไฟล์ Bicep/โครงสร้างพื้นฐาน - เปลี่ยนชื่อ
AZURE_OPENAI_CLIENT_ID→AZURE_CLIENT_IDใน.env, การตั้งค่าแอป, Bicep/โครงสร้างพื้นฐาน และไฟล์ตัวอย่างทดสอบ (ตามแนวทางมาตรฐาน Azure Identity SDK) - แน่ใจว่า
openai>=1.108.1ในrequirements.txtหรือpyproject.toml
ย้ายตัวแปรสภาพแวดล้อม
| ตัวแปรสภาพแวดล้อมเดิม | การดำเนินการ | หมายเหตุ |
AZURE_OPENAI_VERSION | ลบ | ไม่ต้องใช้ api_version กับปลายทาง v1 |
AZURE_OPENAI_API_VERSION | ลบ | เหมือนกันกับด้านบน |
AZURE_OPENAI_CLIENT_ID | เปลี่ยนชื่อ → AZURE_CLIENT_ID | ตามมาตรฐาน Azure Identity SDK สำหรับ ManagedIdentityCredential(client_id=...) |
AZURE_OPENAI_ENDPOINT | เก็บไว้ | ยังคงต้องใช้สำหรับสร้าง base_url |
AZURE_OPENAI_CHAT_DEPLOYMENT | เก็บไว้ | ใช้เป็นพารามิเตอร์ model ใน responses.create |
AZURE_OPENAI_API_KEY | เก็บไว้ | ใช้เป็น api_key สำหรับการยืนยันตัวตนด้วยคีย์ |
ตัวอย่างการตั้งค่าไคลเอนต์ (ซิงค์, อะซิงค์, EntraID, คีย์ API, หลาย tenant) ดูใน cheat-sheet.md
ขั้นตอนที่ 1: ตรวจจับจุดเรียกใช้งานแบบเก่า
รันสคริปต์ detect_legacy.py เพื่อค้นหาจุดเรียกใช้งานทั้งหมดที่ต้องย้าย:
python skills/azure-openai-to-responses/scripts/detect_legacy.py .หรือรันการค้นหาเหล่านี้ด้วยตนเอง — ทุกคำที่ตรงเป็นเป้าหมายการย้าย:
# การเรียก API รุ่นเก่า (ต้องเขียนใหม่)
rg "chat\.completions\.create"
rg "ChatCompletion\.create"
rg "Completion\.create"
# ตัวสร้างไคลเอ็นต์ Azure ที่เลิกใช้แล้ว (ต้องเปลี่ยนใหม่)
rg "AzureOpenAI\("
rg "AsyncAzureOpenAI\("
# รูปแบบการเข้าถึงโครงสร้างการตอบกลับ (ต้องอัปเดต)
rg "choices\[0\]\.message\.content"
rg "choices\[0\]\.delta\.content"
rg "choices\[0\]\.message\.function_call"
rg "choices\[0\]\.message\.tool_calls"
# นิยามเครื่องมือในรูปแบบซ้อนเก่า (ต้องปรับเป็นโครงสร้างแบน)
rg '"function":\s*{\s*"name"'
rg "pydantic_function_tool"
# ผลลัพธ์เครื่องมือในรูปแบบเก่า (ต้องแปลงเป็น function_call_output)
rg '"role":\s*"tool"'
rg '"tool_call_id"'
# พารามิเตอร์ที่เลิกใช้แล้ว (ต้องลบหรือเปลี่ยนชื่อ)
rg "response_format"
rg "max_tokens\b" # เปลี่ยนชื่อเป็น max_output_tokens
rg "['\"]seed['\"]" # remove entirely
# ตัวแปรสภาพแวดล้อมที่เลิกใช้แล้ว (ต้องทำความสะอาด)
rg "AZURE_OPENAI_API_VERSION|AZURE_OPENAI_VERSION"
rg "AZURE_OPENAI_CLIENT_ID" # ควรเป็น AZURE_CLIENT_ID
# จุดเชื่อมต่อโมเดล GitHub (ต้องลบ — API ตอบกลับไม่ได้รับการสนับสนุน)
rg "models\.github\.ai|models\.inference\.ai\.azure"
# รูปแบบเก่าของเฟรมเวิร์กระดับสูง (ต้องอัปเดต)
rg "OpenAIChatCompletionClient" # MAF 1.0.0+: เปลี่ยนเป็น OpenAIChatClient
rg "ChatOpenAI\(" | grep -v "use_responses_api" # LangChain: ต้องใช้ use_responses_api=True
# โครงสร้างพื้นฐานการทดสอบ (ต้องอัปเดต)
rg "ChatCompletionChunk|AsyncCompletions\.create" tests/
rg "_azure_ad_token_provider" tests/
rg "prompt_filter_results|content_filter_results" tests/
rg "choices\[0\]" tests/
# การเข้าถึงข้อมูลข้อผิดพลาดตัวกรองเนื้อหา (ต้องอัปเดต — โครงสร้างเปลี่ยนแปลง)
rg 'innererror.*content_filter_result|error\.body\["innererror"\]'
rg "content_filter_result\[" # รูปแบบเอกพจน์เก่า — ตอนนี้เป็น content_filter_results (พหูพจน์) ภายในอาร์เรย์ content_filters
# การเรียก HTTP ดิบไปยังจุดสิ้นสุด Chat Completions (ต้องอัปเดต URL)
rg "/openai/deployments/.*/chat/completions"
rg "api-version="การประมาณ (ตรวจจับและเขียนใหม่)
- ไคลเอนต์ Chat Completions:
client.chat.completions.create→client.responses.create(...). - ตัวสร้างลูกค้า Azure:
AzureOpenAI(...)→OpenAI(base_url=..., api_key=...). - เครื่องมือ: แปลงคำจำกัดความเครื่องมือเรียกฟังก์ชันจากรูปแบบซ้อนกัน (
{"type": "function", "function": {"name": ...}}) เป็นรูปแบบแบนของ Responses ({"type": "function", "name": ...}); ใช้tool_choice; ส่งคืนผลลัพธ์ของเครื่องมือเป็นรายการ{"type": "function_call_output", "call_id": ..., "output": ...}(ไม่ใช่{"role": "tool", ...}). - รอบเครื่องมือ: เมื่อโมเดลส่งคืนการเรียกฟังก์ชัน ให้แนบรายการ
response.outputลงในการสนทนา (ไม่ใช่ dict แบบแมนนวล{"role": "assistant", "tool_calls": [...]}) จากนั้นแนบรายการfunction_call_outputสำหรับแต่ละผลลัพธ์. - ตัวอย่างเครื่องมือแบบ few-shot: หากการสนทนารวมตัวอย่างการเรียกเครื่องมือแบบกำหนดไว้ล่วงหน้า ให้แปลงเป็นรายการ
{"type": "function_call", "id": "fc_...", "call_id": "fc_...", ...}+{"type": "function_call_output", ...}ต้องให้ ID เริ่มต้นด้วยfc_. pydantic_function_tool(): ตัวช่วยนี้ยังคงสร้างรูปแบบซ้อนแบบเก่าและ ไม่เข้ากันได้ กับresponses.create()ให้แทนที่ด้วยคำจำกัดความเครื่องมือแบบแมนนวลหรือใช้ตัวห่อแปลงรูปแบบแบน.- หลายรอบ: รักษาประวัติการสนทนาในแอป; ส่งผ่านรอบก่อนหน้าผ่านรายการ
input. - การจัดรูปแบบ: แทนที่
response_formatบนระดับบนสุดของ Chat ด้วยtext.formatใน Responses รูปแบบมาตรฐาน:text={"format": {"type": "json_schema", "name": "Output", "strict": True, "schema": {...}}}. - รายการเนื้อหา: แทนที่ Chat
content[].type: "text"ด้วย Responsescontent[].type: "input_text"สำหรับรอบของผู้ใช้/ระบบ. - รายการเนื้อหารูปภาพ: แทนที่ Chat
content[].type: "image_url"ด้วย Responsescontent[].type: "input_image"ฟิลด์image_urlเปลี่ยนจากออบเจ็กต์ซ้อน{"url": "..."}เป็นสตริงแบน ดูตารางสรุปสำหรับตัวอย่างก่อน/หลัง. - ความพยายามในการให้เหตุผล: ย้ายเฉพาะ
reasoningหากมีอยู่แล้วในโค้ดเดิม. - การจัดการข้อผิดพลาดตัวกรองเนื้อหา: โครงสร้าง body ของข้อผิดพลาดเปลี่ยนจากเดิม Chat Completions ใช้
error.body["innererror"]["content_filter_result"](เอกพจน์); Responses API ใช้error.body["content_filters"][0]["content_filter_results"](พหูพจน์ อยู่ในอาเรย์) โค้ดที่เข้าถึงinnererrorจะเกิดKeyErrorให้เขียนใหม่ใช้เส้นทางใหม่. - การเรียก HTTP แบบดิบ: หากแอปเรียก REST API ของ Azure OpenAI โดยตรง (ผ่าน
requests,httpxฯลฯ) ใช้/openai/deployments/{name}/chat/completions?api-version=...ให้เขียนใหม่เป็น/openai/v1/responsesร่างคำขอเปลี่ยน:messages→inputเพิ่มmax_output_tokensและstore: falseลบพารามิเตอร์ queryapi-versionร่างการตอบกลับเปลี่ยน:choices[0].message.content→output[0].content[0].text(หมายเหตุ:output_textเป็นคุณสมบัติสะดวกของ SDK ซึ่งไม่มีใน REST JSON ต้นฉบับ).
ขั้นตอนที่ 2: ใช้การย้ายข้อมูล
หมายเหตุการย้ายข้อมูล (Chat Completions → Responses)
- ทำไมต้องย้าย: Responses คือ API รวมสำหรับข้อความ, เครื่องมือ, และการสตรีม; Chat Completions เป็นของเดิม กับ GPT-5 จำเป็นต้องใช้ Responses เพื่อประสิทธิภาพดีที่สุด.
- HTTP: จุดสิ้นสุด Azure เปลี่ยนจาก
/openai/deployments/{name}/chat/completionsเป็น/openai/v1/responses. - ฟิลด์:
messages→input,max_tokens→max_output_tokensอุณหภูมิยังคงเหมือนเดิม. - การจัดรูปแบบ:
response_format→text.formatโดยใช้วัตถุที่ถูกต้อง. - รายการเนื้อหา: แทนที่ Chat
content[].type: "text"ด้วย Responsescontent[].type: "input_text"สำหรับรอบระบบ/ผู้ใช้. - รายการเนื้อหารูปภาพ: แทนที่ Chat
content[].type: "image_url"ด้วย Responsescontent[].type: "input_image"แบนฟิลด์image_urlจาก{"image_url": {"url": "..."}}เป็น{"image_url": "..."}(เป็นสตริงธรรมดา — อาจเป็น URL HTTPS หรือ data URI ประเภทdata:image/...;base64,...).
แผนที่พารามิเตอร์อ้างอิง
| Chat Completions | Responses API |
prompt | input |
messages | input (อาเรย์ของรายการ) |
max_tokens | max_output_tokens |
response_format | text.format (วัตถุ) |
temperature | temperature (ไม่เปลี่ยนแปลง) |
stop | stop (ไม่เปลี่ยนแปลง) |
frequency_penalty | frequency_penalty (ไม่เปลี่ยนแปลง) |
presence_penalty | presence_penalty (ไม่เปลี่ยนแปลง) |
tools / function-calling | tools (ไม่เปลี่ยนแปลง) |
seed | ลบ (ไม่รองรับ) |
store | store (ตั้งเป็น false) |
content[].type: "text" | content[].type: "input_text" |
content[].type: "image_url" | content[].type: "input_image" |
"image_url": {"url": "..."} | "image_url": "..." (สตริงแบน) |
สำหรับตัวอย่างโค้ดก่อน/หลังแบบสมบูรณ์ ดูที่ cheat-sheet.md.
สำหรับการย้ายโครงสร้างทดสอบ (mocks, snapshots, assertions) ดูที่ test-migration.md.
สำหรับการแก้ไขปัญหาข้อผิดพลาดและปัญหาต่าง ๆ ดูที่ troubleshooting.md.
การเก็บรักษาข้อมูล & สถานะ
- ตั้งค่า
store: falseในคำขอ Responses ทั้งหมด. - อย่าพึ่งพา ID ข้อความก่อนหน้าหรือบริบทที่เก็บไว้ในเซิร์ฟเวอร์; เก็บสถานะแบบจัดการโดยไคลเอนต์และลดเมตาดาต้าให้น้อยที่สุด.
เกณฑ์การยอมรับ
ด่านระดับโค้ด (ต้องผ่านทั้งหมด)
- ไม่มีการจับคู่สำหรับ
rg "chat\.completions\.create|ChatCompletion\.create|Completion\.create"ในไฟล์ที่ย้ายแล้ว. - ไม่มีการจับคู่สำหรับ
rg "AzureOpenAI\(|AsyncAzureOpenAI\("— ตัวสร้างทั้งหมดใช้OpenAI/AsyncOpenAIกับจุดสิ้นสุด v1. - ไม่มีการจับคู่สำหรับ
rg "models\.github\.ai|models\.inference\.ai\.azure"— ลบเส้นทางโค้ด GitHub Models. - ไม่มีการจับคู่สำหรับ
rg "OpenAIChatCompletionClient"— โค้ด MAF 1.0.0+ ใช้OpenAIChatClient(ซึ่งใช้ Responses API) ในเวอร์ชันก่อน 1.0.0 ให้ปรับเป็นagent-framework-openai>=1.0.0. - ทุกการเรียก
ChatOpenAI(...)รวมuse_responses_api=True. - ไม่มีการจับคู่สำหรับ
rg "choices\[0\]"— ทุกการเข้าถึงผลลัพธ์ใช้resp.output_textหรือสคีม่าเอาต์พุต Responses. - ไม่มี
response_formatบนระดับบนสุด; ทุกผลลัพธ์มีโครงสร้างใช้text={"format": {...}}. - ใน
requirements.txtหรือpyproject.tomlมีopenai>=1.108.1และazure-identity; ติดตั้ง dependencies ใหม่แล้ว. - ตั้งค่า
store=Falseในทุกการเรียกresponses.create. - ไม่มี
api_versionในการสร้างไคลเอนต์; ลบAZURE_OPENAI_API_VERSIONออกจากไฟล์ env และโครงสร้างพื้นฐาน.
ด่านโครงสร้างทดสอบ (ต้องผ่านทั้งหมด)
- ไม่มีการจับคู่สำหรับ
rg "ChatCompletionChunk|AsyncCompletions\.create|chat\.completions" tests/. - ไม่มีการจับคู่สำหรับ
rg "_azure_ad_token_provider" tests/— ปรับปรุง assertions ให้ตรวจสอบisinstance(client, AsyncOpenAI)หรือbase_url. - ไม่มีการจับคู่สำหรับ
rg "prompt_filter_results|content_filter_results" tests/— ลบ mocks ตัวกรองเฉพาะ Azure. - ใช้ fixture mocks
kwargs.get("input")แทนkwargs.get("messages"). - ปรับปรุงไฟล์ snapshot / golden เป็นรูปแบบสตรีมของ Responses (ไม่มี
choices[0],function_call,logprobsฯลฯ). pytestผ่านโดยไม่มีข้อผิดพลาดหลังจากแก้ไขการทดสอบทั้งหมด.
ด่านพฤติกรรม (ตรวจสอบด้วยตนเองหรือผ่านชุดทดสอบ)
- การคอมพลีตพื้นฐาน:
responses.createแบบไม่สตรีมส่งคืนoutput_textที่ไม่ว่าง. - ความเท่าเทียมแบบสตรีม: หากโค้ดเดิมใช้การสตรีม โค้ดที่ย้ายจะสตรีมและให้เหตุการณ์
response.output_text.deltaที่มีเดลต้าไม่ว่าง. - เอาต์พุตโครงสร้าง: หากใช้
text.formatกับjson_schemajson.loads(resp.output_text)ผ่านและตรงกับสคีม่า. - ลูปเรียกเครื่องมือ: หากใช้เครื่องมือ โมเดลจะส่งคำสั่งเรียกเครื่องมือ, แอปจะประมวลผล, และคำขอต่อไปจะส่งคืน
output_textสุดท้าย (ไม่มีลูปไม่สิ้นสุด). - ความเท่าเทียมแบบ Async: หากใช้
AsyncAzureOpenAI, การใช้AsyncOpenAIแบบเทียบเท่าทำงานด้วยawait. - อัตราข้อผิดพลาด: ไม่มีข้อผิดพลาด 400/401/404 ใหม่เมื่อเทียบกับเส้นฐานก่อนย้าย.
ผลงานที่ส่งมอบ
- สรุปรายการไฟล์ที่แก้ไข, จำนวนจุดเรียกใช้เดิมและใหม่, และขั้นตอนถัดไป.
- การเปลี่ยนแปลงเป็นการแก้ไขใน working-tree เท่านั้น (ไม่มี commit).
เวอร์ชันที่ต้องใช้ของ SDK
| แพ็กเกจ | เวอร์ชันขั้นต่ำ |
openai | >=1.108.1 |
azure-identity | ล่าสุด (สำหรับการรับรองความถูกต้อง EntraID) |
แหล่งอ้างอิง
- ใบสรุปการโกง — ตัวอย่างโค้ดทั้งหมด
- การย้ายทดสอบ — mocks, snapshots, assertions
- แก้ไขปัญหา — ข้อผิดพลาด, ตารางความเสี่ยง, ปัญหาที่พบบ่อย
- detect_legacy.py — ตัวสแกนอัตโนมัติ
- ชุดเริ่มต้น Azure OpenAI
- เอกสาร Azure OpenAI Responses API
- วงจรชีวิตเวอร์ชัน Azure OpenAI API
- เอกสารอ้างอิง OpenAI Responses API
<!-- CO-OP TRANSLATOR DISCLAIMER START -->ปฏิเสธความรับผิดชอบ: เอกสารนี้ได้รับการแปลโดยใช้บริการแปลภาษา AI Co-op Translator ขณะที่เราพยายามให้ความถูกต้อง โปรดทราบว่าการแปลโดยอัตโนมัติอาจมีข้อผิดพลาดหรือความไม่ถูกต้อง เอกสารต้นฉบับในภาษาต้นทางควรถูกพิจารณาเป็นแหล่งข้อมูลที่เชื่อถือได้ สำหรับข้อมูลที่สำคัญ แนะนำให้ใช้การแปลโดยมนุษย์มืออาชีพ เราไม่รับผิดชอบต่อความเข้าใจผิดหรือการตีความที่ผิดพลาดที่เกิดขึ้นจากการใช้การแปลนี้
<!-- CO-OP TRANSLATOR DISCLAIMER END -->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
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.

