From e6c192e806c0aa7925f15063101e2f99e102957f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=20=28Claude=29?= Date: Thu, 11 Jun 2026 14:48:10 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20image=20quality=20param=20=E2=80=94=20l?= =?UTF-8?q?ow=20for=20posts,=20medium=20for=20article=20covers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit covers.js: generateCoverViaRouterAI принимает quality='medium' по умолчанию postImages.js: quality='low' для постов TG/VK (₽0.25 vs ₽0.84) Экономия 70% на генерации картинок к постам --- src/services/covers.js | 6 +++--- src/services/postImages.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/covers.js b/src/services/covers.js index 8a85156..caf26fb 100644 --- a/src/services/covers.js +++ b/src/services/covers.js @@ -272,9 +272,9 @@ async function generateCoverViaImagesEndpoint({ prompt }) { */ /** * RouterAI — стабильный провайдер через /responses + image_generation tool. - * Используется как третий fallback когда aiguoguo и Nyxos недоступны. + * quality: 'low' для постов TG (₽0.25), 'medium' для обложек/VK (₽0.84) */ -async function generateCoverViaRouterAI({ prompt }) { +async function generateCoverViaRouterAI({ prompt, quality = 'medium' }) { const base = config.ai.routeraiBaseUrl; const key = config.ai.routeraiApiKey; const model = config.ai.routeraiImageModel || 'openai/gpt-5-image-mini'; @@ -283,7 +283,7 @@ async function generateCoverViaRouterAI({ prompt }) { const res = await axios.post(`${base}/responses`, { model, input: `Use the image_generation tool to create this illustration. Only call the tool, no text.\n\n${prompt.slice(0, 3000)}`, - tools: [{ type: 'image_generation' }], + tools: [{ type: 'image_generation', quality }], tool_choice: { type: 'image_generation' }, }, { headers: { Authorization: `Bearer ${key}` }, diff --git a/src/services/postImages.js b/src/services/postImages.js index d2465d9..03bbb2a 100644 --- a/src/services/postImages.js +++ b/src/services/postImages.js @@ -94,7 +94,7 @@ Strictly: no text, no letters, no logos, no faces of real people.`; const res = await axios.post(`${config.ai.routeraiBaseUrl}/responses`, { model, input: `Use the image_generation tool to create this illustration. Only call the tool, no text.\n\n${prompt.slice(0, 3000)}`, - tools: [{ type: 'image_generation' }], + tools: [{ type: 'image_generation', quality: 'low' }], tool_choice: { type: 'image_generation' }, }, { headers: { Authorization: `Bearer ${config.ai.routeraiApiKey}` }, timeout: 120_000 }); const imgCall = (res.data?.output || []).find(o => o.type === 'image_generation_call');