diff --git a/packages/ai/src/types/enums.ts b/packages/ai/src/types/enums.ts index cd7029df3b..3cc6b04955 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,72 @@ 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]; + +/** + * Specifies the size of generated images. + * @public + */ +export const ImageSize = { + 'SIZE_1K': '1K', + 'SIZE_2K': '2K', + 'SIZE_4K': '4K', +} as const; + +/** + * Specifies the size of generated images. + * @public + */ +export type ImageSize = (typeof ImageSize)[keyof typeof ImageSize]; diff --git a/packages/ai/src/types/requests.ts b/packages/ai/src/types/requests.ts index 1e5fa36742..a7bfa2ed81 100644 --- a/packages/ai/src/types/requests.ts +++ b/packages/ai/src/types/requests.ts @@ -22,10 +22,12 @@ import { LanguageModelPromptOptions } from './language-model'; import { + AspectRatio, FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, + ImageSize, InferenceMode, ResponseModality } from './enums'; @@ -133,6 +135,12 @@ export interface GenerationConfig { * Configuration for "thinking" behavior of compatible Gemini models. */ thinkingConfig?: ThinkingConfig; + /** + * Configuration for image generation. + * + * @beta + */ + imageConfig?: ImageConfig; } /** @@ -441,6 +449,22 @@ export interface ThinkingConfig { includeThoughts?: boolean; } +/** + * Configuration for image generation. + * @public + */ +export interface ImageConfig { + /** + * The aspect ratio of the generated images. + */ + aspectRatio?: AspectRatio; + + /** + * The size of generated images.. + */ + imageSize?: ImageSize; +} + /** * Configuration for a pre-built voice. *