From d0589468c1f64d71817d685d3fa3111bd0c6627c Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Tue, 22 Jul 2025 00:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(middleware):=20enhance=20Kling?= =?UTF-8?q?=20request=20adapter=20to=20support=20both=20'model'=20and=20'm?= =?UTF-8?q?odel=5Fname'=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the KlingRequestConvert middleware only extracted model name from the 'model_name' field, which caused 503 errors when requests used the 'model' field instead. This enhancement improves API compatibility by supporting both field names. Changes: - Modified KlingRequestConvert() to check for 'model' field if 'model_name' is empty - Maintains backward compatibility with existing 'model_name' usage - Fixes "no available channels for model" error when model field was not recognized This resolves issues where valid Kling API requests were failing due to field name mismatches, improving the overall user experience for video generation APIs. --- middleware/kling_adapter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/middleware/kling_adapter.go b/middleware/kling_adapter.go index 3d4943d2..5e6d1fbb 100644 --- a/middleware/kling_adapter.go +++ b/middleware/kling_adapter.go @@ -18,7 +18,11 @@ func KlingRequestConvert() func(c *gin.Context) { return } + // 支持 model_name 和 model 两个字段 model, _ := originalReq["model_name"].(string) + if model == "" { + model, _ = originalReq["model"].(string) + } prompt, _ := originalReq["prompt"].(string) unifiedReq := map[string]interface{}{