Add Chat Completions to Responses API migration guide - #3059
Conversation
Adds examples/Migrate_from_chat_completions_to_responses.ipynb, a parameter-by-parameter guide for porting existing Chat Completions code to the Responses API. 97 of the 267 example notebooks in this repo still call chat.completions, and the registry has no guide covering this migration, though it does cover Whisper -> GPT-Transcribe, OpenAI Evals -> Promptfoo, and legacy codebase migration with sandbox agents. The guide covers the renames, the two shape changes that break a naive port (structured outputs and tool definitions both flatten), the parameters with no Responses equivalent, and multi-turn state via previous_response_id. Section 3 derives the parameter map from the installed SDK at runtime by diffing the two create() signatures, so readers can verify against their own version rather than trusting a table that may have gone stale.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85205511d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…idance - Rename to migrate_from_chat_completions_to_responses.ipynb to follow the lowercase notebook naming convention in AGENTS.md, and update the registry path. - Name OPENAI_API_KEY explicitly in the prerequisites and show how to export it, since every cell builds its client from that variable. - Qualify the opening claim of parity: the guide itself documents parameters that have no Responses counterpart. - State precisely that frequency_penalty and presence_penalty are not accepted by responses.create, and note that a Response may echo them as defaults because the model allows extra server-returned fields.
|
Thanks for the review — pushed in c88afcb. Applied as suggested:
On They aren't request parameters on Rather than leave the original absolute wording, I changed it to state that they are "not accepted by |
Summary
Adds
examples/Migrate_from_chat_completions_to_responses.ipynb— a parameter-by-parameter guide for porting existing Chat Completions code to the Responses API.Why
The Responses API is where new platform capabilities land, but this repo's own examples are still mostly written against Chat Completions:
chat.completionsclient.responsesThe registry has six migration guides (Whisper → GPT-Transcribe, OpenAI Evals → Promptfoo, legacy codebase migration with sandbox agents, and others), but none for the migration most OpenAI developers actually face.
That gap matters because the port is not a find-and-replace. The traps are silent:
json_schemakey; Responses hoistsname/schema/strictto sit alongsidetype. Moving the object across unchanged fails validation.schemais also required in Responses where it was optional before.functionwrapper disappears.output_textis empty whenever the model calls a tool. Per the SDK docstring: "If nooutput_textcontent blocks exist, then an empty string is returned." Code that assumes it is populated breaks the first time a tool fires.instructionsdoes not carry acrossprevious_response_idchains — a migrated system prompt silently stops applying on turn 2.n,seed,logit_bias,frequency_penalty,presence_penalty) and need rewrites, not renames.Contents
Ten sections, each showing before/after side by side: the minimal migration, reading the output, the parameter map,
instructions, multi-turn state, structured outputs, tools, streaming, reasoning models, and the parameters with no equivalent — closing with a migration checklist.Section 3 derives the parameter map from the installed SDK at runtime by diffing
Completions.createagainstResponses.create, rather than hardcoding a table. Readers verify against their own version, so the guide cannot silently go stale as the SDK moves.Notes for reviewers
One deliberate departure from the docs. The migration guide lists
verbosityas having no Responses equivalent, but the SDK exposestext.verbosityasLiteral["low", "medium", "high"](ResponseTextConfigParam). The notebook documents the SDK behavior. Happy to change it if the docs are the intended source of truth here.Cells are not executed. The notebook ships without outputs, as several guide-style notebooks in the repo do (
gpt-5/gpt-5-2_prompting_guide.ipynb,skills_in_api.ipynb,mcp/mcp_tool_guide.ipynb). Every cell is runnable; the code is illustrative and readers run it against their own key. I can execute and push outputs if you would prefer them.Validation performed against
openai3.8.0:nbformat.validatepasses; all 19 code cells parseCompletions.create/Responses.createsignaturesusage.input_tokens,usage.output_tokens_details.reasoning_tokens,output_textas a property).github/scripts/check_notebooks.pypassesregistry.yamlvalidates against.github/registry_schema.json; slug unique, path resolvesSampling parameters are left out of the examples since reasoning models may reject them; the notebook notes this rather than demonstrating it.