-
-
Notifications
You must be signed in to change notification settings - Fork 283
Description
Bug Description
When a client sends a standard Chat Completions request (POST /v1/chat/completions) for a Codex OAuth model (e.g. gpt-5.3-codex), the proxy returns Responses API SSE events (event: response.created, event: response.output_text.delta, etc.) instead of the expected Chat Completions SSE format (data: {"choices":[{"delta":...}]}).
This causes clients using the OpenAI-compatible Chat Completions protocol (like Vercel AI SDK's @ai-sdk/openai-compatible) to crash with:
AI_JSONParseError: JSON parsing failed: Text: event: response.created.
Error message: JSON Parse error: Unexpected identifier "event"
Steps to Reproduce
- Configure CLIProxyAPIPlus with Codex OAuth tokens (auth files with
"type":"codex") - Send a Chat Completions request to a Codex model:
curl -X POST https://your-proxy/v1/chat/completions \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{"model": "gpt-5.3-codex", "messages": [{"role": "user", "content": "Hello"}]}'
- Observe the response contains Responses API SSE events instead of Chat Completions format
Expected Behavior
A request to /v1/chat/completions should always return Chat Completions format, regardless of which upstream API the proxy uses internally. If the proxy internally converts to the Responses API for Codex OAuth tokens, it should transcode the response back to Chat Completions SSE format before returning it to the client.
Expected SSE format (Chat Completions):
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hello"}}]}
Actual SSE format returned (Responses API):
event: response.created
data: {"id":"resp_...","type":"response.created",...}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Hello",...}
Suggested Fix
Either:
-
Transcode Responses → Chat Completions: When the proxy internally uses the Responses API for Codex OAuth, convert the response SSE events back to Chat Completions format before returning to the client. This maintains the OpenAI-compatible contract on
/v1/chat/completions. -
Support
/v1/responsesas an input endpoint: Allow clients that natively speak the Responses API (like@ai-sdk/openai) to send requests directly to/v1/responses. Currently this endpoint returns HTTP 400.
Option 1 is preferred as it maintains backward compatibility and the OpenAI-compatible contract.
Environment
- Version: v6.8.32-0-plus
- Docker Image:
eceasy/cli-proxy-api-plus:v6.8.32-0 - Auth type: Codex OAuth tokens (
"type":"codex") - Affected models: All
owned_by=openaimodels routed through Codex OAuth (gpt-5, gpt-5.1, gpt-5.2, gpt-5.3-codex, etc.)