@ai-sdk/bytedance 1.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/CHANGELOG.md +7 -0
- package/LICENSE +13 -0
- package/README.md +202 -0
- package/dist/index.d.mts +62 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +380 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +370 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# AI SDK - ByteDance Provider
|
|
2
|
+
|
|
3
|
+
The **ByteDance provider** for the [AI SDK](https://ai-sdk.dev/docs) contains video model support for ByteDance's Seedance family of video generation models through the [BytePlus ModelArk](https://docs.byteplus.com/en/docs/ModelArk/Video_Generation_API) platform.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
The ByteDance provider is available in the `@ai-sdk/bytedance` module. You can install it with:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @ai-sdk/bytedance
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Skill for Coding Agents
|
|
14
|
+
|
|
15
|
+
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
npx skills add vercel/ai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Provider Instance
|
|
22
|
+
|
|
23
|
+
You can import the default provider instance `byteDance` from `@ai-sdk/bytedance`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Video Models
|
|
30
|
+
|
|
31
|
+
This provider supports text-to-video, image-to-video, audio-video sync, first-and-last frame control, and multi-reference image generation.
|
|
32
|
+
|
|
33
|
+
### Text-to-Video
|
|
34
|
+
|
|
35
|
+
Generate video from a text prompt.
|
|
36
|
+
|
|
37
|
+
Available models: `seedance-1-5-pro-251215`, `seedance-1-0-pro-250528`, `seedance-1-0-pro-fast-251015`, `seedance-1-0-lite-t2v-250428`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
41
|
+
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
42
|
+
|
|
43
|
+
const { video } = await generateVideo({
|
|
44
|
+
model: byteDance.video('seedance-1-0-pro-250528'),
|
|
45
|
+
prompt: 'A cat playing with a ball of yarn in a sunlit room',
|
|
46
|
+
aspectRatio: '16:9',
|
|
47
|
+
duration: 5,
|
|
48
|
+
providerOptions: {
|
|
49
|
+
bytedance: {
|
|
50
|
+
watermark: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log(video.url);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Image-to-Video
|
|
59
|
+
|
|
60
|
+
Generate video from a first-frame image with an optional text prompt.
|
|
61
|
+
|
|
62
|
+
Available models: `seedance-1-5-pro-251215`, `seedance-1-0-pro-250528`, `seedance-1-0-pro-fast-251015`, `seedance-1-0-lite-i2v-250428`
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
66
|
+
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
67
|
+
|
|
68
|
+
const { video } = await generateVideo({
|
|
69
|
+
model: byteDance.video('seedance-1-5-pro-251215'),
|
|
70
|
+
prompt: {
|
|
71
|
+
image: 'https://example.com/first-frame.png',
|
|
72
|
+
text: 'The cat slowly turns its head and blinks',
|
|
73
|
+
},
|
|
74
|
+
duration: 5,
|
|
75
|
+
providerOptions: {
|
|
76
|
+
bytedance: {
|
|
77
|
+
watermark: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Image-to-Video with Audio
|
|
84
|
+
|
|
85
|
+
Seedance 1.5 Pro supports generating synchronized audio alongside the video.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
89
|
+
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
90
|
+
|
|
91
|
+
const { video } = await generateVideo({
|
|
92
|
+
model: byteDance.video('seedance-1-5-pro-251215'),
|
|
93
|
+
prompt: {
|
|
94
|
+
image: 'https://example.com/pianist.png',
|
|
95
|
+
text: 'A young man sits at a piano, playing calmly. Gentle piano music plays in sync.',
|
|
96
|
+
},
|
|
97
|
+
duration: 5,
|
|
98
|
+
providerOptions: {
|
|
99
|
+
bytedance: {
|
|
100
|
+
generateAudio: true,
|
|
101
|
+
watermark: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### First-and-Last Frame Video
|
|
108
|
+
|
|
109
|
+
Generate smooth transitions between a starting and ending keyframe image.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
113
|
+
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
114
|
+
|
|
115
|
+
const { video } = await generateVideo({
|
|
116
|
+
model: byteDance.video('seedance-1-5-pro-251215'),
|
|
117
|
+
prompt: {
|
|
118
|
+
image: 'https://example.com/first-frame.jpg',
|
|
119
|
+
text: 'Create a 360-degree orbiting camera shot based on this photo',
|
|
120
|
+
},
|
|
121
|
+
duration: 5,
|
|
122
|
+
providerOptions: {
|
|
123
|
+
bytedance: {
|
|
124
|
+
lastFrameImage: 'https://example.com/last-frame.jpg',
|
|
125
|
+
generateAudio: true,
|
|
126
|
+
watermark: false,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Multi-Reference Image-to-Video
|
|
133
|
+
|
|
134
|
+
Provide multiple reference images (1-4) that the model uses to faithfully reproduce object shapes, colors, and textures. Use `[Image 1]`, `[Image 2]`, etc. in your prompt to reference specific images.
|
|
135
|
+
|
|
136
|
+
Available models: `seedance-1-0-lite-i2v-250428`
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { byteDance } from '@ai-sdk/bytedance';
|
|
140
|
+
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
141
|
+
|
|
142
|
+
const { video } = await generateVideo({
|
|
143
|
+
model: byteDance.video('seedance-1-0-lite-i2v-250428'),
|
|
144
|
+
prompt:
|
|
145
|
+
'A boy from [Image 1] and a corgi from [Image 2], sitting on the lawn from [Image 3]',
|
|
146
|
+
aspectRatio: '16:9',
|
|
147
|
+
duration: 5,
|
|
148
|
+
providerOptions: {
|
|
149
|
+
bytedance: {
|
|
150
|
+
referenceImages: [
|
|
151
|
+
'https://example.com/boy.png',
|
|
152
|
+
'https://example.com/corgi.png',
|
|
153
|
+
'https://example.com/lawn.png',
|
|
154
|
+
],
|
|
155
|
+
watermark: false,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Provider Options
|
|
162
|
+
|
|
163
|
+
Use `providerOptions.bytedance` to configure video generation:
|
|
164
|
+
|
|
165
|
+
| Option | Description |
|
|
166
|
+
| ----------------- | -------------------------------------------------------------------------------------- |
|
|
167
|
+
| `watermark` | Whether to add a watermark to the generated video |
|
|
168
|
+
| `generateAudio` | Generate synchronized audio (Seedance 1.5 Pro only) |
|
|
169
|
+
| `cameraFixed` | Whether to fix the camera during generation |
|
|
170
|
+
| `returnLastFrame` | Return the last frame of the generated video (useful for chaining) |
|
|
171
|
+
| `serviceTier` | `'default'` for online inference, `'flex'` for offline at 50% price |
|
|
172
|
+
| `draft` | Enable draft mode for low-cost 480p preview generation (Seedance 1.5 Pro only) |
|
|
173
|
+
| `lastFrameImage` | URL of last frame image for first-and-last frame generation |
|
|
174
|
+
| `referenceImages` | Array of reference image URLs (1-4) for multi-reference generation (1.0 Lite I2V only) |
|
|
175
|
+
| `pollIntervalMs` | Poll interval for async generation (default: 3000ms) |
|
|
176
|
+
| `pollTimeoutMs` | Max wait time for generation (default: 300000ms) |
|
|
177
|
+
|
|
178
|
+
Supported aspect ratios: `16:9`, `4:3`, `1:1`, `3:4`, `9:16`, `21:9`, `adaptive` (image-to-video only).
|
|
179
|
+
|
|
180
|
+
## Authentication
|
|
181
|
+
|
|
182
|
+
Set the `ARK_API_KEY` environment variable:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
ARK_API_KEY=your-api-key
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Or pass it directly:
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { createByteDance } from '@ai-sdk/bytedance';
|
|
192
|
+
|
|
193
|
+
const byteDance = createByteDance({
|
|
194
|
+
apiKey: 'your-api-key',
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
You can [obtain an API key](https://console.byteplus.com/ark/apiKey) from the BytePlus console.
|
|
199
|
+
|
|
200
|
+
## Documentation
|
|
201
|
+
|
|
202
|
+
Please check out the **[ByteDance provider](https://ai-sdk.dev/providers/ai-sdk-providers/bytedance)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ProviderV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type ByteDanceVideoModelId = 'seedance-1-5-pro-251215' | 'seedance-1-0-pro-250528' | 'seedance-1-0-pro-fast-251015' | 'seedance-1-0-lite-t2v-250428' | 'seedance-1-0-lite-i2v-250428' | (string & {});
|
|
5
|
+
|
|
6
|
+
interface ByteDanceProviderSettings {
|
|
7
|
+
/**
|
|
8
|
+
* ByteDance Ark API key. Default value is taken from the `ARK_API_KEY`
|
|
9
|
+
* environment variable.
|
|
10
|
+
*/
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for the API calls.
|
|
14
|
+
* Default: https://ark.ap-southeast.bytepluses.com/api/v3
|
|
15
|
+
*/
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom headers to include in the requests.
|
|
19
|
+
*/
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Custom fetch implementation. You can use it as a middleware to intercept
|
|
23
|
+
* requests, or to provide a custom fetch implementation for e.g. testing.
|
|
24
|
+
*/
|
|
25
|
+
fetch?: FetchFunction;
|
|
26
|
+
}
|
|
27
|
+
interface ByteDanceProvider extends ProviderV3 {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a model for video generation.
|
|
30
|
+
*/
|
|
31
|
+
video(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a model for video generation.
|
|
34
|
+
*/
|
|
35
|
+
videoModel(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a ByteDance provider instance.
|
|
39
|
+
*/
|
|
40
|
+
declare function createByteDance(options?: ByteDanceProviderSettings): ByteDanceProvider;
|
|
41
|
+
/**
|
|
42
|
+
* Default ByteDance provider instance.
|
|
43
|
+
*/
|
|
44
|
+
declare const byteDance: ByteDanceProvider;
|
|
45
|
+
|
|
46
|
+
type ByteDanceVideoProviderOptions = {
|
|
47
|
+
watermark?: boolean | null;
|
|
48
|
+
generateAudio?: boolean | null;
|
|
49
|
+
cameraFixed?: boolean | null;
|
|
50
|
+
returnLastFrame?: boolean | null;
|
|
51
|
+
serviceTier?: 'default' | 'flex' | null;
|
|
52
|
+
draft?: boolean | null;
|
|
53
|
+
lastFrameImage?: string | null;
|
|
54
|
+
referenceImages?: string[] | null;
|
|
55
|
+
pollIntervalMs?: number | null;
|
|
56
|
+
pollTimeoutMs?: number | null;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const VERSION: string;
|
|
61
|
+
|
|
62
|
+
export { type ByteDanceProvider, type ByteDanceProviderSettings, type ByteDanceVideoModelId, type ByteDanceVideoProviderOptions, VERSION, byteDance, createByteDance };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ProviderV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type ByteDanceVideoModelId = 'seedance-1-5-pro-251215' | 'seedance-1-0-pro-250528' | 'seedance-1-0-pro-fast-251015' | 'seedance-1-0-lite-t2v-250428' | 'seedance-1-0-lite-i2v-250428' | (string & {});
|
|
5
|
+
|
|
6
|
+
interface ByteDanceProviderSettings {
|
|
7
|
+
/**
|
|
8
|
+
* ByteDance Ark API key. Default value is taken from the `ARK_API_KEY`
|
|
9
|
+
* environment variable.
|
|
10
|
+
*/
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for the API calls.
|
|
14
|
+
* Default: https://ark.ap-southeast.bytepluses.com/api/v3
|
|
15
|
+
*/
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom headers to include in the requests.
|
|
19
|
+
*/
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Custom fetch implementation. You can use it as a middleware to intercept
|
|
23
|
+
* requests, or to provide a custom fetch implementation for e.g. testing.
|
|
24
|
+
*/
|
|
25
|
+
fetch?: FetchFunction;
|
|
26
|
+
}
|
|
27
|
+
interface ByteDanceProvider extends ProviderV3 {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a model for video generation.
|
|
30
|
+
*/
|
|
31
|
+
video(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a model for video generation.
|
|
34
|
+
*/
|
|
35
|
+
videoModel(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a ByteDance provider instance.
|
|
39
|
+
*/
|
|
40
|
+
declare function createByteDance(options?: ByteDanceProviderSettings): ByteDanceProvider;
|
|
41
|
+
/**
|
|
42
|
+
* Default ByteDance provider instance.
|
|
43
|
+
*/
|
|
44
|
+
declare const byteDance: ByteDanceProvider;
|
|
45
|
+
|
|
46
|
+
type ByteDanceVideoProviderOptions = {
|
|
47
|
+
watermark?: boolean | null;
|
|
48
|
+
generateAudio?: boolean | null;
|
|
49
|
+
cameraFixed?: boolean | null;
|
|
50
|
+
returnLastFrame?: boolean | null;
|
|
51
|
+
serviceTier?: 'default' | 'flex' | null;
|
|
52
|
+
draft?: boolean | null;
|
|
53
|
+
lastFrameImage?: string | null;
|
|
54
|
+
referenceImages?: string[] | null;
|
|
55
|
+
pollIntervalMs?: number | null;
|
|
56
|
+
pollTimeoutMs?: number | null;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const VERSION: string;
|
|
61
|
+
|
|
62
|
+
export { type ByteDanceProvider, type ByteDanceProviderSettings, type ByteDanceVideoModelId, type ByteDanceVideoProviderOptions, VERSION, byteDance, createByteDance };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
24
|
+
byteDance: () => byteDance,
|
|
25
|
+
createByteDance: () => createByteDance
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/bytedance-provider.ts
|
|
30
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
31
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
32
|
+
|
|
33
|
+
// src/bytedance-video-model.ts
|
|
34
|
+
var import_provider = require("@ai-sdk/provider");
|
|
35
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
36
|
+
var import_v4 = require("zod/v4");
|
|
37
|
+
var HANDLED_PROVIDER_OPTIONS = /* @__PURE__ */ new Set([
|
|
38
|
+
"watermark",
|
|
39
|
+
"generateAudio",
|
|
40
|
+
"cameraFixed",
|
|
41
|
+
"returnLastFrame",
|
|
42
|
+
"serviceTier",
|
|
43
|
+
"draft",
|
|
44
|
+
"lastFrameImage",
|
|
45
|
+
"referenceImages",
|
|
46
|
+
"pollIntervalMs",
|
|
47
|
+
"pollTimeoutMs"
|
|
48
|
+
]);
|
|
49
|
+
var byteDanceVideoProviderOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
50
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
51
|
+
import_v4.z.object({
|
|
52
|
+
watermark: import_v4.z.boolean().nullish(),
|
|
53
|
+
generateAudio: import_v4.z.boolean().nullish(),
|
|
54
|
+
cameraFixed: import_v4.z.boolean().nullish(),
|
|
55
|
+
returnLastFrame: import_v4.z.boolean().nullish(),
|
|
56
|
+
serviceTier: import_v4.z.enum(["default", "flex"]).nullish(),
|
|
57
|
+
draft: import_v4.z.boolean().nullish(),
|
|
58
|
+
lastFrameImage: import_v4.z.string().nullish(),
|
|
59
|
+
referenceImages: import_v4.z.array(import_v4.z.string()).nullish(),
|
|
60
|
+
pollIntervalMs: import_v4.z.number().positive().nullish(),
|
|
61
|
+
pollTimeoutMs: import_v4.z.number().positive().nullish()
|
|
62
|
+
}).passthrough()
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
var RESOLUTION_MAP = {
|
|
66
|
+
"864x496": "480p",
|
|
67
|
+
"496x864": "480p",
|
|
68
|
+
"752x560": "480p",
|
|
69
|
+
"560x752": "480p",
|
|
70
|
+
"640x640": "480p",
|
|
71
|
+
"992x432": "480p",
|
|
72
|
+
"432x992": "480p",
|
|
73
|
+
"864x480": "480p",
|
|
74
|
+
"480x864": "480p",
|
|
75
|
+
"736x544": "480p",
|
|
76
|
+
"544x736": "480p",
|
|
77
|
+
"960x416": "480p",
|
|
78
|
+
"416x960": "480p",
|
|
79
|
+
"832x480": "480p",
|
|
80
|
+
"480x832": "480p",
|
|
81
|
+
"624x624": "480p",
|
|
82
|
+
"1280x720": "720p",
|
|
83
|
+
"720x1280": "720p",
|
|
84
|
+
"1112x834": "720p",
|
|
85
|
+
"834x1112": "720p",
|
|
86
|
+
"960x960": "720p",
|
|
87
|
+
"1470x630": "720p",
|
|
88
|
+
"630x1470": "720p",
|
|
89
|
+
"1248x704": "720p",
|
|
90
|
+
"704x1248": "720p",
|
|
91
|
+
"1120x832": "720p",
|
|
92
|
+
"832x1120": "720p",
|
|
93
|
+
"1504x640": "720p",
|
|
94
|
+
"640x1504": "720p",
|
|
95
|
+
"1920x1080": "1080p",
|
|
96
|
+
"1080x1920": "1080p",
|
|
97
|
+
"1664x1248": "1080p",
|
|
98
|
+
"1248x1664": "1080p",
|
|
99
|
+
"1440x1440": "1080p",
|
|
100
|
+
"2206x946": "1080p",
|
|
101
|
+
"946x2206": "1080p",
|
|
102
|
+
"1920x1088": "1080p",
|
|
103
|
+
"1088x1920": "1080p",
|
|
104
|
+
"2176x928": "1080p",
|
|
105
|
+
"928x2176": "1080p"
|
|
106
|
+
};
|
|
107
|
+
var ByteDanceVideoModel = class {
|
|
108
|
+
constructor(modelId, config) {
|
|
109
|
+
this.modelId = modelId;
|
|
110
|
+
this.config = config;
|
|
111
|
+
this.specificationVersion = "v3";
|
|
112
|
+
this.maxVideosPerCall = 1;
|
|
113
|
+
}
|
|
114
|
+
get provider() {
|
|
115
|
+
return this.config.provider;
|
|
116
|
+
}
|
|
117
|
+
async doGenerate(options) {
|
|
118
|
+
var _a, _b, _c, _d, _e, _f;
|
|
119
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
120
|
+
const warnings = [];
|
|
121
|
+
const byteDanceOptions = await (0, import_provider_utils.parseProviderOptions)({
|
|
122
|
+
provider: "bytedance",
|
|
123
|
+
providerOptions: options.providerOptions,
|
|
124
|
+
schema: byteDanceVideoProviderOptionsSchema
|
|
125
|
+
});
|
|
126
|
+
if (options.fps) {
|
|
127
|
+
warnings.push({
|
|
128
|
+
type: "unsupported",
|
|
129
|
+
feature: "fps",
|
|
130
|
+
details: "ByteDance video models do not support custom FPS. Frame rate is fixed at 24 fps."
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (options.n != null && options.n > 1) {
|
|
134
|
+
warnings.push({
|
|
135
|
+
type: "unsupported",
|
|
136
|
+
feature: "n",
|
|
137
|
+
details: "ByteDance video models do not support generating multiple videos per call. Only 1 video will be generated."
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const content = [];
|
|
141
|
+
if (options.prompt != null) {
|
|
142
|
+
content.push({
|
|
143
|
+
type: "text",
|
|
144
|
+
text: options.prompt
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (options.image != null) {
|
|
148
|
+
content.push({
|
|
149
|
+
type: "image_url",
|
|
150
|
+
image_url: { url: (0, import_provider_utils.convertImageModelFileToDataUri)(options.image) }
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if ((byteDanceOptions == null ? void 0 : byteDanceOptions.lastFrameImage) != null) {
|
|
154
|
+
content.push({
|
|
155
|
+
type: "image_url",
|
|
156
|
+
image_url: { url: byteDanceOptions.lastFrameImage },
|
|
157
|
+
role: "last_frame"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if ((byteDanceOptions == null ? void 0 : byteDanceOptions.referenceImages) != null && byteDanceOptions.referenceImages.length > 0) {
|
|
161
|
+
for (const imageUrl of byteDanceOptions.referenceImages) {
|
|
162
|
+
content.push({
|
|
163
|
+
type: "image_url",
|
|
164
|
+
image_url: { url: imageUrl },
|
|
165
|
+
role: "reference_image"
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const body = {
|
|
170
|
+
model: this.modelId,
|
|
171
|
+
content
|
|
172
|
+
};
|
|
173
|
+
if (options.aspectRatio) {
|
|
174
|
+
body.ratio = options.aspectRatio;
|
|
175
|
+
}
|
|
176
|
+
if (options.duration) {
|
|
177
|
+
body.duration = options.duration;
|
|
178
|
+
}
|
|
179
|
+
if (options.seed) {
|
|
180
|
+
body.seed = options.seed;
|
|
181
|
+
}
|
|
182
|
+
if (options.resolution) {
|
|
183
|
+
const mapped = RESOLUTION_MAP[options.resolution];
|
|
184
|
+
if (mapped) {
|
|
185
|
+
body.resolution = mapped;
|
|
186
|
+
} else {
|
|
187
|
+
body.resolution = options.resolution;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (byteDanceOptions != null) {
|
|
191
|
+
if (byteDanceOptions.watermark != null) {
|
|
192
|
+
body.watermark = byteDanceOptions.watermark;
|
|
193
|
+
}
|
|
194
|
+
if (byteDanceOptions.generateAudio != null) {
|
|
195
|
+
body.generate_audio = byteDanceOptions.generateAudio;
|
|
196
|
+
}
|
|
197
|
+
if (byteDanceOptions.cameraFixed != null) {
|
|
198
|
+
body.camera_fixed = byteDanceOptions.cameraFixed;
|
|
199
|
+
}
|
|
200
|
+
if (byteDanceOptions.returnLastFrame != null) {
|
|
201
|
+
body.return_last_frame = byteDanceOptions.returnLastFrame;
|
|
202
|
+
}
|
|
203
|
+
if (byteDanceOptions.serviceTier != null) {
|
|
204
|
+
body.service_tier = byteDanceOptions.serviceTier;
|
|
205
|
+
}
|
|
206
|
+
if (byteDanceOptions.draft != null) {
|
|
207
|
+
body.draft = byteDanceOptions.draft;
|
|
208
|
+
}
|
|
209
|
+
for (const [key, value] of Object.entries(byteDanceOptions)) {
|
|
210
|
+
if (!HANDLED_PROVIDER_OPTIONS.has(key)) {
|
|
211
|
+
body[key] = value;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const createUrl = `${this.config.baseURL}/contents/generations/tasks`;
|
|
216
|
+
const { value: createResponse } = await (0, import_provider_utils.postJsonToApi)({
|
|
217
|
+
url: createUrl,
|
|
218
|
+
headers: (0, import_provider_utils.combineHeaders)(
|
|
219
|
+
await (0, import_provider_utils.resolve)(this.config.headers),
|
|
220
|
+
options.headers
|
|
221
|
+
),
|
|
222
|
+
body,
|
|
223
|
+
failedResponseHandler: byteDanceFailedResponseHandler,
|
|
224
|
+
successfulResponseHandler: (0, import_provider_utils.createJsonResponseHandler)(
|
|
225
|
+
byteDanceTaskResponseSchema
|
|
226
|
+
),
|
|
227
|
+
abortSignal: options.abortSignal,
|
|
228
|
+
fetch: this.config.fetch
|
|
229
|
+
});
|
|
230
|
+
const taskId = createResponse.id;
|
|
231
|
+
if (!taskId) {
|
|
232
|
+
throw new import_provider.AISDKError({
|
|
233
|
+
name: "BYTEDANCE_VIDEO_GENERATION_ERROR",
|
|
234
|
+
message: "No task ID returned from API"
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const pollIntervalMs = (_d = byteDanceOptions == null ? void 0 : byteDanceOptions.pollIntervalMs) != null ? _d : 3e3;
|
|
238
|
+
const pollTimeoutMs = (_e = byteDanceOptions == null ? void 0 : byteDanceOptions.pollTimeoutMs) != null ? _e : 3e5;
|
|
239
|
+
const startTime = Date.now();
|
|
240
|
+
let response;
|
|
241
|
+
let responseHeaders;
|
|
242
|
+
while (true) {
|
|
243
|
+
const statusUrl = `${this.config.baseURL}/contents/generations/tasks/${taskId}`;
|
|
244
|
+
const { value: statusResponse, responseHeaders: statusHeaders } = await (0, import_provider_utils.getFromApi)({
|
|
245
|
+
url: statusUrl,
|
|
246
|
+
headers: (0, import_provider_utils.combineHeaders)(
|
|
247
|
+
await (0, import_provider_utils.resolve)(this.config.headers),
|
|
248
|
+
options.headers
|
|
249
|
+
),
|
|
250
|
+
failedResponseHandler: byteDanceFailedResponseHandler,
|
|
251
|
+
successfulResponseHandler: (0, import_provider_utils.createJsonResponseHandler)(
|
|
252
|
+
byteDanceStatusResponseSchema
|
|
253
|
+
),
|
|
254
|
+
abortSignal: options.abortSignal,
|
|
255
|
+
fetch: this.config.fetch
|
|
256
|
+
});
|
|
257
|
+
if (statusResponse.status === "succeeded") {
|
|
258
|
+
response = statusResponse;
|
|
259
|
+
responseHeaders = statusHeaders;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (statusResponse.status === "failed") {
|
|
263
|
+
throw new import_provider.AISDKError({
|
|
264
|
+
name: "BYTEDANCE_VIDEO_GENERATION_FAILED",
|
|
265
|
+
message: `Video generation failed: ${JSON.stringify(statusResponse)}`
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (Date.now() - startTime > pollTimeoutMs) {
|
|
269
|
+
throw new import_provider.AISDKError({
|
|
270
|
+
name: "BYTEDANCE_VIDEO_GENERATION_TIMEOUT",
|
|
271
|
+
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
await (0, import_provider_utils.delay)(pollIntervalMs, { abortSignal: options.abortSignal });
|
|
275
|
+
}
|
|
276
|
+
const videoUrl = (_f = response.content) == null ? void 0 : _f.video_url;
|
|
277
|
+
if (!videoUrl) {
|
|
278
|
+
throw new import_provider.AISDKError({
|
|
279
|
+
name: "BYTEDANCE_VIDEO_GENERATION_ERROR",
|
|
280
|
+
message: "No video URL in response"
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
videos: [
|
|
285
|
+
{
|
|
286
|
+
type: "url",
|
|
287
|
+
url: videoUrl,
|
|
288
|
+
mediaType: "video/mp4"
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
warnings,
|
|
292
|
+
response: {
|
|
293
|
+
timestamp: currentDate,
|
|
294
|
+
modelId: this.modelId,
|
|
295
|
+
headers: responseHeaders
|
|
296
|
+
},
|
|
297
|
+
providerMetadata: {
|
|
298
|
+
bytedance: {
|
|
299
|
+
taskId,
|
|
300
|
+
usage: response.usage
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
var byteDanceTaskResponseSchema = import_v4.z.object({
|
|
307
|
+
id: import_v4.z.string().nullish()
|
|
308
|
+
});
|
|
309
|
+
var byteDanceStatusResponseSchema = import_v4.z.object({
|
|
310
|
+
id: import_v4.z.string().nullish(),
|
|
311
|
+
model: import_v4.z.string().nullish(),
|
|
312
|
+
status: import_v4.z.string(),
|
|
313
|
+
content: import_v4.z.object({
|
|
314
|
+
video_url: import_v4.z.string().nullish()
|
|
315
|
+
}).nullish(),
|
|
316
|
+
usage: import_v4.z.object({
|
|
317
|
+
completion_tokens: import_v4.z.number().nullish()
|
|
318
|
+
}).nullish()
|
|
319
|
+
});
|
|
320
|
+
var byteDanceErrorSchema = import_v4.z.object({
|
|
321
|
+
error: import_v4.z.object({
|
|
322
|
+
message: import_v4.z.string(),
|
|
323
|
+
code: import_v4.z.string().nullish()
|
|
324
|
+
}).nullish(),
|
|
325
|
+
message: import_v4.z.string().nullish()
|
|
326
|
+
});
|
|
327
|
+
var byteDanceFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
328
|
+
errorSchema: byteDanceErrorSchema,
|
|
329
|
+
errorToMessage: (data) => {
|
|
330
|
+
var _a, _b, _c;
|
|
331
|
+
return (_c = (_b = (_a = data.error) == null ? void 0 : _a.message) != null ? _b : data.message) != null ? _c : "Unknown error";
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// src/bytedance-provider.ts
|
|
336
|
+
var defaultBaseURL = "https://ark.ap-southeast.bytepluses.com/api/v3";
|
|
337
|
+
function createByteDance(options = {}) {
|
|
338
|
+
var _a;
|
|
339
|
+
const baseURL = (0, import_provider_utils2.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
340
|
+
const getHeaders = () => ({
|
|
341
|
+
Authorization: `Bearer ${(0, import_provider_utils2.loadApiKey)({
|
|
342
|
+
apiKey: options.apiKey,
|
|
343
|
+
environmentVariableName: "ARK_API_KEY",
|
|
344
|
+
description: "ByteDance ModelArk"
|
|
345
|
+
})}`,
|
|
346
|
+
"Content-Type": "application/json",
|
|
347
|
+
...options.headers
|
|
348
|
+
});
|
|
349
|
+
const createVideoModel = (modelId) => new ByteDanceVideoModel(modelId, {
|
|
350
|
+
provider: "bytedance.video",
|
|
351
|
+
baseURL: baseURL != null ? baseURL : defaultBaseURL,
|
|
352
|
+
headers: getHeaders,
|
|
353
|
+
fetch: options.fetch
|
|
354
|
+
});
|
|
355
|
+
return {
|
|
356
|
+
specificationVersion: "v3",
|
|
357
|
+
embeddingModel: (modelId) => {
|
|
358
|
+
throw new import_provider2.NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
359
|
+
},
|
|
360
|
+
imageModel: (modelId) => {
|
|
361
|
+
throw new import_provider2.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
362
|
+
},
|
|
363
|
+
languageModel: (modelId) => {
|
|
364
|
+
throw new import_provider2.NoSuchModelError({ modelId, modelType: "languageModel" });
|
|
365
|
+
},
|
|
366
|
+
video: createVideoModel,
|
|
367
|
+
videoModel: createVideoModel
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
var byteDance = createByteDance();
|
|
371
|
+
|
|
372
|
+
// src/version.ts
|
|
373
|
+
var VERSION = "1.0.0";
|
|
374
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
375
|
+
0 && (module.exports = {
|
|
376
|
+
VERSION,
|
|
377
|
+
byteDance,
|
|
378
|
+
createByteDance
|
|
379
|
+
});
|
|
380
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/bytedance-provider.ts","../src/bytedance-video-model.ts","../src/version.ts"],"sourcesContent":["export type {\n ByteDanceProvider,\n ByteDanceProviderSettings,\n} from './bytedance-provider';\nexport { byteDance, createByteDance } from './bytedance-provider';\nexport type { ByteDanceVideoProviderOptions } from './bytedance-video-model';\nexport type { ByteDanceVideoModelId } from './bytedance-video-settings';\nexport { VERSION } from './version';\n","import {\n type Experimental_VideoModelV3,\n NoSuchModelError,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { ByteDanceVideoModel } from './bytedance-video-model';\nimport type { ByteDanceVideoModelId } from './bytedance-video-settings';\n\nexport interface ByteDanceProviderSettings {\n /**\n * ByteDance Ark API key. Default value is taken from the `ARK_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the API calls.\n * Default: https://ark.ap-southeast.bytepluses.com/api/v3\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept\n * requests, or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface ByteDanceProvider extends ProviderV3 {\n /**\n * Creates a model for video generation.\n */\n video(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;\n\n /**\n * Creates a model for video generation.\n */\n videoModel(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;\n}\n\nconst defaultBaseURL = 'https://ark.ap-southeast.bytepluses.com/api/v3';\n\n/**\n * Create a ByteDance provider instance.\n */\nexport function createByteDance(\n options: ByteDanceProviderSettings = {},\n): ByteDanceProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'ARK_API_KEY',\n description: 'ByteDance ModelArk',\n })}`,\n 'Content-Type': 'application/json',\n ...options.headers,\n });\n\n const createVideoModel = (modelId: ByteDanceVideoModelId) =>\n new ByteDanceVideoModel(modelId, {\n provider: 'bytedance.video',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n return {\n specificationVersion: 'v3' as const,\n embeddingModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n },\n imageModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n },\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n },\n video: createVideoModel,\n videoModel: createVideoModel,\n };\n}\n\n/**\n * Default ByteDance provider instance.\n */\nexport const byteDance = createByteDance();\n","import {\n AISDKError,\n type Experimental_VideoModelV3,\n type SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n delay,\n getFromApi,\n lazySchema,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { ByteDanceConfig } from './bytedance-config';\nimport type { ByteDanceVideoModelId } from './bytedance-video-settings';\n\nexport type ByteDanceVideoProviderOptions = {\n watermark?: boolean | null;\n generateAudio?: boolean | null;\n cameraFixed?: boolean | null;\n returnLastFrame?: boolean | null;\n serviceTier?: 'default' | 'flex' | null;\n draft?: boolean | null;\n lastFrameImage?: string | null;\n referenceImages?: string[] | null;\n pollIntervalMs?: number | null;\n pollTimeoutMs?: number | null;\n [key: string]: unknown;\n};\n\nconst HANDLED_PROVIDER_OPTIONS = new Set([\n 'watermark',\n 'generateAudio',\n 'cameraFixed',\n 'returnLastFrame',\n 'serviceTier',\n 'draft',\n 'lastFrameImage',\n 'referenceImages',\n 'pollIntervalMs',\n 'pollTimeoutMs',\n]);\n\nexport const byteDanceVideoProviderOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n watermark: z.boolean().nullish(),\n generateAudio: z.boolean().nullish(),\n cameraFixed: z.boolean().nullish(),\n returnLastFrame: z.boolean().nullish(),\n serviceTier: z.enum(['default', 'flex']).nullish(),\n draft: z.boolean().nullish(),\n lastFrameImage: z.string().nullish(),\n referenceImages: z.array(z.string()).nullish(),\n pollIntervalMs: z.number().positive().nullish(),\n pollTimeoutMs: z.number().positive().nullish(),\n })\n .passthrough(),\n ),\n);\n\nconst RESOLUTION_MAP: Record<string, string> = {\n '864x496': '480p',\n '496x864': '480p',\n '752x560': '480p',\n '560x752': '480p',\n '640x640': '480p',\n '992x432': '480p',\n '432x992': '480p',\n '864x480': '480p',\n '480x864': '480p',\n '736x544': '480p',\n '544x736': '480p',\n '960x416': '480p',\n '416x960': '480p',\n '832x480': '480p',\n '480x832': '480p',\n '624x624': '480p',\n '1280x720': '720p',\n '720x1280': '720p',\n '1112x834': '720p',\n '834x1112': '720p',\n '960x960': '720p',\n '1470x630': '720p',\n '630x1470': '720p',\n '1248x704': '720p',\n '704x1248': '720p',\n '1120x832': '720p',\n '832x1120': '720p',\n '1504x640': '720p',\n '640x1504': '720p',\n '1920x1080': '1080p',\n '1080x1920': '1080p',\n '1664x1248': '1080p',\n '1248x1664': '1080p',\n '1440x1440': '1080p',\n '2206x946': '1080p',\n '946x2206': '1080p',\n '1920x1088': '1080p',\n '1088x1920': '1080p',\n '2176x928': '1080p',\n '928x2176': '1080p',\n};\n\ninterface ByteDanceVideoModelConfig extends ByteDanceConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class ByteDanceVideoModel implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxVideosPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: ByteDanceVideoModelId,\n private readonly config: ByteDanceVideoModelConfig,\n ) {}\n\n async doGenerate(\n options: Parameters<Experimental_VideoModelV3['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<Experimental_VideoModelV3['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV3Warning[] = [];\n\n const byteDanceOptions = (await parseProviderOptions({\n provider: 'bytedance',\n providerOptions: options.providerOptions,\n schema: byteDanceVideoProviderOptionsSchema,\n })) as ByteDanceVideoProviderOptions | undefined;\n\n // Warn about unsupported standard options\n if (options.fps) {\n warnings.push({\n type: 'unsupported',\n feature: 'fps',\n details:\n 'ByteDance video models do not support custom FPS. Frame rate is fixed at 24 fps.',\n });\n }\n\n if (options.n != null && options.n > 1) {\n warnings.push({\n type: 'unsupported',\n feature: 'n',\n details:\n 'ByteDance video models do not support generating multiple videos per call. ' +\n 'Only 1 video will be generated.',\n });\n }\n\n const content: Array<Record<string, unknown>> = [];\n\n if (options.prompt != null) {\n content.push({\n type: 'text',\n text: options.prompt,\n });\n }\n\n if (options.image != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(options.image) },\n });\n }\n\n // Add last frame image if provided\n if (byteDanceOptions?.lastFrameImage != null) {\n content.push({\n type: 'image_url',\n image_url: { url: byteDanceOptions.lastFrameImage },\n role: 'last_frame',\n });\n }\n\n // Add reference images if provided\n if (\n byteDanceOptions?.referenceImages != null &&\n byteDanceOptions.referenceImages.length > 0\n ) {\n for (const imageUrl of byteDanceOptions.referenceImages) {\n content.push({\n type: 'image_url',\n image_url: { url: imageUrl },\n role: 'reference_image',\n });\n }\n }\n\n const body: Record<string, unknown> = {\n model: this.modelId,\n content,\n };\n\n if (options.aspectRatio) {\n body.ratio = options.aspectRatio;\n }\n\n if (options.duration) {\n body.duration = options.duration;\n }\n\n if (options.seed) {\n body.seed = options.seed;\n }\n\n if (options.resolution) {\n const mapped = RESOLUTION_MAP[options.resolution];\n if (mapped) {\n body.resolution = mapped;\n } else {\n body.resolution = options.resolution;\n }\n }\n\n if (byteDanceOptions != null) {\n if (byteDanceOptions.watermark != null) {\n body.watermark = byteDanceOptions.watermark;\n }\n if (byteDanceOptions.generateAudio != null) {\n body.generate_audio = byteDanceOptions.generateAudio;\n }\n if (byteDanceOptions.cameraFixed != null) {\n body.camera_fixed = byteDanceOptions.cameraFixed;\n }\n if (byteDanceOptions.returnLastFrame != null) {\n body.return_last_frame = byteDanceOptions.returnLastFrame;\n }\n if (byteDanceOptions.serviceTier != null) {\n body.service_tier = byteDanceOptions.serviceTier;\n }\n if (byteDanceOptions.draft != null) {\n body.draft = byteDanceOptions.draft;\n }\n\n // Pass through any additional options not explicitly handled\n for (const [key, value] of Object.entries(byteDanceOptions)) {\n if (!HANDLED_PROVIDER_OPTIONS.has(key)) {\n body[key] = value;\n }\n }\n }\n\n const createUrl = `${this.config.baseURL}/contents/generations/tasks`;\n\n const { value: createResponse } = await postJsonToApi({\n url: createUrl,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: byteDanceFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n byteDanceTaskResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const taskId = createResponse.id;\n\n if (!taskId) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_ERROR',\n message: 'No task ID returned from API',\n });\n }\n\n const pollIntervalMs = byteDanceOptions?.pollIntervalMs ?? 3000;\n const pollTimeoutMs = byteDanceOptions?.pollTimeoutMs ?? 300000;\n\n const startTime = Date.now();\n let response: ByteDanceResponse;\n let responseHeaders: Record<string, string> | undefined;\n\n while (true) {\n const statusUrl = `${this.config.baseURL}/contents/generations/tasks/${taskId}`;\n\n const { value: statusResponse, responseHeaders: statusHeaders } =\n await getFromApi({\n url: statusUrl,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n failedResponseHandler: byteDanceFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n byteDanceStatusResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n if (statusResponse.status === 'succeeded') {\n response = statusResponse;\n responseHeaders = statusHeaders;\n break;\n }\n\n if (statusResponse.status === 'failed') {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_FAILED',\n message: `Video generation failed: ${JSON.stringify(statusResponse)}`,\n });\n }\n\n if (Date.now() - startTime > pollTimeoutMs) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_TIMEOUT',\n message: `Video generation timed out after ${pollTimeoutMs}ms`,\n });\n }\n\n await delay(pollIntervalMs, { abortSignal: options.abortSignal });\n }\n\n const videoUrl = response.content?.video_url;\n if (!videoUrl) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_ERROR',\n message: 'No video URL in response',\n });\n }\n\n return {\n videos: [\n {\n type: 'url',\n url: videoUrl,\n mediaType: 'video/mp4',\n },\n ],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n providerMetadata: {\n bytedance: {\n taskId,\n usage: response.usage,\n },\n },\n };\n }\n}\n\nconst byteDanceTaskResponseSchema = z.object({\n id: z.string().nullish(),\n});\n\ntype ByteDanceResponse = z.infer<typeof byteDanceStatusResponseSchema>;\n\nconst byteDanceStatusResponseSchema = z.object({\n id: z.string().nullish(),\n model: z.string().nullish(),\n status: z.string(),\n content: z\n .object({\n video_url: z.string().nullish(),\n })\n .nullish(),\n usage: z\n .object({\n completion_tokens: z.number().nullish(),\n })\n .nullish(),\n});\n\nconst byteDanceErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n code: z.string().nullish(),\n })\n .nullish(),\n message: z.string().nullish(),\n});\n\nconst byteDanceFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: byteDanceErrorSchema,\n errorToMessage: data =>\n data.error?.message ?? data.message ?? 'Unknown error',\n});\n","declare const __PACKAGE_VERSION__: string;\n\nexport const VERSION = __PACKAGE_VERSION__;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAIO;AACP,IAAAC,yBAIO;;;ACTP,sBAIO;AACP,4BAYO;AACP,gBAAkB;AAkBlB,IAAM,2BAA2B,oBAAI,IAAI;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AW,gBAAgB,CAAC;AAAA,IACpE;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,EACd;AACF;AAKO,IAAM,YAAY,gBAAgB;;;AE/FlC,IAAM,UAAU;","names":["import_provider","import_provider_utils"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// src/bytedance-provider.ts
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withoutTrailingSlash
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
9
|
+
|
|
10
|
+
// src/bytedance-video-model.ts
|
|
11
|
+
import {
|
|
12
|
+
AISDKError
|
|
13
|
+
} from "@ai-sdk/provider";
|
|
14
|
+
import {
|
|
15
|
+
combineHeaders,
|
|
16
|
+
convertImageModelFileToDataUri,
|
|
17
|
+
createJsonErrorResponseHandler,
|
|
18
|
+
createJsonResponseHandler,
|
|
19
|
+
delay,
|
|
20
|
+
getFromApi,
|
|
21
|
+
lazySchema,
|
|
22
|
+
parseProviderOptions,
|
|
23
|
+
postJsonToApi,
|
|
24
|
+
resolve,
|
|
25
|
+
zodSchema
|
|
26
|
+
} from "@ai-sdk/provider-utils";
|
|
27
|
+
import { z } from "zod/v4";
|
|
28
|
+
var HANDLED_PROVIDER_OPTIONS = /* @__PURE__ */ new Set([
|
|
29
|
+
"watermark",
|
|
30
|
+
"generateAudio",
|
|
31
|
+
"cameraFixed",
|
|
32
|
+
"returnLastFrame",
|
|
33
|
+
"serviceTier",
|
|
34
|
+
"draft",
|
|
35
|
+
"lastFrameImage",
|
|
36
|
+
"referenceImages",
|
|
37
|
+
"pollIntervalMs",
|
|
38
|
+
"pollTimeoutMs"
|
|
39
|
+
]);
|
|
40
|
+
var byteDanceVideoProviderOptionsSchema = lazySchema(
|
|
41
|
+
() => zodSchema(
|
|
42
|
+
z.object({
|
|
43
|
+
watermark: z.boolean().nullish(),
|
|
44
|
+
generateAudio: z.boolean().nullish(),
|
|
45
|
+
cameraFixed: z.boolean().nullish(),
|
|
46
|
+
returnLastFrame: z.boolean().nullish(),
|
|
47
|
+
serviceTier: z.enum(["default", "flex"]).nullish(),
|
|
48
|
+
draft: z.boolean().nullish(),
|
|
49
|
+
lastFrameImage: z.string().nullish(),
|
|
50
|
+
referenceImages: z.array(z.string()).nullish(),
|
|
51
|
+
pollIntervalMs: z.number().positive().nullish(),
|
|
52
|
+
pollTimeoutMs: z.number().positive().nullish()
|
|
53
|
+
}).passthrough()
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
var RESOLUTION_MAP = {
|
|
57
|
+
"864x496": "480p",
|
|
58
|
+
"496x864": "480p",
|
|
59
|
+
"752x560": "480p",
|
|
60
|
+
"560x752": "480p",
|
|
61
|
+
"640x640": "480p",
|
|
62
|
+
"992x432": "480p",
|
|
63
|
+
"432x992": "480p",
|
|
64
|
+
"864x480": "480p",
|
|
65
|
+
"480x864": "480p",
|
|
66
|
+
"736x544": "480p",
|
|
67
|
+
"544x736": "480p",
|
|
68
|
+
"960x416": "480p",
|
|
69
|
+
"416x960": "480p",
|
|
70
|
+
"832x480": "480p",
|
|
71
|
+
"480x832": "480p",
|
|
72
|
+
"624x624": "480p",
|
|
73
|
+
"1280x720": "720p",
|
|
74
|
+
"720x1280": "720p",
|
|
75
|
+
"1112x834": "720p",
|
|
76
|
+
"834x1112": "720p",
|
|
77
|
+
"960x960": "720p",
|
|
78
|
+
"1470x630": "720p",
|
|
79
|
+
"630x1470": "720p",
|
|
80
|
+
"1248x704": "720p",
|
|
81
|
+
"704x1248": "720p",
|
|
82
|
+
"1120x832": "720p",
|
|
83
|
+
"832x1120": "720p",
|
|
84
|
+
"1504x640": "720p",
|
|
85
|
+
"640x1504": "720p",
|
|
86
|
+
"1920x1080": "1080p",
|
|
87
|
+
"1080x1920": "1080p",
|
|
88
|
+
"1664x1248": "1080p",
|
|
89
|
+
"1248x1664": "1080p",
|
|
90
|
+
"1440x1440": "1080p",
|
|
91
|
+
"2206x946": "1080p",
|
|
92
|
+
"946x2206": "1080p",
|
|
93
|
+
"1920x1088": "1080p",
|
|
94
|
+
"1088x1920": "1080p",
|
|
95
|
+
"2176x928": "1080p",
|
|
96
|
+
"928x2176": "1080p"
|
|
97
|
+
};
|
|
98
|
+
var ByteDanceVideoModel = class {
|
|
99
|
+
constructor(modelId, config) {
|
|
100
|
+
this.modelId = modelId;
|
|
101
|
+
this.config = config;
|
|
102
|
+
this.specificationVersion = "v3";
|
|
103
|
+
this.maxVideosPerCall = 1;
|
|
104
|
+
}
|
|
105
|
+
get provider() {
|
|
106
|
+
return this.config.provider;
|
|
107
|
+
}
|
|
108
|
+
async doGenerate(options) {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f;
|
|
110
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
111
|
+
const warnings = [];
|
|
112
|
+
const byteDanceOptions = await parseProviderOptions({
|
|
113
|
+
provider: "bytedance",
|
|
114
|
+
providerOptions: options.providerOptions,
|
|
115
|
+
schema: byteDanceVideoProviderOptionsSchema
|
|
116
|
+
});
|
|
117
|
+
if (options.fps) {
|
|
118
|
+
warnings.push({
|
|
119
|
+
type: "unsupported",
|
|
120
|
+
feature: "fps",
|
|
121
|
+
details: "ByteDance video models do not support custom FPS. Frame rate is fixed at 24 fps."
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (options.n != null && options.n > 1) {
|
|
125
|
+
warnings.push({
|
|
126
|
+
type: "unsupported",
|
|
127
|
+
feature: "n",
|
|
128
|
+
details: "ByteDance video models do not support generating multiple videos per call. Only 1 video will be generated."
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const content = [];
|
|
132
|
+
if (options.prompt != null) {
|
|
133
|
+
content.push({
|
|
134
|
+
type: "text",
|
|
135
|
+
text: options.prompt
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (options.image != null) {
|
|
139
|
+
content.push({
|
|
140
|
+
type: "image_url",
|
|
141
|
+
image_url: { url: convertImageModelFileToDataUri(options.image) }
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if ((byteDanceOptions == null ? void 0 : byteDanceOptions.lastFrameImage) != null) {
|
|
145
|
+
content.push({
|
|
146
|
+
type: "image_url",
|
|
147
|
+
image_url: { url: byteDanceOptions.lastFrameImage },
|
|
148
|
+
role: "last_frame"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if ((byteDanceOptions == null ? void 0 : byteDanceOptions.referenceImages) != null && byteDanceOptions.referenceImages.length > 0) {
|
|
152
|
+
for (const imageUrl of byteDanceOptions.referenceImages) {
|
|
153
|
+
content.push({
|
|
154
|
+
type: "image_url",
|
|
155
|
+
image_url: { url: imageUrl },
|
|
156
|
+
role: "reference_image"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const body = {
|
|
161
|
+
model: this.modelId,
|
|
162
|
+
content
|
|
163
|
+
};
|
|
164
|
+
if (options.aspectRatio) {
|
|
165
|
+
body.ratio = options.aspectRatio;
|
|
166
|
+
}
|
|
167
|
+
if (options.duration) {
|
|
168
|
+
body.duration = options.duration;
|
|
169
|
+
}
|
|
170
|
+
if (options.seed) {
|
|
171
|
+
body.seed = options.seed;
|
|
172
|
+
}
|
|
173
|
+
if (options.resolution) {
|
|
174
|
+
const mapped = RESOLUTION_MAP[options.resolution];
|
|
175
|
+
if (mapped) {
|
|
176
|
+
body.resolution = mapped;
|
|
177
|
+
} else {
|
|
178
|
+
body.resolution = options.resolution;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (byteDanceOptions != null) {
|
|
182
|
+
if (byteDanceOptions.watermark != null) {
|
|
183
|
+
body.watermark = byteDanceOptions.watermark;
|
|
184
|
+
}
|
|
185
|
+
if (byteDanceOptions.generateAudio != null) {
|
|
186
|
+
body.generate_audio = byteDanceOptions.generateAudio;
|
|
187
|
+
}
|
|
188
|
+
if (byteDanceOptions.cameraFixed != null) {
|
|
189
|
+
body.camera_fixed = byteDanceOptions.cameraFixed;
|
|
190
|
+
}
|
|
191
|
+
if (byteDanceOptions.returnLastFrame != null) {
|
|
192
|
+
body.return_last_frame = byteDanceOptions.returnLastFrame;
|
|
193
|
+
}
|
|
194
|
+
if (byteDanceOptions.serviceTier != null) {
|
|
195
|
+
body.service_tier = byteDanceOptions.serviceTier;
|
|
196
|
+
}
|
|
197
|
+
if (byteDanceOptions.draft != null) {
|
|
198
|
+
body.draft = byteDanceOptions.draft;
|
|
199
|
+
}
|
|
200
|
+
for (const [key, value] of Object.entries(byteDanceOptions)) {
|
|
201
|
+
if (!HANDLED_PROVIDER_OPTIONS.has(key)) {
|
|
202
|
+
body[key] = value;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const createUrl = `${this.config.baseURL}/contents/generations/tasks`;
|
|
207
|
+
const { value: createResponse } = await postJsonToApi({
|
|
208
|
+
url: createUrl,
|
|
209
|
+
headers: combineHeaders(
|
|
210
|
+
await resolve(this.config.headers),
|
|
211
|
+
options.headers
|
|
212
|
+
),
|
|
213
|
+
body,
|
|
214
|
+
failedResponseHandler: byteDanceFailedResponseHandler,
|
|
215
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
216
|
+
byteDanceTaskResponseSchema
|
|
217
|
+
),
|
|
218
|
+
abortSignal: options.abortSignal,
|
|
219
|
+
fetch: this.config.fetch
|
|
220
|
+
});
|
|
221
|
+
const taskId = createResponse.id;
|
|
222
|
+
if (!taskId) {
|
|
223
|
+
throw new AISDKError({
|
|
224
|
+
name: "BYTEDANCE_VIDEO_GENERATION_ERROR",
|
|
225
|
+
message: "No task ID returned from API"
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const pollIntervalMs = (_d = byteDanceOptions == null ? void 0 : byteDanceOptions.pollIntervalMs) != null ? _d : 3e3;
|
|
229
|
+
const pollTimeoutMs = (_e = byteDanceOptions == null ? void 0 : byteDanceOptions.pollTimeoutMs) != null ? _e : 3e5;
|
|
230
|
+
const startTime = Date.now();
|
|
231
|
+
let response;
|
|
232
|
+
let responseHeaders;
|
|
233
|
+
while (true) {
|
|
234
|
+
const statusUrl = `${this.config.baseURL}/contents/generations/tasks/${taskId}`;
|
|
235
|
+
const { value: statusResponse, responseHeaders: statusHeaders } = await getFromApi({
|
|
236
|
+
url: statusUrl,
|
|
237
|
+
headers: combineHeaders(
|
|
238
|
+
await resolve(this.config.headers),
|
|
239
|
+
options.headers
|
|
240
|
+
),
|
|
241
|
+
failedResponseHandler: byteDanceFailedResponseHandler,
|
|
242
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
243
|
+
byteDanceStatusResponseSchema
|
|
244
|
+
),
|
|
245
|
+
abortSignal: options.abortSignal,
|
|
246
|
+
fetch: this.config.fetch
|
|
247
|
+
});
|
|
248
|
+
if (statusResponse.status === "succeeded") {
|
|
249
|
+
response = statusResponse;
|
|
250
|
+
responseHeaders = statusHeaders;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
if (statusResponse.status === "failed") {
|
|
254
|
+
throw new AISDKError({
|
|
255
|
+
name: "BYTEDANCE_VIDEO_GENERATION_FAILED",
|
|
256
|
+
message: `Video generation failed: ${JSON.stringify(statusResponse)}`
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (Date.now() - startTime > pollTimeoutMs) {
|
|
260
|
+
throw new AISDKError({
|
|
261
|
+
name: "BYTEDANCE_VIDEO_GENERATION_TIMEOUT",
|
|
262
|
+
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
await delay(pollIntervalMs, { abortSignal: options.abortSignal });
|
|
266
|
+
}
|
|
267
|
+
const videoUrl = (_f = response.content) == null ? void 0 : _f.video_url;
|
|
268
|
+
if (!videoUrl) {
|
|
269
|
+
throw new AISDKError({
|
|
270
|
+
name: "BYTEDANCE_VIDEO_GENERATION_ERROR",
|
|
271
|
+
message: "No video URL in response"
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
videos: [
|
|
276
|
+
{
|
|
277
|
+
type: "url",
|
|
278
|
+
url: videoUrl,
|
|
279
|
+
mediaType: "video/mp4"
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
warnings,
|
|
283
|
+
response: {
|
|
284
|
+
timestamp: currentDate,
|
|
285
|
+
modelId: this.modelId,
|
|
286
|
+
headers: responseHeaders
|
|
287
|
+
},
|
|
288
|
+
providerMetadata: {
|
|
289
|
+
bytedance: {
|
|
290
|
+
taskId,
|
|
291
|
+
usage: response.usage
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var byteDanceTaskResponseSchema = z.object({
|
|
298
|
+
id: z.string().nullish()
|
|
299
|
+
});
|
|
300
|
+
var byteDanceStatusResponseSchema = z.object({
|
|
301
|
+
id: z.string().nullish(),
|
|
302
|
+
model: z.string().nullish(),
|
|
303
|
+
status: z.string(),
|
|
304
|
+
content: z.object({
|
|
305
|
+
video_url: z.string().nullish()
|
|
306
|
+
}).nullish(),
|
|
307
|
+
usage: z.object({
|
|
308
|
+
completion_tokens: z.number().nullish()
|
|
309
|
+
}).nullish()
|
|
310
|
+
});
|
|
311
|
+
var byteDanceErrorSchema = z.object({
|
|
312
|
+
error: z.object({
|
|
313
|
+
message: z.string(),
|
|
314
|
+
code: z.string().nullish()
|
|
315
|
+
}).nullish(),
|
|
316
|
+
message: z.string().nullish()
|
|
317
|
+
});
|
|
318
|
+
var byteDanceFailedResponseHandler = createJsonErrorResponseHandler({
|
|
319
|
+
errorSchema: byteDanceErrorSchema,
|
|
320
|
+
errorToMessage: (data) => {
|
|
321
|
+
var _a, _b, _c;
|
|
322
|
+
return (_c = (_b = (_a = data.error) == null ? void 0 : _a.message) != null ? _b : data.message) != null ? _c : "Unknown error";
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// src/bytedance-provider.ts
|
|
327
|
+
var defaultBaseURL = "https://ark.ap-southeast.bytepluses.com/api/v3";
|
|
328
|
+
function createByteDance(options = {}) {
|
|
329
|
+
var _a;
|
|
330
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
331
|
+
const getHeaders = () => ({
|
|
332
|
+
Authorization: `Bearer ${loadApiKey({
|
|
333
|
+
apiKey: options.apiKey,
|
|
334
|
+
environmentVariableName: "ARK_API_KEY",
|
|
335
|
+
description: "ByteDance ModelArk"
|
|
336
|
+
})}`,
|
|
337
|
+
"Content-Type": "application/json",
|
|
338
|
+
...options.headers
|
|
339
|
+
});
|
|
340
|
+
const createVideoModel = (modelId) => new ByteDanceVideoModel(modelId, {
|
|
341
|
+
provider: "bytedance.video",
|
|
342
|
+
baseURL: baseURL != null ? baseURL : defaultBaseURL,
|
|
343
|
+
headers: getHeaders,
|
|
344
|
+
fetch: options.fetch
|
|
345
|
+
});
|
|
346
|
+
return {
|
|
347
|
+
specificationVersion: "v3",
|
|
348
|
+
embeddingModel: (modelId) => {
|
|
349
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
350
|
+
},
|
|
351
|
+
imageModel: (modelId) => {
|
|
352
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
353
|
+
},
|
|
354
|
+
languageModel: (modelId) => {
|
|
355
|
+
throw new NoSuchModelError({ modelId, modelType: "languageModel" });
|
|
356
|
+
},
|
|
357
|
+
video: createVideoModel,
|
|
358
|
+
videoModel: createVideoModel
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
var byteDance = createByteDance();
|
|
362
|
+
|
|
363
|
+
// src/version.ts
|
|
364
|
+
var VERSION = "1.0.0";
|
|
365
|
+
export {
|
|
366
|
+
VERSION,
|
|
367
|
+
byteDance,
|
|
368
|
+
createByteDance
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bytedance-provider.ts","../src/bytedance-video-model.ts","../src/version.ts"],"sourcesContent":["import {\n type Experimental_VideoModelV3,\n NoSuchModelError,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { ByteDanceVideoModel } from './bytedance-video-model';\nimport type { ByteDanceVideoModelId } from './bytedance-video-settings';\n\nexport interface ByteDanceProviderSettings {\n /**\n * ByteDance Ark API key. Default value is taken from the `ARK_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the API calls.\n * Default: https://ark.ap-southeast.bytepluses.com/api/v3\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept\n * requests, or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface ByteDanceProvider extends ProviderV3 {\n /**\n * Creates a model for video generation.\n */\n video(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;\n\n /**\n * Creates a model for video generation.\n */\n videoModel(modelId: ByteDanceVideoModelId): Experimental_VideoModelV3;\n}\n\nconst defaultBaseURL = 'https://ark.ap-southeast.bytepluses.com/api/v3';\n\n/**\n * Create a ByteDance provider instance.\n */\nexport function createByteDance(\n options: ByteDanceProviderSettings = {},\n): ByteDanceProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'ARK_API_KEY',\n description: 'ByteDance ModelArk',\n })}`,\n 'Content-Type': 'application/json',\n ...options.headers,\n });\n\n const createVideoModel = (modelId: ByteDanceVideoModelId) =>\n new ByteDanceVideoModel(modelId, {\n provider: 'bytedance.video',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n return {\n specificationVersion: 'v3' as const,\n embeddingModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n },\n imageModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n },\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n },\n video: createVideoModel,\n videoModel: createVideoModel,\n };\n}\n\n/**\n * Default ByteDance provider instance.\n */\nexport const byteDance = createByteDance();\n","import {\n AISDKError,\n type Experimental_VideoModelV3,\n type SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n delay,\n getFromApi,\n lazySchema,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { ByteDanceConfig } from './bytedance-config';\nimport type { ByteDanceVideoModelId } from './bytedance-video-settings';\n\nexport type ByteDanceVideoProviderOptions = {\n watermark?: boolean | null;\n generateAudio?: boolean | null;\n cameraFixed?: boolean | null;\n returnLastFrame?: boolean | null;\n serviceTier?: 'default' | 'flex' | null;\n draft?: boolean | null;\n lastFrameImage?: string | null;\n referenceImages?: string[] | null;\n pollIntervalMs?: number | null;\n pollTimeoutMs?: number | null;\n [key: string]: unknown;\n};\n\nconst HANDLED_PROVIDER_OPTIONS = new Set([\n 'watermark',\n 'generateAudio',\n 'cameraFixed',\n 'returnLastFrame',\n 'serviceTier',\n 'draft',\n 'lastFrameImage',\n 'referenceImages',\n 'pollIntervalMs',\n 'pollTimeoutMs',\n]);\n\nexport const byteDanceVideoProviderOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n watermark: z.boolean().nullish(),\n generateAudio: z.boolean().nullish(),\n cameraFixed: z.boolean().nullish(),\n returnLastFrame: z.boolean().nullish(),\n serviceTier: z.enum(['default', 'flex']).nullish(),\n draft: z.boolean().nullish(),\n lastFrameImage: z.string().nullish(),\n referenceImages: z.array(z.string()).nullish(),\n pollIntervalMs: z.number().positive().nullish(),\n pollTimeoutMs: z.number().positive().nullish(),\n })\n .passthrough(),\n ),\n);\n\nconst RESOLUTION_MAP: Record<string, string> = {\n '864x496': '480p',\n '496x864': '480p',\n '752x560': '480p',\n '560x752': '480p',\n '640x640': '480p',\n '992x432': '480p',\n '432x992': '480p',\n '864x480': '480p',\n '480x864': '480p',\n '736x544': '480p',\n '544x736': '480p',\n '960x416': '480p',\n '416x960': '480p',\n '832x480': '480p',\n '480x832': '480p',\n '624x624': '480p',\n '1280x720': '720p',\n '720x1280': '720p',\n '1112x834': '720p',\n '834x1112': '720p',\n '960x960': '720p',\n '1470x630': '720p',\n '630x1470': '720p',\n '1248x704': '720p',\n '704x1248': '720p',\n '1120x832': '720p',\n '832x1120': '720p',\n '1504x640': '720p',\n '640x1504': '720p',\n '1920x1080': '1080p',\n '1080x1920': '1080p',\n '1664x1248': '1080p',\n '1248x1664': '1080p',\n '1440x1440': '1080p',\n '2206x946': '1080p',\n '946x2206': '1080p',\n '1920x1088': '1080p',\n '1088x1920': '1080p',\n '2176x928': '1080p',\n '928x2176': '1080p',\n};\n\ninterface ByteDanceVideoModelConfig extends ByteDanceConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class ByteDanceVideoModel implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxVideosPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: ByteDanceVideoModelId,\n private readonly config: ByteDanceVideoModelConfig,\n ) {}\n\n async doGenerate(\n options: Parameters<Experimental_VideoModelV3['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<Experimental_VideoModelV3['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV3Warning[] = [];\n\n const byteDanceOptions = (await parseProviderOptions({\n provider: 'bytedance',\n providerOptions: options.providerOptions,\n schema: byteDanceVideoProviderOptionsSchema,\n })) as ByteDanceVideoProviderOptions | undefined;\n\n // Warn about unsupported standard options\n if (options.fps) {\n warnings.push({\n type: 'unsupported',\n feature: 'fps',\n details:\n 'ByteDance video models do not support custom FPS. Frame rate is fixed at 24 fps.',\n });\n }\n\n if (options.n != null && options.n > 1) {\n warnings.push({\n type: 'unsupported',\n feature: 'n',\n details:\n 'ByteDance video models do not support generating multiple videos per call. ' +\n 'Only 1 video will be generated.',\n });\n }\n\n const content: Array<Record<string, unknown>> = [];\n\n if (options.prompt != null) {\n content.push({\n type: 'text',\n text: options.prompt,\n });\n }\n\n if (options.image != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(options.image) },\n });\n }\n\n // Add last frame image if provided\n if (byteDanceOptions?.lastFrameImage != null) {\n content.push({\n type: 'image_url',\n image_url: { url: byteDanceOptions.lastFrameImage },\n role: 'last_frame',\n });\n }\n\n // Add reference images if provided\n if (\n byteDanceOptions?.referenceImages != null &&\n byteDanceOptions.referenceImages.length > 0\n ) {\n for (const imageUrl of byteDanceOptions.referenceImages) {\n content.push({\n type: 'image_url',\n image_url: { url: imageUrl },\n role: 'reference_image',\n });\n }\n }\n\n const body: Record<string, unknown> = {\n model: this.modelId,\n content,\n };\n\n if (options.aspectRatio) {\n body.ratio = options.aspectRatio;\n }\n\n if (options.duration) {\n body.duration = options.duration;\n }\n\n if (options.seed) {\n body.seed = options.seed;\n }\n\n if (options.resolution) {\n const mapped = RESOLUTION_MAP[options.resolution];\n if (mapped) {\n body.resolution = mapped;\n } else {\n body.resolution = options.resolution;\n }\n }\n\n if (byteDanceOptions != null) {\n if (byteDanceOptions.watermark != null) {\n body.watermark = byteDanceOptions.watermark;\n }\n if (byteDanceOptions.generateAudio != null) {\n body.generate_audio = byteDanceOptions.generateAudio;\n }\n if (byteDanceOptions.cameraFixed != null) {\n body.camera_fixed = byteDanceOptions.cameraFixed;\n }\n if (byteDanceOptions.returnLastFrame != null) {\n body.return_last_frame = byteDanceOptions.returnLastFrame;\n }\n if (byteDanceOptions.serviceTier != null) {\n body.service_tier = byteDanceOptions.serviceTier;\n }\n if (byteDanceOptions.draft != null) {\n body.draft = byteDanceOptions.draft;\n }\n\n // Pass through any additional options not explicitly handled\n for (const [key, value] of Object.entries(byteDanceOptions)) {\n if (!HANDLED_PROVIDER_OPTIONS.has(key)) {\n body[key] = value;\n }\n }\n }\n\n const createUrl = `${this.config.baseURL}/contents/generations/tasks`;\n\n const { value: createResponse } = await postJsonToApi({\n url: createUrl,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: byteDanceFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n byteDanceTaskResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const taskId = createResponse.id;\n\n if (!taskId) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_ERROR',\n message: 'No task ID returned from API',\n });\n }\n\n const pollIntervalMs = byteDanceOptions?.pollIntervalMs ?? 3000;\n const pollTimeoutMs = byteDanceOptions?.pollTimeoutMs ?? 300000;\n\n const startTime = Date.now();\n let response: ByteDanceResponse;\n let responseHeaders: Record<string, string> | undefined;\n\n while (true) {\n const statusUrl = `${this.config.baseURL}/contents/generations/tasks/${taskId}`;\n\n const { value: statusResponse, responseHeaders: statusHeaders } =\n await getFromApi({\n url: statusUrl,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n failedResponseHandler: byteDanceFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n byteDanceStatusResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n if (statusResponse.status === 'succeeded') {\n response = statusResponse;\n responseHeaders = statusHeaders;\n break;\n }\n\n if (statusResponse.status === 'failed') {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_FAILED',\n message: `Video generation failed: ${JSON.stringify(statusResponse)}`,\n });\n }\n\n if (Date.now() - startTime > pollTimeoutMs) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_TIMEOUT',\n message: `Video generation timed out after ${pollTimeoutMs}ms`,\n });\n }\n\n await delay(pollIntervalMs, { abortSignal: options.abortSignal });\n }\n\n const videoUrl = response.content?.video_url;\n if (!videoUrl) {\n throw new AISDKError({\n name: 'BYTEDANCE_VIDEO_GENERATION_ERROR',\n message: 'No video URL in response',\n });\n }\n\n return {\n videos: [\n {\n type: 'url',\n url: videoUrl,\n mediaType: 'video/mp4',\n },\n ],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n providerMetadata: {\n bytedance: {\n taskId,\n usage: response.usage,\n },\n },\n };\n }\n}\n\nconst byteDanceTaskResponseSchema = z.object({\n id: z.string().nullish(),\n});\n\ntype ByteDanceResponse = z.infer<typeof byteDanceStatusResponseSchema>;\n\nconst byteDanceStatusResponseSchema = z.object({\n id: z.string().nullish(),\n model: z.string().nullish(),\n status: z.string(),\n content: z\n .object({\n video_url: z.string().nullish(),\n })\n .nullish(),\n usage: z\n .object({\n completion_tokens: z.number().nullish(),\n })\n .nullish(),\n});\n\nconst byteDanceErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n code: z.string().nullish(),\n })\n .nullish(),\n message: z.string().nullish(),\n});\n\nconst byteDanceFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: byteDanceErrorSchema,\n errorToMessage: data =>\n data.error?.message ?? data.message ?? 'Unknown error',\n});\n","declare const __PACKAGE_VERSION__: string;\n\nexport const VERSION = __PACKAGE_VERSION__;\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OACK;;;ACTP;AAAA,EACE;AAAA,OAGK;AACP;AA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AAC,YAAoB;AACnC,YAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,IACrE;AAAA,IACA,YAAY,CAAC,YAAoB;AAC/B,YAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,IACjE;AAAA,IACA,eAAe,CAAC,YAAoB;AAClC,YAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,gBAAgB,CAAC;AAAA,IACpE;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,EACd;AACF;AAKO,IAAM,YAAY,gBAAgB;;;AE/FlC,IAAM,UAAU;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-sdk/bytedance",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**/*",
|
|
11
|
+
"CHANGELOG.md",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": "./package.json",
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ai-sdk/provider-utils": "4.0.15",
|
|
24
|
+
"@ai-sdk/provider": "3.0.8"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "20.17.24",
|
|
28
|
+
"tsup": "^8",
|
|
29
|
+
"typescript": "5.8.3",
|
|
30
|
+
"zod": "3.25.76",
|
|
31
|
+
"@ai-sdk/test-server": "1.0.3",
|
|
32
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"zod": "^3.25.76 || ^4.1.8"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://ai-sdk.dev/docs",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/vercel/ai.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/vercel/ai/issues"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"ai",
|
|
53
|
+
"bytedance",
|
|
54
|
+
"seedance",
|
|
55
|
+
"video"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
59
|
+
"build:watch": "pnpm clean && tsup --watch",
|
|
60
|
+
"clean": "del-cli dist *.tsbuildinfo",
|
|
61
|
+
"lint": "eslint \"./**/*.ts*\"",
|
|
62
|
+
"type-check": "tsc --build",
|
|
63
|
+
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
64
|
+
"test": "pnpm test:node && pnpm test:edge",
|
|
65
|
+
"test:update": "pnpm test:node -u",
|
|
66
|
+
"test:watch": "vitest --config vitest.node.config.js",
|
|
67
|
+
"test:edge": "vitest --config vitest.edge.config.js --run",
|
|
68
|
+
"test:node": "vitest --config vitest.node.config.js --run"
|
|
69
|
+
}
|
|
70
|
+
}
|