Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

byteplus-spec.ts

1,402 lines49.9 KB

1/**
2 * BytePlus — hand-ported OpenAPI documents.
3 *
4 * NOTE ON ROLES: the Ark document here is now the FALLBACK. The live Ark spec
5 * is generated at sync time from BytePlus's Go SDK by
6 * `byteplus-ark-build.ts`; this copy is served only when that fetch or parse
7 * fails, so it should be kept roughly current but is no longer the primary
8 * source. The Seed Speech document below IS primary — no BytePlus SDK covers
9 * the voice host.
10 *
11 * BytePlus publishes no public machine-readable spec (its OpenAPI documents
12 * live behind the console's API explorer), so both were originally ported
13 * TanStack AI's `@tanstack/ai-byteplus` wire types
14 * (`packages/ai-byteplus/src/{video,image,audio}/wire-types.ts`,
15 * `message-types.ts`, `text/text-provider-options.ts`), which record their
16 * provenance field-by-field: harvested OpenAPI 3.1 documents for the `ark`
17 * service plus live probes against the ap-southeast host on 2026-07-31.
18 *
19 * Cross-checked 2026-08-12 against BytePlus's own international SDKs
20 * (`github.com/byteplus-sdk/byteplus-go-sdk-v2` v1.0.32
21 * `service/arkruntime/model`, ~1,100 json-tagged fields; the same shapes back
22 * `byteplus-python-sdk-v2` and `byteplus-java-sdk-v2-ark-runtime`). Fields
23 * that exist only in those SDKs are marked SDK-derived at their declaration.
24 * The SDKs cover Ark only — Seed Speech appears in none of them, in any
25 * language.
26 *
27 * SEED SPEECH VERIFICATION STATUS (probed with a real voice key 2026-08-12):
28 * `/tts/create` is now LIVE-VERIFIED end to end — request shape, the flat
29 * `references` member form TanStack could not resolve, the subtitle nesting,
30 * and the success body (which carries no code/message pair). ASR remains
31 * docs-derived: the endpoint answers `403 45000030 [resource_id=
32 * volc.seedasr.auc_turbo] requested resource not granted` on an account
33 * without Seed ASR provisioned, which at least confirms the resource-id
34 * header name and value are right.
35 *
36 * Two hosts, two products, two API keys:
37 * - **Ark (ModelArk)** — chat (`/chat/completions`, OpenAI-compatible),
38 * Seedance video (`/contents/generations/tasks`, async task API) and
39 * Seedream image (`/images/generations`). `Authorization: Bearer
40 * $ARK_API_KEY`; keys are region-isolated (an ap-southeast key does not
41 * work against the EU host).
42 * - **Seed Speech** — TTS (`/tts/create`) and ASR
43 * (`/auc/bigmodel/recognize/flash`) on the voice host, authenticated with
44 * `X-Api-Key: $SEED_SPEECH_API_KEY` (an Ark key there fails with
45 * `45000010 Invalid X-Api-Key`). The voice host serves no spec of its own:
46 * `/openapi.json` and friends return genuine 404s, unlike Ark's catch-all
47 * 200-empty.
48 *
49 * Each spec is built fresh per call so sync-time consumers can never
50 * accidentally share (or mutate) module-scoped state across requests.
51 */
52import { PROVENANCE_MARKER } from './types.ts'
53import type { OpenApiDocument } from './types.ts'
54​
55export const BYTEPLUS_ARK_BASE_URL =
56 'https://ark.ap-southeast.bytepluses.com/api/v3'
57export const BYTEPLUS_VOICE_BASE_URL =
58 'https://voice.ap-southeast-1.bytepluses.com/api/v3'
59​
60/** Human docs the embedded documents were derived from (provenance URLs). */
61export const BYTEPLUS_ARK_DOCS_URL =
62 'https://docs.byteplus.com/en/docs/ModelArk'
63export const BYTEPLUS_VOICE_DOCS_URL =
64 'https://docs.byteplus.com/en/docs/byteplusvoice'
65​
66type Schema = Record<string, unknown>
67​
68// ---------------------------------------------------------------------------
69// Chat (/chat/completions — OpenAI-compatible plus Ark-only extensions)
70// ---------------------------------------------------------------------------
71​
72const chatContentPartSchemas: Record<string, Schema> = {
73 ChatTextContentPart: {
74 type: 'object',
75 description: 'Plain text content part.',
76 properties: {
77 type: { type: 'string', enum: ['text'] },
78 text: { type: 'string' },
79 },
80 required: ['type', 'text'],
81 },
82 ChatImageContentPart: {
83 type: 'object',
84 description:
85 "Image content part. Ark extends OpenAI's image_url with an 'xhigh' detail level and image_pixel_limit bounds.",
86 properties: {
87 type: { type: 'string', enum: ['image_url'] },
88 image_url: {
89 type: 'object',
90 properties: {
91 url: {
92 type: 'string',
93 description: 'Public image URL or data: URI.',
94 },
95 detail: {
96 type: 'string',
97 enum: ['auto', 'low', 'high', 'xhigh'],
98 description:
99 "Processing detail. Ark adds 'xhigh' to OpenAI's set. Default 'auto'.",
100 },
101 image_pixel_limit: {
102 type: 'object',
103 description:
104 'Bounds on how large the image is scaled to before tokenization. Lower max_pixels trades detail for input tokens; a min_pixels below the model floor is rejected.',
105 properties: {
106 max_pixels: { type: 'integer' },
107 min_pixels: { type: 'integer' },
108 },
109 },
110 },
111 required: ['url'],
112 },
113 },
114 required: ['type', 'image_url'],
115 },
116 ChatVideoContentPart: {
117 type: 'object',
118 description:
119 'Video content part (no OpenAI equivalent). Accepts a public URL or a data: URI.',
120 properties: {
121 type: { type: 'string', enum: ['video_url'] },
122 video_url: {
123 type: 'object',
124 properties: {
125 url: { type: 'string' },
126 fps: {
127 type: 'number',
128 description: 'Frame sampling rate in frames per second.',
129 },
130 },
131 required: ['url'],
132 },
133 },
134 required: ['type', 'video_url'],
135 },
136 ChatInputAudioContentPart: {
137 type: 'object',
138 description:
139 "Audio content part. Ark extends OpenAI's input_audio (inline base64 + format) with a url alternative; data and url are mutually exclusive.",
140 properties: {
141 type: { type: 'string', enum: ['input_audio'] },
142 input_audio: {
143 type: 'object',
144 properties: {
145 data: {
146 type: 'string',
147 description: 'Base64 audio payload. Mutually exclusive with url.',
148 },
149 format: {
150 type: 'string',
151 enum: ['wav', 'mp3', 'ogg', 'flac', 'm4a', 'aac', 'pcm'],
152 description: 'Container format of data. Required when data is set.',
153 },
154 url: {
155 type: 'string',
156 description: 'Public audio URL. Mutually exclusive with data.',
157 },
158 },
159 },
160 },
161 required: ['type', 'input_audio'],
162 },
163 ChatContentPart: {
164 oneOf: [
165 { $ref: '#/components/schemas/ChatTextContentPart' },
166 { $ref: '#/components/schemas/ChatImageContentPart' },
167 { $ref: '#/components/schemas/ChatVideoContentPart' },
168 { $ref: '#/components/schemas/ChatInputAudioContentPart' },
169 ],
170 },
172​
173const chatSchemas: Record<string, Schema> = {
174 ...chatContentPartSchemas,
175 ChatToolCall: {
176 type: 'object',
177 properties: {
178 id: { type: 'string' },
179 type: { type: 'string', enum: ['function'] },
180 function: {
181 type: 'object',
182 properties: {
183 name: { type: 'string' },
184 arguments: {
185 type: 'string',
186 description: 'JSON-encoded argument object.',
187 },
188 },
189 required: ['name', 'arguments'],
190 },
191 },
192 required: ['id', 'type', 'function'],
193 },
194 ChatMessage: {
195 type: 'object',
196 properties: {
197 role: {
198 type: 'string',
199 enum: ['system', 'user', 'assistant', 'tool'],
200 },
201 content: {
202 description:
203 'Message text, or an array of multimodal content parts. Null on assistant turns that carry only tool_calls.',
204 oneOf: [
205 { type: 'string' },
206 {
207 type: 'array',
208 items: { $ref: '#/components/schemas/ChatContentPart' },
209 },
210 { type: 'null' },
211 ],
212 },
213 name: { type: 'string' },
214 tool_calls: {
215 type: 'array',
216 items: { $ref: '#/components/schemas/ChatToolCall' },
217 description: 'Tool calls issued by a prior assistant turn.',
218 },
219 tool_call_id: {
220 type: 'string',
221 description: "For role 'tool': id of the call this message answers.",
222 },
223 reasoning_content: {
224 type: 'string',
225 description:
226 'Reasoning trace from a prior assistant turn, echoed back on multi-turn conversations.',
227 },
228 encrypted_content: {
229 type: 'string',
230 description:
231 'Opaque signature blob emitted alongside reasoning_content by thinking-summary models (dola-seed-2-1-turbo, seed-2-0-lite/mini/pro-2604xx family). When present it should be echoed back verbatim on the assistant message in the next turn; omitting it is tolerated.',
232 },
233 },
234 required: ['role'],
235 },
236 ChatTool: {
237 type: 'object',
238 properties: {
239 type: { type: 'string', enum: ['function'] },
240 function: {
241 type: 'object',
242 properties: {
243 name: { type: 'string' },
244 description: { type: 'string' },
245 parameters: {
246 type: 'object',
247 description: 'JSON Schema of the function arguments.',
248 },
249 },
250 required: ['name'],
251 },
252 },
253 required: ['type', 'function'],
254 },
255 ChatToolChoice: {
256 description:
257 "Tool-selection strategy: 'none', 'auto', 'required', or a named function.",
258 oneOf: [
259 { type: 'string', enum: ['none', 'auto', 'required'] },
260 {
261 type: 'object',
262 properties: {
263 type: { type: 'string', enum: ['function'] },
264 function: {
265 type: 'object',
266 properties: { name: { type: 'string' } },
267 required: ['name'],
268 },
269 },
270 required: ['type', 'function'],
271 },
272 ],
273 },
274 ChatResponseFormat: {
275 type: 'object',
276 description:
277 "Structured output. Only {type: 'json_schema'} works, and only on a subset of models (probed 2026-07-31: dola-seed-2-1-turbo-260628, seed-2-0-pro-260328, seed-2-0-lite-260228, seed-2-0-mini-260215, seed-1-8-251228, the seed-1-6 family, glm-5-2-260617). Ark rejects {type: 'json_object'} outright on every model, and glm-4-7-251222 accepts a json_schema but ignores it.",
278 properties: {
279 type: { type: 'string', enum: ['json_schema'] },
280 json_schema: {
281 type: 'object',
282 properties: {
283 name: { type: 'string' },
284 schema: { type: 'object' },
285 strict: { type: 'boolean' },
286 },
287 required: ['name', 'schema'],
288 },
289 },
290 required: ['type', 'json_schema'],
291 },
292 ChatThinking: {
293 type: 'object',
294 description:
295 "Reasoning ('deep thinking') switch. 'enabled' is the default on every model except deepseek-v3-2-251201; 'auto' is only accepted by gpt-oss-120b-250805. Cannot be combined with reasoning_effort when disabled (400 InvalidParameter).",
296 properties: {
297 type: { type: 'string', enum: ['enabled', 'disabled', 'auto'] },
298 },
299 required: ['type'],
300 },
301 ChatCompletionRequest: {
302 type: 'object',
303 description:
304 'Ark chat completion request — OpenAI-compatible plus the Ark-only thinking, reasoning_effort, repetition_penalty and service_tier fields. Every field was accepted by a live request against the ap-southeast host on 2026-07-31.',
305 properties: {
306 model: {
307 type: 'string',
308 description:
309 'Ark model id (e.g. seed-2-0-lite-260428) or a preconfigured endpoint id.',
310 },
311 messages: {
312 type: 'array',
313 items: { $ref: '#/components/schemas/ChatMessage' },
314 },
315 thinking: { $ref: '#/components/schemas/ChatThinking' },
316 reasoning_effort: {
317 type: 'string',
318 enum: ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'],
319 description:
320 "Reasoning budget hint. 'none' and 'xhigh' are only accepted by glm-5-2-260617; 'max' by glm-5-2-260617 and the deepseek-v4-* models. Rejected in combination with thinking: {type: 'disabled'}.",
321 },
322 repetition_penalty: {
323 type: 'number',
324 description:
325 'Penalty applied to repeated tokens. Values above 1 discourage repetition.',
326 },
327 service_tier: {
328 type: 'string',
329 enum: ['default', 'flex'],
330 description:
331 "'flex' routes to the batch queue at a lower price with no latency guarantee.",
332 },
333 temperature: { type: 'number' },
334 top_p: { type: 'number' },
335 top_k: { type: 'integer' },
336 max_tokens: {
337 type: 'integer',
338 description:
339 'Maximum tokens to generate. Mutually exclusive with max_completion_tokens — sending both is a 400.',
340 },
341 max_completion_tokens: {
342 type: 'integer',
343 description:
344 "OpenAI's newer name for max_tokens; mutually exclusive with it.",
345 },
346 frequency_penalty: { type: 'number' },
347 presence_penalty: { type: 'number' },
348 stop: {
349 description: 'Up to four strings that stop generation when produced.',
350 oneOf: [
351 { type: 'string' },
352 { type: 'array', items: { type: 'string' } },
353 ],
354 },
355 n: { type: 'integer', description: 'Number of completions to generate.' },
356 seed: {
357 type: 'integer',
358 description: 'Best-effort determinism hint for repeated requests.',
359 },
360 logprobs: { type: 'boolean' },
361 top_logprobs: {
362 type: 'integer',
363 description: 'Alternatives to report per token. Requires logprobs.',
364 },
365 logit_bias: {
366 type: 'object',
367 additionalProperties: { type: 'number' },
368 description: 'Additive bias per token id, applied before sampling.',
369 },
370 user: {
371 type: 'string',
372 description:
373 'Opaque end-user identifier forwarded for abuse monitoring.',
374 },
375 parallel_tool_calls: { type: 'boolean' },
376 tool_choice: { $ref: '#/components/schemas/ChatToolChoice' },
377 tools: {
378 type: 'array',
379 items: { $ref: '#/components/schemas/ChatTool' },
380 },
381 response_format: { $ref: '#/components/schemas/ChatResponseFormat' },
382 stream: { type: 'boolean' },
383 stream_options: {
384 type: 'object',
385 properties: { include_usage: { type: 'boolean' } },
386 },
387 },
388 required: ['model', 'messages'],
389 },
390 ChatCompletionResponse: {
391 type: 'object',
392 properties: {
393 id: { type: 'string' },
394 object: { type: 'string' },
395 model: {
396 type: 'string',
397 description:
398 'Canonical model id actually used — Ark echoes the prefixed id back for aliases (e.g. dola-seed-2-1-turbo-260628).',
399 },
400 created: { type: 'integer', description: 'Unix seconds.' },
401 service_tier: { type: 'string' },
402 choices: {
403 type: 'array',
404 items: {
405 type: 'object',
406 properties: {
407 index: { type: 'integer' },
408 finish_reason: {
409 type: 'string',
410 description:
411 "Why generation stopped — 'stop', 'length', 'tool_calls' or 'content_filter'.",
412 },
413 message: {
414 type: 'object',
415 properties: {
416 role: { type: 'string' },
417 content: { oneOf: [{ type: 'string' }, { type: 'null' }] },
418 reasoning_content: {
419 type: 'string',
420 description:
421 'Reasoning trace, delivered separately from answer text. Seed models reason by default.',
422 },
423 encrypted_content: {
424 type: 'string',
425 description:
426 'Opaque signature over the reasoning trace (thinking-summary models only); echo back on the next turn when present.',
427 },
428 tool_calls: {
429 type: 'array',
430 items: { $ref: '#/components/schemas/ChatToolCall' },
431 },
432 },
433 },
434 },
435 },
436 },
437 usage: {
438 type: 'object',
439 properties: {
440 prompt_tokens: { type: 'integer' },
441 completion_tokens: { type: 'integer' },
442 total_tokens: { type: 'integer' },
443 prompt_tokens_details: {
444 type: 'object',
445 properties: { cached_tokens: { type: 'integer' } },
446 },
447 completion_tokens_details: {
448 type: 'object',
449 properties: { reasoning_tokens: { type: 'integer' } },
450 },
451 },
452 },
453 },
454 },
456​
457// ---------------------------------------------------------------------------
458// Image (/images/generations — Seedream)
459// ---------------------------------------------------------------------------
460​
461const imageSchemas: Record<string, Schema> = {
462 ImageGenerationRequest: {
463 type: 'object',
464 description:
465 "Seedream image generation. Deviates from OpenAI's endpoint in three ways: there is no n parameter (group-image mode via sequential_image_generation instead), size accepts a shorthand token as well as WxH, and editing inputs ride in the top-level image field rather than a separate /images/edits endpoint.",
466 properties: {
467 model: {
468 type: 'string',
469 description:
470 'Seedream model id (e.g. seedream-4-0-250828) or a preconfigured endpoint id.',
471 },
472 prompt: {
473 type: 'string',
474 description:
475 'Instruction text (docs give the limit as 600 English words).',
476 },
477 image: {
478 type: 'array',
479 items: { type: 'string' },
480 description:
481 'Input images for image-conditioned generation (editing, reference-guided generation, multi-reference composition). Each entry is a publicly reachable URL or a data:image/<format>;base64,<data> URI — <format> must be lowercase. Up to 14 references (10 on dola-seedream-5-0-pro-260628).',
482 },
483 size: {
484 type: 'string',
485 description:
486 "Output size: a shorthand token ('1K', '2K', '4K') or explicit pixels ('2048x2048') — never a mix. Server default 2048x2048.",
487 },
488 response_format: {
489 type: 'string',
490 enum: ['url', 'b64_json'],
491 description:
492 "How generated images come back. 'url' links expire 24 hours after generation. Server default 'url'.",
493 },
494 output_format: {
495 type: 'string',
496 enum: ['png', 'jpeg'],
497 description:
498 "Generated file format. Seedream 5.0 family only; default 'jpeg'.",
499 },
500 watermark: {
501 type: 'boolean',
502 description:
503 "Stamp an 'AI generated' watermark in the bottom-right corner. DEFAULTS TO TRUE — pass false to opt out.",
504 },
505 sequential_image_generation: {
506 type: 'string',
507 enum: ['auto', 'disabled'],
508 description:
509 "Group-image mode: 'auto' lets the model return a set of related images (bounded by sequential_image_generation_options.max_images — an upper bound, not a count); 'disabled' (server default) returns exactly one.",
510 },
511 sequential_image_generation_options: {
512 type: 'object',
513 properties: {
514 max_images: {
515 type: 'integer',
516 minimum: 1,
517 maximum: 15,
518 description: 'Upper bound on images returned for this request.',
519 },
520 },
521 },
522 seed: {
523 type: 'integer',
524 description:
525 'Randomness seed for reproducible generation. SDK-derived (byteplus-go-sdk-v2 GenerateImagesRequest.Seed; also in the Volcengine Python SDK) — not probe-verified.',
526 },
527 guidance_scale: {
528 type: 'number',
529 description:
530 'How strictly the result follows the prompt; higher values adhere more closely at some cost to diversity. SDK-derived (byteplus-go-sdk-v2 GenerateImagesRequest.GuidanceScale) — not probe-verified.',
531 },
532 optimize_prompt: {
533 type: 'boolean',
534 description:
535 'Toggle prompt rewriting. The finer-grained optimize_prompt_options selects the mode. SDK-derived (byteplus-go-sdk-v2) — not probe-verified.',
536 },
537 tools: {
538 type: 'array',
539 description:
540 'Provider tools to run during generation; the only documented member is web search, and its usage comes back under usage.tool_usage.web_search. SDK-derived (byteplus-go-sdk-v2 ContentGenerationTool) — not probe-verified.',
541 items: {
542 type: 'object',
543 properties: { type: { type: 'string' } },
544 required: ['type'],
545 },
546 },
547 optimize_prompt_options: {
548 type: 'object',
549 description: 'Prompt rewriting. Seedream 5.0-lite / 4.5 / 4.0 only.',
550 properties: {
551 mode: {
552 type: 'string',
553 enum: ['standard', 'fast'],
554 description:
555 "'standard' is higher quality but slower; 'fast' is unsupported on Seedream 5.0-lite and 4.5.",
556 },
557 },
558 required: ['mode'],
559 },
560 stream: {
561 type: 'boolean',
562 description:
563 'Server-sent-events mode, emitting each image as it finishes.',
564 },
565 layer_decomposition: {
566 type: 'boolean',
567 description:
568 'Layer decomposition (Seedream 5.0 pro and flash): true splits the single input `image` into a base image plus up to 16 PNG layers. Server default false.',
569 },
570 },
571 required: ['model', 'prompt'],
572 },
573 ImageErrorObject: {
574 type: 'object',
575 description:
576 'Ark error object: dotted codes for transport failures (InvalidEndpointOrModel.NotFound), bare identifiers for content failures (OutputImageSensitiveContentDetected, QuotaExceeded).',
577 properties: {
578 code: { type: 'string' },
579 message: { type: 'string' },
580 },
581 },
582 ImageGenerationResponse: {
583 type: 'object',
584 properties: {
585 model: { type: 'string' },
586 created: { type: 'integer', description: 'Unix seconds.' },
587 data: {
588 type: 'array',
589 items: {
590 type: 'object',
591 description:
592 'A generated image, or (in group-image mode) a per-image failure. size is the actual pixel size produced and only returned by some models.',
593 properties: {
594 url: {
595 type: 'string',
596 description: 'Download URL; expires 24 hours after generation.',
597 },
598 b64_json: { type: 'string' },
599 size: { type: 'string' },
600 error: { $ref: '#/components/schemas/ImageErrorObject' },
601 },
602 },
603 },
604 usage: {
605 type: 'object',
606 description:
607 'BytePlus bills images, not input tokens: total_tokens equals output_tokens, generated_images counts only successes.',
608 properties: {
609 generated_images: { type: 'integer' },
610 output_tokens: { type: 'integer' },
611 total_tokens: { type: 'integer' },
612 },
613 },
614 error: { $ref: '#/components/schemas/ImageErrorObject' },
615 },
616 },
618​
619// ---------------------------------------------------------------------------
620// Video (/contents/generations/tasks — Seedance async task API)
621// ---------------------------------------------------------------------------
622​
623const videoSchemas: Record<string, Schema> = {
624 VideoContentPart: {
625 description:
626 'One entry of the content array: prompt text plus image / video / audio inputs. The API sorts requests into task types from the roles present — i2v (first frame), flf2v (first + last frame) and r2v (reference media) — and the two families are mutually exclusive. On Seedance 2.0, reference_audio cannot be the only reference input.',
627 oneOf: [
628 {
629 type: 'object',
630 properties: {
631 type: { type: 'string', enum: ['text'] },
632 text: { type: 'string' },
633 },
634 required: ['type', 'text'],
635 },
636 {
637 type: 'object',
638 properties: {
639 type: { type: 'string', enum: ['image_url'] },
640 image_url: {
641 type: 'object',
642 properties: {
643 url: {
644 type: 'string',
645 description:
646 'Public URL (fetched server-side) or data: URI carrying the bytes inline.',
647 },
648 },
649 required: ['url'],
650 },
651 role: {
652 type: 'string',
653 enum: [
654 'first_frame',
655 'last_frame',
656 'reference_image',
657 'reference_video',
658 'reference_audio',
659 ],
660 description:
661 "Omitted for a bare first frame — the API defaults to 'first_frame'.",
662 },
663 },
664 required: ['type', 'image_url'],
665 },
666 {
667 type: 'object',
668 properties: {
669 type: { type: 'string', enum: ['video_url'] },
670 video_url: {
671 type: 'object',
672 properties: { url: { type: 'string' } },
673 required: ['url'],
674 },
675 role: {
676 type: 'string',
677 enum: [
678 'first_frame',
679 'last_frame',
680 'reference_image',
681 'reference_video',
682 'reference_audio',
683 ],
684 description: "Reference-media mode requires 'reference_video'.",
685 },
686 },
687 required: ['type', 'video_url'],
688 },
689 {
690 type: 'object',
691 properties: {
692 type: { type: 'string', enum: ['audio_url'] },
693 audio_url: {
694 type: 'object',
695 properties: { url: { type: 'string' } },
696 required: ['url'],
697 },
698 role: {
699 type: 'string',
700 enum: [
701 'first_frame',
702 'last_frame',
703 'reference_image',
704 'reference_video',
705 'reference_audio',
706 ],
707 },
708 },
709 required: ['type', 'audio_url'],
710 },
711 ],
712 },
713 VideoTaskCreateRequest: {
714 type: 'object',
715 description:
716 'Open a Seedance video generation task. Only model and content are required; every other field is model-dependent and Ark rejects an inapplicable field outright rather than ignoring it, so send only what applies to the target model.',
717 properties: {
718 model: {
719 type: 'string',
720 description:
721 'Seedance model id (e.g. seedance-1-5-pro-251215; the 2.0 family requires the dreamina- prefix) or a preconfigured endpoint id.',
722 },
723 content: {
724 type: 'array',
725 items: { $ref: '#/components/schemas/VideoContentPart' },
726 },
727 ratio: {
728 type: 'string',
729 description:
730 "Output aspect ratio: 16:9, 9:16, 4:3, 3:4, 1:1, 21:9, or 'adaptive' (follows the input frame; image-to-video only).",
731 },
732 resolution: {
733 type: 'string',
734 description:
735 'Resolution tier: 480p/720p on Seedance 2.5 and 2.0-fast/-mini, up to 1080p on the 1.x models and 4k on dreamina-seedance-2-0-260128. Matched case-insensitively by the API; there is no 2K tier on any model.',
736 },
737 duration: {
738 type: 'integer',
739 description:
740 'Whole seconds of output (2-12s on 1.0, 4-12s on 1.5-pro, 4-15s on 2.0, 4-30s on 2.5). -1 lets the model choose (2.5 / 2.0 / 1.5-pro).',
741 },
742 frames: {
743 type: 'integer',
744 description:
745 'Frame count, an alternative to duration that allows fractional seconds.',
746 },
747 seed: {
748 type: 'integer',
749 description:
750 'Randomness seed; integers in [-1, 2^32-1], where -1 means unseeded.',
751 },
752 camera_fixed: {
753 type: 'boolean',
754 description:
755 "Appends a 'fix the camera' instruction to the prompt. Default false.",
756 },
757 watermark: {
758 type: 'boolean',
759 description: 'Burn a watermark into the output. Default false.',
760 },
761 generate_audio: {
762 type: 'boolean',
763 description: 'Generate a synchronized audio track. Default false.',
764 },
765 service_tier: {
766 type: 'string',
767 enum: ['default', 'flex'],
768 description:
769 "'default' (online) or 'flex' (offline batch, half price). Note flex tasks are missing from the default task listing unless filter.service_tier=flex is passed.",
770 },
771 return_last_frame: {
772 type: 'boolean',
773 description: 'Also return the final frame as a PNG. Default false.',
774 },
775 draft: {
776 type: 'boolean',
777 description: 'Cheap low-fidelity preview render. Default false.',
778 },
779 priority: {
780 type: 'integer',
781 minimum: 0,
782 maximum: 9,
783 description: 'Queue priority.',
784 },
785 output_format: {
786 type: 'string',
787 description: 'Container of the generated video, e.g. mp4 or mov.',
788 },
789 execution_expires_after: {
790 type: 'integer',
791 description:
792 "Seconds from created_at after which the task is marked 'expired'.",
793 },
794 callback_url: {
795 type: 'string',
796 description:
797 'URL that receives a POST with the task payload on each status change.',
798 },
799 safety_identifier: {
800 type: 'string',
801 maxLength: 64,
802 description: 'Opaque per-end-user identifier for abuse attribution.',
803 },
804 },
805 required: ['model', 'content'],
806 },
807 VideoTaskCreateResponse: {
808 type: 'object',
809 description:
810 'Task acknowledgment (live-verified: the body is just the task id, e.g. cgt-batch-20260731174311-zmz5s — the -batch infix appears on flex-tier routing). The video is not in this body. Poll GET /contents/generations/tasks/{id} until status is succeeded; content.video_url expires 24 hours later (the task record itself is kept for 7 days).',
811 properties: {
812 id: {
813 type: 'string',
814 description:
815 'Task id. Retrieve the video with GET /contents/generations/tasks/{id}.',
816 },
817 },
818 },
819 VideoTask: {
820 type: 'object',
821 description:
822 'Retrieved task. content.video_url is the file once status is succeeded. URLs are valid for 24 hours; task records can be queried for 7 days.',
823 properties: {
824 id: { type: 'string' },
825 model: { type: 'string' },
826 status: {
827 type: 'string',
828 description:
829 'queued, running, succeeded, failed, or cancelled. content.video_url is present once this is succeeded.',
830 },
831 error: {
832 type: 'object',
833 properties: {
834 code: { type: 'string' },
835 message: { type: 'string' },
836 },
837 },
838 content: {
839 type: 'object',
840 description: 'Output of a completed task.',
841 properties: {
842 video_url: {
843 type: 'string',
844 description:
845 'URL of the generated video. Valid for 24 hours. A Dreamina Seedance 2.5 URL can be downloaded up to 100 times.',
846 },
847 last_frame_url: {
848 type: 'string',
849 description:
850 'URL of the last frame, when the create call set return_last_frame: true. Valid for 24 hours.',
851 },
852 },
853 },
854 usage: {
855 type: 'object',
856 properties: {
857 completion_tokens: { type: 'integer' },
858 total_tokens: { type: 'integer' },
859 },
860 },
861 resolution: { type: 'string' },
862 ratio: { type: 'string' },
863 duration: { type: 'integer' },
864 framespersecond: { type: 'integer' },
865 seed: { type: 'integer' },
866 created_at: { type: 'integer' },
867 updated_at: { type: 'integer' },
868 service_tier: { type: 'string' },
869 generate_audio: { type: 'boolean' },
870 draft: { type: 'boolean' },
871 },
872 required: ['id', 'status'],
873 },
875​
876/** Ark data-plane document: chat, Seedream image, Seedance video. */
877export function bytePlusArkSpec(): OpenApiDocument {
878 return {
879 openapi: '3.1.0',
880 info: {
881 title: 'BytePlus ModelArk API',
882 version: 'v3',
883 description:
884 'Synthesized from @tanstack/ai-byteplus wire types (harvested Ark OpenAPI documents + live probes, 2026-07-31). Auth: Authorization: Bearer $ARK_API_KEY; keys are region-isolated.',
885 },
886 servers: [{ url: BYTEPLUS_ARK_BASE_URL }],
887 paths: {
888 '/chat/completions': {
889 post: {
890 [PROVENANCE_MARKER]: {
891 derivation: 'probe-verified',
892 verifiedAt: '2026-07-31',
893 },
894 operationId: 'createChatCompletion',
895 summary:
896 'Chat completion (Seed / GLM / DeepSeek / gpt-oss) — OpenAI-compatible plus thinking, reasoning_effort, repetition_penalty and service_tier',
897 requestBody: {
898 required: true,
899 content: {
900 'application/json': {
901 schema: { $ref: '#/components/schemas/ChatCompletionRequest' },
902 },
903 },
904 },
905 responses: {
906 '200': {
907 description: 'Completion',
908 content: {
909 'application/json': {
910 schema: {
911 $ref: '#/components/schemas/ChatCompletionResponse',
912 },
913 },
914 },
915 },
916 },
917 },
918 },
919 '/images/generations': {
920 post: {
921 [PROVENANCE_MARKER]: {
922 derivation: 'probe-verified',
923 verifiedAt: '2026-07-31',
924 },
925 operationId: 'createImageGeneration',
926 summary: 'Generate or edit images with Seedream',
927 requestBody: {
928 required: true,
929 content: {
930 'application/json': {
931 schema: { $ref: '#/components/schemas/ImageGenerationRequest' },
932 },
933 },
934 },
935 responses: {
936 '200': {
937 description: 'Generated images',
938 content: {
939 'application/json': {
940 schema: {
941 $ref: '#/components/schemas/ImageGenerationResponse',
942 },
943 },
944 },
945 },
946 },
947 },
948 },
949 '/contents/generations/tasks': {
950 post: {
951 [PROVENANCE_MARKER]: {
952 derivation: 'probe-verified',
953 verifiedAt: '2026-07-31',
954 },
955 operationId: 'createContentsGenerationsTask',
956 summary:
957 'Open a Seedance video generation task (async — poll GET /contents/generations/tasks/{id} for the result)',
958 requestBody: {
959 required: true,
960 content: {
961 'application/json': {
962 schema: {
963 $ref: '#/components/schemas/VideoTaskCreateRequest',
964 },
965 },
966 },
967 },
968 responses: {
969 '200': {
970 description: 'Task acknowledgment',
971 content: {
972 'application/json': {
973 schema: {
974 $ref: '#/components/schemas/VideoTaskCreateResponse',
975 },
976 },
977 },
978 },
979 },
980 },
981 },
982 '/contents/generations/tasks/{id}': {
983 get: {
984 [PROVENANCE_MARKER]: {
985 derivation: 'probe-verified',
986 verifiedAt: '2026-07-31',
987 },
988 operationId: 'getContentsGenerationsTask',
989 summary:
990 'Retrieve a Seedance video task. Poll until status is succeeded, then download content.video_url (valid 24 hours).',
991 parameters: [
992 {
993 name: 'id',
994 in: 'path',
995 required: true,
996 description:
997 'Task id from POST /contents/generations/tasks. Records from the past 7 days can be queried.',
998 schema: { type: 'string' },
999 },
1000 ],
1001 responses: {
1002 '200': {
1003 description:
1004 'Task record. content.video_url is the file once status is succeeded.',
1005 content: {
1006 'application/json': {
1007 schema: { $ref: '#/components/schemas/VideoTask' },
1008 },
1009 },
1010 },
1011 },
1012 },
1013 },
1014 },
1015 components: {
1016 schemas: { ...chatSchemas, ...imageSchemas, ...videoSchemas },
1017 },
1020​
1021// ---------------------------------------------------------------------------
1022// Seed Speech (voice host — separate product and API key)
1023// ---------------------------------------------------------------------------
1024​
1025const voiceSchemas: Record<string, Schema> = {
1026 TTSReference: {
1027 type: 'object',
1028 description:
1029 "Voice selection / cloning reference. FLAT shape — the members sit directly on the entry, with no discriminating `type` field (an entry carrying one is accepted only because unknown keys are ignored); an unknown speaker id fails 400 45001115 'speaker … not found in speaker_map, speaker_audio, or mega_info'. Live-verified 2026-08-12. Exactly one of speaker, audio_url or audio_data per entry; at most 3 audio references (30s / 10MB each) and 1 image reference (10MB), and image references are mutually exclusive with audio ones. The @Audio1..@Audio3 markers in text_prompt address audio references positionally.",
1030 properties: {
1031 speaker: {
1032 type: 'string',
1033 description: 'Stock voice id, e.g. en_female_stokie_uranus_bigtts.',
1034 },
1035 audio_url: {
1036 type: 'string',
1037 description: 'URL of a reference clip to clone (≤30s, ≤10MB).',
1038 },
1039 audio_data: {
1040 type: 'string',
1041 description: 'Base64 reference clip to clone (≤30s, ≤10MB).',
1042 },
1043 image_url: {
1044 type: 'string',
1045 description: 'URL of a reference image (≤10MB).',
1046 },
1047 image_data: {
1048 type: 'string',
1049 description: 'Base64 reference image (≤10MB).',
1050 },
1051 },
1052 },
1053 TTSAudioConfig: {
1054 type: 'object',
1055 description:
1056 "Audio output configuration. The *_rate fields are integer percentages relative to the voice's neutral delivery, not multipliers.",
1057 properties: {
1058 format: {
1059 type: 'string',
1060 enum: ['wav', 'mp3', 'pcm', 'ogg_opus'],
1061 description: "Output container/codec. Server default 'wav'.",
1062 },
1063 sample_rate: {
1064 type: 'integer',
1065 description:
1066 'Output sample rate in Hz. The docs list 8000/16000/24000/32000/44100/48000, but the endpoint is not strict — 40000 (the documented default, absent from that list) is accepted with 200. Left unconstrained rather than enumerated so validation does not reject requests the API honours. Live-verified 2026-08-12.',
1067 },
1068 speech_rate: {
1069 type: 'integer',
1070 minimum: -50,
1071 maximum: 100,
1072 description: 'Speaking rate: -50 = 0.5x, 0 = 1x, 100 = 2x.',
1073 },
1074 loudness_rate: {
1075 type: 'integer',
1076 minimum: -50,
1077 maximum: 100,
1078 description: "Loudness adjustment; 0 is the voice's natural level.",
1079 },
1080 pitch_rate: {
1081 type: 'integer',
1082 minimum: -12,
1083 maximum: 12,
1084 description: "Pitch adjustment; 0 is the voice's natural pitch.",
1085 },
1086 enable_subtitle: {
1087 type: 'boolean',
1088 description:
1089 'Emit sentence and word timings in the response. Default false.',
1090 },
1091 },
1092 },
1093 TTSCreateRequest: {
1094 type: 'object',
1095 description:
1096 'Seed Speech synthesis. Output audio is capped at 120 seconds (before rate adjustment). model and text_prompt are the only required fields — live-verified 2026-08-12; references and audio_config are both optional, and unrecognised members inside a references entry are ignored rather than rejected.',
1097 properties: {
1098 model: {
1099 type: 'string',
1100 description: 'Seed Speech synthesis model, e.g. seed-audio-1.0.',
1101 },
1102 text_prompt: {
1103 type: 'string',
1104 maxLength: 3000,
1105 description:
1106 "The text to speak. Dual-purpose: literal text or a natural-language description of the delivery, and where the @Audio1..@Audio3 reference markers go. (The field is text_prompt, not text — the 'text' spelling belongs to the separate /tts/unidirectional endpoint.)",
1107 },
1108 references: {
1109 type: 'array',
1110 items: { $ref: '#/components/schemas/TTSReference' },
1111 },
1112 audio_config: { $ref: '#/components/schemas/TTSAudioConfig' },
1113 watermark: {
1114 type: 'object',
1115 description:
1116 'Watermark the generated audio. NOT a boolean: `true` and a bare string both fail with 500 `55000000 kiteX processing … thrift marshal`, while an object is accepted with 200 — so the wire type is a struct. Its member names could not be confirmed (an unrecognised object is accepted unchanged), so no properties are asserted here. Live-probed 2026-08-12.',
1117 },
1118 },
1119 required: ['model', 'text_prompt'],
1120 },
1121 TTSSubtitleWord: {
1122 type: 'object',
1123 description:
1124 "One timed word. Times are MILLISECONDS — unlike the response's duration fields, which are seconds. Note the tokenizer emits whitespace as its own zero-or-near-zero-width entry.",
1125 properties: {
1126 text: { type: 'string' },
1127 start_time: { type: 'number' },
1128 end_time: { type: 'number' },
1129 },
1130 },
1131 TTSSubtitleSentence: {
1132 type: 'object',
1133 description:
1134 'One timed sentence, carrying its own word-level breakdown. Times are MILLISECONDS.',
1135 properties: {
1136 text: { type: 'string' },
1137 start_time: { type: 'number' },
1138 end_time: { type: 'number' },
1139 words: {
1140 type: 'array',
1141 items: { $ref: '#/components/schemas/TTSSubtitleWord' },
1142 },
1143 },
1144 },
1145 TTSCreateResponse: {
1146 type: 'object',
1147 description:
1148 'Success body, live-verified 2026-08-12. There is NO code/message pair on success — those two appear only on failures, as a flat envelope such as {"code": 45001115, "message": "speaker … not found in speaker_map, speaker_audio, or mega_info"} with a 4xx/5xx status.',
1149 properties: {
1150 audio: {
1151 type: 'string',
1152 description: 'Base64-encoded audio in the requested format.',
1153 },
1154 duration: {
1155 type: 'number',
1156 description:
1157 'Length of the delivered audio in SECONDS (float), after speech_rate is applied.',
1158 },
1159 original_duration: {
1160 type: 'number',
1161 description:
1162 'Length in SECONDS before rate adjustment — the billing basis, capped at 120.',
1163 },
1164 url: {
1165 type: 'string',
1166 description:
1167 'Temporary download URL for the same audio, signed with an x-expires deadline.',
1168 },
1169 subtitle: {
1170 type: 'object',
1171 description:
1172 'Present when audio_config.enable_subtitle was set. Word timings are NESTED inside each sentence — there is no top-level words array — and the block repeats the full text alongside them.',
1173 properties: {
1174 text: {
1175 type: 'string',
1176 description: 'The full spoken text.',
1177 },
1178 sentences: {
1179 type: 'array',
1180 items: { $ref: '#/components/schemas/TTSSubtitleSentence' },
1181 },
1182 },
1183 },
1184 },
1185 },
1186 ASRUtterance: {
1187 type: 'object',
1188 description:
1189 'One recognised utterance; start_time/end_time are milliseconds.',
1190 properties: {
1191 text: { type: 'string' },
1192 start_time: { type: 'number' },
1193 end_time: { type: 'number' },
1194 words: {
1195 type: 'array',
1196 items: {
1197 type: 'object',
1198 properties: {
1199 text: { type: 'string' },
1200 start_time: { type: 'number' },
1201 end_time: { type: 'number' },
1202 confidence: { type: 'number' },
1203 },
1204 },
1205 },
1206 additions: {
1207 type: 'object',
1208 additionalProperties: { type: 'string' },
1209 description:
1210 'Extra per-utterance annotations; speaker labels arrive here when enable_speaker_info is set.',
1211 },
1212 },
1213 },
1214 ASRRecognizeRequest: {
1215 type: 'object',
1216 description:
1217 "Flash (synchronous) recognition. The model is selected entirely by the X-Api-Resource-Id header ('volc.seedasr.auc_turbo') — there is no model field in the body. Files up to 2 hours / 100MB. STILL DOCS-DERIVED: probing 2026-08-12 with a valid voice key returned 403 45000030 '[resource_id=volc.seedasr.auc_turbo] requested resource not granted' (Seed ASR not provisioned on that account), so the request and response bodies below are unverified even though the header contract is now confirmed.",
1218 properties: {
1219 user: {
1220 type: 'object',
1221 properties: { uid: { type: 'string' } },
1222 },
1223 audio: {
1224 type: 'object',
1225 properties: {
1226 url: {
1227 type: 'string',
1228 description: 'Publicly reachable URL of the audio file.',
1229 },
1230 data: {
1231 type: 'string',
1232 description: 'Base64-encoded audio bytes.',
1233 },
1234 format: {
1235 type: 'string',
1236 description: 'Container hint, e.g. mp3, wav, ogg.',
1237 },
1238 },
1239 },
1240 request: {
1241 type: 'object',
1242 properties: {
1243 model_name: {
1244 type: 'string',
1245 description: "Recognition model family. Defaults to 'bigmodel'.",
1246 },
1247 enable_itn: {
1248 type: 'boolean',
1249 description:
1250 'Inverse text normalisation (spoken numbers → digits).',
1251 },
1252 enable_punc: { type: 'boolean', description: 'Insert punctuation.' },
1253 enable_ddc: {
1254 type: 'boolean',
1255 description: "Disfluency removal ('um', repeated words).",
1256 },
1257 enable_speaker_info: {
1258 type: 'boolean',
1259 description: 'Attach per-utterance speaker labels.',
1260 },
1261 show_utterances: {
1262 type: 'boolean',
1263 description:
1264 'Return the utterances breakdown as well as the flat transcript.',
1265 },
1266 language: {
1267 type: 'string',
1268 description: 'Spoken language hint, e.g. en-US.',
1269 },
1270 },
1271 },
1272 },
1273 required: ['audio'],
1274 },
1275 ASRRecognizeResponse: {
1276 type: 'object',
1277 description:
1278 'The Volcengine-lineage wire shape nests everything under result; the flat transcript/utterances spellings are tolerated aliases.',
1279 properties: {
1280 audio_info: {
1281 type: 'object',
1282 properties: {
1283 duration: {
1284 type: 'number',
1285 description: 'Audio length in MILLISECONDS.',
1286 },
1287 },
1288 },
1289 result: {
1290 type: 'object',
1291 properties: {
1292 text: { type: 'string' },
1293 utterances: {
1294 type: 'array',
1295 items: { $ref: '#/components/schemas/ASRUtterance' },
1296 },
1297 },
1298 },
1299 transcript: {
1300 type: 'string',
1301 description: 'Flat alias for result.text.',
1302 },
1303 utterances: {
1304 type: 'array',
1305 items: { $ref: '#/components/schemas/ASRUtterance' },
1306 },
1307 },
1308 },
1310​
1311/** Seed Speech document: TTS + flash ASR on the voice host. */
1312export function bytePlusVoiceSpec(): OpenApiDocument {
1313 return {
1314 openapi: '3.1.0',
1315 info: {
1316 title: 'BytePlus Seed Speech API',
1317 version: 'v3',
1318 description:
1319 "Synthesized from @tanstack/ai-byteplus wire types (BytePlus Seed Speech docs + Volcengine flash-recognition reference); request/response BODIES remain docs-derived and unverified. Auth is a separate product from Ark and the host accepts two schemes: X-Api-Key, and the classic Volcengine triple X-Api-App-Key + X-Api-Access-Key + X-Api-Resource-Id (which additionally requires the service to be provisioned for the account — an unprovisioned one fails 'load grant: requested grant not found in SaaS storage'). An Ark key fails with 45000010 Invalid X-Api-Key. Errors surface both in the body and as x-api-status-code / x-api-message response headers. Probed 2026-08-12.",
1320 },
1321 servers: [{ url: BYTEPLUS_VOICE_BASE_URL }],
1322 paths: {
1323 '/tts/create': {
1324 post: {
1325 // Every field below was exercised against the live endpoint.
1326 [PROVENANCE_MARKER]: {
1327 derivation: 'probe-verified',
1328 verifiedAt: '2026-08-12',
1329 },
1330 operationId: 'createSpeech',
1331 summary:
1332 'Synthesize speech with Seed Audio (stock voices or reference-clip cloning)',
1333 requestBody: {
1334 required: true,
1335 content: {
1336 'application/json': {
1337 schema: { $ref: '#/components/schemas/TTSCreateRequest' },
1338 },
1339 },
1340 },
1341 responses: {
1342 '200': {
1343 description: 'Synthesized audio',
1344 content: {
1345 'application/json': {
1346 schema: { $ref: '#/components/schemas/TTSCreateResponse' },
1347 },
1348 },
1349 },
1350 },
1351 },
1352 },
1353 '/auc/bigmodel/recognize/flash': {
1354 post: {
1355 // Header contract confirmed, but the account has no Seed ASR grant
1356 // so the request/response bodies were never exercised.
1357 [PROVENANCE_MARKER]: { derivation: 'docs-derived' },
1358 operationId: 'recognizeFlash',
1359 summary:
1360 'Transcribe audio with Seed ASR (model selected via the X-Api-Resource-Id header)',
1361 parameters: [
1363 name: 'X-Api-Request-Id',
1364 in: 'header',
1365 required: true,
1366 schema: { type: 'string', format: 'uuid' },
1367 description:
1368 'Caller-generated request id. REQUIRED — omitting it fails routing before auth is even evaluated, with 400 `45000000 error extract basicHttpRoutingPreference missing X-Api-Request-Id`. Echoed back as `header.reqid` in the response body. Live-verified 2026-08-12.',
1369 },
1371 name: 'X-Api-Resource-Id',
1372 in: 'header',
1373 required: true,
1374 schema: { type: 'string', enum: ['volc.seedasr.auc_turbo'] },
1375 description:
1376 'Selects the Seed ASR turbo model; the body takes no model field.',
1377 },
1378 ],
1379 requestBody: {
1380 required: true,
1381 content: {
1382 'application/json': {
1383 schema: { $ref: '#/components/schemas/ASRRecognizeRequest' },
1384 },
1385 },
1386 },
1387 responses: {
1388 '200': {
1389 description: 'Transcription',
1390 content: {
1391 'application/json': {
1392 schema: { $ref: '#/components/schemas/ASRRecognizeResponse' },
1393 },
1394 },
1395 },
1396 },
1397 },
1398 },
1399 },
1400 components: { schemas: voiceSchemas },