/* * 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 ControlImage = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type BodyControlNetGen = { /** * The control image to use as guidance. */ controlImage: ControlImage | Blob; /** * The text prompt to guide the image transformation. */ prompt: string; /** * Configuration scale for the image diffusion process. */ cfgScale?: number | undefined; /** * The scale of conditioning for the control image. */ conditioningScale?: number | undefined; /** * The name of the ControlNet model to use. */ controlNetName?: string | undefined; /** * The height of the generated image. */ height?: number | undefined; /** * The text prompt to guide the image transformation. */ negativePrompt?: 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 ControlImage$inboundSchema: z.ZodType< ControlImage, 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 ControlImage$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const ControlImage$outboundSchema: z.ZodType< ControlImage$Outbound, z.ZodTypeDef, ControlImage > = 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 ControlImage$ { /** @deprecated use `ControlImage$inboundSchema` instead. */ export const inboundSchema = ControlImage$inboundSchema; /** @deprecated use `ControlImage$outboundSchema` instead. */ export const outboundSchema = ControlImage$outboundSchema; /** @deprecated use `ControlImage$Outbound` instead. */ export type Outbound = ControlImage$Outbound; } export function controlImageToJSON(controlImage: ControlImage): string { return JSON.stringify(ControlImage$outboundSchema.parse(controlImage)); } export function controlImageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ControlImage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ControlImage' from JSON`, ); } /** @internal */ export const BodyControlNetGen$inboundSchema: z.ZodType< BodyControlNetGen, z.ZodTypeDef, unknown > = z.object({ control_image: z.lazy(() => ControlImage$inboundSchema), prompt: z.string(), cfg_scale: z.number().optional(), conditioning_scale: z.number().optional(), control_net_name: z.string().optional(), height: z.number().int().optional(), negative_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, { "control_image": "controlImage", "cfg_scale": "cfgScale", "conditioning_scale": "conditioningScale", "control_net_name": "controlNetName", "negative_prompt": "negativePrompt", "safety_check": "safetyCheck", "step_schedule_end": "stepScheduleEnd", "step_schedule_start": "stepScheduleStart", }); }); /** @internal */ export type BodyControlNetGen$Outbound = { control_image: ControlImage$Outbound | Blob; prompt: string; cfg_scale?: number | undefined; conditioning_scale?: number | undefined; control_net_name?: string | undefined; height?: number | undefined; negative_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 BodyControlNetGen$outboundSchema: z.ZodType< BodyControlNetGen$Outbound, z.ZodTypeDef, BodyControlNetGen > = z.object({ controlImage: z.lazy(() => ControlImage$outboundSchema).or(blobLikeSchema), prompt: z.string(), cfgScale: z.number().optional(), conditioningScale: z.number().optional(), controlNetName: z.string().optional(), height: z.number().int().optional(), negativePrompt: 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, { controlImage: "control_image", cfgScale: "cfg_scale", conditioningScale: "conditioning_scale", controlNetName: "control_net_name", 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 BodyControlNetGen$ { /** @deprecated use `BodyControlNetGen$inboundSchema` instead. */ export const inboundSchema = BodyControlNetGen$inboundSchema; /** @deprecated use `BodyControlNetGen$outboundSchema` instead. */ export const outboundSchema = BodyControlNetGen$outboundSchema; /** @deprecated use `BodyControlNetGen$Outbound` instead. */ export type Outbound = BodyControlNetGen$Outbound; } export function bodyControlNetGenToJSON( bodyControlNetGen: BodyControlNetGen, ): string { return JSON.stringify( BodyControlNetGen$outboundSchema.parse(bodyControlNetGen), ); } export function bodyControlNetGenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BodyControlNetGen$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyControlNetGen' from JSON`, ); }