/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * An individual image object in the response. */ export type ImageGenerationResponseData = { /** * The URL of the generated image, if response_format is 'url' (default). The URL is valid for 1 hour. */ url?: string | undefined; /** * The base64-encoded JSON of the generated image, if response_format is 'b64_json'. */ b64Json?: string | undefined; /** * The prompt that was used to generate the image, if there was any revision to the prompt. */ revisedPrompt?: string | undefined; }; /** * Response from the image generation endpoint containing the generated images and metadata. */ export type ImageGenerationResponse = { /** * The Unix timestamp (in seconds) of when the image generation was completed. */ created: number; /** * A list of image objects containing the generated image data. */ data: Array; }; /** @internal */ export const ImageGenerationResponseData$inboundSchema: z.ZodType< ImageGenerationResponseData, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), b64_json: z.string().optional(), revised_prompt: z.string().optional(), }).transform((v) => { return remap$(v, { "b64_json": "b64Json", "revised_prompt": "revisedPrompt", }); }); /** @internal */ export type ImageGenerationResponseData$Outbound = { url?: string | undefined; b64_json?: string | undefined; revised_prompt?: string | undefined; }; /** @internal */ export const ImageGenerationResponseData$outboundSchema: z.ZodType< ImageGenerationResponseData$Outbound, z.ZodTypeDef, ImageGenerationResponseData > = z.object({ url: z.string().optional(), b64Json: z.string().optional(), revisedPrompt: z.string().optional(), }).transform((v) => { return remap$(v, { b64Json: "b64_json", revisedPrompt: "revised_prompt", }); }); export function imageGenerationResponseDataToJSON( imageGenerationResponseData: ImageGenerationResponseData, ): string { return JSON.stringify( ImageGenerationResponseData$outboundSchema.parse( imageGenerationResponseData, ), ); } export function imageGenerationResponseDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ImageGenerationResponseData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ImageGenerationResponseData' from JSON`, ); } /** @internal */ export const ImageGenerationResponse$inboundSchema: z.ZodType< ImageGenerationResponse, z.ZodTypeDef, unknown > = z.object({ created: z.number(), data: z.array(z.lazy(() => ImageGenerationResponseData$inboundSchema)), }); /** @internal */ export type ImageGenerationResponse$Outbound = { created: number; data: Array; }; /** @internal */ export const ImageGenerationResponse$outboundSchema: z.ZodType< ImageGenerationResponse$Outbound, z.ZodTypeDef, ImageGenerationResponse > = z.object({ created: z.number(), data: z.array(z.lazy(() => ImageGenerationResponseData$outboundSchema)), }); export function imageGenerationResponseToJSON( imageGenerationResponse: ImageGenerationResponse, ): string { return JSON.stringify( ImageGenerationResponse$outboundSchema.parse(imageGenerationResponse), ); } export function imageGenerationResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ImageGenerationResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ImageGenerationResponse' from JSON`, ); }