import {z} from 'zod' export type CreateApiGenerateVideoMinimaxH3MaxCameraControlsArgs = {'X-Webhook-URL'?: string | undefined, body: {prompt: string, start_image: string, resolution?: ('480p' | '768p' | '1080p') | undefined, duration?: number | undefined, seed?: number | undefined, prompt_expansion_mode?: ('balanced' | 'quality') | undefined, camera_trajectory: Array<{time: number, distance: number, azimuth: number, elevation: number}>}}; export type CreateApiGenerateVideoMinimaxH3MaxCameraControlsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiGenerateVideoMinimaxH3MaxCameraControlsResponse = z.object({job_id: z.string(), status: z.enum(["backlogged", "queued", "scheduled", "processing", "sampling", "intermediate-complete", "completed", "failed", "cancelled"]), created_at: z.string(), completed_at: z.unknown(), result: z.unknown(), error: z.object({code: z.string(), message: z.string().optional(), param: z.string().optional()}).optional(), progress: z.number().gte(0).lte(1).nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * minimax_h3max_camera * * POST /generate/video/minimax/h3-max-camera-controls */ export const createApiGenerateVideoMinimaxH3MaxCameraControls = async (args: CreateApiGenerateVideoMinimaxH3MaxCameraControlsArgs, options?: CreateApiGenerateVideoMinimaxH3MaxCameraControlsOptions) => { const {baseUrl = "https://api.krea.ai", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Webhook-URL'] != null) headers.set("X-Webhook-URL", String(args['X-Webhook-URL'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/generate/video/minimax/h3-max-camera-controls${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiGenerateVideoMinimaxH3MaxCameraControlsResponse, await res.json()) };