-
Notifications
You must be signed in to change notification settings - Fork 6k
Add OpenAI Responses API support with chat_completions capability flag #39989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add OpenAI Responses API support with chat_completions capability flag #39989
Conversation
Add support for OpenAI's /responses endpoint as a fallback for models that don't support the standard /chat/completions API. This enables compatibility with newer model variants while maintaining backward compatibility. Changes: - Add supports_chat_completions flag to model capabilities - Implement responses API client with streaming support - Add ResponseEventMapper to convert responses events to completion events - Update UI to allow toggling chat_completions capability - Route requests to /responses when chat_completions is false - Add gpt-5-codex model variant
|
@mstallone Quick Question: I built your branch but still get the error Dont think this pr solves the copilot chat problem. Looks like it adds support for OpenAi/ openAi compatible providers hence it does not close #38858 , but nice to have the code that supports /responses. Thanks. Would be less difficult to extend to copilot chat |
|
Hi @somtooo, thanks for giving the branch a test! I am not sure I understand what you mean about the copilot chat. I added some screenshots below showing that the chat does work with attachments on a fresh install from the branch: OpenAI as a provider with
Azure OpenAI as a third-party OpenAI compatible endpoint with a custom
For OpenAI compatible, you must set "openai_compatible": {
"Azure OpenAI": {
"api_url": "https://zed.openai.azure.com/openai/v1/",
"available_models": [
{
"name": "gpt-5-codex",
"display_name": "gpt-5-codex - Azure OpenAI",
"max_tokens": 272000,
"max_output_tokens": 128000,
"max_completion_tokens": 128000,
"capabilities": {
"tools": true,
"images": true,
"chat_completions": false
}
}
]
}
}If you could let me know where it is failing (am I missing a chat somewhere?), I can try to take a look. Best |
|
@mstallone Yes this would work. but that issue is for people who use the github copilot provider not OpenAi as a provider. |
|
Ah, I understand now. I assumed copilot was just referencing the chat system, not GitHub Copilot. I don't pay for that service, and I don't intend to at the moment, so if someone wants to take the lead on that, that'd be great. Probably Codex or Claude could easily adapt what I have without much effort. |
|
@mstallone all good pulled your branch and started adapting it for copilot already. Thanks for the initial work. But update commit that says closes issue #38858 😭 cause I was overjoyed in error when I read that before looking at the code changes Edit: Was able to extend nicely and make the ResponseEventMapper.mapStream() shorter |
| } | ||
| } | ||
|
|
||
| pub fn map_stream( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this code you pass in the stop sequences so you can handle it if you see it in the model response - (Correct me if im wrong). But when looking at the response api, vscode-chat implementation, openAi sdk i can find proof that the stop parameter is supported. (https://community.openai.com/t/how-to-prevent-the-api-returning-multiple-outputs/1251365/3).But even if it is i dont think the model response includes the actual stop sequences it returns the text before the stop sequence. Thats why the OpenAiEventMapper.map_stream function dosent check for it despite sending the stop sequence to the model.
If im correct then this code can be reduced which would be nice. Let me know thoughts. Thanks
Add support for GithubCopilot /responses endpoint. This gives the copilot chat provider the ability to use the new GPT-5 codex model and any other model that lacks support for /chat/copmletions endpoint. Closes #38858 Release Notes: - Add support for GithubCopilot /responses endpoint. # Added 1. copilot_response.rs that has the /response endpoint types 2. uses response endpoint if model does not support /chat/completions. 3. new into_copilot_response() to map LanguageCompletionEvents to Request. 4. new map_stream() to map response stream event to LanguageCompletionEvents and tests. 5. Fixed a bug where trying to parse response for non streaming for /chat/completion was failing # Notes There is a pr open - #39989 for adding /response support for OpenAi and OpenAi compatible API. Altough they share some similarities (copilot api seems to mirror openAi directly) ive simplified some stuff and tried to keep it the same with the vscode-chat implementation where possible. There might be a case for code reuse but i think keeping them separate for now should be ok. # Tool Calls <img width="716" height="670" alt="Screenshot from 2025-10-15 17-12-30" src="https://github.com/user-attachments/assets/14e88a52-ba8b-4209-8f78-73d15034b1e0" /> # Image <img width="923" height="494" alt="Screenshot from 2025-10-21 02-02-26" src="https://github.com/user-attachments/assets/b96ce97c-331e-45cb-b5b1-7aa10ed387b4" />



Add support for OpenAI's /responses endpoint for models that don't support /chat/completions API. This enables compatibility with newer model variants (
gpt-5-codex,gpt-5-pro,o3-pro, etc) while maintaining compatibility with existing configsChanges:
supports_chat_completionsflag to model capabilities that defaults to true for existing behaviorResponseEventMapperto convert responses events to completion events for maintainer simplicitychat_completionscapabilitygpt-5-codexmodelCloses #38858
Release Notes:
gpt-5-codexmodel to assistant