Add Chat Completions routing for Codex providers

- Add a Codex API format selector and routing badge for Chat Completions providers.
- Convert Codex Responses requests to upstream Chat Completions when routing is required.
- Convert Chat Completions JSON and SSE responses back to Responses format.
- Keep generated Codex wire_api values on Responses for Codex compatibility.
- Add i18n labels, provider metadata handling, and focused conversion tests.
This commit is contained in:
Jason
2026-05-19 10:23:48 +08:00
parent 61e68d754c
commit 1c82b8a3fa
19 changed files with 2230 additions and 35 deletions
+6 -1
View File
@@ -161,7 +161,7 @@ export interface ProviderMeta {
costMultiplier?: string;
// 供应商计费模式来源
pricingModelSource?: string;
// Claude API 格式(Claude 供应商使用)
// API 格式(Claude / Codex 供应商使用)
// - "anthropic": 原生 Anthropic Messages API 格式,直接透传
// - "openai_chat": OpenAI Chat Completions 格式,需要格式转换
// - "openai_responses": OpenAI Responses API 格式,需要格式转换
@@ -204,6 +204,11 @@ export type ClaudeApiFormat =
| "openai_responses"
| "gemini_native";
// Codex API 格式类型
// - "openai_responses": OpenAI Responses API 格式,直接透传
// - "openai_chat": OpenAI Chat Completions 格式,需要本地路由转换
export type CodexApiFormat = "openai_responses" | "openai_chat";
// Claude 认证字段类型
export type ClaudeApiKeyField = "ANTHROPIC_AUTH_TOKEN" | "ANTHROPIC_API_KEY";