@tanstack/ai-byteplus 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +202 -0
- package/dist/esm/adapters/image.d.ts +89 -0
- package/dist/esm/adapters/image.js +229 -0
- package/dist/esm/adapters/image.js.map +1 -0
- package/dist/esm/adapters/text.d.ts +163 -0
- package/dist/esm/adapters/text.js +347 -0
- package/dist/esm/adapters/text.js.map +1 -0
- package/dist/esm/adapters/transcription.d.ts +102 -0
- package/dist/esm/adapters/transcription.js +274 -0
- package/dist/esm/adapters/transcription.js.map +1 -0
- package/dist/esm/adapters/tts.d.ts +143 -0
- package/dist/esm/adapters/tts.js +307 -0
- package/dist/esm/adapters/tts.js.map +1 -0
- package/dist/esm/adapters/video.d.ts +182 -0
- package/dist/esm/adapters/video.js +442 -0
- package/dist/esm/adapters/video.js.map +1 -0
- package/dist/esm/audio/transcription-provider-options.d.ts +46 -0
- package/dist/esm/audio/tts-provider-options.d.ts +114 -0
- package/dist/esm/audio/wire-types.d.ts +261 -0
- package/dist/esm/audio/wire-types.js +28 -0
- package/dist/esm/audio/wire-types.js.map +1 -0
- package/dist/esm/image/image-provider-options.d.ts +165 -0
- package/dist/esm/image/image-provider-options.js +134 -0
- package/dist/esm/image/image-provider-options.js.map +1 -0
- package/dist/esm/image/wire-types.d.ts +149 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/message-types.d.ts +154 -0
- package/dist/esm/model-meta.d.ts +594 -0
- package/dist/esm/model-meta.js +619 -0
- package/dist/esm/model-meta.js.map +1 -0
- package/dist/esm/text/text-provider-options.d.ts +109 -0
- package/dist/esm/utils/client.d.ts +183 -0
- package/dist/esm/utils/client.js +253 -0
- package/dist/esm/utils/client.js.map +1 -0
- package/dist/esm/video/video-provider-options.d.ts +197 -0
- package/dist/esm/video/video-provider-options.js +191 -0
- package/dist/esm/video/video-provider-options.js.map +1 -0
- package/dist/esm/video/wire-types.d.ts +248 -0
- package/package.json +77 -0
- package/src/adapters/image.ts +409 -0
- package/src/adapters/text.ts +539 -0
- package/src/adapters/transcription.ts +479 -0
- package/src/adapters/tts.ts +447 -0
- package/src/adapters/video.ts +732 -0
- package/src/audio/transcription-provider-options.ts +46 -0
- package/src/audio/tts-provider-options.ts +122 -0
- package/src/audio/wire-types.ts +290 -0
- package/src/image/image-provider-options.ts +288 -0
- package/src/image/wire-types.ts +169 -0
- package/src/index.ts +222 -0
- package/src/message-types.ts +169 -0
- package/src/model-meta.ts +954 -0
- package/src/text/text-provider-options.ts +151 -0
- package/src/utils/client.ts +377 -0
- package/src/video/video-provider-options.ts +361 -0
- package/src/video/wire-types.ts +293 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the BytePlus Ark Seedance video task API
|
|
3
|
+
* (`/contents/generations/tasks`).
|
|
4
|
+
*
|
|
5
|
+
* Hand-written minimal shapes covering only the fields this adapter sends and
|
|
6
|
+
* reads, with provenance noted inline. Three sources:
|
|
7
|
+
*
|
|
8
|
+
* 1. The harvested OpenAPI 3.1 documents for the `ark` service, actions
|
|
9
|
+
* `CreateContentsGenerationsTasks` (`x-updated-time: 2026-05-07`),
|
|
10
|
+
* `GetContentsGenerationsTask` (`2026-04-14`),
|
|
11
|
+
* `ListContentsGenerationsTasks` (`2026-03-24`) and
|
|
12
|
+
* `DeleteContentsGenerationsTasks` — authoritative for field names,
|
|
13
|
+
* defaults and response shapes.
|
|
14
|
+
* 2. Live calls against `https://ark.ap-southeast.bytepluses.com/api/v3` on
|
|
15
|
+
* 2026-07-31 with a real `ARK_API_KEY`, which pinned the create response,
|
|
16
|
+
* the per-model parameter applicability (see
|
|
17
|
+
* `video-provider-options.ts`) and the `content[]` role vocabulary.
|
|
18
|
+
* 3. The Seedance prose docs, for the retention windows.
|
|
19
|
+
*
|
|
20
|
+
* Two casing traps worth knowing: the response frame-rate field is
|
|
21
|
+
* `framespersecond` (all lowercase, no underscores), and `resolution` is
|
|
22
|
+
* matched case-insensitively on the way in (`4K`, `4k` and even `1080P` are
|
|
23
|
+
* all accepted — live-verified), so this package standardizes on lowercase.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Task lifecycle states.
|
|
27
|
+
*
|
|
28
|
+
* `queued` and `running` are non-terminal; the rest are terminal. `cancelled`
|
|
29
|
+
* records are dropped 24 hours after cancellation, and only a `queued` task
|
|
30
|
+
* can be cancelled at all.
|
|
31
|
+
*
|
|
32
|
+
* Source: `GetContentsGenerationsTask` / `ListContentsGenerationsTasks`
|
|
33
|
+
* `status` descriptions. (The Get document omits `expired` from its list
|
|
34
|
+
* while the List document includes it; `execution_expires_after` is documented
|
|
35
|
+
* as producing `expired` on both, so it is included here.)
|
|
36
|
+
*/
|
|
37
|
+
export type BytePlusVideoTaskStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'expired';
|
|
38
|
+
/**
|
|
39
|
+
* Role of a media item inside `content[]`.
|
|
40
|
+
*
|
|
41
|
+
* Live-verified: an unknown role is rejected with "invalid role specified for
|
|
42
|
+
* image content", and the API sorts requests into task types from the roles
|
|
43
|
+
* present — `i2v` (first frame), `flf2v` (first + last frame) and `r2v`
|
|
44
|
+
* (reference media). The two families are mutually exclusive: mixing them
|
|
45
|
+
* fails with "first/last frame content cannot be mixed with reference media
|
|
46
|
+
* content".
|
|
47
|
+
*/
|
|
48
|
+
export type BytePlusVideoContentRole = 'first_frame' | 'last_frame' | 'reference_image' | 'reference_video' | 'reference_audio';
|
|
49
|
+
/** Instruction text for the generation. */
|
|
50
|
+
export interface BytePlusVideoTextContent {
|
|
51
|
+
type: 'text';
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* An image input. A public URL is fetched by BytePlus server-side; a
|
|
56
|
+
* `data:` URI carries the bytes inline.
|
|
57
|
+
*/
|
|
58
|
+
export interface BytePlusVideoImageContent {
|
|
59
|
+
type: 'image_url';
|
|
60
|
+
image_url: {
|
|
61
|
+
url: string;
|
|
62
|
+
};
|
|
63
|
+
/** Omitted for a bare first frame — the API defaults to `first_frame`. */
|
|
64
|
+
role?: BytePlusVideoContentRole;
|
|
65
|
+
}
|
|
66
|
+
/** A video input. Reference-media mode requires `role: 'reference_video'`. */
|
|
67
|
+
export interface BytePlusVideoVideoContent {
|
|
68
|
+
type: 'video_url';
|
|
69
|
+
video_url: {
|
|
70
|
+
url: string;
|
|
71
|
+
};
|
|
72
|
+
role?: BytePlusVideoContentRole;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* An audio input. Live-verified: audio can only accompany another reference
|
|
76
|
+
* input — "reference_audio cannot be the only reference input".
|
|
77
|
+
*/
|
|
78
|
+
export interface BytePlusVideoAudioContent {
|
|
79
|
+
type: 'audio_url';
|
|
80
|
+
audio_url: {
|
|
81
|
+
url: string;
|
|
82
|
+
};
|
|
83
|
+
role?: BytePlusVideoContentRole;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* One entry of the `content[]` array.
|
|
87
|
+
*
|
|
88
|
+
* The create schema declares `maxItems: 5`, but the live API does not enforce
|
|
89
|
+
* it — 7 entries (6 reference images plus text) were accepted on
|
|
90
|
+
* `dreamina-seedance-2-0-260128`. The adapter therefore does not cap the array
|
|
91
|
+
* locally; a genuinely over-long request gets whatever Ark decides to say.
|
|
92
|
+
*/
|
|
93
|
+
export type BytePlusVideoContentPart = BytePlusVideoTextContent | BytePlusVideoImageContent | BytePlusVideoVideoContent | BytePlusVideoAudioContent;
|
|
94
|
+
/**
|
|
95
|
+
* Request body for `POST /contents/generations/tasks`.
|
|
96
|
+
*
|
|
97
|
+
* Only `model` and `content` are required. Every other field is
|
|
98
|
+
* model-dependent — Ark rejects an inapplicable field outright ("the
|
|
99
|
+
* specified parameter `draft` is not supported for model … must be empty")
|
|
100
|
+
* rather than ignoring it, so the adapter only sends what the caller asked
|
|
101
|
+
* for. See `video-provider-options.ts` for the live-probed applicability
|
|
102
|
+
* matrix.
|
|
103
|
+
*/
|
|
104
|
+
export interface BytePlusVideoCreateRequest {
|
|
105
|
+
/** Seedance model id (or a preconfigured endpoint id). */
|
|
106
|
+
model: string;
|
|
107
|
+
/** Prompt text plus any image / video / audio inputs, max 5 entries. */
|
|
108
|
+
content: Array<BytePlusVideoContentPart>;
|
|
109
|
+
/** Output aspect ratio, e.g. `16:9`. `adaptive` follows the input frame. */
|
|
110
|
+
ratio?: string;
|
|
111
|
+
/** Resolution tier, e.g. `720p`. Matched case-insensitively by the API. */
|
|
112
|
+
resolution?: string;
|
|
113
|
+
/** Whole seconds of output. `-1` lets the model choose (Seedance 2.0 / 1.5). */
|
|
114
|
+
duration?: number;
|
|
115
|
+
/** Frame count, an alternative to `duration` that allows fractional seconds. */
|
|
116
|
+
frames?: number;
|
|
117
|
+
/** Randomness seed; integers in `[-1, 2^32-1]`, where `-1` means unseeded. */
|
|
118
|
+
seed?: number;
|
|
119
|
+
/** Appends a "fix the camera" instruction to the prompt. Default `false`. */
|
|
120
|
+
camera_fixed?: boolean;
|
|
121
|
+
/** Burn a watermark into the output. Default `false`. */
|
|
122
|
+
watermark?: boolean;
|
|
123
|
+
/** Generate a synchronized audio track. Default `false`. */
|
|
124
|
+
generate_audio?: boolean;
|
|
125
|
+
/** `default` (online) or `flex` (offline batch, half price). */
|
|
126
|
+
service_tier?: string;
|
|
127
|
+
/** Also return the final frame as a PNG. Default `false`. */
|
|
128
|
+
return_last_frame?: boolean;
|
|
129
|
+
/** Cheap low-fidelity preview render. Default `false`. */
|
|
130
|
+
draft?: boolean;
|
|
131
|
+
/** Queue priority `[0, 9]`. */
|
|
132
|
+
priority?: number;
|
|
133
|
+
/** Seconds from `created_at` after which the task is marked `expired`. */
|
|
134
|
+
execution_expires_after?: number;
|
|
135
|
+
/** URL that receives a POST with the task payload on each status change. */
|
|
136
|
+
callback_url?: string;
|
|
137
|
+
/** Opaque per-end-user identifier for abuse attribution, max 64 chars. */
|
|
138
|
+
safety_identifier?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Response of `POST /contents/generations/tasks`.
|
|
142
|
+
*
|
|
143
|
+
* Live-verified: the body is just the task id (e.g.
|
|
144
|
+
* `cgt-batch-20260731174311-zmz5s`; the `-batch` infix appears when the task
|
|
145
|
+
* is routed to the `flex` offline queue).
|
|
146
|
+
*/
|
|
147
|
+
export interface BytePlusVideoCreateResponse {
|
|
148
|
+
id?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Error detail attached to a terminal task.
|
|
152
|
+
*
|
|
153
|
+
* Codes are the dotted/PascalCase Ark strings — the create, get and list
|
|
154
|
+
* documents enumerate `InputTextSensitiveContentDetected`,
|
|
155
|
+
* `InputImageSensitiveContentDetected`, `OutputVideoSensitiveContentDetected`
|
|
156
|
+
* and `QuotaExceeded` under `x-error-code`. The set is open-ended, so this
|
|
157
|
+
* stays a plain `string`.
|
|
158
|
+
*/
|
|
159
|
+
export interface BytePlusVideoTaskError {
|
|
160
|
+
code?: string;
|
|
161
|
+
message?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Token usage for a finished task. Video generation bills output only, so
|
|
165
|
+
* `total_tokens` equals `completion_tokens` and there is no prompt count.
|
|
166
|
+
*
|
|
167
|
+
* The schema types both counts as `string` while the documented example
|
|
168
|
+
* response shows bare numbers, so both are accepted and coerced.
|
|
169
|
+
*/
|
|
170
|
+
export interface BytePlusVideoTaskUsage {
|
|
171
|
+
completion_tokens?: number | string;
|
|
172
|
+
total_tokens?: number | string;
|
|
173
|
+
/** Only present when a provider tool (web search) ran. */
|
|
174
|
+
tool_usage?: {
|
|
175
|
+
web_search?: number;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Output URLs of a succeeded task. Both links expire 24 hours after success. */
|
|
179
|
+
export interface BytePlusVideoTaskContent {
|
|
180
|
+
/** MP4 download URL. */
|
|
181
|
+
video_url?: string;
|
|
182
|
+
/** Final frame as PNG; only when `return_last_frame` was set. */
|
|
183
|
+
last_frame_url?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Response of `GET /contents/generations/tasks/{id}`.
|
|
187
|
+
*
|
|
188
|
+
* `content` appears once the task succeeds; `error` appears when it fails.
|
|
189
|
+
* Note `duration` comes back as a string here while the list endpoint types
|
|
190
|
+
* it as an integer, so both are accepted.
|
|
191
|
+
*/
|
|
192
|
+
export interface BytePlusVideoTask {
|
|
193
|
+
id?: string;
|
|
194
|
+
/** `{model name}-{version}` actually used — not necessarily the id sent. */
|
|
195
|
+
model?: string;
|
|
196
|
+
status?: BytePlusVideoTaskStatus;
|
|
197
|
+
error?: BytePlusVideoTaskError;
|
|
198
|
+
/** Unix seconds. Anchors the 7-day task-record retention. */
|
|
199
|
+
created_at?: number;
|
|
200
|
+
/** Unix seconds of the last status change — for a succeeded task, when the
|
|
201
|
+
* output (and its 24-hour URL) was produced. */
|
|
202
|
+
updated_at?: number;
|
|
203
|
+
content?: BytePlusVideoTaskContent;
|
|
204
|
+
seed?: number;
|
|
205
|
+
resolution?: string;
|
|
206
|
+
ratio?: string;
|
|
207
|
+
duration?: number | string;
|
|
208
|
+
frames?: number;
|
|
209
|
+
/** Frame rate. Lowercase and unseparated on the wire — not `frames_per_second`. */
|
|
210
|
+
framespersecond?: number;
|
|
211
|
+
generate_audio?: boolean;
|
|
212
|
+
service_tier?: string;
|
|
213
|
+
draft?: boolean;
|
|
214
|
+
draft_task_id?: string;
|
|
215
|
+
execution_expires_after?: number;
|
|
216
|
+
safety_identifier?: string;
|
|
217
|
+
usage?: BytePlusVideoTaskUsage;
|
|
218
|
+
/** Queue priority the task ran at. */
|
|
219
|
+
priority?: number;
|
|
220
|
+
/** Container of the generated video, e.g. `mp4`. */
|
|
221
|
+
output_format?: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* One entry of the list response.
|
|
225
|
+
*
|
|
226
|
+
* The list document declares the same fields as the get document (including
|
|
227
|
+
* `error` — despite BytePlus prose elsewhere calling the list-side field
|
|
228
|
+
* `failure_reason`, no such field exists in the harvested schema, so it is
|
|
229
|
+
* not typed here).
|
|
230
|
+
*/
|
|
231
|
+
export interface BytePlusVideoTaskListItem extends BytePlusVideoTask {
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Response of `GET /contents/generations/tasks`.
|
|
235
|
+
*
|
|
236
|
+
* Supported query parameters: `page_num` and `page_size` (both `[1, 500]`),
|
|
237
|
+
* `filter.status`, repeated `filter.task_ids`, and `filter.service_tier`.
|
|
238
|
+
*
|
|
239
|
+
* **`flex` tasks are missing from the default listing.** An unfiltered list
|
|
240
|
+
* returned `{total: 0, items: []}` both while a live `flex` task was running
|
|
241
|
+
* and immediately after it succeeded, so offline-tier work is invisible here
|
|
242
|
+
* unless `filter.service_tier=flex` is passed. Poll a known task id rather
|
|
243
|
+
* than relying on the listing to discover tasks.
|
|
244
|
+
*/
|
|
245
|
+
export interface BytePlusVideoTaskListResponse {
|
|
246
|
+
items?: Array<BytePlusVideoTaskListItem>;
|
|
247
|
+
total?: number;
|
|
248
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/ai-byteplus",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "BytePlus ModelArk adapter for TanStack AI: Seed LLM chat, Seedance video, Seedream image, and Seed Speech TTS/ASR.",
|
|
5
|
+
"author": "Tanner Linsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://tanstack.com/ai",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/TanStack/ai.git",
|
|
14
|
+
"directory": "packages/ai-byteplus"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/TanStack/ai/issues"
|
|
18
|
+
},
|
|
19
|
+
"funding": {
|
|
20
|
+
"type": "github",
|
|
21
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"module": "./dist/esm/index.js",
|
|
25
|
+
"types": "./dist/esm/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/esm/index.d.ts",
|
|
29
|
+
"import": "./dist/esm/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"clean": "premove ./build ./dist",
|
|
39
|
+
"lint:fix": "oxlint src --type-aware --fix",
|
|
40
|
+
"test:build": "publint --strict",
|
|
41
|
+
"test:oxlint": "oxlint src --type-aware",
|
|
42
|
+
"test:lib": "vitest run",
|
|
43
|
+
"test:lib:dev": "pnpm test:lib --watch",
|
|
44
|
+
"test:types": "tsc"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"ai",
|
|
48
|
+
"ai-sdk",
|
|
49
|
+
"typescript",
|
|
50
|
+
"tanstack",
|
|
51
|
+
"byteplus",
|
|
52
|
+
"modelark",
|
|
53
|
+
"seed",
|
|
54
|
+
"seedance",
|
|
55
|
+
"seedream",
|
|
56
|
+
"adapter",
|
|
57
|
+
"llm",
|
|
58
|
+
"chat",
|
|
59
|
+
"video-generation",
|
|
60
|
+
"image-generation",
|
|
61
|
+
"text-to-speech"
|
|
62
|
+
],
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@tanstack/ai": "workspace:*",
|
|
65
|
+
"@vitest/coverage-v8": "4.0.14",
|
|
66
|
+
"vite": "^8.1.4"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@tanstack/ai": "workspace:^",
|
|
70
|
+
"zod": "^4.0.0"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@tanstack/ai-utils": "workspace:*",
|
|
74
|
+
"@tanstack/openai-base": "workspace:*",
|
|
75
|
+
"openai": "^6.41.0"
|
|
76
|
+
}
|
|
77
|
+
}
|