MCPcopy Create free account
hub / github.com/TanStack/ai / validateImageSize

Function validateImageSize

packages/ai-gemini/src/image/image-provider-options.ts:241–256  ·  view source on GitHub ↗
(
  model: string,
  size: string | undefined,
)

Source from the content-addressed store, hash-verified

239 * Throws an error if the size is invalid
240 */
241export function validateImageSize(
242 model: string,
243 size: string | undefined,
244): void {
245 if (!size) return
246
247 const aspectRatio = sizeToAspectRatio(size)
248 if (!aspectRatio) {
249 const validSizes = Object.keys(GEMINI_SIZE_TO_ASPECT_RATIO)
250 throw new Error(
251 `Invalid size "${size}" for model "${model}". ` +
252 `Gemini Imagen uses aspect ratios. Valid sizes that map to aspect ratios: ${validSizes.join(', ')}. ` +
253 `Alternatively, use providerOptions.aspectRatio directly with values: 1:1, 3:4, 4:3, 9:16, 16:9, 9:21, 21:9`,
254 )
255 }
256}
257
258/**
259 * Per-model caps on images per request.

Callers 2

generateImagesMethod · 0.90

Calls 1

sizeToAspectRatioFunction · 0.85

Tested by

no test coverage detected