From 24d19a5f787f55c7b0aa25294d29d41d67090429 Mon Sep 17 00:00:00 2001 From: kzw200015 Date: Sat, 10 Jan 2026 19:37:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=8Ecodex=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=B8=AD=E7=A7=BB=E9=99=A4max=5Foutput=5Ftok?= =?UTF-8?q?ens=20(#231)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 某些客户端比如 opencode 会在请求中附加 max_output_tokens,这会导致上游返回400错误 --- backend/internal/service/openai_gateway_service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/internal/service/openai_gateway_service.go b/backend/internal/service/openai_gateway_service.go index 5bb7574a..9d365ad6 100644 --- a/backend/internal/service/openai_gateway_service.go +++ b/backend/internal/service/openai_gateway_service.go @@ -545,6 +545,8 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco // 2. Normalize input format for Codex API compatibility if account.Type == AccountTypeOAuth { reqBody["store"] = false + // Codex 上游不接受 max_output_tokens 参数,需要在转发前移除。 + delete(reqBody, "max_output_tokens") bodyModified = true // Normalize input format: convert AI SDK multi-part content format to simplified format