/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The quality tier of the generated image. Higher tiers may incur higher latency or cost. 'auto' lets the gateway pick a sensible value per model. 'standard' and 'hd' are accepted as legacy aliases. */ export const Quality = { Low: "low", Medium: "medium", High: "high", Auto: "auto", Standard: "standard", Hd: "hd", } as const; /** * The quality tier of the generated image. Higher tiers may incur higher latency or cost. 'auto' lets the gateway pick a sensible value per model. 'standard' and 'hd' are accepted as legacy aliases. */ export type Quality = ClosedEnum; /** * The format in which the generated images are returned. 'url' returns a URL to the image, 'b64_json' returns the image as a base64-encoded JSON string. Defaults to 'url'. */ export const ImageGenerationRequestResponseFormat = { Url: "url", B64Json: "b64_json", } as const; /** * The format in which the generated images are returned. 'url' returns a URL to the image, 'b64_json' returns the image as a base64-encoded JSON string. Defaults to 'url'. */ export type ImageGenerationRequestResponseFormat = ClosedEnum< typeof ImageGenerationRequestResponseFormat >; /** * The size of the generated image. 'auto' defers to the model's default. */ export const Size = { TwoHundredAndFiftySixx256: "256x256", FiveHundredAndTwelvex512: "512x512", OneThousandAndTwentyFourx1024: "1024x1024", OneThousandAndTwentyFourx1536: "1024x1536", OneThousandFiveHundredAndThirtySixx1024: "1536x1024", OneThousandSevenHundredAndNinetyTwox1024: "1792x1024", OneThousandAndTwentyFourx1792: "1024x1792", Auto: "auto", } as const; /** * The size of the generated image. 'auto' defers to the model's default. */ export type Size = ClosedEnum; /** * The style of the generated image. 'vivid' leans toward hyper-real and dramatic. 'natural' produces more naturalistic results. Conditionally supported. */ export const Style = { Vivid: "vivid", Natural: "natural", } as const; /** * The style of the generated image. 'vivid' leans toward hyper-real and dramatic. 'natural' produces more naturalistic results. Conditionally supported. */ export type Style = ClosedEnum; /** * Output file format. Conditionally supported. */ export const OutputFormat = { Png: "png", Webp: "webp", Jpeg: "jpeg", } as const; /** * Output file format. Conditionally supported. */ export type OutputFormat = ClosedEnum; /** * Request parameters for generating images. Creates one or more images from a text prompt. */ export type ImageGenerationRequest = { /** * The model to use for image generation. Defaults to 'auto'. */ model?: string | undefined; /** * A text description of the desired image(s). The maximum length is 1000 characters. */ prompt: string; /** * The number of images to generate. Must be between 1 and 10. Defaults to 1. */ n?: number | undefined; /** * The quality tier of the generated image. Higher tiers may incur higher latency or cost. 'auto' lets the gateway pick a sensible value per model. 'standard' and 'hd' are accepted as legacy aliases. */ quality?: Quality | undefined; /** * The format in which the generated images are returned. 'url' returns a URL to the image, 'b64_json' returns the image as a base64-encoded JSON string. Defaults to 'url'. */ responseFormat?: ImageGenerationRequestResponseFormat | undefined; /** * The size of the generated image. 'auto' defers to the model's default. */ size?: Size | undefined; /** * The style of the generated image. 'vivid' leans toward hyper-real and dramatic. 'natural' produces more naturalistic results. Conditionally supported. */ style?: Style | undefined; /** * Output file format. Conditionally supported. */ outputFormat?: OutputFormat | undefined; /** * A unique identifier representing your end-user, which can help monitor and detect abuse. */ user?: string | undefined; }; /** @internal */ export const Quality$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Quality); /** @internal */ export const Quality$outboundSchema: z.ZodNativeEnum = Quality$inboundSchema; /** @internal */ export const ImageGenerationRequestResponseFormat$inboundSchema: z.ZodNativeEnum = z.nativeEnum( ImageGenerationRequestResponseFormat, ); /** @internal */ export const ImageGenerationRequestResponseFormat$outboundSchema: z.ZodNativeEnum = ImageGenerationRequestResponseFormat$inboundSchema; /** @internal */ export const Size$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Size, ); /** @internal */ export const Size$outboundSchema: z.ZodNativeEnum = Size$inboundSchema; /** @internal */ export const Style$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Style, ); /** @internal */ export const Style$outboundSchema: z.ZodNativeEnum = Style$inboundSchema; /** @internal */ export const OutputFormat$inboundSchema: z.ZodNativeEnum = z.nativeEnum(OutputFormat); /** @internal */ export const OutputFormat$outboundSchema: z.ZodNativeEnum = OutputFormat$inboundSchema; /** @internal */ export const ImageGenerationRequest$inboundSchema: z.ZodType< ImageGenerationRequest, z.ZodTypeDef, unknown > = z.object({ model: z.string().default("auto"), prompt: z.string(), n: z.number().int().default(1), quality: Quality$inboundSchema.default("auto"), response_format: ImageGenerationRequestResponseFormat$inboundSchema.default( "url", ), size: Size$inboundSchema.default("1024x1024"), style: Style$inboundSchema.default("vivid"), output_format: OutputFormat$inboundSchema.optional(), user: z.string().optional(), }).transform((v) => { return remap$(v, { "response_format": "responseFormat", "output_format": "outputFormat", }); }); /** @internal */ export type ImageGenerationRequest$Outbound = { model: string; prompt: string; n: number; quality: string; response_format: string; size: string; style: string; output_format?: string | undefined; user?: string | undefined; }; /** @internal */ export const ImageGenerationRequest$outboundSchema: z.ZodType< ImageGenerationRequest$Outbound, z.ZodTypeDef, ImageGenerationRequest > = z.object({ model: z.string().default("auto"), prompt: z.string(), n: z.number().int().default(1), quality: Quality$outboundSchema.default("auto"), responseFormat: ImageGenerationRequestResponseFormat$outboundSchema.default( "url", ), size: Size$outboundSchema.default("1024x1024"), style: Style$outboundSchema.default("vivid"), outputFormat: OutputFormat$outboundSchema.optional(), user: z.string().optional(), }).transform((v) => { return remap$(v, { responseFormat: "response_format", outputFormat: "output_format", }); }); export function imageGenerationRequestToJSON( imageGenerationRequest: ImageGenerationRequest, ): string { return JSON.stringify( ImageGenerationRequest$outboundSchema.parse(imageGenerationRequest), ); } export function imageGenerationRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ImageGenerationRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ImageGenerationRequest' from JSON`, ); }