retry capacity-style upstream errors

This commit is contained in:
2026-06-29 15:54:36 +08:00
parent 778068af42
commit 283c14b6b4
8 changed files with 384 additions and 24 deletions
+9
View File
@@ -9,6 +9,7 @@ tg群:https://t.me/AI_INPUT_IM
- 保持 Codex 继续使用现有 `auth.json`
- 只把 `config.toml` 的当前 provider `base_url` 改成本地网关
- 非流式命中 `reasoning_tokens = 516` 时返回 `502`
- 上游若返回明确的容量错误(默认匹配 `429/503` 且错误文案包含 `Selected model is at capacity. Please try a different model.`),也会转成本地 `502`
- 流式命中时默认先缓存并判断;一旦命中 `516`,统一返回 `502`
- 默认同时拦截 root 路径和 `/v1` 路径:
- `/responses`
@@ -139,6 +140,8 @@ profile env 默认放在:
- `CODEX_RETRY_GATEWAY_LISTEN_PORT`
- `CODEX_RETRY_GATEWAY_UPSTREAM_BASE_URL`
- `CODEX_RETRY_GATEWAY_REASONING_EQUALS`
- `CODEX_RETRY_GATEWAY_RETRYABLE_STATUS_CODES`
- `CODEX_RETRY_GATEWAY_RETRYABLE_ERROR_MESSAGES`
- `CODEX_RETRY_GATEWAY_UPSTREAM_AUTH_MODE`
- `CODEX_RETRY_GATEWAY_UPSTREAM_AUTH_ENV`
- `CODEX_RETRY_GATEWAY_UPSTREAM_AUTH_FILE`
@@ -213,6 +216,7 @@ gateway 运行时只负责 API 与静态文件服务,不再把复杂 UI 硬写
- 切换 provider `base_url`
- 切换 `passthrough` / `manual_bearer` / `fixed_bearer` / `auth_json` 认证模式
-`reasoning_equals`
- 改 capacity error 的匹配状态码和错误文案
-`endpoints`
-`non_stream_status_code`
- 开关 `log_match`
@@ -246,6 +250,11 @@ macOS / Linux: ~/.codex-retry-gateway/config/config.json
- `reasoning_equals`
- 例如 `[516]`
- `retryable_status_codes`
- 默认 `[429, 503]`
- `retryable_error_messages`
- 默认包含 `Selected model is at capacity. Please try a different model.`
- 只要上游 JSON 错误里包含这些文案之一,gateway 就会把上游错误翻成本地 `non_stream_status_code`
- `endpoints`
- 默认包含 root 与 `/v1` 两套路径
- `non_stream_status_code`