Codex Switch v0.6.0
Codex Switch v0.6.0
本版本新增 Anthropic Messages 双向协议支持, 将 Responses, Chat Completions 和 Anthropic Messages 连接为完整的文本协议转换矩阵. Claude Code 等 Anthropic 客户端现在可以直接使用 Codex Switch 中已有的 OpenAI 兼容上游, 也可以接入原生 Anthropic 上游.
Highlights
- 新增
/v1/messages,/v1/messages/count_tokens和 Anthropic Models 接口, 本地访问 key 同时支持 Bearer 与x-api-key. - Responses, Chat Completions 和 Anthropic Messages 可以按入站与上游能力进行 3x3 双向转换, 同协议请求继续保持直通.
- JSON 与 SSE 转换覆盖文本, 图片, system/developer 指令, thinking/reasoning, 工具调用与结果, web search, usage 和终止事件.
Protocol Routing
- 上游可以声明 Responses, Chat Completions 或 Anthropic Messages Wire API. Claude Code 发出的 Messages 请求可以转换到 Responses 或 Chat Completions 上游.
- 同协议路径保留 provider 私有字段, Anthropic
cache_control, thinking signature, 客户端anthropic-version和anthropic-beta. - 跨协议路径使用 Responses 作为规范结构. 无法安全表达的 document/PDF, audio 和未知 server tool 会返回对应客户端协议的
400 invalid_request_error. - 流式转换支持任意 SSE chunk 分割, CRLF, ping, 并行工具参数增量, thinking 增量, usage 与失败事件.
Anthropic Upstreams
- Anthropic 上游默认使用
x-api-key, 并发送anthropic-version: 2023-06-01. Bearer 认证仍可用于兼容中转. - SQLite schema migration 13 为上游增加持久化认证方式, 现有上游保持 Bearer.
- Anthropic Models 列表支持
before_id,after_id和limit分页, 并提供单模型查询. count_tokens只选择原生支持计数的 Responses 或 Anthropic 上游, 不使用 Chat Completions 本地估算.
Reliability And Cache
- 上游错误分类增加 Anthropic
429,529,overloaded_error和流式error事件. - Anthropic 缓存保持请求保留原始 cache marker, 使用
stream=false和max_tokens=1, 并记录 cache read/create token. - Images 和 Responses compact 不会选择 Anthropic 上游. Anthropic 模式在界面中会强制关闭 compact.
Upgrade Notes
- 升级时会自动执行 schema migration 13, 不需要清除数据库或重新导入上游.
- 现有 API Key 上游保持 Bearer 认证和原有 Wire API. DeepSeek, Qwen, GLM, Kimi 等 OpenAI 兼容服务通常应继续选择 Chat Completions.
- 原生 Anthropic 或兼容 Messages 服务需要将 Wire API 设为 Anthropic Messages, 并按服务要求选择
x-api-key或 Bearer.
Full Changelog: v0.5.0...v0.6.0