Add backward-compatible OpenAI Responses API support with opt-in env var#305
Draft
Add backward-compatible OpenAI Responses API support with opt-in env var#305
Conversation
Co-authored-by: robgruen <25374553+robgruen@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Verify backward compatibility for PR#277 changes
Add backward-compatible OpenAI Responses API support with opt-in env var
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #277 proposed switching the default OpenAI endpoint from
/chat/completionsto/responses, but the change was incomplete: the Responses API has a different request format (inputvsmessages) and response shape (output[0].content[0].textvschoices[0].message.content), making the PR as-is a silent breaking change.Changes
New export
createOpenAIResponsesLanguageModel— mirrorscreateOpenAILanguageModelbut targets the Responses API with the correct request/response handling:input(notmessages) in the request bodyoutput[0].content[0].textfrom the responsehttps://api.openai.com/v1/responsescreateOpenAILanguageModelunchanged — still defaults to/chat/completions; no breakage for existing users or Azure OpenAI (which may not support/responses)createLanguageModelopt-in flag — setOPENAI_USE_RESPONSES_API=trueto route through the Responses API path; omitting it preserves the existing behaviortypescript/tests/model.test.mjs) using Node's built-innode:testwith mockedfetch, covering both API paths andcreateLanguageModelrouting;"test"script added topackage.json💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.