feat: image quality param — low for posts, medium for article covers
covers.js: generateCoverViaRouterAI принимает quality='medium' по умолчанию postImages.js: quality='low' для постов TG/VK (₽0.25 vs ₽0.84) Экономия 70% на генерации картинок к постам
This commit is contained in:
@@ -272,9 +272,9 @@ async function generateCoverViaImagesEndpoint({ prompt }) {
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* RouterAI — стабильный провайдер через /responses + image_generation tool.
|
* 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 base = config.ai.routeraiBaseUrl;
|
||||||
const key = config.ai.routeraiApiKey;
|
const key = config.ai.routeraiApiKey;
|
||||||
const model = config.ai.routeraiImageModel || 'openai/gpt-5-image-mini';
|
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`, {
|
const res = await axios.post(`${base}/responses`, {
|
||||||
model,
|
model,
|
||||||
input: `Use the image_generation tool to create this illustration. Only call the tool, no text.\n\n${prompt.slice(0, 3000)}`,
|
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' },
|
tool_choice: { type: 'image_generation' },
|
||||||
}, {
|
}, {
|
||||||
headers: { Authorization: `Bearer ${key}` },
|
headers: { Authorization: `Bearer ${key}` },
|
||||||
|
|||||||
@@ -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`, {
|
const res = await axios.post(`${config.ai.routeraiBaseUrl}/responses`, {
|
||||||
model,
|
model,
|
||||||
input: `Use the image_generation tool to create this illustration. Only call the tool, no text.\n\n${prompt.slice(0, 3000)}`,
|
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' },
|
tool_choice: { type: 'image_generation' },
|
||||||
}, { headers: { Authorization: `Bearer ${config.ai.routeraiApiKey}` }, timeout: 120_000 });
|
}, { headers: { Authorization: `Bearer ${config.ai.routeraiApiKey}` }, timeout: 120_000 });
|
||||||
const imgCall = (res.data?.output || []).find(o => o.type === 'image_generation_call');
|
const imgCall = (res.data?.output || []).find(o => o.type === 'image_generation_call');
|
||||||
|
|||||||
Reference in New Issue
Block a user