Bladeren bron

gpt-image2大模型新增参考图编辑模式

lh 1 maand geleden
bovenliggende
commit
baa4e1d18a
1 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
  1. 5 2
      app/Services/AIGeneration/AIImageGenerationService.php

+ 5 - 2
app/Services/AIGeneration/AIImageGenerationService.php

@@ -252,6 +252,8 @@ class AIImageGenerationService
             if ($task->width && $task->height) {
                 $apiParams['size'] = $task->width . 'x' . $task->height;
             }
+
+            $api_url = 'https://token.ithinkai.cn/v1/images/generations';
             
             // 参考图片
             if ($task->ref_img_url) {
@@ -259,13 +261,14 @@ class AIImageGenerationService
                 $apiParams['image_url'] = [
                     'url' => $imageUrl
                 ];
+                $api_url = 'https://token.ithinkai.cn/v1/images/edits';
             }
 
             dLog('generate')->info('GPT-Image2 API参数: ', $apiParams);
-            logDB('generate', 'info', 'GPT-Image2任务提交', ['task_id' => $task->task_id, 'params' => $apiParams]);
+            logDB('generate', 'info', 'GPT-Image2任务提交', ['task_id' => $task->task_id, 'api_url' => $api_url, 'params' => $apiParams]);
             
             // 调用GPT-Image2 API
-            $response = $this->httpClient->post('https://token.ithinkai.cn/v1/images/generations', [
+            $response = $this->httpClient->post($api_url, [
                 'headers' => [
                     'Authorization' => 'Bearer ' . $apiKey,
                     'Content-Type' => 'application/json',