Skip to content

Conversation

@mstallone
Copy link

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 configs

Changes:

  • Add supports_chat_completions flag to model capabilities that defaults to true for existing behavior
  • Implement responses API client with streaming support as per OpenAI documentation.
  • Add ResponseEventMapper to convert responses events to completion events for maintainer simplicity
  • Update UI to allow toggling chat_completions capability
  • Add gpt-5-codex model

Closes #38858

Release Notes:

  • Added support for OpenAI's /responses endpoint for models that don't support /chat/completions API.
  • Added OpenAI gpt-5-codex model to assistant

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
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 11, 2025
@SomeoneToIgnore SomeoneToIgnore added the ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Oct 11, 2025
@somtooo
Copy link
Contributor

somtooo commented Oct 13, 2025

@mstallone Quick Question: I built your branch but still get the error

Failed to connect to API: 400 Bad Request {"error":{"message":"model gpt-5-codex is not accessible via the /chat/completions endpoint","code":"unsupported_api_for_model"}}

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

@mstallone
Copy link
Author

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 gpt-5-codex builtin:

Screenshot 2025-10-14 at 8 35 40 PM

Azure OpenAI as a third-party OpenAI compatible endpoint with a custom gpt-5-codex deployment:

Screenshot 2025-10-14 at 8 43 21 PM

For OpenAI compatible, you must set chat_completions to false otherwise it will try the completions endpoint.

"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

@somtooo
Copy link
Contributor

somtooo commented Oct 15, 2025

@mstallone Yes this would work. but that issue is for people who use the github copilot provider not OpenAi as a provider.

@mstallone
Copy link
Author

mstallone commented Oct 15, 2025

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.

@somtooo
Copy link
Contributor

somtooo commented Oct 15, 2025

@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
Screenshot from 2025-10-15 17-12-30

}
}

pub fn map_stream(
Copy link
Contributor

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

ConradIrwin pushed a commit that referenced this pull request Oct 24, 2025
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"
/>
@zed-industries-bot
Copy link

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against de0e5f2

@bennetbo bennetbo self-assigned this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI: 400 Bad Request on GPT-5-Codex in Copilot Agent

5 participants