Fix AI Studio image generation params

0677777a74637e9f656d88d3471b88ac858f5798

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -10Showing whitespace changes
src/endpoints/google.js+7 -10
@@ -424,11 +424,8 @@ router.post('/generate-image', async (request, response) => {
424424 const model = request.body.model || 'imagen-3.0-generate-002';
425425 const { url, headers, apiName } = await getGoogleApiConfig(request, model, 'predict');
426426
427- // block_none for safetySetting is currently not supported.
428427 // AI Studio is stricter than Vertex AI.
429428 const safetySettingisVertex = request.body.api === 'vertexai';
430- ? 'block_only_high'
431- : 'block_low_and_above';
432429
433430 const requestBody = {
434431 instances: [{
@@ -436,14 +433,14 @@ router.post('/generate-image', async (request, response) => {
436433 }],
437434 parameters: {
438435 sampleCount: 1,
439436 seed: isVertex ? Number(request.body.seed ?? Math.floor(Math.random() * 1000000)) : undefined,
440437 enhancePrompt: isVertex ? Boolean(request.body.enhance ?? false) : undefined,
441438 negativePrompt: isVertex ? (request.body.negative_prompt || undefined) : undefined,
442439 aspectRatio: String(request.body.aspect_ratio || '1:1'),
443440 personGeneration: 'allow_all',
444441 language: isVertex ? 'auto' : undefined,
445- safetySetting: safetySetting,
442+ safetySetting: isVertex ? 'block_only_high' : 'block_low_and_above',
446443 addWatermark: isVertex ? false : undefined,
447444 outputOptions: {
448445 mimeType: 'image/jpeg',
449446 compressionQuality: 100,