Open History to see the last commit
1import type {
2 BytePlusVideoModel,
3 BytePlusVideoModelOrString,
4 BytePlusVideoRatio,
5 BytePlusVideoResolution,
6 BytePlusVideoServiceTier,
7} from '@tanstack/ai-byteplus'
8
9/**
10 * Seedance Studio catalog — the client half of the per-model capability
11 * surface.
12 *
13 * Everything the adapter can tell us at runtime (duration range, resolution
14 * tiers, first/last-frame support, reference-media support) is read from
15 * `@tanstack/ai-byteplus` on the server and shipped down as
16 * {@link SeedanceCapability}; this file only carries what the package
17 * documents in prose rather than in a runtime table: display copy, and the
18 * per-field applicability policy for the provider options.
19 */
20
21/** Which optional provider-option fields a model accepts. */
22export interface SeedanceExtras {
23 /**
24 * `generate_audio` — accepted by every model at the validation layer, but
25 * only Seedance 2.5, the 2.0 family and 1.5-pro actually produce an audio
26 * track.
27 */
28 generateAudio: boolean
29 /** `camera_fixed` — Seedance 1.x only; the 2.x family rejects it. */
30 cameraFixed: boolean
31 /** `service_tier: 'flex'` — Seedance 1.x only (no offline tier on 2.x). */
32 serviceTier: boolean
33 /** `frames` — Seedance 1.0-pro and 1.0-pro-fast only. */
34 frames: boolean
35 /** `draft` — Seedance 1.5-pro only. */
36 draft: boolean
37 /** `priority` (0-9) — Seedance 2.5 and the 2.0 family. */
38 priority: boolean
39 /** `duration: -1` (model picks the length) — Seedance 2.5, 2.0 and 1.5-pro. */
40 autoDuration: boolean
41}
42
43export interface SeedanceModelEntry {
44 id: BytePlusVideoModelOrString
45 name: string
46 blurb: string
47 extras: SeedanceExtras
48}
49
50/** Resolves only for `never`; anything else is a compile error naming it. */
51type AssertNever<T extends never> = T
52
53/**
54 * The Seedance models, with option applicability from
55 * `BytePlusVideoProviderOptions` (2.0/1.x live-probed; 2.5 from ModelArk
56 * docs). Ark 400s on an inapplicable field rather than ignoring it, so these
57 * flags decide what the studio is allowed to send — not just what it renders.
58 */
59export const SEEDANCE_MODELS = [
60 {
61 id: 'dreamina-seedance-2-5-260628',
62 name: 'Seedance 2.5',
63 blurb:
64 'Current multimodal flagship — up to 30s, native 1080p, audio-only references',
65 extras: {
66 generateAudio: true,
67 cameraFixed: false,
68 serviceTier: false,
69 frames: false,
70 draft: false,
71 priority: true,
72 autoDuration: true,
73 },
74 },
75 {
76 id: 'dreamina-seedance-2-0-260128',
77 name: 'Seedance 2.0',
78 blurb: '2.0 flagship — the only Seedance model with a 4k tier',
79 extras: {
80 generateAudio: true,
81 cameraFixed: false,
82 serviceTier: false,
83 frames: false,
84 draft: false,
85 priority: true,
86 autoDuration: true,
87 },
88 },
89 {
90 id: 'dreamina-seedance-2-0-fast-260128',
91 name: 'Seedance 2.0 Fast',
92 blurb: 'Faster 2.0 sibling, capped at 720p',
93 extras: {
94 generateAudio: true,
95 cameraFixed: false,
96 serviceTier: false,
97 frames: false,
98 draft: false,
99 priority: true,
100 autoDuration: true,
101 },
102 },
103 {
104 id: 'dreamina-seedance-2-0-mini-260615',
105 name: 'Seedance 2.0 Mini',
106 blurb: 'Smallest 2.0 model, still takes reference media',
107 extras: {
108 generateAudio: true,
109 cameraFixed: false,
110 serviceTier: false,
111 frames: false,
112 draft: false,
113 priority: true,
114 autoDuration: true,
115 },
116 },
117 {
118 id: 'seedance-1-5-pro-251215',
119 name: 'Seedance 1.5 Pro',
120 blurb: 'Audio-capable 1.x flagship with cheap draft renders',
121 extras: {
122 generateAudio: true,
123 cameraFixed: true,
124 serviceTier: true,
125 frames: false,
126 draft: true,
127 priority: false,
128 autoDuration: true,
129 },
130 },
131 {
132 id: 'seedance-1-0-pro-250528',
133 name: 'Seedance 1.0 Pro',
134 blurb: 'Frame-count output and first-and-last-frame mode',
135 extras: {
136 generateAudio: false,
137 cameraFixed: true,
138 serviceTier: true,
139 frames: true,
140 draft: false,
141 priority: false,
142 autoDuration: false,
143 },
144 },
145 {
146 id: 'seedance-1-0-pro-fast-251015',
147 name: 'Seedance 1.0 Pro Fast',
148 blurb: 'Cheapest run — text-to-video and opening-frame only',
149 extras: {
150 generateAudio: false,
151 cameraFixed: true,
152 serviceTier: true,
153 frames: true,
154 draft: false,
155 priority: false,
156 autoDuration: false,
157 },
158 },
159] as const satisfies ReadonlyArray<SeedanceModelEntry>
160
161/**
162 * Compile-time link between this catalog and the package's model list: a new
163 * model shipping in `@tanstack/ai-byteplus` fails the example's build here —
164 * naming the id it is missing — instead of silently going absent from the
165 * picker with no capability copy or option policy.
166 */
167export type SeedanceCatalogCoversEveryModel = AssertNever<
168 Exclude<BytePlusVideoModel, (typeof SEEDANCE_MODELS)[number]['id']>
169>
170
171/**
172 * Look up a catalog entry, or `undefined` for an id this file has no policy
173 * for. There is deliberately no fallback entry: handing back some other
174 * model's option policy would gate the studio on the wrong model's rules —
175 * exactly the class of bug the per-model gating exists to prevent. A custom
176 * id goes through the explicit unknown-model path instead.
177 */
178export function seedanceModel(
179 id: BytePlusVideoModel,
180): SeedanceModelEntry | undefined {
181 return SEEDANCE_MODELS.find((entry) => entry.id === id)
182}
183
184/**
185 * The runtime half of a model's capabilities, derived on the server from the
186 * adapter's own metadata rather than restated here.
187 */
188export interface SeedanceCapability {
189 model: BytePlusVideoModel
190 /** Tiers this model accepts, in ascending order. */
191 resolutions: Array<BytePlusVideoResolution>
192 /** Whole-second range from the adapter's `availableDurations()`. */
193 duration: { min: number; max: number; step: number }
194 /** Whether an `end_frame` image is accepted (`flf2v`). */
195 supportsLastFrame: boolean
196 /** Whether reference images / video / audio are accepted (`r2v`). */
197 supportsReferenceMedia: boolean
198}
199
200/**
201 * Placeholder for the advanced custom-id field when trying an id this package
202 * has not catalogued yet. Known models (including Seedance 2.5) live in the
203 * picker above.
204 */
205export const SEEDANCE_CUSTOM_MODEL_PLACEHOLDER = 'dreamina-seedance-…-yymmdd'
206
207/**
208 * Option applicability for an id the package has no table for: everything on.
209 *
210 * This is not optimism. `@tanstack/ai-byteplus` deliberately leaves an unknown
211 * id ungated — the adapter's per-model guards switch off and Ark judges the
212 * request — because clamping a future model against today's tables would
213 * reject requests the API would have accepted. The studio mirrors that: it
214 * offers the full surface and lets the API be the authority.
215 */
216export const SEEDANCE_UNKNOWN_MODEL_EXTRAS: SeedanceExtras = {
217 generateAudio: true,
218 cameraFixed: true,
219 serviceTier: true,
220 frames: true,
221 draft: true,
222 priority: true,
223 autoDuration: true,
224}
225
226/**
227 * Every resolution tier Seedance has shipped so far. Which of them a known
228 * model accepts is decided by the adapter (see `SeedanceCapability`); for an
229 * unknown model these are offered as a starting point alongside a free-text
230 * field, since a future model may bring a tier that does not exist today.
231 */
232export const SEEDANCE_RESOLUTION_TIERS: ReadonlyArray<BytePlusVideoResolution> =
233 ['480p', '720p', '1080p', '4k']
234
235/**
236 * The studio's curated slice of `BytePlusVideoProviderOptions`, as sent from
237 * the browser. The server maps it onto the provider's own (snake_case) field
238 * names and drops anything the selected model does not accept.
239 */
240export interface SeedanceJobOptions {
241 ratio?: BytePlusVideoRatio
242 resolution?: BytePlusVideoResolution
243 /**
244 * Full `ratio_resolution` template, used instead of `ratio`/`resolution` for
245 * a custom model id. Those two are typed against the tiers this package
246 * knows; the generic `size` is the open path, and the adapter only checks an
247 * unknown model's template shape before handing the values to Ark.
248 */
249 size?: string
250 /** Whole seconds, or `-1` to let the model choose (2.5 / 2.0 / 1.5-pro). */
251 duration?: number
252 /** Frame count instead of seconds; wins over `duration` server-side. */
253 frames?: number
254 /** `[-1, 2^32-1]`; `-1` leaves generation unseeded. */
255 seed?: number
256 watermark?: boolean
257 generateAudio?: boolean
258 cameraFixed?: boolean
259 serviceTier?: BytePlusVideoServiceTier
260 draft?: boolean
261 /** Queue priority `[0, 9]`. */
262 priority?: number
263}
264
265/**
266 * How the prompt's media parts are shaped. Seedance sorts them into mutually
267 * exclusive task types, so the studio picks one mode rather than letting a
268 * user mix frame roles with reference roles into a request the adapter would
269 * reject.
270 */
271export type SeedanceInputMode =
272 | 'text'
273 | 'first-frame'
274 | 'first-last-frame'
275 | 'reference'
276
277/**
278 * Aspect ratios the create endpoint accepts. `adaptive` (follow the input
279 * frame) only makes sense with an image attached — Seedance 1.0 rejects it
280 * outright for text-to-video — so the studio offers it conditionally.
281 */
282export const SEEDANCE_RATIOS: ReadonlyArray<BytePlusVideoRatio> = [
283 '16:9',
284 '9:16',
285 '4:3',
286 '3:4',
287 '1:1',
288 '21:9',
289]
290
291/** Seedance renders at 24 fps, which is what makes `frames` a duration. */
292export const SEEDANCE_FPS = 24
293
294/**
295 * Snap a frame count onto the grid Seedance accepts: the integers of the form
296 * `25 + 4n` inside `[29, 289]`.
297 */
298export function snapSeedanceFrames(frames: number): number {
299 const steps = Math.min(66, Math.max(1, Math.round((frames - 25) / 4)))
300 return 25 + steps * 4
301}
302
303/** Smallest / largest frame counts on that grid. */
304export const SEEDANCE_MIN_FRAMES = snapSeedanceFrames(0)
305export const SEEDANCE_MAX_FRAMES = snapSeedanceFrames(Number.MAX_SAFE_INTEGER)
306
307/** One-line capability summary shown under each model in the picker. */
308export function describeSeedanceModel(
309 entry: SeedanceModelEntry,
310 capability: SeedanceCapability | undefined,
311): string {
312 if (!capability) return entry.blurb
313 const parts = [
314 `${capability.duration.min}-${capability.duration.max}s`,
315 capability.resolutions.join(' / '),
316 ]
317 if (entry.extras.generateAudio) parts.push('audio')
318 if (capability.supportsReferenceMedia) parts.push('references')
319 if (capability.supportsLastFrame) parts.push('first+last frame')
320 if (entry.extras.serviceTier) parts.push('flex tier')
321 if (entry.extras.frames) parts.push('frame count')
322 if (entry.extras.draft) parts.push('draft')
323 if (entry.extras.priority) parts.push('priority')
324 return parts.join(' · ')
325}