sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

Support OpenAI Chat Completions API as a complement to the existing Responses API

Open daleydeng opened this issue 9 months ago • 14 comments

Feature Request

Summary

Add support for the OpenAI Chat Completions API (POST /v1/chat/completions) as a complement to the currently supported Responses API.

Motivation

The Chat Completions API is the most widely used OpenAI-compatible interface and serves as the standard for many third-party clients and frameworks (e.g., LangChain, OpenAI SDKs, various chat UIs). Supporting it would greatly broaden compatibility and allow more developers to integrate sub2api into their existing workflows without modifications.

Proposed Behavior

  • Add a /v1/chat/completions endpoint that accepts standard OpenAI Chat Completions request payloads.
  • Support both streaming (stream: true) and non-streaming responses.
  • Route requests appropriately to the underlying model providers (Claude, Gemini, etc.) via the existing middleware/translation layer.
  • Preserve full compatibility with the existing Responses API — this is intended as an additive feature, not a replacement.

Expected Request Format

{
  "model": "claude-3-5-sonnet",
  "messages": [
    { "role": "user", "content": "Hello!" }
  ],
  "stream": false
}

Additional Context

  • This would make sub2api more plug-and-play for users already using OpenAI-compatible tools.
  • Could also improve cost-sharing and carpooling scenarios by enabling more client diversity.

daleydeng avatar Feb 19 '26 11:02 daleydeng

agree!

befantasy avatar Feb 21 '26 06:02 befantasy

agree!

pcprinciple avatar Feb 22 '26 14:02 pcprinciple

agree!

Abel-j avatar Feb 23 '26 03:02 Abel-j

强烈同意

gqingc1314 avatar Feb 24 '26 12:02 gqingc1314

agree!

fzkun avatar Feb 25 '26 12:02 fzkun

agree !强烈同意!

xsha511 avatar Feb 27 '26 03:02 xsha511

强烈同意

Cabbagewwc avatar Feb 28 '26 12:02 Cabbagewwc

agree!

937bb avatar Mar 03 '26 02:03 937bb

强烈建议!

BytePioneer-AI avatar Mar 03 '26 04:03 BytePioneer-AI

agree !强烈同意! +1

Unsupported legacy protocol: /v1/chat/completions is not supported. Please use /v1/responses. {"error":{"message":"Unsupported legacy protocol: /v1/chat/completions is not supported. Please use /v1/responses.","type":"invalid_request_error"}}

gopkg-dev avatar Mar 03 '26 19:03 gopkg-dev

Strongly agree!

EeeeeGhost avatar Mar 04 '26 10:03 EeeeeGhost

同意

vvnocode avatar Mar 05 '26 08:03 vvnocode

https://github.com/Wei-Shaw/sub2api/pull/648

我看有人提 pr 了

gopkg-dev avatar Mar 05 '26 09:03 gopkg-dev

#926 已经合并了

dacheng-gao avatar Mar 20 '26 03:03 dacheng-gao