@ai-sdk/provider 3.0.7 → 4.0.0-beta.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 +12 -0
- package/dist/index.d.mts +2712 -438
- package/dist/index.d.ts +2712 -438
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/embedding-model/index.ts +1 -0
- package/src/embedding-model/v4/embedding-model-v4-call-options.ts +26 -0
- package/src/embedding-model/v4/embedding-model-v4-embedding.ts +5 -0
- package/src/embedding-model/v4/embedding-model-v4-result.ts +48 -0
- package/src/embedding-model/v4/embedding-model-v4.ts +54 -0
- package/src/embedding-model/v4/index.ts +4 -0
- package/src/embedding-model-middleware/index.ts +1 -0
- package/src/embedding-model-middleware/v4/embedding-model-v4-middleware.ts +69 -0
- package/src/embedding-model-middleware/v4/index.ts +1 -0
- package/src/errors/no-such-model-error.ts +4 -2
- package/src/image-model/index.ts +1 -0
- package/src/image-model/v4/image-model-v4-call-options.ts +74 -0
- package/src/image-model/v4/image-model-v4-file.ts +44 -0
- package/src/image-model/v4/image-model-v4-usage.ts +19 -0
- package/src/image-model/v4/image-model-v4.ts +110 -0
- package/src/image-model/v4/index.ts +7 -0
- package/src/image-model-middleware/index.ts +1 -0
- package/src/image-model-middleware/v4/image-model-v4-middleware.ts +61 -0
- package/src/image-model-middleware/v4/index.ts +1 -0
- package/src/language-model/index.ts +1 -0
- package/src/language-model/v4/index.ts +21 -0
- package/src/language-model/v4/language-model-v4-call-options.ts +125 -0
- package/src/language-model/v4/language-model-v4-content.ts +16 -0
- package/src/language-model/v4/language-model-v4-data-content.ts +4 -0
- package/src/language-model/v4/language-model-v4-file.ts +32 -0
- package/src/language-model/v4/language-model-v4-finish-reason.ts +33 -0
- package/src/language-model/v4/language-model-v4-function-tool.ts +53 -0
- package/src/language-model/v4/language-model-v4-generate-result.ts +63 -0
- package/src/language-model/v4/language-model-v4-prompt.ts +422 -0
- package/src/language-model/v4/language-model-v4-provider-tool.ts +28 -0
- package/src/language-model/v4/language-model-v4-reasoning.ts +14 -0
- package/src/language-model/v4/language-model-v4-response-metadata.ts +16 -0
- package/src/language-model/v4/language-model-v4-source.ts +67 -0
- package/src/language-model/v4/language-model-v4-stream-part.ts +106 -0
- package/src/language-model/v4/language-model-v4-stream-result.ts +32 -0
- package/src/language-model/v4/language-model-v4-text.ts +15 -0
- package/src/language-model/v4/language-model-v4-tool-approval-request.ts +27 -0
- package/src/language-model/v4/language-model-v4-tool-call.ts +41 -0
- package/src/language-model/v4/language-model-v4-tool-choice.ts +5 -0
- package/src/language-model/v4/language-model-v4-tool-result.ts +51 -0
- package/src/language-model/v4/language-model-v4-usage.ts +59 -0
- package/src/language-model/v4/language-model-v4.ts +61 -0
- package/src/language-model-middleware/index.ts +1 -0
- package/src/language-model-middleware/v4/index.ts +1 -0
- package/src/language-model-middleware/v4/language-model-v4-middleware.ts +84 -0
- package/src/provider/index.ts +1 -0
- package/src/provider/v4/index.ts +1 -0
- package/src/provider/v4/provider-v4.ts +79 -0
- package/src/reranking-model/index.ts +1 -0
- package/src/reranking-model/v4/index.ts +2 -0
- package/src/reranking-model/v4/reranking-model-v4-call-options.ts +40 -0
- package/src/reranking-model/v4/reranking-model-v4.ts +90 -0
- package/src/shared/index.ts +1 -0
- package/src/shared/v4/index.ts +4 -0
- package/src/shared/v4/shared-v4-headers.ts +1 -0
- package/src/shared/v4/shared-v4-provider-metadata.ts +24 -0
- package/src/shared/v4/shared-v4-provider-options.ts +24 -0
- package/src/shared/v4/shared-v4-warning.ts +50 -0
- package/src/speech-model/index.ts +2 -1
- package/src/speech-model/v4/index.ts +2 -0
- package/src/speech-model/v4/speech-model-v4-call-options.ts +62 -0
- package/src/speech-model/v4/speech-model-v4.ts +89 -0
- package/src/transcription-model/index.ts +2 -1
- package/src/transcription-model/v4/index.ts +2 -0
- package/src/transcription-model/v4/transcription-model-v4-call-options.ts +45 -0
- package/src/transcription-model/v4/transcription-model-v4.ts +117 -0
- package/src/video-model/index.ts +1 -0
- package/src/video-model/v4/index.ts +6 -0
- package/src/video-model/v4/video-model-v4-call-options.ts +81 -0
- package/src/video-model/v4/video-model-v4-file.ts +40 -0
- package/src/video-model/v4/video-model-v4.ts +132 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { JSONObject } from '../../json-value/json-value';
|
|
2
|
+
|
|
3
|
+
type SpeechModelV4ProviderOptions = Record<string, JSONObject>;
|
|
4
|
+
|
|
5
|
+
export type SpeechModelV4CallOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Text to convert to speech.
|
|
8
|
+
*/
|
|
9
|
+
text: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The voice to use for speech synthesis.
|
|
13
|
+
* This is provider-specific and may be a voice ID, name, or other identifier.
|
|
14
|
+
*/
|
|
15
|
+
voice?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The desired output format for the audio e.g. "mp3", "wav", etc.
|
|
19
|
+
*/
|
|
20
|
+
outputFormat?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Instructions for the speech generation e.g. "Speak in a slow and steady tone".
|
|
24
|
+
*/
|
|
25
|
+
instructions?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The speed of the speech generation.
|
|
29
|
+
*/
|
|
30
|
+
speed?: number;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr")
|
|
34
|
+
* or "auto" for automatic language detection. Provider support varies.
|
|
35
|
+
*/
|
|
36
|
+
language?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Additional provider-specific options that are passed through to the provider
|
|
40
|
+
* as body parameters.
|
|
41
|
+
*
|
|
42
|
+
* The outer record is keyed by the provider name, and the inner
|
|
43
|
+
* record is keyed by the provider-specific metadata key.
|
|
44
|
+
* ```ts
|
|
45
|
+
* {
|
|
46
|
+
* "openai": {}
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
providerOptions?: SpeechModelV4ProviderOptions;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Abort signal for cancelling the operation.
|
|
54
|
+
*/
|
|
55
|
+
abortSignal?: AbortSignal;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Additional HTTP headers to be sent with the request.
|
|
59
|
+
* Only applicable for HTTP-based providers.
|
|
60
|
+
*/
|
|
61
|
+
headers?: Record<string, string | undefined>;
|
|
62
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { JSONObject } from '../../json-value';
|
|
2
|
+
import { SharedV2Headers } from '../../shared';
|
|
3
|
+
import { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
4
|
+
import { SpeechModelV4CallOptions } from './speech-model-v4-call-options';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Speech model specification version 3.
|
|
8
|
+
*/
|
|
9
|
+
export type SpeechModelV4 = {
|
|
10
|
+
/**
|
|
11
|
+
* The speech model must specify which speech model interface
|
|
12
|
+
* version it implements. This will allow us to evolve the speech
|
|
13
|
+
* model interface and retain backwards compatibility. The different
|
|
14
|
+
* implementation versions can be handled as a discriminated union
|
|
15
|
+
* on our side.
|
|
16
|
+
*/
|
|
17
|
+
readonly specificationVersion: 'v4';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Name of the provider for logging purposes.
|
|
21
|
+
*/
|
|
22
|
+
readonly provider: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provider-specific model ID for logging purposes.
|
|
26
|
+
*/
|
|
27
|
+
readonly modelId: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generates speech audio from text.
|
|
31
|
+
*/
|
|
32
|
+
doGenerate(options: SpeechModelV4CallOptions): PromiseLike<{
|
|
33
|
+
/**
|
|
34
|
+
* Generated audio as an ArrayBuffer.
|
|
35
|
+
* The audio should be returned without any unnecessary conversion.
|
|
36
|
+
* If the API returns base64 encoded strings, the audio should be returned
|
|
37
|
+
* as base64 encoded strings. If the API returns binary data, the audio
|
|
38
|
+
* should be returned as binary data.
|
|
39
|
+
*/
|
|
40
|
+
audio: string | Uint8Array;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
44
|
+
*/
|
|
45
|
+
warnings: Array<SharedV4Warning>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Optional request information for telemetry and debugging purposes.
|
|
49
|
+
*/
|
|
50
|
+
request?: {
|
|
51
|
+
/**
|
|
52
|
+
* Response body (available only for providers that use HTTP requests).
|
|
53
|
+
*/
|
|
54
|
+
body?: unknown;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Response information for telemetry and debugging purposes.
|
|
59
|
+
*/
|
|
60
|
+
response: {
|
|
61
|
+
/**
|
|
62
|
+
* Timestamp for the start of the generated response.
|
|
63
|
+
*/
|
|
64
|
+
timestamp: Date;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The ID of the response model that was used to generate the response.
|
|
68
|
+
*/
|
|
69
|
+
modelId: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Response headers.
|
|
73
|
+
*/
|
|
74
|
+
headers?: SharedV2Headers;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Response body.
|
|
78
|
+
*/
|
|
79
|
+
body?: unknown;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Additional provider-specific metadata. They are passed through
|
|
84
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
85
|
+
* results that can be fully encapsulated in the provider.
|
|
86
|
+
*/
|
|
87
|
+
providerMetadata?: Record<string, JSONObject>;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { JSONObject } from '../../json-value/json-value';
|
|
2
|
+
|
|
3
|
+
type TranscriptionModelV4ProviderOptions = Record<string, JSONObject>;
|
|
4
|
+
|
|
5
|
+
export type TranscriptionModelV4CallOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Audio data to transcribe.
|
|
8
|
+
* Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file.
|
|
9
|
+
*/
|
|
10
|
+
audio: Uint8Array | string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The IANA media type of the audio data.
|
|
14
|
+
*
|
|
15
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
16
|
+
*/
|
|
17
|
+
mediaType: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Additional provider-specific options that are passed through to the provider
|
|
21
|
+
* as body parameters.
|
|
22
|
+
*
|
|
23
|
+
* The outer record is keyed by the provider name, and the inner
|
|
24
|
+
* record is keyed by the provider-specific metadata key.
|
|
25
|
+
* ```ts
|
|
26
|
+
* {
|
|
27
|
+
* "openai": {
|
|
28
|
+
* "timestampGranularities": ["word"]
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
providerOptions?: TranscriptionModelV4ProviderOptions;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Abort signal for cancelling the operation.
|
|
37
|
+
*/
|
|
38
|
+
abortSignal?: AbortSignal;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Additional HTTP headers to be sent with the request.
|
|
42
|
+
* Only applicable for HTTP-based providers.
|
|
43
|
+
*/
|
|
44
|
+
headers?: Record<string, string | undefined>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { JSONObject } from '../../json-value';
|
|
2
|
+
import { SharedV4Headers } from '../../shared';
|
|
3
|
+
import { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
4
|
+
import { TranscriptionModelV4CallOptions } from './transcription-model-v4-call-options';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transcription model specification version 3.
|
|
8
|
+
*/
|
|
9
|
+
export type TranscriptionModelV4 = {
|
|
10
|
+
/**
|
|
11
|
+
* The transcription model must specify which transcription model interface
|
|
12
|
+
* version it implements. This will allow us to evolve the transcription
|
|
13
|
+
* model interface and retain backwards compatibility. The different
|
|
14
|
+
* implementation versions can be handled as a discriminated union
|
|
15
|
+
* on our side.
|
|
16
|
+
*/
|
|
17
|
+
readonly specificationVersion: 'v4';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Name of the provider for logging purposes.
|
|
21
|
+
*/
|
|
22
|
+
readonly provider: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provider-specific model ID for logging purposes.
|
|
26
|
+
*/
|
|
27
|
+
readonly modelId: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generates a transcript.
|
|
31
|
+
*/
|
|
32
|
+
doGenerate(options: TranscriptionModelV4CallOptions): PromiseLike<{
|
|
33
|
+
/**
|
|
34
|
+
* The complete transcribed text from the audio.
|
|
35
|
+
*/
|
|
36
|
+
text: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Array of transcript segments with timing information.
|
|
40
|
+
* Each segment represents a portion of the transcribed text with start and end times.
|
|
41
|
+
*/
|
|
42
|
+
segments: Array<{
|
|
43
|
+
/**
|
|
44
|
+
* The text content of this segment.
|
|
45
|
+
*/
|
|
46
|
+
text: string;
|
|
47
|
+
/**
|
|
48
|
+
* The start time of this segment in seconds.
|
|
49
|
+
*/
|
|
50
|
+
startSecond: number;
|
|
51
|
+
/**
|
|
52
|
+
* The end time of this segment in seconds.
|
|
53
|
+
*/
|
|
54
|
+
endSecond: number;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English).
|
|
59
|
+
* May be undefined if the language couldn't be detected.
|
|
60
|
+
*/
|
|
61
|
+
language: string | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The total duration of the audio file in seconds.
|
|
65
|
+
* May be undefined if the duration couldn't be determined.
|
|
66
|
+
*/
|
|
67
|
+
durationInSeconds: number | undefined;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
71
|
+
*/
|
|
72
|
+
warnings: Array<SharedV4Warning>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Optional request information for telemetry and debugging purposes.
|
|
76
|
+
*/
|
|
77
|
+
request?: {
|
|
78
|
+
/**
|
|
79
|
+
* Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
|
80
|
+
* Non-HTTP(s) providers should not set this.
|
|
81
|
+
*/
|
|
82
|
+
body?: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Response information for telemetry and debugging purposes.
|
|
87
|
+
*/
|
|
88
|
+
response: {
|
|
89
|
+
/**
|
|
90
|
+
* Timestamp for the start of the generated response.
|
|
91
|
+
*/
|
|
92
|
+
timestamp: Date;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The ID of the response model that was used to generate the response.
|
|
96
|
+
*/
|
|
97
|
+
modelId: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Response headers.
|
|
101
|
+
*/
|
|
102
|
+
headers?: SharedV4Headers;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Response body.
|
|
106
|
+
*/
|
|
107
|
+
body?: unknown;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Additional provider-specific metadata. They are passed through
|
|
112
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
113
|
+
* results that can be fully encapsulated in the provider.
|
|
114
|
+
*/
|
|
115
|
+
providerMetadata?: Record<string, JSONObject>;
|
|
116
|
+
}>;
|
|
117
|
+
};
|
package/src/video-model/index.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
VideoModelV4 as Experimental_VideoModelV4,
|
|
3
|
+
VideoModelV4VideoData as Experimental_VideoModelV4VideoData,
|
|
4
|
+
} from './video-model-v4';
|
|
5
|
+
export type { VideoModelV4CallOptions as Experimental_VideoModelV4CallOptions } from './video-model-v4-call-options';
|
|
6
|
+
export type { VideoModelV4File as Experimental_VideoModelV4File } from './video-model-v4-file';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SharedV4ProviderOptions } from '../../shared';
|
|
2
|
+
import { VideoModelV4File } from './video-model-v4-file';
|
|
3
|
+
|
|
4
|
+
export type VideoModelV4CallOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Text prompt for the video generation.
|
|
7
|
+
*/
|
|
8
|
+
prompt: string | undefined;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Number of videos to generate. Default: 1.
|
|
12
|
+
* Most video models only support n=1 due to computational cost.
|
|
13
|
+
*/
|
|
14
|
+
n: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Aspect ratio of the videos to generate.
|
|
18
|
+
* Must have the format `{width}:{height}`.
|
|
19
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
20
|
+
* Common values: '16:9', '9:16', '1:1', '21:9', '4:3'
|
|
21
|
+
*/
|
|
22
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolution of the video to generate.
|
|
26
|
+
* Format: `{width}x{height}` (e.g., '1280x720', '1920x1080')
|
|
27
|
+
* `undefined` will use the provider's default resolution.
|
|
28
|
+
*/
|
|
29
|
+
resolution: `${number}x${number}` | undefined;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Duration of the video in seconds.
|
|
33
|
+
* `undefined` will use the provider's default duration.
|
|
34
|
+
* Typically 3-10 seconds for most models.
|
|
35
|
+
*/
|
|
36
|
+
duration: number | undefined;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Frames per second (FPS) for the video.
|
|
40
|
+
* `undefined` will use the provider's default FPS.
|
|
41
|
+
* Common values: 24, 30, 60
|
|
42
|
+
*/
|
|
43
|
+
fps: number | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Seed for deterministic video generation.
|
|
47
|
+
* `undefined` will use a random seed.
|
|
48
|
+
*/
|
|
49
|
+
seed: number | undefined;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Input image for image-to-video generation.
|
|
53
|
+
* The image serves as the starting frame that the model will animate.
|
|
54
|
+
*/
|
|
55
|
+
image: VideoModelV4File | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Additional provider-specific options that are passed through to the provider
|
|
59
|
+
* as body parameters.
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* {
|
|
63
|
+
* "fal": {
|
|
64
|
+
* "loop": true,
|
|
65
|
+
* "motionStrength": 0.8
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
*/
|
|
69
|
+
providerOptions: SharedV4ProviderOptions;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Abort signal for cancelling the operation.
|
|
73
|
+
*/
|
|
74
|
+
abortSignal?: AbortSignal;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Additional HTTP headers to be sent with the request.
|
|
78
|
+
* Only applicable for HTTP-based providers.
|
|
79
|
+
*/
|
|
80
|
+
headers?: Record<string, string | undefined>;
|
|
81
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SharedV4ProviderMetadata } from '../../shared';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A video or image file that can be used for video editing or image-to-video generation.
|
|
5
|
+
* Supports both image inputs (for image-to-video) and video inputs (for editing).
|
|
6
|
+
*/
|
|
7
|
+
export type VideoModelV4File =
|
|
8
|
+
| {
|
|
9
|
+
type: 'file';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The IANA media type of the file.
|
|
13
|
+
* Video types: 'video/mp4', 'video/webm', 'video/quicktime'
|
|
14
|
+
* Image types: 'image/png', 'image/jpeg', 'image/webp'
|
|
15
|
+
*/
|
|
16
|
+
mediaType: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* File data as base64 encoded string or binary data.
|
|
20
|
+
*/
|
|
21
|
+
data: string | Uint8Array;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Optional provider-specific metadata for the file part.
|
|
25
|
+
*/
|
|
26
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
type: 'url';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The URL of the video or image file.
|
|
33
|
+
*/
|
|
34
|
+
url: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Optional provider-specific metadata for the file part.
|
|
38
|
+
*/
|
|
39
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
40
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { VideoModelV4CallOptions } from './video-model-v4-call-options';
|
|
2
|
+
import type { SharedV4ProviderMetadata } from '../../shared/v4/shared-v4-provider-metadata';
|
|
3
|
+
import type { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
4
|
+
|
|
5
|
+
type GetMaxVideosPerCallFunction = (options: {
|
|
6
|
+
modelId: string;
|
|
7
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generated video data. Can be a URL, base64-encoded string, or binary data.
|
|
11
|
+
*/
|
|
12
|
+
export type VideoModelV4VideoData =
|
|
13
|
+
| {
|
|
14
|
+
/**
|
|
15
|
+
* Video available as a URL (most common for video providers).
|
|
16
|
+
*/
|
|
17
|
+
type: 'url';
|
|
18
|
+
url: string;
|
|
19
|
+
mediaType: string;
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
/**
|
|
23
|
+
* Video as base64-encoded string.
|
|
24
|
+
*/
|
|
25
|
+
type: 'base64';
|
|
26
|
+
data: string;
|
|
27
|
+
mediaType: string;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
/**
|
|
31
|
+
* Video as binary data.
|
|
32
|
+
*/
|
|
33
|
+
type: 'binary';
|
|
34
|
+
data: Uint8Array;
|
|
35
|
+
mediaType: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Video generation model specification version 3.
|
|
40
|
+
*/
|
|
41
|
+
export type VideoModelV4 = {
|
|
42
|
+
/**
|
|
43
|
+
* The video model must specify which video model interface
|
|
44
|
+
* version it implements. This will allow us to evolve the video
|
|
45
|
+
* model interface and retain backwards compatibility. The different
|
|
46
|
+
* implementation versions can be handled as a discriminated union
|
|
47
|
+
* on our side.
|
|
48
|
+
*/
|
|
49
|
+
readonly specificationVersion: 'v4';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Name of the provider for logging purposes.
|
|
53
|
+
*/
|
|
54
|
+
readonly provider: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Provider-specific model ID for logging purposes.
|
|
58
|
+
*/
|
|
59
|
+
readonly modelId: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Limit of how many videos can be generated in a single API call.
|
|
63
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
64
|
+
* the global limit, or a function that returns a number or undefined,
|
|
65
|
+
* optionally as a promise.
|
|
66
|
+
*
|
|
67
|
+
* Most video models only support generating 1 video at a time due to
|
|
68
|
+
* computational cost. Default is typically 1.
|
|
69
|
+
*/
|
|
70
|
+
readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Generates an array of videos.
|
|
74
|
+
*/
|
|
75
|
+
doGenerate(options: VideoModelV4CallOptions): PromiseLike<{
|
|
76
|
+
/**
|
|
77
|
+
* Generated videos as URLs, base64 strings, or binary data.
|
|
78
|
+
*
|
|
79
|
+
* Most providers return URLs to video files (MP4, WebM) due to large file sizes.
|
|
80
|
+
* Use the discriminated union to indicate the type of video data being returned.
|
|
81
|
+
*/
|
|
82
|
+
videos: Array<VideoModelV4VideoData>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Warnings for the call, e.g. unsupported features.
|
|
86
|
+
*/
|
|
87
|
+
warnings: Array<SharedV4Warning>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Additional provider-specific metadata. They are passed through
|
|
91
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
92
|
+
* results that can be fully encapsulated in the provider.
|
|
93
|
+
*
|
|
94
|
+
* The outer record is keyed by the provider name, and the inner
|
|
95
|
+
* record is provider-specific metadata.
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* {
|
|
99
|
+
* "fal": {
|
|
100
|
+
* "videos": [{
|
|
101
|
+
* "duration": 5.0,
|
|
102
|
+
* "fps": 24,
|
|
103
|
+
* "width": 1280,
|
|
104
|
+
* "height": 720
|
|
105
|
+
* }]
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Response information for telemetry and debugging purposes.
|
|
114
|
+
*/
|
|
115
|
+
response: {
|
|
116
|
+
/**
|
|
117
|
+
* Timestamp for the start of the generated response.
|
|
118
|
+
*/
|
|
119
|
+
timestamp: Date;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The ID of the response model that was used to generate the response.
|
|
123
|
+
*/
|
|
124
|
+
modelId: string;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Response headers.
|
|
128
|
+
*/
|
|
129
|
+
headers: Record<string, string> | undefined;
|
|
130
|
+
};
|
|
131
|
+
}>;
|
|
132
|
+
};
|