Add backward-compatible OpenAI Responses API support with URL auto-detection#305
Merged
Conversation
Co-authored-by: robgruen <[email protected]>
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
robgruen
requested changes
May 4, 2026
…o-detection, retry-after support, and improved docs Agent-Logs-Url: https://github.com/microsoft/TypeChat/sessions/1e304792-c4f0-4d9a-8cff-8ae75788bc8a Co-authored-by: robgruen <[email protected]>
…for clarity Agent-Logs-Url: https://github.com/microsoft/TypeChat/sessions/1e304792-c4f0-4d9a-8cff-8ae75788bc8a Co-authored-by: robgruen <[email protected]>
Copilot
AI
changed the title
Add backward-compatible OpenAI Responses API support with opt-in env var
Add backward-compatible OpenAI Responses API support with URL auto-detection
May 4, 2026
robgruen
requested changes
May 4, 2026
… to all transient errors Agent-Logs-Url: https://github.com/microsoft/TypeChat/sessions/a10ca0ce-110b-4b44-b6d2-5a64387a9dd2 Co-authored-by: robgruen <[email protected]>
Agent-Logs-Url: https://github.com/microsoft/TypeChat/sessions/a10ca0ce-110b-4b44-b6d2-5a64387a9dd2 Co-authored-by: robgruen <[email protected]>
robgruen
approved these changes
May 4, 2026
robgruen
approved these changes
May 4, 2026
robgruen
approved these changes
May 4, 2026
TalZaccai
approved these changes
May 4, 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
createOpenAILanguageModelextended — accepts an optional fifth parameteruseResponsesApi?: booleanand auto-detects the API variant from the endpoint URL (path ending with/responses):useResponsesApi: true— forces Responses API regardless of URLuseResponsesApi: false— forces Chat Completions regardless of URLuseResponsesApiomitted (default) — inferred from the endpoint URLURL auto-detection — any endpoint whose path ends with
/responses(e.g.https://api.openai.com/v1/responsesor an Azure deployment URL likehttps://{resource}.openai.azure.com/.../responses?api-version=...) automatically uses the Responses API request/response format; all other URLs use Chat CompletionscreateOpenAIResponsesLanguageModelremoved — the separate function was never published and has been deleted; all Responses API usage goes throughcreateOpenAILanguageModelcreateLanguageModelsimplified — theOPENAI_USE_RESPONSES_APIenv var is removed; to opt into the Responses API setOPENAI_ENDPOINTto a/responsesURL and URL auto-detection handles the restretry-afterheader support — on transient error responses (429, 503, etc.), theRetry-Afterheader value (seconds) is used as the back-off delay, capped atretryPauseMs × retryMaxAttemptsto stay within the configured total retry budgetImproved documentation —
createResponsesFetchLanguageModelnow includes a sample response JSON, links to OpenAI and Azure OpenAI Responses API docs, and full@paramdocumentationtypescript/tests/model.test.mjs) using Node's built-innode:testwith mockedfetch, covering both API paths, URL auto-detection, theuseResponsesApiflag,retry-afterhandling (429 and 503) for both paths, andcreateLanguageModelrouting;"test"script added topackage.json💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.