Open History to see the last commit
1---
2title: BytePlus
3id: byteplus-adapter
4order: 8
5description: "Use BytePlus ModelArk in TanStack AI with @tanstack/ai-byteplus: Seed chat models with reasoning, Seedance video, Seedream images, and Seed Speech text-to-speech and transcription."
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
23`@tanstack/ai-byteplus` calls Seed chat models with reasoning, plus Seedance video, Seedream images, and Seed Speech.
24
25## 1. Install
26
27<!-- ::start:tabs variant="package-manager" mode="install" -->
28
29react: @tanstack/ai-byteplus
30vue: @tanstack/ai-byteplus
31solid: @tanstack/ai-byteplus
32svelte: @tanstack/ai-byteplus
33preact: @tanstack/ai-byteplus
34angular: @tanstack/ai-byteplus
35vanilla: @tanstack/ai-byteplus
36octane: @tanstack/ai-byteplus
37
38<!-- ::end:tabs -->
39
40## 2. Set the API keys
41
42BytePlus sells these models as two products, and each product has its own key. Put both keys in the environment of your server:
43
44```bash
45# ModelArk: chat, Seedance video, Seedream images
46ARK_API_KEY=...
47
48# Seed Speech: text-to-speech and transcription
49BYTEPLUS_VOICE_API_KEY=...
50```
51
52- `byteplusText`, `byteplusVideo`, and `byteplusImage` read `ARK_API_KEY`. If it is not set, they read `BYTEPLUS_API_KEY`.
53- `byteplusSpeech` and `byteplusTranscription` read `BYTEPLUS_VOICE_API_KEY`. An Ark key fails here with `45000010 Invalid X-Api-Key`.
54
55To pass the key in code, use the `create*` factory of the same adapter:
56
57```typescript
58import { createBytePlusText } from "@tanstack/ai-byteplus";
59
60const adapter = createBytePlusText("dola-seed-2-1-turbo-260628", process.env.ARK_API_KEY!);
61```
62
63Ark keys work in one region only. The default endpoint is Asia-Pacific south-east. For a key from another region, see [Regions](./byteplus-advanced#regions).
64
65## 3. Stream a chat from the server
66
67```typescript
68import {
69 chat,
70 chatParamsFromRequest,
71 toServerSentEventsResponse,
72} from "@tanstack/ai";
73import { byteplusText } from "@tanstack/ai-byteplus";
74
75export async function POST(request: Request) {
76 const { messages, threadId, runId } = await chatParamsFromRequest(request);
77
78 const stream = chat({
79 adapter: byteplusText("dola-seed-2-1-turbo-260628"),
80 messages,
81 threadId,
82 runId,
83 });
84
85 return toServerSentEventsResponse(stream);
86}
87```
88
89## 4. Render the chat
90
91The client is the same for every provider. Point `useChat` at your route:
92
93```tsx
94import { useState } from "react";
95import { useChat, fetchServerSentEvents } from "@tanstack/ai-react";
96
97export function Chat() {
98 const [input, setInput] = useState("");
99 const { messages, sendMessage } = useChat({
100 connection: fetchServerSentEvents("/api/chat"),
101 threadId: "support-chat",
102 });
103
104 return (
105 <form
106 onSubmit={(event) => {
107 event.preventDefault();
108 sendMessage(input);
109 setInput("");
110 }}
111 >
112 {messages.map((message) => (
113 <p key={message.id}>
114 {message.parts
115 .map((part) => (part.type === "text" ? part.content : ""))
116 .join("")}
117 </p>
118 ))}
119 <input value={input} onChange={(event) => setInput(event.target.value)} />
120 </form>
121 );
122}
123```
124
125For Vue, Solid, Svelte, Angular, and the other frameworks, see [Quick Start](../getting-started/quick-start#3-render-the-chat).
126
127You now have a streaming chat on BytePlus. Seed models think before they answer, and `useChat` shows that thinking as separate thinking parts. [Tools](../tools/tools) work the same as with every adapter. BytePlus has no provider tools of its own.
128
129## Video generation (Seedance)
130
131> Video generation is an [experimental feature](../media/video-generation).
132
133Seedance runs as a job. `generateVideo()` starts the job and returns a `jobId`. Poll the job until it has a video URL:
134
135```typescript
136import { generateVideo, getVideoJobStatus } from "@tanstack/ai";
137import { byteplusVideo } from "@tanstack/ai-byteplus";
138
139const adapter = byteplusVideo("dreamina-seedance-2-5-260628");
140
141const { jobId } = await generateVideo({
142 adapter,
143 prompt: "a guitar being played in a store",
144 threadId: "thread-1",
145 size: "16:9_720p",
146 duration: 5,
147});
148
149let status = await getVideoJobStatus({ adapter, jobId });
150while (status.status === "pending" || status.status === "processing") {
151 await new Promise((resolve) => setTimeout(resolve, 5000));
152 status = await getVideoJobStatus({ adapter, jobId });
153}
154
155console.log(status.status === "completed" ? status.url : status.error);
156```
157
158- The video URL expires 24 hours after the job completes. If you want to keep the video, download it. See [Keeping generated files](../persistence/keep-generated-files).
159- `size` is a ratio (`"16:9"`) or a ratio with a resolution (`"16:9_720p"`). The ratios are `16:9`, `9:16`, `4:3`, `3:4`, `1:1`, `21:9`, and `adaptive`.
160- The Seedance 2 models can need activation in the Ark Console first. Until then, a call fails with `404 ModelNotOpen`.
161
162To run the job from a React component, and for the options of each model, see [BytePlus: Advanced](./byteplus-advanced#run-a-seedance-job-from-the-client).
163
164## Image generation (Seedream)
165
166```typescript
167import { generateImage } from "@tanstack/ai";
168import { byteplusImage } from "@tanstack/ai-byteplus";
169
170const result = await generateImage({
171 adapter: byteplusImage("dola-seedream-5-0-pro-260628"),
172 prompt: "a guitar being played in a store",
173 threadId: "thread-1",
174 size: "2K",
175 modelOptions: { watermark: false },
176});
177
178console.log(result.images[0]?.url);
179```
180
181- `watermark` is `true` by default. BytePlus then writes "AI generated" in the bottom-right corner. Set `watermark: false` to stop this.
182- `size` is a token (`1K`, `2K`, `4K`) or pixels (`2048x2048`). Do not mix the two.
183- `numberOfImages` is a maximum, not an exact count. The model decides how many images to return.
184- Result URLs expire after 24 hours. To get the bytes in the response, set `response_format: "b64_json"` in `modelOptions`.
185
186To edit an existing image, see [Seedream reference images](./byteplus-advanced#seedream-reference-images).
187
188## Text-to-speech (Seed Speech)
189
190This adapter uses `BYTEPLUS_VOICE_API_KEY`:
191
192```typescript
193import { generateSpeech } from "@tanstack/ai";
194import { byteplusSpeech } from "@tanstack/ai-byteplus";
195
196const result = await generateSpeech({
197 adapter: byteplusSpeech("seed-audio-1.0"),
198 text: "welcome to the guitar store",
199 threadId: "thread-1",
200 voice: "en_female_stokie_uranus_bigtts",
201 format: "mp3",
202});
203
204console.log(result.contentType, result.audio.length);
205```
206
207- Formats: `wav`, `mp3`, `pcm`, and `ogg_opus`.
208- One request makes 120 seconds of audio at most.
209- `timestamps: true` gives you word timings, and `turns` makes a dialogue with up to three voices.
210
211The voice ids, voice cloning, timings, dialogue, and watermarks are in [Seed Speech](./byteplus-advanced#seed-speech). The client half is the standard [`useGenerateSpeech` hook](../media/text-to-speech#quick-setup).
212
213## Transcription (Seed Speech ASR)
214
215This adapter also uses `BYTEPLUS_VOICE_API_KEY`. The call is synchronous, so you get the transcript back with no polling:
216
217```typescript
218import { generateTranscription } from "@tanstack/ai";
219import { byteplusTranscription } from "@tanstack/ai-byteplus";
220
221const result = await generateTranscription({
222 adapter: byteplusTranscription("seed-asr"),
223 audio: "https://example.com/recording.mp3",
224 modelOptions: { enable_punc: true, enable_speaker_info: true },
225 threadId: "thread-1",
226});
227
228console.log(result.text);
229for (const segment of result.segments ?? []) {
230 console.log(segment.speaker, segment.text);
231}
232```
233
234`audio` takes a `File`, base64, a data URL, or a public URL. The limit is two hours and 100 MB. For the other options, see [Transcription options](./byteplus-advanced#transcription-options).
235
236## Models and options
237
238### Model options
239
240Ark speaks the OpenAI chat format, so the sampling options keep their OpenAI names. They go in `modelOptions`:
241
242```typescript
243import { chat } from "@tanstack/ai";
244import { byteplusText } from "@tanstack/ai-byteplus";
245
246const stream = chat({
247 adapter: byteplusText("dola-seed-2-1-turbo-260628"),
248 messages: [{ role: "user", content: "Hello!" }],
249 threadId: "thread-1",
250 modelOptions: {
251 temperature: 0.7,
252 top_p: 0.9,
253 max_tokens: 2048,
254 },
255});
256```
257
258- Send `max_tokens` or `max_completion_tokens`, not both. Ark returns a `400` when you send both. The types cannot catch this.
259- `repetition_penalty` and `service_tier` are Ark options. `service_tier: "flex"` sends the request to a cheaper batch queue with no latency guarantee.
260
261Need a header on each request, or a log of each model call? The chat adapter supports [`wrapFetch`](../advanced/middleware#change-the-http-requests-of-a-call).
262
263### Reasoning
264
265Seed models think by default. Set how hard they think with `reasoning` on `chat()`:
266
267```typescript
268import { chat } from "@tanstack/ai";
269import { byteplusText } from "@tanstack/ai-byteplus";
270
271const stream = chat({
272 adapter: byteplusText("glm-5-2-260617"),
273 messages: [{ role: "user", content: "Hello!" }],
274 threadId: "thread-1",
275 reasoning: "off",
276});
277```
278
279The levels of each model:
280
281- `dola-seed-2-1-turbo-260628` and the `seed-*` models: `minimal` to `high`. They cannot stop thinking.
282- `glm-5-2-260617`: `off` to `high`.
283- `glm-4-7-251222`, `deepseek-v3-2-251201`: `off`, `high`.
284- `deepseek-v4-pro-260425`, `deepseek-v4-flash-260425`: `off`, `high`, `max`.
285- `gpt-oss-120b-250805`: `low`, `medium`, `high`.
286
287What goes over the wire, and how the adapter keeps the `encrypted_content` of the reasoning, is in [Reasoning and `encrypted_content`](./byteplus-advanced#reasoning-and-encrypted_content).
288
289### Structured output
290
291Ten of the 18 chat models support `chat({ outputSchema })`. Use `dola-seed-2-1-turbo-260628` or `seed-2-0-lite-260228`. On the other models, the call fails with an error that names the models that work. See [Structured output](./byteplus-advanced#structured-output).
292
293### Models
294
295Newest first. The package exports the full lists: `BYTEPLUS_CHAT_MODELS`, `BYTEPLUS_VIDEO_MODELS`, `BYTEPLUS_IMAGE_MODELS`, `BYTEPLUS_TTS_MODELS`, and `BYTEPLUS_TRANSCRIPTION_MODELS`.
296
297| Activity | Factory | Models |
298| --- | --- | --- |
299| Chat | `byteplusText` | `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` |
300| Video | `byteplusVideo` | `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` |
301| Images | `byteplusImage` | `dola-seedream-5-0-pro-260628`, `seedream-5-0-260128`, `seedream-5-0-lite-260128`, `seedream-4-5-251128`, `seedream-4-0-250828` |
302| Speech | `byteplusSpeech` | `seed-audio-1.0` |
303| Transcription | `byteplusTranscription` | `seed-asr` |
304
305BytePlus retires model ids often, and its published lists contain ids that do not work. This package lists only dated ids that answered a live request.
306
307`adapter.inputModalities` lists the input kinds of the selected model. See [Check what a model accepts](../advanced/extend-adapter#check-what-a-model-accepts).
308
309## Advanced
310
311These topics are on [BytePlus: Advanced](./byteplus-advanced):
312
313- Regions, and the two BYOK providers.
314- Reasoning, `encrypted_content`, and structured output.
315- Seedance from the client, the options of each model, and Seedance 2.5.
316- Seedream reference images, Seed Speech details, and transcription options.
317- The API reference.