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

byteplus.md

625 lines26.3 KB

1---
2title: BytePlus
3id: byteplus-adapter
4order: 8
5description: "Use BytePlus ModelArk with TanStack AI — Seed chat models with reasoning, Seedance video generation, Seedream image generation, and Seed Speech text-to-speech and transcription via @tanstack/ai-byteplus."
6keywords:
7 - tanstack ai
8 - byteplus
9 - modelark
10 - ark
11 - seed
12 - seedance
13 - seedream
14 - seed speech
15 - bytedance
16 - video generation
17 - image generation
18 - text to speech
19 - transcription
20 - adapter
21---
22​
23The BytePlus adapter connects TanStack AI to [BytePlus](https://www.byteplus.com/), ByteDance's international model platform, across four generation kinds:
24​
25- **Chat** — the Seed model family (plus GLM, DeepSeek and gpt-oss) on ModelArk's OpenAI-compatible `/chat/completions` endpoint, with reasoning on by default.
26- **Video** — Seedance, an asynchronous task API.
27- **Image** — Seedream.
28- **Speech** — Seed Speech text-to-speech and transcription, which live on a **different host with a different API key** (see [Two products, two keys](#two-products-two-keys)).
29​
30## Installation
31​
32<!-- ::start:tabs variant="package-manager" mode="install" -->
33​
34react: @tanstack/ai-byteplus
35vue: @tanstack/ai-byteplus
36solid: @tanstack/ai-byteplus
37svelte: @tanstack/ai-byteplus
38preact: @tanstack/ai-byteplus
39angular: @tanstack/ai-byteplus
40vanilla: @tanstack/ai-byteplus
41octane: @tanstack/ai-byteplus
42​
43<!-- ::end:tabs -->
44​
45## Two products, two keys
46​
47BytePlus splits these models across two products, and they do not share credentials:
48​
49| Adapters | Product | Env var | Auth header |
50| --- | --- | --- | --- |
51| `byteplusText`, `byteplusVideo`, `byteplusImage` | ModelArk (Ark) | `ARK_API_KEY` (falls back to `BYTEPLUS_API_KEY`) | `Authorization: Bearer` |
52| `byteplusSpeech`, `byteplusTranscription` | Seed Speech | `BYTEPLUS_VOICE_API_KEY` | `X-Api-Key` |
53​
54BYOK uses two slugs because these are two keys: `byteplusByok` (Ark) and `byteplusVoiceByok` (Seed Speech), both from `@tanstack/ai-byteplus/byok`.
55​
56```bash
57# ModelArk: chat, Seedance video, Seedream image
58ARK_API_KEY=...
59​
60# Seed Speech: TTS and transcription — a separate product key
61BYTEPLUS_VOICE_API_KEY=...
62```
63​
64Passing an Ark key to the speech adapters fails with `45000010 Invalid X-Api-Key`.
65​
66Ark keys are also **region-isolated**: the default base URL is the Asia-Pacific south-east endpoint (`https://ark.ap-southeast.bytepluses.com/api/v3`), and a key issued for one region will not authenticate against another. Point the adapter elsewhere with `baseURL`:
67​
68```typescript
69import { createBytePlusText } from '@tanstack/ai-byteplus'
70import { arkApiKey } from './config'
71​
72const adapter = createBytePlusText('dola-seed-2-1-turbo-260628', arkApiKey, {
73 baseURL: 'https://ark.eu-west.bytepluses.com/api/v3',
74})
75```
76​
77Per the BytePlus docs the EU endpoint serves chat and image only — Seedance video is Asia-Pacific only.
78​
79## Chat
80​
81The adapter carries the model, so there is no separate `model` option.
82​
83**Server** — an endpoint that streams the reply back over SSE:
84​
85```typescript
86import { chat, toServerSentEventsResponse } from '@tanstack/ai'
87import { byteplusText } from '@tanstack/ai-byteplus'
88​
89export async function POST(request: Request) {
90 const { messages } = await request.json()
91​
92 const stream = chat({
93 adapter: byteplusText('dola-seed-2-1-turbo-260628'),
94 messages,
95 })
96​
97 return toServerSentEventsResponse(stream)
99```
100​
101**Client** — the same `useChat` hook as every other provider:
102​
103```tsx
104import { useState } from 'react'
105import { fetchServerSentEvents, useChat } from '@tanstack/ai-react'
106​
107export function Chat() {
108 const [input, setInput] = useState('')
109​
110 const { messages, sendMessage, isLoading } = useChat({
111 connection: fetchServerSentEvents('/api/chat'),
112 })
113​
114 return (
115 <div>
116 {messages.map((message) => (
117 <div key={message.id}>
118 <strong>{message.role}</strong>
119 {message.parts.map((part, index) =>
120 part.type === 'text' ? <p key={index}>{part.content}</p> : null,
121 )}
122 </div>
123 ))}
124​
125 <form
126 onSubmit={(event) => {
127 event.preventDefault()
128 if (!input.trim() || isLoading) return
129 sendMessage(input)
130 setInput('')
131 }}
132 >
133 <input value={input} onChange={(e) => setInput(e.target.value)} />
134 <button type="submit" disabled={isLoading}>
135 Send
136 </button>
137 </form>
138 </div>
139 )
141```
142​
143### Model options
144​
145Ark's chat endpoint is OpenAI-compatible, so sampling parameters keep their OpenAI snake_case names and live in `modelOptions`. `thinking`, `reasoning_effort`, `repetition_penalty` and `service_tier` are the Ark-only additions:
146​
147```typescript
148import { chat, toServerSentEventsResponse } from '@tanstack/ai'
149import { byteplusText } from '@tanstack/ai-byteplus'
150​
151export async function POST(request: Request) {
152 const { messages } = await request.json()
153​
154 const stream = chat({
155 adapter: byteplusText('dola-seed-2-1-turbo-260628'),
156 messages,
157 modelOptions: {
158 temperature: 0.7,
159 top_p: 0.9,
160 max_tokens: 2048,
161 thinking: { type: 'enabled' },
162 reasoning_effort: 'medium',
163 },
164 })
165​
166 return toServerSentEventsResponse(stream)
168```
169​
170Two constraints the type system can't express, both live-verified as `400`s:
171​
172- `max_tokens` and `max_completion_tokens` are mutually exclusive.
173- `reasoning_effort` cannot be combined with `thinking: { type: 'disabled' }`.
174​
175`service_tier: 'flex'` routes the request to the cheaper offline batch queue with no latency guarantee.
176​
177## Reasoning and `encrypted_content`
178​
179Seed models reason by default. Reasoning arrives as its own stream of `reasoning_content` deltas and is surfaced as reasoning content rather than answer text, so `useChat` renders it separately from the reply. Turn it off per request:
180​
181```typescript
182import { chat, toServerSentEventsResponse } from '@tanstack/ai'
183import { byteplusText } from '@tanstack/ai-byteplus'
184​
185export async function POST(request: Request) {
186 const { messages } = await request.json()
187​
188 const stream = chat({
189 adapter: byteplusText('dola-seed-2-1-turbo-260628'),
190 messages,
191 modelOptions: { thinking: { type: 'disabled' } },
192 })
193​
194 return toServerSentEventsResponse(stream)
196```
197​
198`disabled` works everywhere; `auto` is accepted only by `gpt-oss-120b-250805`. `deepseek-v3-2-251201` is the one model that defaults to reasoning *off*.
199​
200The four "thinking summary" models — `dola-seed-2-1-turbo-260628`, `seed-2-0-lite-260428`, `seed-2-0-mini-260428` and `seed-2-0-pro-260328` — also emit an opaque `encrypted_content` blob alongside the reasoning trace. It is a signature over that trace, and BytePlus's docs ask for it back verbatim on the assistant message in the next turn.
201​
202**The adapter round-trips it for you**, over the same seam Anthropic's thinking signatures use: the blob is captured off the stream and attached to the reasoning step as its `signature`, which lands on the thinking part of the assistant message and is echoed back on the next request. Two consequences worth knowing:
203​
204- If you persist and replay conversation history yourself, keep the thinking parts' `signature` — dropping it costs you the reasoning-cache hit. It is not fatal: a live probe confirmed Ark accepts a turn whose assistant message omits `encrypted_content`.
205- A structured-output turn doesn't capture the blob, for the same reason — again a lost cache hit, not a failed request.
206​
207## Structured output
208​
209Ten of the eighteen chat models accept `response_format: { type: 'json_schema' }`:
210​
211`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`, `seed-1-6-250915`, `seed-1-6-250615`, `seed-1-6-flash-250715`, `seed-1-6-flash-250615`, `glm-5-2-260617`.
212​
213```typescript
214import { chat } from '@tanstack/ai'
215import { byteplusText } from '@tanstack/ai-byteplus'
216import { z } from 'zod'
217​
218const RecipeSchema = z.object({
219 name: z.string().meta({ description: 'Name of the dish' }),
220 minutes: z.number().meta({ description: 'Total cooking time in minutes' }),
221 ingredients: z.array(z.string()),
222})
223​
224const recipe = await chat({
225 adapter: byteplusText('dola-seed-2-1-turbo-260628'),
226 messages: [{ role: 'user', content: 'Give me a recipe for carbonara' }],
227 outputSchema: RecipeSchema,
228})
229​
230console.log(recipe.name, recipe.minutes)
231```
232​
233On the other eight models the adapter **fails loudly** rather than degrading: `chat({ outputSchema })` throws, and the streaming form emits a `RUN_ERROR` naming the models that do work. There is no JSON-mode fallback to fall back *to* — Ark rejects `response_format: { type: 'json_object' }` on every one of them too.
234​
235Two traps worth knowing, both found by probing the live API rather than reading the tables:
236​
237- **The published capability tables are wrong in both directions.** `seed-2-0-lite-260428` — the obvious default model — is one of the eight that reject a JSON schema. Reach for `seed-2-0-lite-260228` or `dola-seed-2-1-turbo-260628` when you need typed output.
238- **`glm-4-7-251222` accepts a schema and then ignores it**, answering in prose with a `200`. It is deliberately excluded from the supported list, so the adapter rejects it up front instead of handing you unparseable output.
239​
240`BYTEPLUS_STRUCTURED_OUTPUT_CHAT_MODELS` is exported if you want to gate a model picker on it.
241​
242## Video generation (Seedance)
243​
244> Video generation is an [experimental feature](../media/video-generation).
245​
246Seedance is an asynchronous task API: `generateVideo()` opens the job and returns a `jobId`, and the video URL arrives with the terminal status.
247​
248```typescript
249import { generateVideo, getVideoJobStatus } from '@tanstack/ai'
250import { byteplusVideo } from '@tanstack/ai-byteplus'
251​
252const adapter = byteplusVideo('dreamina-seedance-2-0-260128')
253​
254const { jobId } = await generateVideo({
255 adapter,
256 prompt: 'a guitar being played in a store',
257 size: '16:9_720p',
258 duration: 5,
259})
260​
261let status = await getVideoJobStatus({ adapter, jobId })
262while (status.status === 'pending' || status.status === 'processing') {
263 await new Promise((resolve) => setTimeout(resolve, 5000))
264 status = await getVideoJobStatus({ adapter, jobId })
266​
267console.log(status.status === 'completed' ? status.url : status.error)
268```
269​
270**Generated video URLs expire 24 hours after the task completes** (the task record itself is kept for seven days), so download anything you intend to keep — see [Keeping generated files](../persistence/keep-generated-files).
271​
272`size` is a `ratio` or `ratio_resolution` template (`'16:9'`, `'16:9_720p'`). Ratios are `16:9`, `9:16`, `4:3`, `3:4`, `1:1`, `21:9` and `adaptive`.
273​
274### Driving the whole lifecycle from the client
275​
276**Server** — hand the polling to the core with `stream: true` and pipe the chunks out:
277​
278```typescript
279import { generateVideo, toServerSentEventsResponse } from '@tanstack/ai'
280import { byteplusVideo } from '@tanstack/ai-byteplus'
281​
282export async function POST(request: Request) {
283 const { prompt } = await request.json()
284​
285 const stream = generateVideo({
286 adapter: byteplusVideo('dreamina-seedance-2-0-260128'),
287 prompt,
288 size: '16:9_720p',
289 duration: 5,
290 stream: true,
291 pollingInterval: 5000,
292 })
293​
294 return toServerSentEventsResponse(stream)
296```
297​
298**Client** — `useGenerateVideo` tracks the job for you:
299​
300```tsx
301import { fetchServerSentEvents, useGenerateVideo } from '@tanstack/ai-react'
302​
303export function SeedanceGenerator() {
304 const { generate, result, videoStatus, isLoading, error } = useGenerateVideo({
305 connection: fetchServerSentEvents('/api/generate/video'),
306 })
307​
308 return (
309 <div>
310 <button
311 onClick={() => generate({ prompt: 'a guitar being played in a store' })}
312 disabled={isLoading}
313 >
314 {isLoading ? 'Generating…' : 'Generate video'}
315 </button>
316​
317 {isLoading && <p>Status: {videoStatus?.status ?? 'starting…'}</p>}
318 {error && <p>Error: {error.message}</p>}
319 {result && <video src={result.url} controls width={640} />}
320 </div>
321 )
323```
324​
325### Per-model options
326​
327Seedance options are model-specific, and **Ark rejects an inapplicable field with a `400` rather than ignoring it** — "the specified parameter `draft` is not supported for model seedance-1-0-pro in t2v, must be empty". The applicable set:
328​
329| Option | Models that accept it |
330| --- | --- |
331| `service_tier` (`'default'` \| `'flex'`) | Seedance 1.x only — Seedance 2.5 and the 2.0 family reject it |
332| `camera_fixed` | Seedance 1.x only |
333| `frames` (fractional-second output, `25 + 4n` in `[29, 289]`) | `seedance-1-0-pro-250528`, `seedance-1-0-pro-fast-251015` |
334| `draft` (cheap low-fidelity preview) | `seedance-1-5-pro-251215` only |
335| `priority` (`0`–`9`) | Seedance 2.5 and the `dreamina-seedance-2-0-*` family |
336| `duration: -1` (model picks the length) | Seedance 2.5, 2.0 and `seedance-1-5-pro-251215` |
337| `output_format` (`'mp4'` \| `'mov'`) | Seedance 2.5 (default `mp4`) |
338| `seed`, `watermark`, `generate_audio`, `return_last_frame`, `callback_url` | every model |
339​
340`watermark` defaults to `false` for video (the opposite of Seedream images). `generate_audio` is accepted everywhere but only Seedance 2.5, 2.0 and 1.5-pro actually produce an audio track.
341​
342Resolutions are per model too: there is **no 2K tier on any Seedance model**, `4k` exists only on `dreamina-seedance-2-0-260128`, Seedance 2.5 accepts **480p/720p/1080p**, and `seedance-1-0-pro-fast-251015` does accept `1080p` despite older prose listing it as 480p/720p only. An unsupported combination is caught locally with a clear error before the request goes out.
343​
344Reference media follows the shared [role hints](../media/video-generation#role-hints) — `start_frame`, `end_frame` and `reference`. Seedance 2.5 and the 2.0 family take full multimodal references (reference images, video and audio); Seedance 2.5 additionally accepts **audio-only** reference input and up to 30 reference images / 10 videos / 10 audio clips (2.0 is 9 / 3 / 3). The 1.x models take start/end frames only, and `seedance-1-0-pro-fast-251015` takes a start frame only.
345​
346### Seedance 2.5
347​
348Seedance 2.5 (`dreamina-seedance-2-5-260628`) is a first-class model in this package. It is the current multimodal flagship for longer clips (up to **30 seconds**), audio-only reference input, and `output_format: 'mov'`. Like the 2.0 series it may still require model activation / a resource pack in the Ark Console before the account can call it (`404 ModelNotOpen` until then).
349​
350```typescript
351import { generateVideo } from '@tanstack/ai'
352import { byteplusVideo } from '@tanstack/ai-byteplus'
353​
354const { jobId } = await generateVideo({
355 adapter: byteplusVideo('dreamina-seedance-2-5-260628'),
356 prompt: 'a guitar being played in a store',
357 size: '16:9_1080p',
358 duration: 10,
359 modelOptions: {
360 generate_audio: true,
361 priority: 5,
362 output_format: 'mp4',
363 },
364})
365```
366​
367| Capability | Seedance 2.5 |
368| --- | --- |
369| Duration | 4–30s, or `-1` (model chooses; required for video-editing tasks) |
370| Resolution | `480p`, `720p`, `1080p` (default `720p`) — no 4k |
371| Reference media | images 1–30, videos 0–10, audio 0–10; **audio-only allowed** |
372| First + last frame | yes |
373| `priority` / `generate_audio` | yes |
374| `service_tier` / `camera_fixed` / `frames` / `draft` | no |
375​
376`byteplusVideo()` still accepts any string for ids BytePlus ships between package releases. An unknown id relaxes local guards so Ark validates the request; known ids (including 2.5) keep their documented narrowing.
377​
378### Seedance here vs. Seedance via fal
379​
380Seedance is also reachable through [`@tanstack/ai-fal`](./fal), which proxies it alongside hundreds of other hosted models. This adapter talks to BytePlus directly, which means BytePlus billing and rate limits, model ids in BytePlus's own naming, and the first-class Seedance request fields above (`camera_fixed`, `draft`, `priority`, reference-media roles) rather than fal's normalized subset. Pick whichever matches the account you already have; there is no reason to install both just for Seedance.
381​
382## Image generation (Seedream)
383​
384```typescript
385import { generateImage } from '@tanstack/ai'
386import { byteplusImage } from '@tanstack/ai-byteplus'
387​
388const result = await generateImage({
389 adapter: byteplusImage('dola-seedream-5-0-pro-260628'),
390 prompt: 'a guitar being played in a store',
391 size: '2K',
392 modelOptions: { watermark: false },
393})
394​
395console.log(result.images[0]?.url)
396```
397​
398`size` takes either a token (`1K`, `2K`, `4K`) or explicit pixels (`2048x2048`) — never a mix of the two. Pass image parts in the `prompt` array to edit or condition on existing images (up to 14 references, 10 on `dola-seedream-5-0-pro-260628`):
399​
400```typescript
401import { generateImage } from '@tanstack/ai'
402import { byteplusImage } from '@tanstack/ai-byteplus'
403​
404const result = await generateImage({
405 adapter: byteplusImage('seedream-5-0-260128'),
406 prompt: [
407 { type: 'text', content: 'Put this guitar on a concert stage' },
408 {
409 type: 'image',
410 source: { type: 'url', value: 'https://example.com/guitar.png' },
411 },
412 ],
413})
414​
415console.log(result.images.length)
416```
417​
418Two behaviours surprise people:
419​
420- **`watermark` defaults to `true`.** BytePlus stamps "AI generated" into the bottom-right corner unless you pass `watermark: false`. The adapter never sets the field implicitly, so the provider default applies.
421- **`numberOfImages` is an upper bound, not a count.** Seedream has no `n` parameter; asking for more than one image maps onto its group-image mode (`sequential_image_generation: 'auto'` with `max_images`), where the model decides how many images the prompt actually warrants. A request for four can come back with two, and the adapter logs a warning when it does.
422​
423Result URLs expire after 24 hours. Pass `response_format: 'b64_json'` in `modelOptions` to get the bytes inline instead.
424​
425## Text-to-speech (Seed Speech)
426​
427Seed Speech uses `BYTEPLUS_VOICE_API_KEY`, not the Ark key.
428​
429```typescript
430import { generateSpeech } from '@tanstack/ai'
431import { byteplusSpeech } from '@tanstack/ai-byteplus'
432​
433const result = await generateSpeech({
434 adapter: byteplusSpeech('seed-audio-1.0'),
435 text: 'welcome to the guitar store',
436 voice: 'en_female_stokie_uranus_bigtts',
437 format: 'mp3',
438})
439​
440console.log(result.contentType, result.audio.length)
441```
442​
443Seed Speech has **no top-level `speaker` field** — the voice travels inside a
444`references` entry, so the adapter turns `voice` into
445`references: [{ speaker: 'en_female_stokie_uranus_bigtts' }]` for you. The
446consequence: `modelOptions.references` **replaces** that entry rather than
447merging with it, so a request that passes `references` for voice cloning
448silently drops `voice`. Include a `speaker` member yourself if you still want a
449stock voice alongside your clips.
450​
451The suffix on a voice id tells you which generation you are asking for:
452​
453- `_uranus_bigtts` — TTS 2.0 voices, the current generation.
454- `_mars_bigtts` / `_moon_bigtts` — TTS 1.0 voices.
455- `*_emo_v2_*` — TTS 1.0 voices that additionally accept emotion tags.
456​
457The full roster lives in the [BytePlus voice list](https://docs.byteplus.com/en/docs/byteplusvoice/voicelist) and changes far more often than this package ships, so any string is accepted.
458​
459`speaker` also takes a voice you cloned through Voice Replication, not only a stock id. That field is the join between replication and synthesis.
460​
461Output formats are `wav`, `mp3`, `pcm` and `ogg_opus`. Reach for `modelOptions` for `ogg_opus`, for an explicit `sample_rate`, for `references` (voice cloning, up to three 30-second audio clips, addressed from the text as `@Audio1` to `@Audio3`), for `watermark`, or for word-level timings:
462​
463```typescript
464import { generateSpeech } from '@tanstack/ai'
465import { byteplusSpeech, type BytePlusTTSResult } from '@tanstack/ai-byteplus'
466​
467const result: BytePlusTTSResult = await generateSpeech({
468 adapter: byteplusSpeech('seed-audio-1.0'),
469 text: 'welcome to the guitar store',
470 modelOptions: {
471 format: 'ogg_opus',
472 sample_rate: 48000,
473 speech_rate: 20,
474 enable_subtitle: true,
475 },
476})
477​
478for (const sentence of result.subtitle?.sentences ?? []) {
479 console.log(sentence.text, sentence.start_time)
481```
482​
483Prefer the cross-provider `timestamps: true` over `modelOptions.enable_subtitle`
484unless you want the raw BytePlus block. It sets the same flag and maps the
485response onto `result.alignment` (per word) and `result.segments` (per
486sentence), already converted to seconds:
487​
488```typescript
489import { generateSpeech } from '@tanstack/ai'
490import { byteplusSpeech } from '@tanstack/ai-byteplus'
491​
492const result = await generateSpeech({
493 adapter: byteplusSpeech('seed-audio-1.0'),
494 text: 'welcome to the guitar store',
495 timestamps: true,
496})
497​
498console.log(result.alignment?.unit) // 'word'
499console.log(result.alignment?.endSeconds.at(-1)) // where speech stops
500```
501​
502Seed Audio 1.0 also synthesizes multi-role dialogue in one pass. Pass `turns`
503and the adapter builds the `references` array and the role-structured prompt
504for you, up to **three distinct voices** per request:
505​
506```typescript
507import { generateSpeech } from '@tanstack/ai'
508import { byteplusSpeech } from '@tanstack/ai-byteplus'
509​
510// Replace SECOND_VOICE with another voice id from the BytePlus voice list.
511const SECOND_VOICE = 'your-second-voice-id'
512​
513const result = await generateSpeech({
514 adapter: byteplusSpeech('seed-audio-1.0'),
515 turns: [
516 { text: 'Do you sell picks?', voice: 'en_female_stokie_uranus_bigtts' },
517 { text: 'By the till.', voice: SECOND_VOICE },
518 ],
519 timestamps: true,
520})
521​
522for (const segment of result.segments ?? []) {
523 console.log(segment.startSeconds, segment.text)
525```
526​
527### Watermarking speech
528​
529Seed Audio takes an object here, not a flag. Two markers, both off by default:
530​
531- `aigc_watermark`: appends an audible rhythm marker to the end of the clip.
532- `aigc_metadata`: writes provenance into the audio header. It writes nothing unless `enable` is `true`.
533​
534```typescript
535import { generateSpeech } from '@tanstack/ai'
536import { byteplusSpeech } from '@tanstack/ai-byteplus'
537​
538const result = await generateSpeech({
539 adapter: byteplusSpeech('seed-audio-1.0'),
540 text: 'welcome to the guitar store',
541 modelOptions: {
542 watermark: {
543 aigc_watermark: true,
544 aigc_metadata: { enable: true, content_producer: 'guitar-store' },
545 },
546 },
547})
548```
549​
550`watermark: true` is shorthand for `{ aigc_watermark: true }`, so the audible marker is what a boolean gives you. Images and video keep their own boolean `watermark`. Only speech takes the object.
551​
552Three things to plan around:
553​
554- **Synthesis is capped at 120 seconds of output.** The cap applies to `originalDuration` (the length before `speech_rate` is applied), which is also what BytePlus bills on.
555- **Subtitle timings are milliseconds** on the raw `subtitle` block, while `duration` and `originalDuration` are seconds. `alignment` and `segments` are always seconds.
556- The `url` on the result expires roughly two hours after generation — persist the base64 `audio`, not the link.
557​
558The client half is the standard [`useGenerateSpeech` hook](../media/text-to-speech#streaming-mode-server-route--client-hook); nothing about it is BytePlus-specific.
559​
560## Transcription (Seed Speech ASR)
561​
562Also on the voice key. The endpoint is synchronous — audio in, transcript out, no polling:
563​
564```typescript
565import { generateTranscription } from '@tanstack/ai'
566import { byteplusTranscription } from '@tanstack/ai-byteplus'
567import { audioFile } from './audio'
568​
569const result = await generateTranscription({
570 adapter: byteplusTranscription('seed-asr'),
571 audio: audioFile,
572 modelOptions: { enable_punc: true, enable_speaker_info: true },
573})
574​
575console.log(result.text)
576for (const segment of result.segments ?? []) {
577 console.log(segment.speaker, segment.text)
579```
580​
581Audio can be a `File`, base64, a data URL or a public URL, up to two hours and 100 MB. `enable_itn` renders spoken numbers and dates as digits, `enable_punc` inserts punctuation, `enable_ddc` strips fillers, and `enable_speaker_info` attaches speaker labels that surface as `segment.speaker`.
582​
583## Supported models
584​
585- **Chat** — `dola-seed-2-1-turbo-260628`, `seed-2-0-lite-260428`, `seed-2-0-mini-260428`, `seed-2-0-pro-260328`, `seed-2-0-lite-260228`, `seed-2-0-mini-260215`, `seed-2-0-code-preview-260328`, `seed-1-8-251228`, `seed-1-6-250915`, `seed-1-6-250615`, `seed-1-6-flash-250715`, `seed-1-6-flash-250615`, `glm-5-2-260617`, `glm-4-7-251222`, `deepseek-v4-pro-260425`, `deepseek-v4-flash-260425`, `deepseek-v3-2-251201`, `gpt-oss-120b-250805`.
586- **Video** — `dreamina-seedance-2-5-260628`, `dreamina-seedance-2-0-260128`, `dreamina-seedance-2-0-fast-260128`, `dreamina-seedance-2-0-mini-260615`, `seedance-1-5-pro-251215`, `seedance-1-0-pro-250528`, `seedance-1-0-pro-fast-251015`.
587- **Image** — `dola-seedream-5-0-pro-260628`, `seedream-5-0-260128`, `seedream-5-0-lite-260128`, `seedream-4-5-251128`, `seedream-4-0-250828`.
588- **Speech** — `seed-audio-1.0` (TTS) and `seed-asr` (transcription).
589​
590BytePlus retires model ids aggressively and its published lists include ids that no longer resolve, so this package ships only dated ids that answered a live request. `BYTEPLUS_CHAT_MODELS`, `BYTEPLUS_VIDEO_MODELS`, `BYTEPLUS_IMAGE_MODELS`, `BYTEPLUS_TTS_MODELS` and `BYTEPLUS_TRANSCRIPTION_MODELS` are the authoritative lists and are exported for building model pickers.
591​
592## API Reference
593​
594Every factory has an environment-variable form and an explicit-key form.
595​
596### `byteplusText(model, config?)` / `createBytePlusText(model, apiKey, config?)`
597​
598Chat adapter for the Seed, GLM, DeepSeek and gpt-oss models. Reads `ARK_API_KEY` (or `BYTEPLUS_API_KEY`). `config.baseURL` overrides the region endpoint.
599​
600### `byteplusVideo(model, config?)` / `createBytePlusVideo(model, apiKey, config?)`
601​
602Seedance video adapter (experimental). Reads `ARK_API_KEY`.
603​
604### `byteplusImage(model, config?)` / `createBytePlusImage(model, apiKey, config?)`
605​
606Seedream image adapter. Reads `ARK_API_KEY`.
607​
608### `byteplusSpeech(model, config?)` / `createBytePlusSpeech(model, apiKey, config?)`
609​
610Seed Speech TTS adapter. Reads **`BYTEPLUS_VOICE_API_KEY`**.
611​
612### `byteplusTranscription(model, config?)` / `createBytePlusTranscription(model, apiKey, config?)`
613​
614Seed Speech transcription adapter. Reads **`BYTEPLUS_VOICE_API_KEY`**.
615​
616## Provider Tools
617​
618BytePlus does not expose provider-specific tool factories. Define your own with `toolDefinition()` from `@tanstack/ai` — Ark's tool calling is the standard OpenAI shape and works with the usual [tools flow](../tools/tools.md).
619​
620## Next Steps
621​
622- [Video Generation](../media/video-generation) — the full jobs/polling flow and the `useGenerateVideo` hook
623- [Image Generation](../media/image-generation) — image-conditioned generation and role hints
624- [Structured Outputs](../structured-outputs/one-shot) — schemas, validation and streaming
625- [Other Adapters](./openai) — explore other providers