@apicity/kie 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +569 -0
- package/dist/src/chat.d.ts +56 -0
- package/dist/src/chat.d.ts.map +1 -0
- package/dist/src/chat.js +75 -0
- package/dist/src/chat.js.map +1 -0
- package/dist/src/claude.d.ts +76 -0
- package/dist/src/claude.d.ts.map +1 -0
- package/dist/src/claude.js +83 -0
- package/dist/src/claude.js.map +1 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +186 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +14 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/kie.d.ts +5 -0
- package/dist/src/kie.d.ts.map +1 -0
- package/dist/src/kie.js +388 -0
- package/dist/src/kie.js.map +1 -0
- package/dist/src/middleware.d.ts +34 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +219 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/model-schemas.d.ts +3 -0
- package/dist/src/model-schemas.d.ts.map +1 -0
- package/dist/src/model-schemas.js +1172 -0
- package/dist/src/model-schemas.js.map +1 -0
- package/dist/src/request.d.ts +9 -0
- package/dist/src/request.d.ts.map +1 -0
- package/dist/src/request.js +46 -0
- package/dist/src/request.js.map +1 -0
- package/dist/src/sse.d.ts +2 -0
- package/dist/src/sse.d.ts.map +1 -0
- package/dist/src/sse.js +41 -0
- package/dist/src/sse.js.map +1 -0
- package/dist/src/suno.d.ts +313 -0
- package/dist/src/suno.d.ts.map +1 -0
- package/dist/src/suno.js +391 -0
- package/dist/src/suno.js.map +1 -0
- package/dist/src/types.d.ts +119 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/veo.d.ts +52 -0
- package/dist/src/veo.d.ts.map +1 -0
- package/dist/src/veo.js +40 -0
- package/dist/src/veo.js.map +1 -0
- package/dist/src/zod.d.ts +1982 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +866 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +61 -0
package/dist/src/zod.js
ADDED
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Enums / named union types
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export const KieMediaModelSchema = z.enum([
|
|
6
|
+
"kling-3.0/video",
|
|
7
|
+
"kling-3.0/motion-control",
|
|
8
|
+
"grok-imagine/text-to-image",
|
|
9
|
+
"grok-imagine/image-to-image",
|
|
10
|
+
"grok-imagine/text-to-video",
|
|
11
|
+
"grok-imagine/image-to-video",
|
|
12
|
+
"nano-banana-pro",
|
|
13
|
+
"nano-banana-2",
|
|
14
|
+
"gpt-image/1.5-image-to-image",
|
|
15
|
+
"gpt-image-2-image-to-image",
|
|
16
|
+
"gpt-image-2-text-to-image",
|
|
17
|
+
"seedream/5-lite-image-to-image",
|
|
18
|
+
"seedream/5-lite-text-to-image",
|
|
19
|
+
"grok-imagine/extend",
|
|
20
|
+
"grok-imagine/upscale",
|
|
21
|
+
"qwen2/text-to-image",
|
|
22
|
+
"qwen2/image-edit",
|
|
23
|
+
"bytedance/seedance-2-fast",
|
|
24
|
+
"bytedance/seedance-2",
|
|
25
|
+
"wan/2-7-image-to-video",
|
|
26
|
+
"wan/2-7-text-to-video",
|
|
27
|
+
"wan/2-7-r2v",
|
|
28
|
+
"wan/2-7-videoedit",
|
|
29
|
+
"wan/2-7-image",
|
|
30
|
+
"wan/2-7-image-pro",
|
|
31
|
+
"happyhorse/text-to-video",
|
|
32
|
+
"happyhorse/image-to-video",
|
|
33
|
+
"happyhorse/reference-to-video",
|
|
34
|
+
"happyhorse/video-edit",
|
|
35
|
+
"sora-watermark-remover",
|
|
36
|
+
]);
|
|
37
|
+
export const MediaTypeSchema = z.enum([
|
|
38
|
+
"image",
|
|
39
|
+
"video",
|
|
40
|
+
"audio",
|
|
41
|
+
"transcription",
|
|
42
|
+
]);
|
|
43
|
+
export const KlingDurationSchema = z.enum([
|
|
44
|
+
"3",
|
|
45
|
+
"4",
|
|
46
|
+
"5",
|
|
47
|
+
"6",
|
|
48
|
+
"7",
|
|
49
|
+
"8",
|
|
50
|
+
"9",
|
|
51
|
+
"10",
|
|
52
|
+
"11",
|
|
53
|
+
"12",
|
|
54
|
+
"13",
|
|
55
|
+
"14",
|
|
56
|
+
"15",
|
|
57
|
+
]);
|
|
58
|
+
export const KlingAspectRatioSchema = z.enum(["16:9", "9:16", "1:1"]);
|
|
59
|
+
export const KlingModeSchema = z.enum(["std", "pro", "4K"]);
|
|
60
|
+
export const GrokImagineModeSchema = z.enum(["fun", "normal", "spicy"]);
|
|
61
|
+
export const GrokImagineDurationSchema = z.enum(["6", "10"]);
|
|
62
|
+
export const GrokImagineResolutionSchema = z.enum(["480p", "720p"]);
|
|
63
|
+
export const NanoBananaResolutionSchema = z.enum(["1K", "2K", "4K"]);
|
|
64
|
+
export const NanoBananaOutputFormatSchema = z.enum(["png", "jpg"]);
|
|
65
|
+
export const GptImageQualitySchema = z.enum(["medium", "high"]);
|
|
66
|
+
export const Qwen2ImageSizeSchema = z.enum([
|
|
67
|
+
"square",
|
|
68
|
+
"square_hd",
|
|
69
|
+
"portrait_4_3",
|
|
70
|
+
"portrait_16_9",
|
|
71
|
+
"landscape_4_3",
|
|
72
|
+
"landscape_16_9",
|
|
73
|
+
]);
|
|
74
|
+
export const Qwen2AccelerationSchema = z.enum(["none", "regular", "high"]);
|
|
75
|
+
export const Wan27ResolutionSchema = z.enum(["720p", "1080p"]);
|
|
76
|
+
export const Wan27AspectRatioSchema = z.enum([
|
|
77
|
+
"16:9",
|
|
78
|
+
"9:16",
|
|
79
|
+
"1:1",
|
|
80
|
+
"4:3",
|
|
81
|
+
"3:4",
|
|
82
|
+
]);
|
|
83
|
+
export const Wan27AudioSettingSchema = z.enum(["auto", "origin"]);
|
|
84
|
+
export const Wan27ImageResolutionSchema = z.enum(["1K", "2K", "4K"]);
|
|
85
|
+
export const Wan27ImageAspectRatioSchema = z.enum([
|
|
86
|
+
"1:1",
|
|
87
|
+
"16:9",
|
|
88
|
+
"4:3",
|
|
89
|
+
"21:9",
|
|
90
|
+
"3:4",
|
|
91
|
+
"9:16",
|
|
92
|
+
"8:1",
|
|
93
|
+
"1:8",
|
|
94
|
+
]);
|
|
95
|
+
export const HappyHorseResolutionSchema = z.enum(["720p", "1080p"]);
|
|
96
|
+
export const HappyHorseAspectRatioSchema = z.enum([
|
|
97
|
+
"16:9",
|
|
98
|
+
"9:16",
|
|
99
|
+
"1:1",
|
|
100
|
+
"4:3",
|
|
101
|
+
"3:4",
|
|
102
|
+
]);
|
|
103
|
+
export const HappyHorseAudioSettingSchema = z.enum(["auto", "origin"]);
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Sub-schemas (composable building blocks)
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
export const KlingElementSchema = z.object({
|
|
108
|
+
name: z.string().min(1),
|
|
109
|
+
description: z.string().min(1),
|
|
110
|
+
element_input_urls: z.array(z.string()).optional(),
|
|
111
|
+
element_input_video_urls: z.array(z.string()).optional(),
|
|
112
|
+
});
|
|
113
|
+
export const MultiShotPromptSchema = z.object({
|
|
114
|
+
prompt: z.string().min(1).max(500),
|
|
115
|
+
duration: z.number().int().min(1).max(12),
|
|
116
|
+
});
|
|
117
|
+
export const Wan27ImageColorPaletteSchema = z.object({
|
|
118
|
+
hex: z.string().min(1),
|
|
119
|
+
ratio: z.string().min(1),
|
|
120
|
+
});
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// Media request schemas
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
export const KlingVideoRequestSchema = z.object({
|
|
125
|
+
model: z.literal("kling-3.0/video"),
|
|
126
|
+
callBackUrl: z.string().optional(),
|
|
127
|
+
input: z.object({
|
|
128
|
+
prompt: z.string().optional(),
|
|
129
|
+
image_urls: z.array(z.string()).optional(),
|
|
130
|
+
sound: z.boolean(),
|
|
131
|
+
duration: KlingDurationSchema,
|
|
132
|
+
aspect_ratio: KlingAspectRatioSchema.optional(),
|
|
133
|
+
mode: KlingModeSchema,
|
|
134
|
+
multi_shots: z.boolean(),
|
|
135
|
+
multi_prompt: z.array(MultiShotPromptSchema).optional(),
|
|
136
|
+
kling_elements: z.array(KlingElementSchema).max(3).optional(),
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
139
|
+
export const KlingMotionControlRequestSchema = z.object({
|
|
140
|
+
model: z.literal("kling-3.0/motion-control"),
|
|
141
|
+
callBackUrl: z.string().optional(),
|
|
142
|
+
input: z.object({
|
|
143
|
+
prompt: z.string().optional(),
|
|
144
|
+
input_urls: z.array(z.string()).min(1).max(1),
|
|
145
|
+
video_urls: z.array(z.string()).min(1),
|
|
146
|
+
mode: z.enum(["720p", "1080p"]).optional(),
|
|
147
|
+
character_orientation: z.enum(["video", "image"]).optional(),
|
|
148
|
+
background_source: z.enum(["input_video", "input_image"]).optional(),
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
export const GrokTextToImageRequestSchema = z.object({
|
|
152
|
+
model: z.literal("grok-imagine/text-to-image"),
|
|
153
|
+
callBackUrl: z.string().optional(),
|
|
154
|
+
input: z.object({
|
|
155
|
+
prompt: z.string().min(1).max(5000),
|
|
156
|
+
aspect_ratio: z.enum(["2:3", "3:2", "1:1", "16:9", "9:16"]).default("16:9"),
|
|
157
|
+
nsfw_checker: z.boolean().default(false),
|
|
158
|
+
enable_pro: z.boolean().optional(),
|
|
159
|
+
}),
|
|
160
|
+
});
|
|
161
|
+
export const Qwen2TextToImageRequestSchema = z.object({
|
|
162
|
+
model: z.literal("qwen2/text-to-image"),
|
|
163
|
+
callBackUrl: z.string().optional(),
|
|
164
|
+
input: z.object({
|
|
165
|
+
prompt: z.string().min(1),
|
|
166
|
+
image_size: Qwen2ImageSizeSchema.optional(),
|
|
167
|
+
num_inference_steps: z.number().optional(),
|
|
168
|
+
seed: z.number().optional(),
|
|
169
|
+
guidance_scale: z.number().optional(),
|
|
170
|
+
enable_safety_checker: z.boolean().optional(),
|
|
171
|
+
output_format: z.enum(["png", "jpeg"]).optional(),
|
|
172
|
+
negative_prompt: z.string().optional(),
|
|
173
|
+
acceleration: Qwen2AccelerationSchema.optional(),
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
export const Qwen2ImageEditRequestSchema = z.object({
|
|
177
|
+
model: z.literal("qwen2/image-edit"),
|
|
178
|
+
callBackUrl: z.string().optional(),
|
|
179
|
+
input: z.object({
|
|
180
|
+
prompt: z.string().min(1),
|
|
181
|
+
image_url: z.array(z.string().min(1)).min(1).max(3),
|
|
182
|
+
image_size: z
|
|
183
|
+
.enum(["1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", "21:9"])
|
|
184
|
+
.default("16:9"),
|
|
185
|
+
output_format: z.enum(["png", "jpeg"]).default("png"),
|
|
186
|
+
seed: z.number().optional(),
|
|
187
|
+
nsfw_checker: z.boolean().default(false),
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
export const GrokImageToImageRequestSchema = z.object({
|
|
191
|
+
model: z.literal("grok-imagine/image-to-image"),
|
|
192
|
+
callBackUrl: z.string().optional(),
|
|
193
|
+
input: z.object({
|
|
194
|
+
prompt: z.string().max(390000).optional(),
|
|
195
|
+
image_urls: z.tuple([z.string()]),
|
|
196
|
+
nsfw_checker: z.boolean().default(false),
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
export const GrokTextToVideoRequestSchema = z.object({
|
|
200
|
+
model: z.literal("grok-imagine/text-to-video"),
|
|
201
|
+
callBackUrl: z.string().optional(),
|
|
202
|
+
input: z.object({
|
|
203
|
+
prompt: z.string().min(1).max(5000),
|
|
204
|
+
aspect_ratio: z.enum(["2:3", "3:2", "1:1", "16:9", "9:16"]).optional(),
|
|
205
|
+
mode: GrokImagineModeSchema.optional(),
|
|
206
|
+
duration: z.number().int().min(6).max(30).optional(),
|
|
207
|
+
resolution: GrokImagineResolutionSchema.optional(),
|
|
208
|
+
nsfw_checker: z.boolean().default(false),
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
// Spec types image-to-video duration as a string (e.g. "6"), even though the
|
|
212
|
+
// underlying value is a 6–30 second integer. text-to-video uses a number.
|
|
213
|
+
export const GrokImageToVideoDurationSchema = z
|
|
214
|
+
.string()
|
|
215
|
+
.regex(/^([6-9]|[12][0-9]|30)$/);
|
|
216
|
+
export const GrokImageToVideoRequestSchema = z.object({
|
|
217
|
+
model: z.literal("grok-imagine/image-to-video"),
|
|
218
|
+
callBackUrl: z.string().optional(),
|
|
219
|
+
input: z.object({
|
|
220
|
+
prompt: z.string().max(5000).optional(),
|
|
221
|
+
image_urls: z.array(z.string()).max(7).optional(),
|
|
222
|
+
task_id: z.string().max(100).optional(),
|
|
223
|
+
index: z.number().int().min(0).max(5).optional(),
|
|
224
|
+
mode: GrokImagineModeSchema.optional(),
|
|
225
|
+
duration: GrokImageToVideoDurationSchema.optional(),
|
|
226
|
+
resolution: GrokImagineResolutionSchema.optional(),
|
|
227
|
+
aspect_ratio: z.enum(["2:3", "3:2", "1:1", "16:9", "9:16"]).optional(),
|
|
228
|
+
nsfw_checker: z.boolean().default(false),
|
|
229
|
+
}),
|
|
230
|
+
});
|
|
231
|
+
export const GrokVideoExtendRequestSchema = z.object({
|
|
232
|
+
model: z.literal("grok-imagine/extend"),
|
|
233
|
+
callBackUrl: z.string().optional(),
|
|
234
|
+
input: z.object({
|
|
235
|
+
task_id: z.string().min(1).max(100),
|
|
236
|
+
prompt: z.string().min(1).max(5000),
|
|
237
|
+
extend_at: z.string(),
|
|
238
|
+
extend_times: GrokImagineDurationSchema,
|
|
239
|
+
}),
|
|
240
|
+
});
|
|
241
|
+
export const GrokVideoUpscaleRequestSchema = z.object({
|
|
242
|
+
model: z.literal("grok-imagine/upscale"),
|
|
243
|
+
callBackUrl: z.string().optional(),
|
|
244
|
+
input: z.object({
|
|
245
|
+
task_id: z.string().min(1).max(100),
|
|
246
|
+
}),
|
|
247
|
+
});
|
|
248
|
+
export const NanoBananaProRequestSchema = z.object({
|
|
249
|
+
model: z.literal("nano-banana-pro"),
|
|
250
|
+
callBackUrl: z.string().optional(),
|
|
251
|
+
input: z.object({
|
|
252
|
+
prompt: z.string().min(1),
|
|
253
|
+
image_input: z.array(z.string()).max(8).optional(),
|
|
254
|
+
aspect_ratio: z
|
|
255
|
+
.enum([
|
|
256
|
+
"1:1",
|
|
257
|
+
"2:3",
|
|
258
|
+
"3:2",
|
|
259
|
+
"3:4",
|
|
260
|
+
"4:3",
|
|
261
|
+
"4:5",
|
|
262
|
+
"5:4",
|
|
263
|
+
"9:16",
|
|
264
|
+
"16:9",
|
|
265
|
+
"21:9",
|
|
266
|
+
"auto",
|
|
267
|
+
])
|
|
268
|
+
.default("16:9"),
|
|
269
|
+
resolution: NanoBananaResolutionSchema.default("2K"),
|
|
270
|
+
output_format: NanoBananaOutputFormatSchema.optional(),
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
273
|
+
// Inner input schema kept unrefined so callers can walk `.shape` for slot
|
|
274
|
+
// introspection (see Seedance2InputSchema for full rationale).
|
|
275
|
+
export const Seedance2FastInputSchema = z.object({
|
|
276
|
+
prompt: z.string().min(3).max(20000),
|
|
277
|
+
first_frame_url: z.string().optional(),
|
|
278
|
+
last_frame_url: z.string().optional(),
|
|
279
|
+
reference_image_urls: z.array(z.string()).max(9).optional(),
|
|
280
|
+
reference_video_urls: z.array(z.string()).max(3).optional(),
|
|
281
|
+
reference_audio_urls: z.array(z.string()).max(3).optional(),
|
|
282
|
+
/** @deprecated */
|
|
283
|
+
return_last_frame: z.boolean().optional(),
|
|
284
|
+
generate_audio: z.boolean().optional(),
|
|
285
|
+
resolution: z.enum(["480p", "720p"]).optional(),
|
|
286
|
+
aspect_ratio: z
|
|
287
|
+
.enum(["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "adaptive"])
|
|
288
|
+
.optional(),
|
|
289
|
+
duration: z.number().int().min(4).max(15).default(5),
|
|
290
|
+
web_search: z.boolean().optional(),
|
|
291
|
+
nsfw_checker: z.boolean().default(false),
|
|
292
|
+
});
|
|
293
|
+
const Seedance2FastRequestObjectSchema = z.object({
|
|
294
|
+
model: z.literal("bytedance/seedance-2-fast"),
|
|
295
|
+
callBackUrl: z.string().optional(),
|
|
296
|
+
input: Seedance2FastInputSchema,
|
|
297
|
+
});
|
|
298
|
+
// Mirrors the bytedance/seedance-2 mutual-exclusion rule — fast variant
|
|
299
|
+
// shares the input shape and the same documented constraint that
|
|
300
|
+
// first/last frames and multimodal references are mutually exclusive.
|
|
301
|
+
export const Seedance2FastRequestSchema = Seedance2FastRequestObjectSchema.refine((v) => {
|
|
302
|
+
const hasReference = (v.input.reference_image_urls?.length ?? 0) > 0 ||
|
|
303
|
+
(v.input.reference_video_urls?.length ?? 0) > 0 ||
|
|
304
|
+
(v.input.reference_audio_urls?.length ?? 0) > 0;
|
|
305
|
+
const hasFrame = Boolean(v.input.first_frame_url) || Boolean(v.input.last_frame_url);
|
|
306
|
+
return !(hasReference && hasFrame);
|
|
307
|
+
}, {
|
|
308
|
+
message: "bytedance/seedance-2-fast does not accept reference_image_urls, reference_video_urls, or reference_audio_urls combined with first_frame_url or last_frame_url (these scenarios are mutually exclusive)",
|
|
309
|
+
path: ["input", "reference_image_urls"],
|
|
310
|
+
});
|
|
311
|
+
// Inner input schema kept unrefined so callers (e.g. clipfirst) can walk
|
|
312
|
+
// `.shape` for slot-constraint introspection — wrapping the request in
|
|
313
|
+
// `.refine()` below turns it into ZodEffects and hides `.shape`.
|
|
314
|
+
export const Seedance2InputSchema = z.object({
|
|
315
|
+
prompt: z.string().min(3).max(20000),
|
|
316
|
+
first_frame_url: z.string().optional(),
|
|
317
|
+
last_frame_url: z.string().optional(),
|
|
318
|
+
reference_image_urls: z.array(z.string()).max(9).optional(),
|
|
319
|
+
reference_video_urls: z.array(z.string()).max(3).optional(),
|
|
320
|
+
reference_audio_urls: z.array(z.string()).max(3).optional(),
|
|
321
|
+
/** @deprecated */
|
|
322
|
+
return_last_frame: z.boolean().optional(),
|
|
323
|
+
generate_audio: z.boolean().optional(),
|
|
324
|
+
resolution: z.enum(["480p", "720p", "1080p"]).optional(),
|
|
325
|
+
aspect_ratio: z
|
|
326
|
+
.enum(["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "adaptive"])
|
|
327
|
+
.optional(),
|
|
328
|
+
duration: z.number().int().min(4).max(15).default(5),
|
|
329
|
+
web_search: z.boolean().optional(),
|
|
330
|
+
nsfw_checker: z.boolean().default(false),
|
|
331
|
+
});
|
|
332
|
+
const Seedance2RequestObjectSchema = z.object({
|
|
333
|
+
model: z.literal("bytedance/seedance-2"),
|
|
334
|
+
callBackUrl: z.string().optional(),
|
|
335
|
+
input: Seedance2InputSchema,
|
|
336
|
+
});
|
|
337
|
+
// Per Kie docs, bytedance/seedance-2 has three mutually exclusive scenarios:
|
|
338
|
+
// Image-to-Video (first frame), Image-to-Video (first + last frames), and
|
|
339
|
+
// Multimodal Reference-to-Video (any of reference_image_urls /
|
|
340
|
+
// reference_video_urls / reference_audio_urls). Mixing first/last frames
|
|
341
|
+
// with any reference_* field returns "The reference video and the first
|
|
342
|
+
// and last frames are mutually exclusive, and only one scene can be
|
|
343
|
+
// selected" from createTask. Enforce at the SDK boundary.
|
|
344
|
+
export const Seedance2RequestSchema = Seedance2RequestObjectSchema.refine((v) => {
|
|
345
|
+
const hasReference = (v.input.reference_image_urls?.length ?? 0) > 0 ||
|
|
346
|
+
(v.input.reference_video_urls?.length ?? 0) > 0 ||
|
|
347
|
+
(v.input.reference_audio_urls?.length ?? 0) > 0;
|
|
348
|
+
const hasFrame = Boolean(v.input.first_frame_url) || Boolean(v.input.last_frame_url);
|
|
349
|
+
return !(hasReference && hasFrame);
|
|
350
|
+
}, {
|
|
351
|
+
message: "bytedance/seedance-2 does not accept reference_image_urls, reference_video_urls, or reference_audio_urls combined with first_frame_url or last_frame_url (these scenarios are mutually exclusive)",
|
|
352
|
+
path: ["input", "reference_image_urls"],
|
|
353
|
+
});
|
|
354
|
+
export const NanoBanana2RequestSchema = z.object({
|
|
355
|
+
model: z.literal("nano-banana-2"),
|
|
356
|
+
callBackUrl: z.string().optional(),
|
|
357
|
+
input: z.object({
|
|
358
|
+
prompt: z.string().min(1),
|
|
359
|
+
image_input: z.array(z.string()).optional(),
|
|
360
|
+
aspect_ratio: z
|
|
361
|
+
.enum([
|
|
362
|
+
"1:1",
|
|
363
|
+
"2:3",
|
|
364
|
+
"3:2",
|
|
365
|
+
"3:4",
|
|
366
|
+
"4:3",
|
|
367
|
+
"4:5",
|
|
368
|
+
"5:4",
|
|
369
|
+
"9:16",
|
|
370
|
+
"16:9",
|
|
371
|
+
"21:9",
|
|
372
|
+
"1:4",
|
|
373
|
+
"1:8",
|
|
374
|
+
"4:1",
|
|
375
|
+
"8:1",
|
|
376
|
+
"auto",
|
|
377
|
+
])
|
|
378
|
+
.default("16:9"),
|
|
379
|
+
resolution: NanoBananaResolutionSchema.default("2K"),
|
|
380
|
+
output_format: NanoBananaOutputFormatSchema.optional(),
|
|
381
|
+
google_search: z.boolean().optional(),
|
|
382
|
+
}),
|
|
383
|
+
});
|
|
384
|
+
export const GptImageToImageRequestSchema = z.object({
|
|
385
|
+
model: z.literal("gpt-image/1.5-image-to-image"),
|
|
386
|
+
callBackUrl: z.string().optional(),
|
|
387
|
+
input: z.object({
|
|
388
|
+
input_urls: z.array(z.string()).min(1).max(4),
|
|
389
|
+
prompt: z.string().min(1),
|
|
390
|
+
aspect_ratio: z.enum(["1:1", "2:3", "3:2"]).optional(),
|
|
391
|
+
quality: GptImageQualitySchema.optional(),
|
|
392
|
+
}),
|
|
393
|
+
});
|
|
394
|
+
export const GptImage2ImageToImageAspectRatioSchema = z.enum([
|
|
395
|
+
"auto",
|
|
396
|
+
"1:1",
|
|
397
|
+
"9:16",
|
|
398
|
+
"16:9",
|
|
399
|
+
"4:3",
|
|
400
|
+
"3:4",
|
|
401
|
+
]);
|
|
402
|
+
export const GptImage2ImageToImageResolutionSchema = z.enum(["1K", "2K", "4K"]);
|
|
403
|
+
export const GptImage2ImageToImageRequestSchema = z.object({
|
|
404
|
+
model: z.literal("gpt-image-2-image-to-image"),
|
|
405
|
+
callBackUrl: z.string().optional(),
|
|
406
|
+
input: z.object({
|
|
407
|
+
prompt: z.string().min(1).max(20000),
|
|
408
|
+
input_urls: z.array(z.string()).min(1).max(16),
|
|
409
|
+
aspect_ratio: GptImage2ImageToImageAspectRatioSchema.default("16:9"),
|
|
410
|
+
resolution: GptImage2ImageToImageResolutionSchema.default("2K"),
|
|
411
|
+
nsfw_checker: z.boolean().default(false),
|
|
412
|
+
}),
|
|
413
|
+
});
|
|
414
|
+
export const GptImage2TextToImageAspectRatioSchema = z.enum([
|
|
415
|
+
"auto",
|
|
416
|
+
"1:1",
|
|
417
|
+
"9:16",
|
|
418
|
+
"16:9",
|
|
419
|
+
"4:3",
|
|
420
|
+
"3:4",
|
|
421
|
+
]);
|
|
422
|
+
export const GptImage2TextToImageResolutionSchema = z.enum(["1K", "2K", "4K"]);
|
|
423
|
+
export const GptImage2TextToImageRequestSchema = z.object({
|
|
424
|
+
model: z.literal("gpt-image-2-text-to-image"),
|
|
425
|
+
callBackUrl: z.string().optional(),
|
|
426
|
+
input: z.object({
|
|
427
|
+
prompt: z.string().min(1).max(20000),
|
|
428
|
+
aspect_ratio: GptImage2TextToImageAspectRatioSchema.default("16:9"),
|
|
429
|
+
resolution: GptImage2TextToImageResolutionSchema.default("2K"),
|
|
430
|
+
nsfw_checker: z.boolean().default(false),
|
|
431
|
+
}),
|
|
432
|
+
});
|
|
433
|
+
// Kie's seedream/5-lite createTask rejects requests with `"This field is
|
|
434
|
+
// required"` when `quality` is missing, even though their docs list it as
|
|
435
|
+
// optional with a default. Treat it as required at the SDK boundary so the
|
|
436
|
+
// type system forces callers to pick basic/high.
|
|
437
|
+
export const SeedreamImageToImageRequestSchema = z.object({
|
|
438
|
+
model: z.literal("seedream/5-lite-image-to-image"),
|
|
439
|
+
callBackUrl: z.string().optional(),
|
|
440
|
+
input: z.object({
|
|
441
|
+
image_urls: z.array(z.string()).min(1).max(14),
|
|
442
|
+
prompt: z.string().min(3).max(3000),
|
|
443
|
+
aspect_ratio: z
|
|
444
|
+
.enum(["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"])
|
|
445
|
+
.default("16:9"),
|
|
446
|
+
quality: z.enum(["basic", "high"]),
|
|
447
|
+
nsfw_checker: z.boolean().default(false),
|
|
448
|
+
}),
|
|
449
|
+
});
|
|
450
|
+
export const SeedreamTextToImageRequestSchema = z.object({
|
|
451
|
+
model: z.literal("seedream/5-lite-text-to-image"),
|
|
452
|
+
callBackUrl: z.string().optional(),
|
|
453
|
+
input: z.object({
|
|
454
|
+
prompt: z.string().min(3).max(3000),
|
|
455
|
+
aspect_ratio: z
|
|
456
|
+
.enum(["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"])
|
|
457
|
+
.default("16:9"),
|
|
458
|
+
quality: z.enum(["basic", "high"]),
|
|
459
|
+
nsfw_checker: z.boolean().default(false),
|
|
460
|
+
}),
|
|
461
|
+
});
|
|
462
|
+
export const SoraWatermarkRequestSchema = z.object({
|
|
463
|
+
model: z.literal("sora-watermark-remover"),
|
|
464
|
+
callBackUrl: z.string().optional(),
|
|
465
|
+
input: z.object({
|
|
466
|
+
video_url: z.string().min(1),
|
|
467
|
+
upload_method: z.enum(["s3", "oss"]).optional(),
|
|
468
|
+
}),
|
|
469
|
+
});
|
|
470
|
+
export const HappyHorseTextToVideoRequestSchema = z.object({
|
|
471
|
+
model: z.literal("happyhorse/text-to-video"),
|
|
472
|
+
callBackUrl: z.string().optional(),
|
|
473
|
+
input: z.object({
|
|
474
|
+
prompt: z.string().min(1).max(5000),
|
|
475
|
+
resolution: HappyHorseResolutionSchema.optional(),
|
|
476
|
+
aspect_ratio: HappyHorseAspectRatioSchema.optional(),
|
|
477
|
+
duration: z.number().int().min(3).max(15).optional(),
|
|
478
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
479
|
+
}),
|
|
480
|
+
});
|
|
481
|
+
export const HappyHorseImageToVideoRequestSchema = z.object({
|
|
482
|
+
model: z.literal("happyhorse/image-to-video"),
|
|
483
|
+
callBackUrl: z.string().optional(),
|
|
484
|
+
input: z.object({
|
|
485
|
+
prompt: z.string().max(5000).optional(),
|
|
486
|
+
image_urls: z.array(z.string()).min(1).max(1),
|
|
487
|
+
resolution: HappyHorseResolutionSchema.optional(),
|
|
488
|
+
duration: z.number().int().min(3).max(15).optional(),
|
|
489
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
490
|
+
}),
|
|
491
|
+
});
|
|
492
|
+
export const HappyHorseReferenceToVideoRequestSchema = z.object({
|
|
493
|
+
model: z.literal("happyhorse/reference-to-video"),
|
|
494
|
+
callBackUrl: z.string().optional(),
|
|
495
|
+
input: z.object({
|
|
496
|
+
prompt: z.string().min(1).max(5000),
|
|
497
|
+
reference_image: z.array(z.string()).min(1).max(9),
|
|
498
|
+
resolution: HappyHorseResolutionSchema.optional(),
|
|
499
|
+
aspect_ratio: HappyHorseAspectRatioSchema.optional(),
|
|
500
|
+
duration: z.number().int().min(3).max(15).optional(),
|
|
501
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
502
|
+
}),
|
|
503
|
+
});
|
|
504
|
+
export const HappyHorseVideoEditRequestSchema = z.object({
|
|
505
|
+
model: z.literal("happyhorse/video-edit"),
|
|
506
|
+
callBackUrl: z.string().optional(),
|
|
507
|
+
input: z.object({
|
|
508
|
+
prompt: z.string().min(1).max(5000),
|
|
509
|
+
video_url: z.string().min(1),
|
|
510
|
+
reference_image: z.array(z.string()).max(5).optional(),
|
|
511
|
+
resolution: HappyHorseResolutionSchema.optional(),
|
|
512
|
+
audio_setting: HappyHorseAudioSettingSchema.optional(),
|
|
513
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
514
|
+
}),
|
|
515
|
+
});
|
|
516
|
+
// Refines live on the outer request object (not the `input` sub-object) so
|
|
517
|
+
// that `input.*` fields remain introspectable by downstream tools that walk
|
|
518
|
+
// ZodArray/ZodObject defs (e.g. clipfirst's readSlotConstraints).
|
|
519
|
+
export const Wan27ImageToVideoRequestSchema = z
|
|
520
|
+
.object({
|
|
521
|
+
model: z.literal("wan/2-7-image-to-video"),
|
|
522
|
+
callBackUrl: z.string().optional(),
|
|
523
|
+
input: z.object({
|
|
524
|
+
prompt: z.string().min(1).max(5000),
|
|
525
|
+
negative_prompt: z.string().max(500).optional(),
|
|
526
|
+
first_frame_url: z.string().optional(),
|
|
527
|
+
last_frame_url: z.string().optional(),
|
|
528
|
+
first_clip_url: z.string().optional(),
|
|
529
|
+
driving_audio_url: z.string().optional(),
|
|
530
|
+
resolution: Wan27ResolutionSchema.optional(),
|
|
531
|
+
duration: z.number().int().min(2).max(15).optional(),
|
|
532
|
+
prompt_extend: z.boolean().optional(),
|
|
533
|
+
watermark: z.boolean().optional(),
|
|
534
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
535
|
+
nsfw_checker: z.boolean().default(false),
|
|
536
|
+
}),
|
|
537
|
+
})
|
|
538
|
+
.refine((v) => Boolean(v.input.first_frame_url) ||
|
|
539
|
+
Boolean(v.input.last_frame_url) ||
|
|
540
|
+
Boolean(v.input.first_clip_url), {
|
|
541
|
+
message: "wan/2-7-image-to-video requires at least one of first_frame_url, last_frame_url, or first_clip_url",
|
|
542
|
+
path: ["input", "first_frame_url"],
|
|
543
|
+
})
|
|
544
|
+
.refine((v) => !(v.input.first_clip_url &&
|
|
545
|
+
(v.input.first_frame_url || v.input.last_frame_url)), {
|
|
546
|
+
message: "wan/2-7-image-to-video does not accept first_clip_url combined with first_frame_url or last_frame_url",
|
|
547
|
+
path: ["input", "first_clip_url"],
|
|
548
|
+
});
|
|
549
|
+
export const Wan27TextToVideoRequestSchema = z.object({
|
|
550
|
+
model: z.literal("wan/2-7-text-to-video"),
|
|
551
|
+
callBackUrl: z.string().optional(),
|
|
552
|
+
input: z.object({
|
|
553
|
+
prompt: z.string().min(1).max(5000),
|
|
554
|
+
negative_prompt: z.string().max(500).optional(),
|
|
555
|
+
audio_url: z.string().optional(),
|
|
556
|
+
resolution: Wan27ResolutionSchema.optional(),
|
|
557
|
+
ratio: Wan27AspectRatioSchema.optional(),
|
|
558
|
+
duration: z.number().int().min(2).max(15).optional(),
|
|
559
|
+
prompt_extend: z.boolean().optional(),
|
|
560
|
+
watermark: z.boolean().optional(),
|
|
561
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
562
|
+
nsfw_checker: z.boolean().default(false),
|
|
563
|
+
}),
|
|
564
|
+
});
|
|
565
|
+
// Per-field max(5) on reference_image/reference_video; the combined-≤5 cap is
|
|
566
|
+
// enforced by callers (would require a wrapper-level refine, which would
|
|
567
|
+
// turn this into ZodEffects and break `.shape` introspection used by
|
|
568
|
+
// clipfirst's slot-constraint readers).
|
|
569
|
+
export const Wan27RefToVideoRequestSchema = z.object({
|
|
570
|
+
model: z.literal("wan/2-7-r2v"),
|
|
571
|
+
callBackUrl: z.string().optional(),
|
|
572
|
+
input: z.object({
|
|
573
|
+
prompt: z.string().min(1).max(5000),
|
|
574
|
+
negative_prompt: z.string().max(500).optional(),
|
|
575
|
+
reference_image: z.array(z.string()).max(5).optional(),
|
|
576
|
+
reference_video: z.array(z.string()).max(5).optional(),
|
|
577
|
+
first_frame: z.string().optional(),
|
|
578
|
+
reference_voice: z.string().optional(),
|
|
579
|
+
resolution: Wan27ResolutionSchema.optional(),
|
|
580
|
+
aspect_ratio: Wan27AspectRatioSchema.optional(),
|
|
581
|
+
duration: z.number().int().min(2).max(10).optional(),
|
|
582
|
+
prompt_extend: z.boolean().optional(),
|
|
583
|
+
watermark: z.boolean().optional(),
|
|
584
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
585
|
+
nsfw_checker: z.boolean().default(false),
|
|
586
|
+
}),
|
|
587
|
+
});
|
|
588
|
+
export const Wan27VideoEditRequestSchema = z
|
|
589
|
+
.object({
|
|
590
|
+
model: z.literal("wan/2-7-videoedit"),
|
|
591
|
+
callBackUrl: z.string().optional(),
|
|
592
|
+
input: z.object({
|
|
593
|
+
prompt: z.string().max(5000).optional(),
|
|
594
|
+
negative_prompt: z.string().max(500).optional(),
|
|
595
|
+
video_url: z.string().min(1),
|
|
596
|
+
reference_image: z.string().optional(),
|
|
597
|
+
resolution: Wan27ResolutionSchema.optional(),
|
|
598
|
+
aspect_ratio: Wan27AspectRatioSchema.optional(),
|
|
599
|
+
duration: z.number().int().optional(),
|
|
600
|
+
audio_setting: Wan27AudioSettingSchema.optional(),
|
|
601
|
+
prompt_extend: z.boolean().optional(),
|
|
602
|
+
watermark: z.boolean().optional(),
|
|
603
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
604
|
+
nsfw_checker: z.boolean().default(false),
|
|
605
|
+
}),
|
|
606
|
+
})
|
|
607
|
+
.refine((v) => {
|
|
608
|
+
const d = v.input.duration;
|
|
609
|
+
return d === undefined || d === 0 || (d >= 2 && d <= 10);
|
|
610
|
+
}, {
|
|
611
|
+
message: "wan/2-7-videoedit duration must be 0 (full input) or between 2 and 10 seconds",
|
|
612
|
+
path: ["input", "duration"],
|
|
613
|
+
});
|
|
614
|
+
const Wan27ImageInputShape = {
|
|
615
|
+
prompt: z.string().min(1).max(5000),
|
|
616
|
+
input_urls: z.array(z.string()).max(9).optional(),
|
|
617
|
+
aspect_ratio: Wan27ImageAspectRatioSchema.default("16:9"),
|
|
618
|
+
enable_sequential: z.boolean().optional(),
|
|
619
|
+
n: z.number().int().min(1).max(12).optional(),
|
|
620
|
+
resolution: Wan27ImageResolutionSchema.default("2K"),
|
|
621
|
+
thinking_mode: z.boolean().optional(),
|
|
622
|
+
color_palette: z
|
|
623
|
+
.array(Wan27ImageColorPaletteSchema)
|
|
624
|
+
.min(3)
|
|
625
|
+
.max(10)
|
|
626
|
+
.optional(),
|
|
627
|
+
bbox_list: z.array(z.array(z.array(z.number()).length(4)).max(2)).optional(),
|
|
628
|
+
watermark: z.boolean().optional(),
|
|
629
|
+
seed: z.number().int().min(0).max(2147483647).optional(),
|
|
630
|
+
nsfw_checker: z.boolean().default(false),
|
|
631
|
+
};
|
|
632
|
+
const wan27ImageAspectRatioRequiresResolution = (v) => v.input.aspect_ratio === undefined || v.input.resolution !== undefined;
|
|
633
|
+
const wan27ImageAspectRatioRefinement = {
|
|
634
|
+
message: "aspect_ratio requires resolution",
|
|
635
|
+
path: ["input", "resolution"],
|
|
636
|
+
};
|
|
637
|
+
const wan27Image4KRequiresNonSequentialTextToImage = (v) => {
|
|
638
|
+
if (v.input.resolution !== "4K")
|
|
639
|
+
return true;
|
|
640
|
+
if (v.input.enable_sequential === true)
|
|
641
|
+
return false;
|
|
642
|
+
const urls = v.input.input_urls;
|
|
643
|
+
if (Array.isArray(urls) && urls.length > 0)
|
|
644
|
+
return false;
|
|
645
|
+
return true;
|
|
646
|
+
};
|
|
647
|
+
const wan27Image4KRefinement = {
|
|
648
|
+
message: "resolution 4K is only supported for non-sequential text-to-image",
|
|
649
|
+
path: ["input", "resolution"],
|
|
650
|
+
};
|
|
651
|
+
export const Wan27ImageInputSchema = z.object(Wan27ImageInputShape);
|
|
652
|
+
const Wan27ImageRequestObjectSchema = z.object({
|
|
653
|
+
model: z.literal("wan/2-7-image"),
|
|
654
|
+
callBackUrl: z.string().optional(),
|
|
655
|
+
input: Wan27ImageInputSchema,
|
|
656
|
+
});
|
|
657
|
+
const Wan27ImageProRequestObjectSchema = z.object({
|
|
658
|
+
model: z.literal("wan/2-7-image-pro"),
|
|
659
|
+
callBackUrl: z.string().optional(),
|
|
660
|
+
input: Wan27ImageInputSchema,
|
|
661
|
+
});
|
|
662
|
+
export const Wan27ImageRequestSchema = Wan27ImageRequestObjectSchema.refine(wan27ImageAspectRatioRequiresResolution, wan27ImageAspectRatioRefinement).refine(wan27Image4KRequiresNonSequentialTextToImage, wan27Image4KRefinement);
|
|
663
|
+
export const Wan27ImageProRequestSchema = Wan27ImageProRequestObjectSchema.refine(wan27ImageAspectRatioRequiresResolution, wan27ImageAspectRatioRefinement).refine(wan27Image4KRequiresNonSequentialTextToImage, wan27Image4KRefinement);
|
|
664
|
+
// ---------------------------------------------------------------------------
|
|
665
|
+
// Wan 2.7 task result schemas (parsed from KieTaskInfoData.resultJson)
|
|
666
|
+
//
|
|
667
|
+
// kie wraps async task results in a JSON envelope on `resultJson`. Both image
|
|
668
|
+
// and video Wan 2.7 endpoints return the same shape: an array of result URLs
|
|
669
|
+
// (image URLs for image jobs; one video URL for video jobs) plus an optional
|
|
670
|
+
// passthrough `resultObject` for endpoint-specific metadata. Consumers should
|
|
671
|
+
// `JSON.parse(data.resultJson)` then validate with these.
|
|
672
|
+
// ---------------------------------------------------------------------------
|
|
673
|
+
export const Wan27TaskResultJsonSchema = z.object({
|
|
674
|
+
resultUrls: z.array(z.string().url()).min(1),
|
|
675
|
+
resultObject: z.record(z.string(), z.unknown()).optional(),
|
|
676
|
+
});
|
|
677
|
+
export const Wan27VideoResultSchema = Wan27TaskResultJsonSchema;
|
|
678
|
+
export const Wan27ImageResultSchema = Wan27TaskResultJsonSchema;
|
|
679
|
+
// ---------------------------------------------------------------------------
|
|
680
|
+
// Upload schemas
|
|
681
|
+
// ---------------------------------------------------------------------------
|
|
682
|
+
const blobSchema = z.instanceof(Blob);
|
|
683
|
+
export const UploadMediaRequestSchema = z.object({
|
|
684
|
+
file: blobSchema,
|
|
685
|
+
filename: z.string().min(1),
|
|
686
|
+
uploadPath: z.string().min(1),
|
|
687
|
+
fileName: z.string().optional(),
|
|
688
|
+
mimeType: z.string().optional(),
|
|
689
|
+
});
|
|
690
|
+
export const FileUrlUploadRequestSchema = z.object({
|
|
691
|
+
fileUrl: z.string().min(1),
|
|
692
|
+
uploadPath: z.string().min(1),
|
|
693
|
+
fileName: z.string().optional(),
|
|
694
|
+
});
|
|
695
|
+
export const FileBase64UploadRequestSchema = z.object({
|
|
696
|
+
base64Data: z.string().min(1),
|
|
697
|
+
uploadPath: z.string().min(1),
|
|
698
|
+
fileName: z.string().optional(),
|
|
699
|
+
mimeType: z.string().optional(),
|
|
700
|
+
});
|
|
701
|
+
// ---------------------------------------------------------------------------
|
|
702
|
+
// Download URL
|
|
703
|
+
// ---------------------------------------------------------------------------
|
|
704
|
+
export const DownloadUrlRequestSchema = z.object({
|
|
705
|
+
url: z.string().min(1),
|
|
706
|
+
});
|
|
707
|
+
// ---------------------------------------------------------------------------
|
|
708
|
+
// Options
|
|
709
|
+
// ---------------------------------------------------------------------------
|
|
710
|
+
export const KieOptionsSchema = z.object({
|
|
711
|
+
apiKey: z.string().min(1),
|
|
712
|
+
baseURL: z.string().url().optional(),
|
|
713
|
+
uploadBaseURL: z.string().url().optional(),
|
|
714
|
+
timeout: z.number().int().positive().optional(),
|
|
715
|
+
fetch: z
|
|
716
|
+
.custom()
|
|
717
|
+
.optional(),
|
|
718
|
+
});
|
|
719
|
+
// ---------------------------------------------------------------------------
|
|
720
|
+
// CreateTask request (alias for MediaGenerationRequest — what the createTask
|
|
721
|
+
// endpoint actually receives)
|
|
722
|
+
// ---------------------------------------------------------------------------
|
|
723
|
+
export const CreateTaskRequestSchema = z.object({
|
|
724
|
+
model: KieMediaModelSchema,
|
|
725
|
+
callBackUrl: z.string().optional(),
|
|
726
|
+
input: z.record(z.string(), z.unknown()),
|
|
727
|
+
});
|
|
728
|
+
// ---------------------------------------------------------------------------
|
|
729
|
+
// Sub-provider schemas: Veo
|
|
730
|
+
// ---------------------------------------------------------------------------
|
|
731
|
+
export const VeoGenerateRequestSchema = z.object({
|
|
732
|
+
prompt: z.string().min(1),
|
|
733
|
+
model: z.enum(["veo3", "veo3_fast"]).optional(),
|
|
734
|
+
aspectRatio: z.enum(["16:9", "9:16", "Auto"]).optional(),
|
|
735
|
+
generationType: z
|
|
736
|
+
.enum([
|
|
737
|
+
"TEXT_2_VIDEO",
|
|
738
|
+
"REFERENCE_2_VIDEO",
|
|
739
|
+
"FIRST_AND_LAST_FRAMES_2_VIDEO",
|
|
740
|
+
])
|
|
741
|
+
.optional(),
|
|
742
|
+
imageUrls: z.array(z.string()).optional(),
|
|
743
|
+
seeds: z.number().optional(),
|
|
744
|
+
watermark: z.string().optional(),
|
|
745
|
+
enableTranslation: z.boolean().optional(),
|
|
746
|
+
});
|
|
747
|
+
export const VeoExtendRequestSchema = z.object({
|
|
748
|
+
taskId: z.string().min(1),
|
|
749
|
+
prompt: z.string().min(1),
|
|
750
|
+
model: z.enum(["fast", "quality"]).optional(),
|
|
751
|
+
seeds: z.number().optional(),
|
|
752
|
+
watermark: z.string().optional(),
|
|
753
|
+
});
|
|
754
|
+
// ---------------------------------------------------------------------------
|
|
755
|
+
// Sub-provider schemas: Suno
|
|
756
|
+
// ---------------------------------------------------------------------------
|
|
757
|
+
export const SunoGenerateRequestSchema = z.object({
|
|
758
|
+
prompt: z.string().min(1),
|
|
759
|
+
model: z.enum(["V3_5", "V4", "V4_5", "V4_5PLUS", "V4_5ALL", "V5", "V5_5"]),
|
|
760
|
+
instrumental: z.boolean(),
|
|
761
|
+
customMode: z.boolean(),
|
|
762
|
+
callBackUrl: z.string().min(1),
|
|
763
|
+
style: z.string().optional(),
|
|
764
|
+
negativeTags: z.string().optional(),
|
|
765
|
+
title: z.string().optional(),
|
|
766
|
+
vocalGender: z.enum(["m", "f"]).optional(),
|
|
767
|
+
styleWeight: z.number().min(0).max(1).optional(),
|
|
768
|
+
weirdnessConstraint: z.number().min(0).max(1).optional(),
|
|
769
|
+
audioWeight: z.number().min(0).max(1).optional(),
|
|
770
|
+
personaId: z.string().optional(),
|
|
771
|
+
});
|
|
772
|
+
// ---------------------------------------------------------------------------
|
|
773
|
+
// Sub-provider schemas: Chat (GPT-5.5 / GPT-5.2 via Kie)
|
|
774
|
+
// ---------------------------------------------------------------------------
|
|
775
|
+
export const KieChatContentPartSchema = z.object({
|
|
776
|
+
type: z.enum(["text", "image_url"]),
|
|
777
|
+
text: z.string().optional(),
|
|
778
|
+
image_url: z.object({ url: z.string() }).optional(),
|
|
779
|
+
});
|
|
780
|
+
export const KieChatMessageSchema = z.object({
|
|
781
|
+
role: z.enum(["user", "assistant", "system"]),
|
|
782
|
+
content: z.union([z.string(), z.array(KieChatContentPartSchema)]),
|
|
783
|
+
});
|
|
784
|
+
export const KieChatRequestSchema = z.object({
|
|
785
|
+
model: z.string(),
|
|
786
|
+
messages: z.array(KieChatMessageSchema),
|
|
787
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
788
|
+
max_tokens: z.number().int().positive().optional(),
|
|
789
|
+
stream: z.boolean().optional(),
|
|
790
|
+
response_format: z
|
|
791
|
+
.object({
|
|
792
|
+
type: z.enum(["text", "json_object", "json_schema"]),
|
|
793
|
+
json_schema: z.record(z.string(), z.unknown()).optional(),
|
|
794
|
+
})
|
|
795
|
+
.optional(),
|
|
796
|
+
});
|
|
797
|
+
// ---------------------------------------------------------------------------
|
|
798
|
+
// Sub-provider schemas: Claude (via Kie)
|
|
799
|
+
// ---------------------------------------------------------------------------
|
|
800
|
+
export const KieClaudeToolInputSchemaSchema = z.object({
|
|
801
|
+
type: z.string(),
|
|
802
|
+
properties: z.record(z.string(), z.unknown()).optional(),
|
|
803
|
+
required: z.array(z.string()).optional(),
|
|
804
|
+
});
|
|
805
|
+
export const KieClaudeToolSchema = z.object({
|
|
806
|
+
name: z.string(),
|
|
807
|
+
description: z.string(),
|
|
808
|
+
input_schema: KieClaudeToolInputSchemaSchema,
|
|
809
|
+
});
|
|
810
|
+
export const KieClaudeContentPartSchema = z
|
|
811
|
+
.object({
|
|
812
|
+
type: z.string(),
|
|
813
|
+
text: z.string().optional(),
|
|
814
|
+
})
|
|
815
|
+
.passthrough();
|
|
816
|
+
export const KieClaudeMessageSchema = z.object({
|
|
817
|
+
role: z.enum(["user", "assistant"]),
|
|
818
|
+
content: z.union([z.string(), z.array(KieClaudeContentPartSchema)]),
|
|
819
|
+
});
|
|
820
|
+
export const KieClaudeRequestSchema = z.object({
|
|
821
|
+
model: z.enum(["claude-sonnet-4-6", "claude-haiku-4-5"]),
|
|
822
|
+
messages: z.array(KieClaudeMessageSchema),
|
|
823
|
+
tools: z.array(KieClaudeToolSchema).optional(),
|
|
824
|
+
thinkingFlag: z.boolean().optional(),
|
|
825
|
+
stream: z.boolean().optional(),
|
|
826
|
+
});
|
|
827
|
+
// ---------------------------------------------------------------------------
|
|
828
|
+
// Media generation request (discriminated union on model)
|
|
829
|
+
// ---------------------------------------------------------------------------
|
|
830
|
+
// Plain union (not discriminatedUnion) so individual members can be refined —
|
|
831
|
+
// discriminatedUnion requires ZodObject members, but `.refine()` wraps an
|
|
832
|
+
// object in ZodEffects. Parsing cost is slightly higher (tries each member)
|
|
833
|
+
// but accepted for the added input-contract validation.
|
|
834
|
+
export const MediaGenerationRequestSchema = z.union([
|
|
835
|
+
KlingVideoRequestSchema,
|
|
836
|
+
KlingMotionControlRequestSchema,
|
|
837
|
+
GrokTextToImageRequestSchema,
|
|
838
|
+
GrokImageToImageRequestSchema,
|
|
839
|
+
GrokTextToVideoRequestSchema,
|
|
840
|
+
GrokImageToVideoRequestSchema,
|
|
841
|
+
GrokVideoExtendRequestSchema,
|
|
842
|
+
GrokVideoUpscaleRequestSchema,
|
|
843
|
+
NanoBananaProRequestSchema,
|
|
844
|
+
NanoBanana2RequestSchema,
|
|
845
|
+
GptImageToImageRequestSchema,
|
|
846
|
+
GptImage2ImageToImageRequestSchema,
|
|
847
|
+
GptImage2TextToImageRequestSchema,
|
|
848
|
+
SeedreamImageToImageRequestSchema,
|
|
849
|
+
SeedreamTextToImageRequestSchema,
|
|
850
|
+
Qwen2TextToImageRequestSchema,
|
|
851
|
+
Qwen2ImageEditRequestSchema,
|
|
852
|
+
Seedance2FastRequestSchema,
|
|
853
|
+
Seedance2RequestSchema,
|
|
854
|
+
Wan27ImageToVideoRequestSchema,
|
|
855
|
+
Wan27TextToVideoRequestSchema,
|
|
856
|
+
Wan27RefToVideoRequestSchema,
|
|
857
|
+
Wan27VideoEditRequestSchema,
|
|
858
|
+
Wan27ImageRequestSchema,
|
|
859
|
+
Wan27ImageProRequestSchema,
|
|
860
|
+
HappyHorseTextToVideoRequestSchema,
|
|
861
|
+
HappyHorseImageToVideoRequestSchema,
|
|
862
|
+
HappyHorseReferenceToVideoRequestSchema,
|
|
863
|
+
HappyHorseVideoEditRequestSchema,
|
|
864
|
+
SoraWatermarkRequestSchema,
|
|
865
|
+
]);
|
|
866
|
+
//# sourceMappingURL=zod.js.map
|