@ai-sdk/provider 3.0.6 → 3.0.7
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 +6 -0
- package/dist/index.d.mts +217 -1
- package/dist/index.d.ts +217 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/video-model/index.ts +1 -0
- package/src/video-model/v3/index.ts +6 -0
- package/src/video-model/v3/video-model-v3-call-options.ts +81 -0
- package/src/video-model/v3/video-model-v3-file.ts +40 -0
- package/src/video-model/v3/video-model-v3.ts +132 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -3811,4 +3811,220 @@ interface ProviderV2 {
|
|
|
3811
3811
|
speechModel?(modelId: string): SpeechModelV2;
|
|
3812
3812
|
}
|
|
3813
3813
|
|
|
3814
|
-
|
|
3814
|
+
/**
|
|
3815
|
+
* A video or image file that can be used for video editing or image-to-video generation.
|
|
3816
|
+
* Supports both image inputs (for image-to-video) and video inputs (for editing).
|
|
3817
|
+
*/
|
|
3818
|
+
type VideoModelV3File = {
|
|
3819
|
+
type: 'file';
|
|
3820
|
+
/**
|
|
3821
|
+
* The IANA media type of the file.
|
|
3822
|
+
* Video types: 'video/mp4', 'video/webm', 'video/quicktime'
|
|
3823
|
+
* Image types: 'image/png', 'image/jpeg', 'image/webp'
|
|
3824
|
+
*/
|
|
3825
|
+
mediaType: string;
|
|
3826
|
+
/**
|
|
3827
|
+
* File data as base64 encoded string or binary data.
|
|
3828
|
+
*/
|
|
3829
|
+
data: string | Uint8Array;
|
|
3830
|
+
/**
|
|
3831
|
+
* Optional provider-specific metadata for the file part.
|
|
3832
|
+
*/
|
|
3833
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
3834
|
+
} | {
|
|
3835
|
+
type: 'url';
|
|
3836
|
+
/**
|
|
3837
|
+
* The URL of the video or image file.
|
|
3838
|
+
*/
|
|
3839
|
+
url: string;
|
|
3840
|
+
/**
|
|
3841
|
+
* Optional provider-specific metadata for the file part.
|
|
3842
|
+
*/
|
|
3843
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
type VideoModelV3CallOptions = {
|
|
3847
|
+
/**
|
|
3848
|
+
* Text prompt for the video generation.
|
|
3849
|
+
*/
|
|
3850
|
+
prompt: string | undefined;
|
|
3851
|
+
/**
|
|
3852
|
+
* Number of videos to generate. Default: 1.
|
|
3853
|
+
* Most video models only support n=1 due to computational cost.
|
|
3854
|
+
*/
|
|
3855
|
+
n: number;
|
|
3856
|
+
/**
|
|
3857
|
+
* Aspect ratio of the videos to generate.
|
|
3858
|
+
* Must have the format `{width}:{height}`.
|
|
3859
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
3860
|
+
* Common values: '16:9', '9:16', '1:1', '21:9', '4:3'
|
|
3861
|
+
*/
|
|
3862
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
3863
|
+
/**
|
|
3864
|
+
* Resolution of the video to generate.
|
|
3865
|
+
* Format: `{width}x{height}` (e.g., '1280x720', '1920x1080')
|
|
3866
|
+
* `undefined` will use the provider's default resolution.
|
|
3867
|
+
*/
|
|
3868
|
+
resolution: `${number}x${number}` | undefined;
|
|
3869
|
+
/**
|
|
3870
|
+
* Duration of the video in seconds.
|
|
3871
|
+
* `undefined` will use the provider's default duration.
|
|
3872
|
+
* Typically 3-10 seconds for most models.
|
|
3873
|
+
*/
|
|
3874
|
+
duration: number | undefined;
|
|
3875
|
+
/**
|
|
3876
|
+
* Frames per second (FPS) for the video.
|
|
3877
|
+
* `undefined` will use the provider's default FPS.
|
|
3878
|
+
* Common values: 24, 30, 60
|
|
3879
|
+
*/
|
|
3880
|
+
fps: number | undefined;
|
|
3881
|
+
/**
|
|
3882
|
+
* Seed for deterministic video generation.
|
|
3883
|
+
* `undefined` will use a random seed.
|
|
3884
|
+
*/
|
|
3885
|
+
seed: number | undefined;
|
|
3886
|
+
/**
|
|
3887
|
+
* Input image for image-to-video generation.
|
|
3888
|
+
* The image serves as the starting frame that the model will animate.
|
|
3889
|
+
*/
|
|
3890
|
+
image: VideoModelV3File | undefined;
|
|
3891
|
+
/**
|
|
3892
|
+
* Additional provider-specific options that are passed through to the provider
|
|
3893
|
+
* as body parameters.
|
|
3894
|
+
*
|
|
3895
|
+
* Example:
|
|
3896
|
+
* {
|
|
3897
|
+
* "fal": {
|
|
3898
|
+
* "loop": true,
|
|
3899
|
+
* "motionStrength": 0.8
|
|
3900
|
+
* }
|
|
3901
|
+
* }
|
|
3902
|
+
*/
|
|
3903
|
+
providerOptions: SharedV3ProviderOptions;
|
|
3904
|
+
/**
|
|
3905
|
+
* Abort signal for cancelling the operation.
|
|
3906
|
+
*/
|
|
3907
|
+
abortSignal?: AbortSignal;
|
|
3908
|
+
/**
|
|
3909
|
+
* Additional HTTP headers to be sent with the request.
|
|
3910
|
+
* Only applicable for HTTP-based providers.
|
|
3911
|
+
*/
|
|
3912
|
+
headers?: Record<string, string | undefined>;
|
|
3913
|
+
};
|
|
3914
|
+
|
|
3915
|
+
type GetMaxVideosPerCallFunction = (options: {
|
|
3916
|
+
modelId: string;
|
|
3917
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
3918
|
+
/**
|
|
3919
|
+
* Generated video data. Can be a URL, base64-encoded string, or binary data.
|
|
3920
|
+
*/
|
|
3921
|
+
type VideoModelV3VideoData = {
|
|
3922
|
+
/**
|
|
3923
|
+
* Video available as a URL (most common for video providers).
|
|
3924
|
+
*/
|
|
3925
|
+
type: 'url';
|
|
3926
|
+
url: string;
|
|
3927
|
+
mediaType: string;
|
|
3928
|
+
} | {
|
|
3929
|
+
/**
|
|
3930
|
+
* Video as base64-encoded string.
|
|
3931
|
+
*/
|
|
3932
|
+
type: 'base64';
|
|
3933
|
+
data: string;
|
|
3934
|
+
mediaType: string;
|
|
3935
|
+
} | {
|
|
3936
|
+
/**
|
|
3937
|
+
* Video as binary data.
|
|
3938
|
+
*/
|
|
3939
|
+
type: 'binary';
|
|
3940
|
+
data: Uint8Array;
|
|
3941
|
+
mediaType: string;
|
|
3942
|
+
};
|
|
3943
|
+
/**
|
|
3944
|
+
* Video generation model specification version 3.
|
|
3945
|
+
*/
|
|
3946
|
+
type VideoModelV3 = {
|
|
3947
|
+
/**
|
|
3948
|
+
* The video model must specify which video model interface
|
|
3949
|
+
* version it implements. This will allow us to evolve the video
|
|
3950
|
+
* model interface and retain backwards compatibility. The different
|
|
3951
|
+
* implementation versions can be handled as a discriminated union
|
|
3952
|
+
* on our side.
|
|
3953
|
+
*/
|
|
3954
|
+
readonly specificationVersion: 'v3';
|
|
3955
|
+
/**
|
|
3956
|
+
* Name of the provider for logging purposes.
|
|
3957
|
+
*/
|
|
3958
|
+
readonly provider: string;
|
|
3959
|
+
/**
|
|
3960
|
+
* Provider-specific model ID for logging purposes.
|
|
3961
|
+
*/
|
|
3962
|
+
readonly modelId: string;
|
|
3963
|
+
/**
|
|
3964
|
+
* Limit of how many videos can be generated in a single API call.
|
|
3965
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
3966
|
+
* the global limit, or a function that returns a number or undefined,
|
|
3967
|
+
* optionally as a promise.
|
|
3968
|
+
*
|
|
3969
|
+
* Most video models only support generating 1 video at a time due to
|
|
3970
|
+
* computational cost. Default is typically 1.
|
|
3971
|
+
*/
|
|
3972
|
+
readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction;
|
|
3973
|
+
/**
|
|
3974
|
+
* Generates an array of videos.
|
|
3975
|
+
*/
|
|
3976
|
+
doGenerate(options: VideoModelV3CallOptions): PromiseLike<{
|
|
3977
|
+
/**
|
|
3978
|
+
* Generated videos as URLs, base64 strings, or binary data.
|
|
3979
|
+
*
|
|
3980
|
+
* Most providers return URLs to video files (MP4, WebM) due to large file sizes.
|
|
3981
|
+
* Use the discriminated union to indicate the type of video data being returned.
|
|
3982
|
+
*/
|
|
3983
|
+
videos: Array<VideoModelV3VideoData>;
|
|
3984
|
+
/**
|
|
3985
|
+
* Warnings for the call, e.g. unsupported features.
|
|
3986
|
+
*/
|
|
3987
|
+
warnings: Array<SharedV3Warning>;
|
|
3988
|
+
/**
|
|
3989
|
+
* Additional provider-specific metadata. They are passed through
|
|
3990
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
3991
|
+
* results that can be fully encapsulated in the provider.
|
|
3992
|
+
*
|
|
3993
|
+
* The outer record is keyed by the provider name, and the inner
|
|
3994
|
+
* record is provider-specific metadata.
|
|
3995
|
+
*
|
|
3996
|
+
* ```ts
|
|
3997
|
+
* {
|
|
3998
|
+
* "fal": {
|
|
3999
|
+
* "videos": [{
|
|
4000
|
+
* "duration": 5.0,
|
|
4001
|
+
* "fps": 24,
|
|
4002
|
+
* "width": 1280,
|
|
4003
|
+
* "height": 720
|
|
4004
|
+
* }]
|
|
4005
|
+
* }
|
|
4006
|
+
* }
|
|
4007
|
+
* ```
|
|
4008
|
+
*/
|
|
4009
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
4010
|
+
/**
|
|
4011
|
+
* Response information for telemetry and debugging purposes.
|
|
4012
|
+
*/
|
|
4013
|
+
response: {
|
|
4014
|
+
/**
|
|
4015
|
+
* Timestamp for the start of the generated response.
|
|
4016
|
+
*/
|
|
4017
|
+
timestamp: Date;
|
|
4018
|
+
/**
|
|
4019
|
+
* The ID of the response model that was used to generate the response.
|
|
4020
|
+
*/
|
|
4021
|
+
modelId: string;
|
|
4022
|
+
/**
|
|
4023
|
+
* Response headers.
|
|
4024
|
+
*/
|
|
4025
|
+
headers: Record<string, string> | undefined;
|
|
4026
|
+
};
|
|
4027
|
+
}>;
|
|
4028
|
+
};
|
|
4029
|
+
|
|
4030
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -3811,4 +3811,220 @@ interface ProviderV2 {
|
|
|
3811
3811
|
speechModel?(modelId: string): SpeechModelV2;
|
|
3812
3812
|
}
|
|
3813
3813
|
|
|
3814
|
-
|
|
3814
|
+
/**
|
|
3815
|
+
* A video or image file that can be used for video editing or image-to-video generation.
|
|
3816
|
+
* Supports both image inputs (for image-to-video) and video inputs (for editing).
|
|
3817
|
+
*/
|
|
3818
|
+
type VideoModelV3File = {
|
|
3819
|
+
type: 'file';
|
|
3820
|
+
/**
|
|
3821
|
+
* The IANA media type of the file.
|
|
3822
|
+
* Video types: 'video/mp4', 'video/webm', 'video/quicktime'
|
|
3823
|
+
* Image types: 'image/png', 'image/jpeg', 'image/webp'
|
|
3824
|
+
*/
|
|
3825
|
+
mediaType: string;
|
|
3826
|
+
/**
|
|
3827
|
+
* File data as base64 encoded string or binary data.
|
|
3828
|
+
*/
|
|
3829
|
+
data: string | Uint8Array;
|
|
3830
|
+
/**
|
|
3831
|
+
* Optional provider-specific metadata for the file part.
|
|
3832
|
+
*/
|
|
3833
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
3834
|
+
} | {
|
|
3835
|
+
type: 'url';
|
|
3836
|
+
/**
|
|
3837
|
+
* The URL of the video or image file.
|
|
3838
|
+
*/
|
|
3839
|
+
url: string;
|
|
3840
|
+
/**
|
|
3841
|
+
* Optional provider-specific metadata for the file part.
|
|
3842
|
+
*/
|
|
3843
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
type VideoModelV3CallOptions = {
|
|
3847
|
+
/**
|
|
3848
|
+
* Text prompt for the video generation.
|
|
3849
|
+
*/
|
|
3850
|
+
prompt: string | undefined;
|
|
3851
|
+
/**
|
|
3852
|
+
* Number of videos to generate. Default: 1.
|
|
3853
|
+
* Most video models only support n=1 due to computational cost.
|
|
3854
|
+
*/
|
|
3855
|
+
n: number;
|
|
3856
|
+
/**
|
|
3857
|
+
* Aspect ratio of the videos to generate.
|
|
3858
|
+
* Must have the format `{width}:{height}`.
|
|
3859
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
3860
|
+
* Common values: '16:9', '9:16', '1:1', '21:9', '4:3'
|
|
3861
|
+
*/
|
|
3862
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
3863
|
+
/**
|
|
3864
|
+
* Resolution of the video to generate.
|
|
3865
|
+
* Format: `{width}x{height}` (e.g., '1280x720', '1920x1080')
|
|
3866
|
+
* `undefined` will use the provider's default resolution.
|
|
3867
|
+
*/
|
|
3868
|
+
resolution: `${number}x${number}` | undefined;
|
|
3869
|
+
/**
|
|
3870
|
+
* Duration of the video in seconds.
|
|
3871
|
+
* `undefined` will use the provider's default duration.
|
|
3872
|
+
* Typically 3-10 seconds for most models.
|
|
3873
|
+
*/
|
|
3874
|
+
duration: number | undefined;
|
|
3875
|
+
/**
|
|
3876
|
+
* Frames per second (FPS) for the video.
|
|
3877
|
+
* `undefined` will use the provider's default FPS.
|
|
3878
|
+
* Common values: 24, 30, 60
|
|
3879
|
+
*/
|
|
3880
|
+
fps: number | undefined;
|
|
3881
|
+
/**
|
|
3882
|
+
* Seed for deterministic video generation.
|
|
3883
|
+
* `undefined` will use a random seed.
|
|
3884
|
+
*/
|
|
3885
|
+
seed: number | undefined;
|
|
3886
|
+
/**
|
|
3887
|
+
* Input image for image-to-video generation.
|
|
3888
|
+
* The image serves as the starting frame that the model will animate.
|
|
3889
|
+
*/
|
|
3890
|
+
image: VideoModelV3File | undefined;
|
|
3891
|
+
/**
|
|
3892
|
+
* Additional provider-specific options that are passed through to the provider
|
|
3893
|
+
* as body parameters.
|
|
3894
|
+
*
|
|
3895
|
+
* Example:
|
|
3896
|
+
* {
|
|
3897
|
+
* "fal": {
|
|
3898
|
+
* "loop": true,
|
|
3899
|
+
* "motionStrength": 0.8
|
|
3900
|
+
* }
|
|
3901
|
+
* }
|
|
3902
|
+
*/
|
|
3903
|
+
providerOptions: SharedV3ProviderOptions;
|
|
3904
|
+
/**
|
|
3905
|
+
* Abort signal for cancelling the operation.
|
|
3906
|
+
*/
|
|
3907
|
+
abortSignal?: AbortSignal;
|
|
3908
|
+
/**
|
|
3909
|
+
* Additional HTTP headers to be sent with the request.
|
|
3910
|
+
* Only applicable for HTTP-based providers.
|
|
3911
|
+
*/
|
|
3912
|
+
headers?: Record<string, string | undefined>;
|
|
3913
|
+
};
|
|
3914
|
+
|
|
3915
|
+
type GetMaxVideosPerCallFunction = (options: {
|
|
3916
|
+
modelId: string;
|
|
3917
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
3918
|
+
/**
|
|
3919
|
+
* Generated video data. Can be a URL, base64-encoded string, or binary data.
|
|
3920
|
+
*/
|
|
3921
|
+
type VideoModelV3VideoData = {
|
|
3922
|
+
/**
|
|
3923
|
+
* Video available as a URL (most common for video providers).
|
|
3924
|
+
*/
|
|
3925
|
+
type: 'url';
|
|
3926
|
+
url: string;
|
|
3927
|
+
mediaType: string;
|
|
3928
|
+
} | {
|
|
3929
|
+
/**
|
|
3930
|
+
* Video as base64-encoded string.
|
|
3931
|
+
*/
|
|
3932
|
+
type: 'base64';
|
|
3933
|
+
data: string;
|
|
3934
|
+
mediaType: string;
|
|
3935
|
+
} | {
|
|
3936
|
+
/**
|
|
3937
|
+
* Video as binary data.
|
|
3938
|
+
*/
|
|
3939
|
+
type: 'binary';
|
|
3940
|
+
data: Uint8Array;
|
|
3941
|
+
mediaType: string;
|
|
3942
|
+
};
|
|
3943
|
+
/**
|
|
3944
|
+
* Video generation model specification version 3.
|
|
3945
|
+
*/
|
|
3946
|
+
type VideoModelV3 = {
|
|
3947
|
+
/**
|
|
3948
|
+
* The video model must specify which video model interface
|
|
3949
|
+
* version it implements. This will allow us to evolve the video
|
|
3950
|
+
* model interface and retain backwards compatibility. The different
|
|
3951
|
+
* implementation versions can be handled as a discriminated union
|
|
3952
|
+
* on our side.
|
|
3953
|
+
*/
|
|
3954
|
+
readonly specificationVersion: 'v3';
|
|
3955
|
+
/**
|
|
3956
|
+
* Name of the provider for logging purposes.
|
|
3957
|
+
*/
|
|
3958
|
+
readonly provider: string;
|
|
3959
|
+
/**
|
|
3960
|
+
* Provider-specific model ID for logging purposes.
|
|
3961
|
+
*/
|
|
3962
|
+
readonly modelId: string;
|
|
3963
|
+
/**
|
|
3964
|
+
* Limit of how many videos can be generated in a single API call.
|
|
3965
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
3966
|
+
* the global limit, or a function that returns a number or undefined,
|
|
3967
|
+
* optionally as a promise.
|
|
3968
|
+
*
|
|
3969
|
+
* Most video models only support generating 1 video at a time due to
|
|
3970
|
+
* computational cost. Default is typically 1.
|
|
3971
|
+
*/
|
|
3972
|
+
readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction;
|
|
3973
|
+
/**
|
|
3974
|
+
* Generates an array of videos.
|
|
3975
|
+
*/
|
|
3976
|
+
doGenerate(options: VideoModelV3CallOptions): PromiseLike<{
|
|
3977
|
+
/**
|
|
3978
|
+
* Generated videos as URLs, base64 strings, or binary data.
|
|
3979
|
+
*
|
|
3980
|
+
* Most providers return URLs to video files (MP4, WebM) due to large file sizes.
|
|
3981
|
+
* Use the discriminated union to indicate the type of video data being returned.
|
|
3982
|
+
*/
|
|
3983
|
+
videos: Array<VideoModelV3VideoData>;
|
|
3984
|
+
/**
|
|
3985
|
+
* Warnings for the call, e.g. unsupported features.
|
|
3986
|
+
*/
|
|
3987
|
+
warnings: Array<SharedV3Warning>;
|
|
3988
|
+
/**
|
|
3989
|
+
* Additional provider-specific metadata. They are passed through
|
|
3990
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
3991
|
+
* results that can be fully encapsulated in the provider.
|
|
3992
|
+
*
|
|
3993
|
+
* The outer record is keyed by the provider name, and the inner
|
|
3994
|
+
* record is provider-specific metadata.
|
|
3995
|
+
*
|
|
3996
|
+
* ```ts
|
|
3997
|
+
* {
|
|
3998
|
+
* "fal": {
|
|
3999
|
+
* "videos": [{
|
|
4000
|
+
* "duration": 5.0,
|
|
4001
|
+
* "fps": 24,
|
|
4002
|
+
* "width": 1280,
|
|
4003
|
+
* "height": 720
|
|
4004
|
+
* }]
|
|
4005
|
+
* }
|
|
4006
|
+
* }
|
|
4007
|
+
* ```
|
|
4008
|
+
*/
|
|
4009
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
4010
|
+
/**
|
|
4011
|
+
* Response information for telemetry and debugging purposes.
|
|
4012
|
+
*/
|
|
4013
|
+
response: {
|
|
4014
|
+
/**
|
|
4015
|
+
* Timestamp for the start of the generated response.
|
|
4016
|
+
*/
|
|
4017
|
+
timestamp: Date;
|
|
4018
|
+
/**
|
|
4019
|
+
* The ID of the response model that was used to generate the response.
|
|
4020
|
+
*/
|
|
4021
|
+
modelId: string;
|
|
4022
|
+
/**
|
|
4023
|
+
* Response headers.
|
|
4024
|
+
*/
|
|
4025
|
+
headers: Record<string, string> | undefined;
|
|
4026
|
+
};
|
|
4027
|
+
}>;
|
|
4028
|
+
};
|
|
4029
|
+
|
|
4030
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors/ai-sdk-error.ts","../src/errors/api-call-error.ts","../src/errors/empty-response-body-error.ts","../src/errors/get-error-message.ts","../src/errors/invalid-argument-error.ts","../src/errors/invalid-prompt-error.ts","../src/errors/invalid-response-data-error.ts","../src/errors/json-parse-error.ts","../src/errors/load-api-key-error.ts","../src/errors/load-setting-error.ts","../src/errors/no-content-generated-error.ts","../src/errors/no-such-model-error.ts","../src/errors/too-many-embedding-values-for-call-error.ts","../src/errors/type-validation-error.ts","../src/errors/unsupported-functionality-error.ts","../src/json-value/is-json.ts"],"sourcesContent":["export * from './embedding-model/index';\nexport * from './errors/index';\nexport * from './image-model/index';\nexport * from './image-model-middleware/index';\nexport * from './json-value/index';\nexport * from './language-model-middleware/index';\nexport * from './embedding-model-middleware/index';\nexport * from './language-model/index';\nexport * from './provider/index';\nexport * from './reranking-model/index';\nexport * from './shared/index';\nexport * from './speech-model/index';\nexport * from './transcription-model/index';\n\nexport type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\n","/**\n * Symbol used for identifying AI SDK Error instances.\n * Enables checking if an error is an instance of AISDKError across package versions.\n */\nconst marker = 'vercel.ai.error';\nconst symbol = Symbol.for(marker);\n\n/**\n * Custom error class for AI SDK related errors.\n * @extends Error\n */\nexport class AISDKError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n /**\n * The underlying cause of the error, if any.\n */\n readonly cause?: unknown;\n\n /**\n * Creates an AI SDK Error.\n *\n * @param {Object} params - The parameters for creating the error.\n * @param {string} params.name - The name of the error.\n * @param {string} params.message - The error message.\n * @param {unknown} [params.cause] - The underlying cause of the error.\n */\n constructor({\n name,\n message,\n cause,\n }: {\n name: string;\n message: string;\n cause?: unknown;\n }) {\n super(message);\n\n this.name = name;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is an AI SDK Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n */\n static isInstance(error: unknown): error is AISDKError {\n return AISDKError.hasMarker(error, marker);\n }\n\n protected static hasMarker(error: unknown, marker: string): boolean {\n const markerSymbol = Symbol.for(marker);\n return (\n error != null &&\n typeof error === 'object' &&\n markerSymbol in error &&\n typeof error[markerSymbol] === 'boolean' &&\n error[markerSymbol] === true\n );\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_APICallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class APICallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly url: string;\n readonly requestBodyValues: unknown;\n readonly statusCode?: number;\n\n readonly responseHeaders?: Record<string, string>;\n readonly responseBody?: string;\n\n readonly isRetryable: boolean;\n readonly data?: unknown;\n\n constructor({\n message,\n url,\n requestBodyValues,\n statusCode,\n responseHeaders,\n responseBody,\n cause,\n isRetryable = statusCode != null &&\n (statusCode === 408 || // request timeout\n statusCode === 409 || // conflict\n statusCode === 429 || // too many requests\n statusCode >= 500), // server error\n data,\n }: {\n message: string;\n url: string;\n requestBodyValues: unknown;\n statusCode?: number;\n responseHeaders?: Record<string, string>;\n responseBody?: string;\n cause?: unknown;\n isRetryable?: boolean;\n data?: unknown;\n }) {\n super({ name, message, cause });\n\n this.url = url;\n this.requestBodyValues = requestBodyValues;\n this.statusCode = statusCode;\n this.responseHeaders = responseHeaders;\n this.responseBody = responseBody;\n this.isRetryable = isRetryable;\n this.data = data;\n }\n\n static isInstance(error: unknown): error is APICallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_EmptyResponseBodyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class EmptyResponseBodyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message = 'Empty response body' }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is EmptyResponseBodyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","export function getErrorMessage(error: unknown | undefined) {\n if (error == null) {\n return 'unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return JSON.stringify(error);\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidArgumentError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A function argument is invalid.\n */\nexport class InvalidArgumentError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly argument: string;\n\n constructor({\n message,\n cause,\n argument,\n }: {\n argument: string;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message, cause });\n\n this.argument = argument;\n }\n\n static isInstance(error: unknown): error is InvalidArgumentError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidPromptError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A prompt is invalid. This error should be thrown by providers when they cannot\n * process a prompt.\n */\nexport class InvalidPromptError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly prompt: unknown;\n\n constructor({\n prompt,\n message,\n cause,\n }: {\n prompt: unknown;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message: `Invalid prompt: ${message}`, cause });\n\n this.prompt = prompt;\n }\n\n static isInstance(error: unknown): error is InvalidPromptError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidResponseDataError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Server returned a response with invalid data content.\n * This should be thrown by providers when they cannot parse the response from the API.\n */\nexport class InvalidResponseDataError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly data: unknown;\n\n constructor({\n data,\n message = `Invalid response data: ${JSON.stringify(data)}.`,\n }: {\n data: unknown;\n message?: string;\n }) {\n super({ name, message });\n\n this.data = data;\n }\n\n static isInstance(error: unknown): error is InvalidResponseDataError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_JSONParseError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class JSONParseError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly text: string;\n\n constructor({ text, cause }: { text: string; cause: unknown }) {\n super({\n name,\n message:\n `JSON parsing failed: ` +\n `Text: ${text}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.text = text;\n }\n\n static isInstance(error: unknown): error is JSONParseError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadAPIKeyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadAPIKeyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadAPIKeyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadSettingError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadSettingError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadSettingError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoContentGeneratedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when the AI provider fails to generate any content.\n */\nexport class NoContentGeneratedError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({\n message = 'No content generated.',\n }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is NoContentGeneratedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoSuchModelError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class NoSuchModelError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly modelId: string;\n readonly modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel';\n\n constructor({\n errorName = name,\n modelId,\n modelType,\n message = `No such ${modelType}: ${modelId}`,\n }: {\n errorName?: string;\n modelId: string;\n modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel';\n message?: string;\n }) {\n super({ name: errorName, message });\n\n this.modelId = modelId;\n this.modelType = modelType;\n }\n\n static isInstance(error: unknown): error is NoSuchModelError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_TooManyEmbeddingValuesForCallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TooManyEmbeddingValuesForCallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly provider: string;\n readonly modelId: string;\n readonly maxEmbeddingsPerCall: number;\n readonly values: Array<unknown>;\n\n constructor(options: {\n provider: string;\n modelId: string;\n maxEmbeddingsPerCall: number;\n values: Array<unknown>;\n }) {\n super({\n name,\n message:\n `Too many values for a single embedding call. ` +\n `The ${options.provider} model \"${options.modelId}\" can only embed up to ` +\n `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,\n });\n\n this.provider = options.provider;\n this.modelId = options.modelId;\n this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n this.values = options.values;\n }\n\n static isInstance(\n error: unknown,\n ): error is TooManyEmbeddingValuesForCallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_TypeValidationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport interface TypeValidationContext {\n /**\n * Field path in dot notation (e.g., \"message.metadata\", \"message.parts[3].data\")\n */\n field?: string;\n\n /**\n * Entity name (e.g., tool name, data type name)\n */\n entityName?: string;\n\n /**\n * Entity identifier (e.g., message ID, tool call ID)\n */\n entityId?: string;\n}\n\nexport class TypeValidationError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly value: unknown;\n readonly context?: TypeValidationContext;\n\n constructor({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }) {\n let contextPrefix = 'Type validation failed';\n\n if (context?.field) {\n contextPrefix += ` for ${context.field}`;\n }\n\n if (context?.entityName || context?.entityId) {\n contextPrefix += ' (';\n const parts: string[] = [];\n if (context.entityName) {\n parts.push(context.entityName);\n }\n if (context.entityId) {\n parts.push(`id: \"${context.entityId}\"`);\n }\n contextPrefix += parts.join(', ');\n contextPrefix += ')';\n }\n\n super({\n name,\n message:\n `${contextPrefix}: ` +\n `Value: ${JSON.stringify(value)}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.value = value;\n this.context = context;\n }\n\n static isInstance(error: unknown): error is TypeValidationError {\n return AISDKError.hasMarker(error, marker);\n }\n\n /**\n * Wraps an error into a TypeValidationError.\n * If the cause is already a TypeValidationError with the same value and context, it returns the cause.\n * Otherwise, it creates a new TypeValidationError.\n *\n * @param {Object} params - The parameters for wrapping the error.\n * @param {unknown} params.value - The value that failed validation.\n * @param {unknown} params.cause - The original error or cause of the validation failure.\n * @param {TypeValidationContext} params.context - Optional context about what is being validated.\n * @returns {TypeValidationError} A TypeValidationError instance.\n */\n static wrap({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }): TypeValidationError {\n if (\n TypeValidationError.isInstance(cause) &&\n cause.value === value &&\n cause.context?.field === context?.field &&\n cause.context?.entityName === context?.entityName &&\n cause.context?.entityId === context?.entityId\n ) {\n return cause;\n }\n\n return new TypeValidationError({ value, cause, context });\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_UnsupportedFunctionalityError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class UnsupportedFunctionalityError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly functionality: string;\n\n constructor({\n functionality,\n message = `'${functionality}' functionality not supported.`,\n }: {\n functionality: string;\n message?: string;\n }) {\n super({ name, message });\n this.functionality = functionality;\n }\n\n static isInstance(error: unknown): error is UnsupportedFunctionalityError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { JSONArray, JSONObject, JSONValue } from './json-value';\n\nexport function isJSONValue(value: unknown): value is JSONValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.every(isJSONValue);\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is JSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is JSONObject {\n return (\n value != null &&\n typeof value === 'object' &&\n Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AALhC;AAWO,IAAM,aAAN,MAAM,qBAAmB,YACZ,aADY,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBpC,YAAY;AAAA,IACV,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,OAAO;AAxBf,SAAkB,MAAU;AA0B1B,SAAK,OAAOA;AACZ,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,OAAqC;AACrD,WAAO,YAAW,UAAU,OAAO,MAAM;AAAA,EAC3C;AAAA,EAEA,OAAiB,UAAU,OAAgBC,UAAyB;AAClE,UAAM,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,QAAM;AAAA,EAC3C;AACF;;;ACvBO,SAAS,YAAY,OAAoC;AAC9D,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,WAAW;AAAA,EAChC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,IACpE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAAqC;AAChE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,EACpE;AAEJ;","names":["name","marker","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors/ai-sdk-error.ts","../src/errors/api-call-error.ts","../src/errors/empty-response-body-error.ts","../src/errors/get-error-message.ts","../src/errors/invalid-argument-error.ts","../src/errors/invalid-prompt-error.ts","../src/errors/invalid-response-data-error.ts","../src/errors/json-parse-error.ts","../src/errors/load-api-key-error.ts","../src/errors/load-setting-error.ts","../src/errors/no-content-generated-error.ts","../src/errors/no-such-model-error.ts","../src/errors/too-many-embedding-values-for-call-error.ts","../src/errors/type-validation-error.ts","../src/errors/unsupported-functionality-error.ts","../src/json-value/is-json.ts"],"sourcesContent":["export * from './embedding-model/index';\nexport * from './errors/index';\nexport * from './image-model/index';\nexport * from './image-model-middleware/index';\nexport * from './json-value/index';\nexport * from './language-model-middleware/index';\nexport * from './embedding-model-middleware/index';\nexport * from './language-model/index';\nexport * from './provider/index';\nexport * from './reranking-model/index';\nexport * from './shared/index';\nexport * from './speech-model/index';\nexport * from './transcription-model/index';\nexport * from './video-model/index';\n\nexport type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\n","/**\n * Symbol used for identifying AI SDK Error instances.\n * Enables checking if an error is an instance of AISDKError across package versions.\n */\nconst marker = 'vercel.ai.error';\nconst symbol = Symbol.for(marker);\n\n/**\n * Custom error class for AI SDK related errors.\n * @extends Error\n */\nexport class AISDKError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n /**\n * The underlying cause of the error, if any.\n */\n readonly cause?: unknown;\n\n /**\n * Creates an AI SDK Error.\n *\n * @param {Object} params - The parameters for creating the error.\n * @param {string} params.name - The name of the error.\n * @param {string} params.message - The error message.\n * @param {unknown} [params.cause] - The underlying cause of the error.\n */\n constructor({\n name,\n message,\n cause,\n }: {\n name: string;\n message: string;\n cause?: unknown;\n }) {\n super(message);\n\n this.name = name;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is an AI SDK Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n */\n static isInstance(error: unknown): error is AISDKError {\n return AISDKError.hasMarker(error, marker);\n }\n\n protected static hasMarker(error: unknown, marker: string): boolean {\n const markerSymbol = Symbol.for(marker);\n return (\n error != null &&\n typeof error === 'object' &&\n markerSymbol in error &&\n typeof error[markerSymbol] === 'boolean' &&\n error[markerSymbol] === true\n );\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_APICallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class APICallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly url: string;\n readonly requestBodyValues: unknown;\n readonly statusCode?: number;\n\n readonly responseHeaders?: Record<string, string>;\n readonly responseBody?: string;\n\n readonly isRetryable: boolean;\n readonly data?: unknown;\n\n constructor({\n message,\n url,\n requestBodyValues,\n statusCode,\n responseHeaders,\n responseBody,\n cause,\n isRetryable = statusCode != null &&\n (statusCode === 408 || // request timeout\n statusCode === 409 || // conflict\n statusCode === 429 || // too many requests\n statusCode >= 500), // server error\n data,\n }: {\n message: string;\n url: string;\n requestBodyValues: unknown;\n statusCode?: number;\n responseHeaders?: Record<string, string>;\n responseBody?: string;\n cause?: unknown;\n isRetryable?: boolean;\n data?: unknown;\n }) {\n super({ name, message, cause });\n\n this.url = url;\n this.requestBodyValues = requestBodyValues;\n this.statusCode = statusCode;\n this.responseHeaders = responseHeaders;\n this.responseBody = responseBody;\n this.isRetryable = isRetryable;\n this.data = data;\n }\n\n static isInstance(error: unknown): error is APICallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_EmptyResponseBodyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class EmptyResponseBodyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message = 'Empty response body' }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is EmptyResponseBodyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","export function getErrorMessage(error: unknown | undefined) {\n if (error == null) {\n return 'unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return JSON.stringify(error);\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidArgumentError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A function argument is invalid.\n */\nexport class InvalidArgumentError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly argument: string;\n\n constructor({\n message,\n cause,\n argument,\n }: {\n argument: string;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message, cause });\n\n this.argument = argument;\n }\n\n static isInstance(error: unknown): error is InvalidArgumentError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidPromptError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A prompt is invalid. This error should be thrown by providers when they cannot\n * process a prompt.\n */\nexport class InvalidPromptError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly prompt: unknown;\n\n constructor({\n prompt,\n message,\n cause,\n }: {\n prompt: unknown;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message: `Invalid prompt: ${message}`, cause });\n\n this.prompt = prompt;\n }\n\n static isInstance(error: unknown): error is InvalidPromptError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidResponseDataError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Server returned a response with invalid data content.\n * This should be thrown by providers when they cannot parse the response from the API.\n */\nexport class InvalidResponseDataError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly data: unknown;\n\n constructor({\n data,\n message = `Invalid response data: ${JSON.stringify(data)}.`,\n }: {\n data: unknown;\n message?: string;\n }) {\n super({ name, message });\n\n this.data = data;\n }\n\n static isInstance(error: unknown): error is InvalidResponseDataError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_JSONParseError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class JSONParseError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly text: string;\n\n constructor({ text, cause }: { text: string; cause: unknown }) {\n super({\n name,\n message:\n `JSON parsing failed: ` +\n `Text: ${text}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.text = text;\n }\n\n static isInstance(error: unknown): error is JSONParseError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadAPIKeyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadAPIKeyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadAPIKeyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadSettingError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadSettingError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadSettingError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoContentGeneratedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when the AI provider fails to generate any content.\n */\nexport class NoContentGeneratedError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({\n message = 'No content generated.',\n }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is NoContentGeneratedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoSuchModelError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class NoSuchModelError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly modelId: string;\n readonly modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel';\n\n constructor({\n errorName = name,\n modelId,\n modelType,\n message = `No such ${modelType}: ${modelId}`,\n }: {\n errorName?: string;\n modelId: string;\n modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel';\n message?: string;\n }) {\n super({ name: errorName, message });\n\n this.modelId = modelId;\n this.modelType = modelType;\n }\n\n static isInstance(error: unknown): error is NoSuchModelError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_TooManyEmbeddingValuesForCallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TooManyEmbeddingValuesForCallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly provider: string;\n readonly modelId: string;\n readonly maxEmbeddingsPerCall: number;\n readonly values: Array<unknown>;\n\n constructor(options: {\n provider: string;\n modelId: string;\n maxEmbeddingsPerCall: number;\n values: Array<unknown>;\n }) {\n super({\n name,\n message:\n `Too many values for a single embedding call. ` +\n `The ${options.provider} model \"${options.modelId}\" can only embed up to ` +\n `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,\n });\n\n this.provider = options.provider;\n this.modelId = options.modelId;\n this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n this.values = options.values;\n }\n\n static isInstance(\n error: unknown,\n ): error is TooManyEmbeddingValuesForCallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_TypeValidationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport interface TypeValidationContext {\n /**\n * Field path in dot notation (e.g., \"message.metadata\", \"message.parts[3].data\")\n */\n field?: string;\n\n /**\n * Entity name (e.g., tool name, data type name)\n */\n entityName?: string;\n\n /**\n * Entity identifier (e.g., message ID, tool call ID)\n */\n entityId?: string;\n}\n\nexport class TypeValidationError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly value: unknown;\n readonly context?: TypeValidationContext;\n\n constructor({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }) {\n let contextPrefix = 'Type validation failed';\n\n if (context?.field) {\n contextPrefix += ` for ${context.field}`;\n }\n\n if (context?.entityName || context?.entityId) {\n contextPrefix += ' (';\n const parts: string[] = [];\n if (context.entityName) {\n parts.push(context.entityName);\n }\n if (context.entityId) {\n parts.push(`id: \"${context.entityId}\"`);\n }\n contextPrefix += parts.join(', ');\n contextPrefix += ')';\n }\n\n super({\n name,\n message:\n `${contextPrefix}: ` +\n `Value: ${JSON.stringify(value)}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.value = value;\n this.context = context;\n }\n\n static isInstance(error: unknown): error is TypeValidationError {\n return AISDKError.hasMarker(error, marker);\n }\n\n /**\n * Wraps an error into a TypeValidationError.\n * If the cause is already a TypeValidationError with the same value and context, it returns the cause.\n * Otherwise, it creates a new TypeValidationError.\n *\n * @param {Object} params - The parameters for wrapping the error.\n * @param {unknown} params.value - The value that failed validation.\n * @param {unknown} params.cause - The original error or cause of the validation failure.\n * @param {TypeValidationContext} params.context - Optional context about what is being validated.\n * @returns {TypeValidationError} A TypeValidationError instance.\n */\n static wrap({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }): TypeValidationError {\n if (\n TypeValidationError.isInstance(cause) &&\n cause.value === value &&\n cause.context?.field === context?.field &&\n cause.context?.entityName === context?.entityName &&\n cause.context?.entityId === context?.entityId\n ) {\n return cause;\n }\n\n return new TypeValidationError({ value, cause, context });\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_UnsupportedFunctionalityError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class UnsupportedFunctionalityError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly functionality: string;\n\n constructor({\n functionality,\n message = `'${functionality}' functionality not supported.`,\n }: {\n functionality: string;\n message?: string;\n }) {\n super({ name, message });\n this.functionality = functionality;\n }\n\n static isInstance(error: unknown): error is UnsupportedFunctionalityError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { JSONArray, JSONObject, JSONValue } from './json-value';\n\nexport function isJSONValue(value: unknown): value is JSONValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.every(isJSONValue);\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is JSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is JSONObject {\n return (\n value != null &&\n typeof value === 'object' &&\n Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AALhC;AAWO,IAAM,aAAN,MAAM,qBAAmB,YACZ,aADY,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBpC,YAAY;AAAA,IACV,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,OAAO;AAxBf,SAAkB,MAAU;AA0B1B,SAAK,OAAOA;AACZ,SAAK,QAAQ;AAAA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B,GAGG;AACD,UAAM,EAAE,MAAAJ,QAAM,QAAQ,CAAC;AAXzB,SAAkBG,QAAU;AAY1B,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,OAAO,WAAW,OAAwD;AACxE,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACvBO,SAAS,YAAY,OAAoC;AAC9D,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,WAAW;AAAA,EAChC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,IACpE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAAqC;AAChE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,EACpE;AAEJ;","names":["name","marker","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b"]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,5 +11,6 @@ export * from './reranking-model/index';
|
|
|
11
11
|
export * from './shared/index';
|
|
12
12
|
export * from './speech-model/index';
|
|
13
13
|
export * from './transcription-model/index';
|
|
14
|
+
export * from './video-model/index';
|
|
14
15
|
|
|
15
16
|
export type { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v3/index';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
VideoModelV3 as Experimental_VideoModelV3,
|
|
3
|
+
VideoModelV3VideoData as Experimental_VideoModelV3VideoData,
|
|
4
|
+
} from './video-model-v3';
|
|
5
|
+
export type { VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions } from './video-model-v3-call-options';
|
|
6
|
+
export type { VideoModelV3File as Experimental_VideoModelV3File } from './video-model-v3-file';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SharedV3ProviderOptions } from '../../shared';
|
|
2
|
+
import { VideoModelV3File } from './video-model-v3-file';
|
|
3
|
+
|
|
4
|
+
export type VideoModelV3CallOptions = {
|
|
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: VideoModelV3File | 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: SharedV3ProviderOptions;
|
|
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 { SharedV3ProviderMetadata } 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 VideoModelV3File =
|
|
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?: SharedV3ProviderMetadata;
|
|
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?: SharedV3ProviderMetadata;
|
|
40
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { VideoModelV3CallOptions } from './video-model-v3-call-options';
|
|
2
|
+
import type { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata';
|
|
3
|
+
import type { SharedV3Warning } from '../../shared/v3/shared-v3-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 VideoModelV3VideoData =
|
|
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 VideoModelV3 = {
|
|
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: 'v3';
|
|
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: VideoModelV3CallOptions): 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<VideoModelV3VideoData>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Warnings for the call, e.g. unsupported features.
|
|
86
|
+
*/
|
|
87
|
+
warnings: Array<SharedV3Warning>;
|
|
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?: SharedV3ProviderMetadata;
|
|
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
|
+
};
|