diff --git a/packages/ai/src/types/enums.ts b/packages/ai/src/types/enums.ts index cd7029df3b0..32cd3027fe8 100644 --- a/packages/ai/src/types/enums.ts +++ b/packages/ai/src/types/enums.ts @@ -238,7 +238,28 @@ export const FinishReason = { /** * The function call generated by the model was invalid. */ - MALFORMED_FUNCTION_CALL: 'MALFORMED_FUNCTION_CALL' + MALFORMED_FUNCTION_CALL: 'MALFORMED_FUNCTION_CALL', + /** + * Image generation stopped due to safety settings. + */ + IMAGE_SAFETY: 'IMAGE_SAFETY', + /** + * Image generation stopped because generated images has other prohibited + * content. + */ + IMAGE_PROHIBITED_CONTENT: 'IMAGE_PROHIBITED_CONTENT', + /** + * Image generation stopped due to recitation. + */ + IMAGE_RECITATION: 'IMAGE_RECITATION', + /** + * Image generation stopped because of other miscellaneous issue. + */ + IMAGE_OTHER: 'IMAGE_OTHER', + /** + * The model was expected to generate an image, but none was generated. + */ + NO_IMAGE: 'NO_IMAGE' } as const; /** @@ -414,3 +435,56 @@ export const Language = { * @beta */ export type Language = (typeof Language)[keyof typeof Language]; + +/** + * Aspect ratios for generated images. + * @public + */ +export const AspectRatio = { + /** + * Square (1:1) aspect ratio. + */ + SQUARE_1x1: '1:1', + /** + * Portrait (2:3) aspect ratio. + */ + PORTRAIT_2x3: '2:3', + /** + * Landscape (3:2) aspect ratio. + */ + LANDSCAPE_3x2: '3:2', + /** + * Portrait (3:4) aspect ratio. + */ + PORTRAIT_3x4: '3:4', + /** + * Landscape (4:3) aspect ratio. + */ + LANDSCAPE_4x3: '4:3', + /** + * Portrait (4:5) aspect ratio. + */ + PORTRAIT_4x5: '4:5', + /** + * Landscape (5:4) aspect ratio. + */ + LANDSCAPE_5x4: '5:4', + /** + * Portrait (9:16) aspect ratio. + */ + PORTRAIT_9x16: '9:16', + /** + * Landscape (16:9) aspect ratio. + */ + LANDSCAPE_16x9: '16:9', + /** + * Landscape (21:9) aspect ratio. + */ + LANDSCAPE_21x9: '21:9' +} as const; + +/** + * Aspect ratios for generated images. + * @public + */ +export type AspectRatio = (typeof AspectRatio)[keyof typeof AspectRatio]; diff --git a/packages/ai/src/types/requests.ts b/packages/ai/src/types/requests.ts index 1e5fa367420..277ccc848bf 100644 --- a/packages/ai/src/types/requests.ts +++ b/packages/ai/src/types/requests.ts @@ -22,6 +22,7 @@ import { LanguageModelPromptOptions } from './language-model'; import { + AspectRatio, FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, @@ -133,6 +134,12 @@ export interface GenerationConfig { * Configuration for "thinking" behavior of compatible Gemini models. */ thinkingConfig?: ThinkingConfig; + /** + * Configuration for image generation. + * + * @beta + */ + imageConfig?: ImageConfig; } /** @@ -441,6 +448,17 @@ export interface ThinkingConfig { includeThoughts?: boolean; } +/** + * Configuration for image generation. + * @public + */ +export interface ImageConfig { + /** + * The aspect ratio of the generated images. + */ + aspectRatio?: AspectRatio; +} + /** * Configuration for a pre-built voice. *