/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { blobLikeSchema } from "../types/blobs.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type InitImage = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type BodyImage2imageGen = { /** * The initial image to transform. */ initImage: InitImage | Blob; /** * Configuration scale for the image diffusion process. */ cfgScale?: number | undefined; /** * The height of the generated image. */ height?: number | undefined; /** * The strength of the initial image. */ imageStrength?: number | undefined; /** * The mode for initializing the image transformation process. */ initImageMode?: string | undefined; /** * The text prompt to guide the image transformation. */ negativePrompt?: string | undefined; /** * The text prompt to guide the image transformation. */ prompt?: string | undefined; /** * Enable a safety check for each response. */ safetyCheck?: boolean | undefined; /** * The sampler to use for the image generation process. */ sampler?: string | undefined; /** * The number of samples to generate. */ samples?: number | undefined; /** * Random noise seed (omit this option or use `0` for a random seed). */ seed?: number | undefined; /** * The end value for the step schedule. */ stepScheduleEnd?: number | undefined; /** * The start value for the step schedule. */ stepScheduleStart?: number | undefined; /** * Number of diffusion steps to run. */ steps?: number | undefined; /** * The width of the generated image. */ width?: number | undefined; }; /** @internal */ export const InitImage$inboundSchema: z.ZodType< InitImage, z.ZodTypeDef, unknown > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type InitImage$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const InitImage$outboundSchema: z.ZodType< InitImage$Outbound, z.ZodTypeDef, InitImage > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InitImage$ { /** @deprecated use `InitImage$inboundSchema` instead. */ export const inboundSchema = InitImage$inboundSchema; /** @deprecated use `InitImage$outboundSchema` instead. */ export const outboundSchema = InitImage$outboundSchema; /** @deprecated use `InitImage$Outbound` instead. */ export type Outbound = InitImage$Outbound; } export function initImageToJSON(initImage: InitImage): string { return JSON.stringify(InitImage$outboundSchema.parse(initImage)); } export function initImageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InitImage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InitImage' from JSON`, ); } /** @internal */ export const BodyImage2imageGen$inboundSchema: z.ZodType< BodyImage2imageGen, z.ZodTypeDef, unknown > = z.object({ init_image: z.lazy(() => InitImage$inboundSchema), cfg_scale: z.number().optional(), height: z.number().int().optional(), image_strength: z.number().optional(), init_image_mode: z.string().optional(), negative_prompt: z.string().optional(), prompt: z.string().optional(), safety_check: z.boolean().optional(), sampler: z.string().optional(), samples: z.number().int().optional(), seed: z.number().int().optional(), step_schedule_end: z.number().optional(), step_schedule_start: z.number().optional(), steps: z.number().int().optional(), width: z.number().int().optional(), }).transform((v) => { return remap$(v, { "init_image": "initImage", "cfg_scale": "cfgScale", "image_strength": "imageStrength", "init_image_mode": "initImageMode", "negative_prompt": "negativePrompt", "safety_check": "safetyCheck", "step_schedule_end": "stepScheduleEnd", "step_schedule_start": "stepScheduleStart", }); }); /** @internal */ export type BodyImage2imageGen$Outbound = { init_image: InitImage$Outbound | Blob; cfg_scale?: number | undefined; height?: number | undefined; image_strength?: number | undefined; init_image_mode?: string | undefined; negative_prompt?: string | undefined; prompt?: string | undefined; safety_check?: boolean | undefined; sampler?: string | undefined; samples?: number | undefined; seed?: number | undefined; step_schedule_end?: number | undefined; step_schedule_start?: number | undefined; steps?: number | undefined; width?: number | undefined; }; /** @internal */ export const BodyImage2imageGen$outboundSchema: z.ZodType< BodyImage2imageGen$Outbound, z.ZodTypeDef, BodyImage2imageGen > = z.object({ initImage: z.lazy(() => InitImage$outboundSchema).or(blobLikeSchema), cfgScale: z.number().optional(), height: z.number().int().optional(), imageStrength: z.number().optional(), initImageMode: z.string().optional(), negativePrompt: z.string().optional(), prompt: z.string().optional(), safetyCheck: z.boolean().optional(), sampler: z.string().optional(), samples: z.number().int().optional(), seed: z.number().int().optional(), stepScheduleEnd: z.number().optional(), stepScheduleStart: z.number().optional(), steps: z.number().int().optional(), width: z.number().int().optional(), }).transform((v) => { return remap$(v, { initImage: "init_image", cfgScale: "cfg_scale", imageStrength: "image_strength", initImageMode: "init_image_mode", negativePrompt: "negative_prompt", safetyCheck: "safety_check", stepScheduleEnd: "step_schedule_end", stepScheduleStart: "step_schedule_start", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BodyImage2imageGen$ { /** @deprecated use `BodyImage2imageGen$inboundSchema` instead. */ export const inboundSchema = BodyImage2imageGen$inboundSchema; /** @deprecated use `BodyImage2imageGen$outboundSchema` instead. */ export const outboundSchema = BodyImage2imageGen$outboundSchema; /** @deprecated use `BodyImage2imageGen$Outbound` instead. */ export type Outbound = BodyImage2imageGen$Outbound; } export function bodyImage2imageGenToJSON( bodyImage2imageGen: BodyImage2imageGen, ): string { return JSON.stringify( BodyImage2imageGen$outboundSchema.parse(bodyImage2imageGen), ); } export function bodyImage2imageGenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BodyImage2imageGen$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyImage2imageGen' from JSON`, ); }