Skip to content

[Bug]Codex 兼容性问题:/v1/responses 流式响应未正常结束 #63

Description

@sandleft

版本 / Version

2.0.3

部署方式 / Deployment

其他 / Other

问题描述 / What happened?

Codex 兼容性问题:/v1/responses 流式响应未正常结束

问题描述

新版 Codex 强制要求 wire_api = "responses",即所有请求必须走 /v1/responses 端点,不再支持 /v1/chat/completions。WindsurfAPI 目前没有实现该端点,导致 Codex 无法使用。

期望

希望官方在 src/server.js 中原生支持 /v1/responses 端点,并正确实现流式事件序列,以兼容新版 Codex。

复现步骤 / Steps to reproduce

### 复现步骤

1. 在 Codex `config.toml` 中配置 WindsurfAPI 为自定义 provider
2. 发送任意对话请求
3. 报错:`unexpected status 404 Not Found: POST /v1/responses not found`

### 临时修复方案(已验证非流式可用,流式仍有问题)`src/server.js` 中手动添加 `/v1/responses` 路由,将请求转换为 `chat/completions` 格式处理:

- 非流式(`stream: false`):已正常返回 Responses API 格式的 JSON,测试通过
- 流式(`stream: true`):响应中途断开,Codex 报错 `stream disconnected before completion: stream closed before response.completed`

### 流式问题分析

Codex 要求 SSE 流必须包含完整的事件序列才能正常结束,目前的适配层将 `chat/completions` 的 SSE 格式转换为 Responses API 格式时,`response.completed` 事件未能可靠发出,导致 Codex 判定流异常中断。

日志 / Logs

模型 / Model

gpt

环境 / Environment

  • WindsurfAPI(Docker 部署,3 实例 + nginx 负载均衡)
  • 客户端:OpenAI Codex(最新版)
  • 系统:Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaves incorrectlyfixed已修复 等待确认

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions