@ai-sdk/provider 3.0.5 → 3.0.6
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 +733 -715
- package/dist/index.d.ts +733 -715
- package/dist/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/embedding-model/v2/embedding-model-v2-embedding.ts +2 -2
- package/src/embedding-model/v2/embedding-model-v2.ts +39 -39
- package/src/embedding-model/v3/embedding-model-v3-call-options.ts +11 -11
- package/src/embedding-model/v3/embedding-model-v3-embedding.ts +2 -2
- package/src/embedding-model/v3/embedding-model-v3-result.ts +2 -2
- package/src/embedding-model/v3/embedding-model-v3.ts +19 -19
- package/src/errors/index.ts +1 -0
- package/src/errors/no-content-generated-error.ts +1 -1
- package/src/errors/type-validation-error.ts +63 -6
- package/src/image-model/v2/image-model-v2-call-options.ts +33 -33
- package/src/image-model/v2/image-model-v2-call-warning.ts +2 -2
- package/src/image-model/v2/image-model-v2.ts +42 -42
- package/src/image-model/v3/image-model-v3-usage.ts +4 -4
- package/src/image-model/v3/image-model-v3.ts +43 -43
- package/src/json-value/json-value.ts +2 -2
- package/src/language-model/v2/language-model-v2-call-options.ts +44 -44
- package/src/language-model/v2/language-model-v2-call-warning.ts +2 -2
- package/src/language-model/v2/language-model-v2-data-content.ts +2 -2
- package/src/language-model/v2/language-model-v2-file.ts +14 -14
- package/src/language-model/v2/language-model-v2-finish-reason.ts +10 -10
- package/src/language-model/v2/language-model-v2-function-tool.ts +11 -11
- package/src/language-model/v2/language-model-v2-prompt.ts +38 -38
- package/src/language-model/v2/language-model-v2-provider-defined-tool.ts +6 -6
- package/src/language-model/v2/language-model-v2-reasoning.ts +1 -1
- package/src/language-model/v2/language-model-v2-response-metadata.ts +6 -6
- package/src/language-model/v2/language-model-v2-source.ts +1 -1
- package/src/language-model/v2/language-model-v2-text.ts +2 -2
- package/src/language-model/v2/language-model-v2-tool-result.ts +1 -1
- package/src/language-model/v2/language-model-v2-usage.ts +11 -11
- package/src/language-model/v2/language-model-v2.ts +42 -42
- package/src/language-model/v3/language-model-v3-call-options.ts +44 -44
- package/src/language-model/v3/language-model-v3-data-content.ts +2 -2
- package/src/language-model/v3/language-model-v3-file.ts +14 -14
- package/src/language-model/v3/language-model-v3-function-tool.ts +11 -11
- package/src/language-model/v3/language-model-v3-prompt.ts +43 -43
- package/src/language-model/v3/language-model-v3-reasoning.ts +1 -1
- package/src/language-model/v3/language-model-v3-response-metadata.ts +6 -6
- package/src/language-model/v3/language-model-v3-source.ts +1 -1
- package/src/language-model/v3/language-model-v3-text.ts +2 -2
- package/src/language-model/v3/language-model-v3-tool-result.ts +1 -1
- package/src/language-model/v3/language-model-v3-usage.ts +1 -1
- package/src/provider/v2/provider-v2.ts +37 -37
- package/src/provider/v3/provider-v3.ts +55 -55
- package/src/transcription-model/v2/transcription-model-v2-call-options.ts +24 -24
- package/src/transcription-model/v2/transcription-model-v2-call-warning.ts +2 -2
- package/src/transcription-model/v2/transcription-model-v2.ts +25 -25
- package/src/transcription-model/v3/transcription-model-v3-call-options.ts +24 -24
- package/src/transcription-model/v3/transcription-model-v3.ts +25 -25
|
@@ -2,35 +2,35 @@ import { EmbeddingModelV3CallOptions } from './embedding-model-v3-call-options';
|
|
|
2
2
|
import { EmbeddingModelV3Result } from './embedding-model-v3-result';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
Specification for an embedding model that implements the embedding model
|
|
6
|
-
interface version 3.
|
|
7
|
-
|
|
8
|
-
It is specific to text embeddings.
|
|
5
|
+
* Specification for an embedding model that implements the embedding model
|
|
6
|
+
* interface version 3.
|
|
7
|
+
*
|
|
8
|
+
* It is specific to text embeddings.
|
|
9
9
|
*/
|
|
10
10
|
export type EmbeddingModelV3 = {
|
|
11
11
|
/**
|
|
12
|
-
The embedding model must specify which embedding model interface
|
|
13
|
-
version it implements. This will allow us to evolve the embedding
|
|
14
|
-
model interface and retain backwards compatibility. The different
|
|
15
|
-
implementation versions can be handled as a discriminated union
|
|
16
|
-
on our side.
|
|
12
|
+
* The embedding model must specify which embedding model interface
|
|
13
|
+
* version it implements. This will allow us to evolve the embedding
|
|
14
|
+
* model interface and retain backwards compatibility. The different
|
|
15
|
+
* implementation versions can be handled as a discriminated union
|
|
16
|
+
* on our side.
|
|
17
17
|
*/
|
|
18
18
|
readonly specificationVersion: 'v3';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
Name of the provider for logging purposes.
|
|
21
|
+
* Name of the provider for logging purposes.
|
|
22
22
|
*/
|
|
23
23
|
readonly provider: string;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
Provider-specific model ID for logging purposes.
|
|
26
|
+
* Provider-specific model ID for logging purposes.
|
|
27
27
|
*/
|
|
28
28
|
readonly modelId: string;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
Limit of how many embeddings can be generated in a single API call.
|
|
32
|
-
|
|
33
|
-
Use Infinity for models that do not have a limit.
|
|
31
|
+
* Limit of how many embeddings can be generated in a single API call.
|
|
32
|
+
*
|
|
33
|
+
* Use Infinity for models that do not have a limit.
|
|
34
34
|
*/
|
|
35
35
|
readonly maxEmbeddingsPerCall:
|
|
36
36
|
| PromiseLike<number | undefined>
|
|
@@ -38,15 +38,15 @@ Use Infinity for models that do not have a limit.
|
|
|
38
38
|
| undefined;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
True if the model can handle multiple embedding calls in parallel.
|
|
41
|
+
* True if the model can handle multiple embedding calls in parallel.
|
|
42
42
|
*/
|
|
43
43
|
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
Generates a list of embeddings for the given input text.
|
|
47
|
-
|
|
48
|
-
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
49
|
-
by the user.
|
|
46
|
+
* Generates a list of embeddings for the given input text.
|
|
47
|
+
*
|
|
48
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
49
|
+
* by the user.
|
|
50
50
|
*/
|
|
51
51
|
doEmbed(
|
|
52
52
|
options: EmbeddingModelV3CallOptions,
|
package/src/errors/index.ts
CHANGED
|
@@ -11,5 +11,6 @@ export { LoadSettingError } from './load-setting-error';
|
|
|
11
11
|
export { NoContentGeneratedError } from './no-content-generated-error';
|
|
12
12
|
export { NoSuchModelError } from './no-such-model-error';
|
|
13
13
|
export { TooManyEmbeddingValuesForCallError } from './too-many-embedding-values-for-call-error';
|
|
14
|
+
export type { TypeValidationContext } from './type-validation-error';
|
|
14
15
|
export { TypeValidationError } from './type-validation-error';
|
|
15
16
|
export { UnsupportedFunctionalityError } from './unsupported-functionality-error';
|
|
@@ -5,7 +5,7 @@ const marker = `vercel.ai.error.${name}`;
|
|
|
5
5
|
const symbol = Symbol.for(marker);
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
Thrown when the AI provider fails to generate any content.
|
|
8
|
+
* Thrown when the AI provider fails to generate any content.
|
|
9
9
|
*/
|
|
10
10
|
export class NoContentGeneratedError extends AISDKError {
|
|
11
11
|
private readonly [symbol] = true; // used in isInstance
|
|
@@ -5,22 +5,68 @@ const name = 'AI_TypeValidationError';
|
|
|
5
5
|
const marker = `vercel.ai.error.${name}`;
|
|
6
6
|
const symbol = Symbol.for(marker);
|
|
7
7
|
|
|
8
|
+
export interface TypeValidationContext {
|
|
9
|
+
/**
|
|
10
|
+
* Field path in dot notation (e.g., "message.metadata", "message.parts[3].data")
|
|
11
|
+
*/
|
|
12
|
+
field?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Entity name (e.g., tool name, data type name)
|
|
16
|
+
*/
|
|
17
|
+
entityName?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Entity identifier (e.g., message ID, tool call ID)
|
|
21
|
+
*/
|
|
22
|
+
entityId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
8
25
|
export class TypeValidationError extends AISDKError {
|
|
9
26
|
private readonly [symbol] = true; // used in isInstance
|
|
10
27
|
|
|
11
28
|
readonly value: unknown;
|
|
29
|
+
readonly context?: TypeValidationContext;
|
|
30
|
+
|
|
31
|
+
constructor({
|
|
32
|
+
value,
|
|
33
|
+
cause,
|
|
34
|
+
context,
|
|
35
|
+
}: {
|
|
36
|
+
value: unknown;
|
|
37
|
+
cause: unknown;
|
|
38
|
+
context?: TypeValidationContext;
|
|
39
|
+
}) {
|
|
40
|
+
let contextPrefix = 'Type validation failed';
|
|
41
|
+
|
|
42
|
+
if (context?.field) {
|
|
43
|
+
contextPrefix += ` for ${context.field}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (context?.entityName || context?.entityId) {
|
|
47
|
+
contextPrefix += ' (';
|
|
48
|
+
const parts: string[] = [];
|
|
49
|
+
if (context.entityName) {
|
|
50
|
+
parts.push(context.entityName);
|
|
51
|
+
}
|
|
52
|
+
if (context.entityId) {
|
|
53
|
+
parts.push(`id: "${context.entityId}"`);
|
|
54
|
+
}
|
|
55
|
+
contextPrefix += parts.join(', ');
|
|
56
|
+
contextPrefix += ')';
|
|
57
|
+
}
|
|
12
58
|
|
|
13
|
-
constructor({ value, cause }: { value: unknown; cause: unknown }) {
|
|
14
59
|
super({
|
|
15
60
|
name,
|
|
16
61
|
message:
|
|
17
|
-
|
|
62
|
+
`${contextPrefix}: ` +
|
|
18
63
|
`Value: ${JSON.stringify(value)}.\n` +
|
|
19
64
|
`Error message: ${getErrorMessage(cause)}`,
|
|
20
65
|
cause,
|
|
21
66
|
});
|
|
22
67
|
|
|
23
68
|
this.value = value;
|
|
69
|
+
this.context = context;
|
|
24
70
|
}
|
|
25
71
|
|
|
26
72
|
static isInstance(error: unknown): error is TypeValidationError {
|
|
@@ -29,23 +75,34 @@ export class TypeValidationError extends AISDKError {
|
|
|
29
75
|
|
|
30
76
|
/**
|
|
31
77
|
* Wraps an error into a TypeValidationError.
|
|
32
|
-
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
78
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
33
79
|
* Otherwise, it creates a new TypeValidationError.
|
|
34
80
|
*
|
|
35
81
|
* @param {Object} params - The parameters for wrapping the error.
|
|
36
82
|
* @param {unknown} params.value - The value that failed validation.
|
|
37
83
|
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
84
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
38
85
|
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
39
86
|
*/
|
|
40
87
|
static wrap({
|
|
41
88
|
value,
|
|
42
89
|
cause,
|
|
90
|
+
context,
|
|
43
91
|
}: {
|
|
44
92
|
value: unknown;
|
|
45
93
|
cause: unknown;
|
|
94
|
+
context?: TypeValidationContext;
|
|
46
95
|
}): TypeValidationError {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
96
|
+
if (
|
|
97
|
+
TypeValidationError.isInstance(cause) &&
|
|
98
|
+
cause.value === value &&
|
|
99
|
+
cause.context?.field === context?.field &&
|
|
100
|
+
cause.context?.entityName === context?.entityName &&
|
|
101
|
+
cause.context?.entityId === context?.entityId
|
|
102
|
+
) {
|
|
103
|
+
return cause;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return new TypeValidationError({ value, cause, context });
|
|
50
107
|
}
|
|
51
108
|
}
|
|
@@ -2,59 +2,59 @@ import { SharedV2ProviderOptions } from '../../shared';
|
|
|
2
2
|
|
|
3
3
|
export type ImageModelV2CallOptions = {
|
|
4
4
|
/**
|
|
5
|
-
Prompt for the image generation.
|
|
6
|
-
|
|
5
|
+
* Prompt for the image generation.
|
|
6
|
+
*/
|
|
7
7
|
prompt: string;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
Number of images to generate.
|
|
11
|
-
|
|
10
|
+
* Number of images to generate.
|
|
11
|
+
*/
|
|
12
12
|
n: number;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
Size of the images to generate.
|
|
16
|
-
Must have the format `{width}x{height}`.
|
|
17
|
-
`undefined` will use the provider's default size.
|
|
18
|
-
|
|
15
|
+
* Size of the images to generate.
|
|
16
|
+
* Must have the format `{width}x{height}`.
|
|
17
|
+
* `undefined` will use the provider's default size.
|
|
18
|
+
*/
|
|
19
19
|
size: `${number}x${number}` | undefined;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
Aspect ratio of the images to generate.
|
|
23
|
-
Must have the format `{width}:{height}`.
|
|
24
|
-
`undefined` will use the provider's default aspect ratio.
|
|
25
|
-
|
|
22
|
+
* Aspect ratio of the images to generate.
|
|
23
|
+
* Must have the format `{width}:{height}`.
|
|
24
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
25
|
+
*/
|
|
26
26
|
aspectRatio: `${number}:${number}` | undefined;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
Seed for the image generation.
|
|
30
|
-
`undefined` will use the provider's default seed.
|
|
31
|
-
|
|
29
|
+
* Seed for the image generation.
|
|
30
|
+
* `undefined` will use the provider's default seed.
|
|
31
|
+
*/
|
|
32
32
|
seed: number | undefined;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
Additional provider-specific options that are passed through to the provider
|
|
36
|
-
as body parameters.
|
|
37
|
-
|
|
38
|
-
The outer record is keyed by the provider name, and the inner
|
|
39
|
-
record is keyed by the provider-specific metadata key.
|
|
40
|
-
```ts
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
35
|
+
* Additional provider-specific options that are passed through to the provider
|
|
36
|
+
* as body parameters.
|
|
37
|
+
*
|
|
38
|
+
* The outer record is keyed by the provider name, and the inner
|
|
39
|
+
* record is keyed by the provider-specific metadata key.
|
|
40
|
+
* ```ts
|
|
41
|
+
* {
|
|
42
|
+
* "openai": {
|
|
43
|
+
* "style": "vivid"
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
48
|
providerOptions: SharedV2ProviderOptions;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
Abort signal for cancelling the operation.
|
|
52
|
-
|
|
51
|
+
* Abort signal for cancelling the operation.
|
|
52
|
+
*/
|
|
53
53
|
abortSignal?: AbortSignal;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
Additional HTTP headers to be sent with the request.
|
|
57
|
-
Only applicable for HTTP-based providers.
|
|
58
|
-
|
|
56
|
+
* Additional HTTP headers to be sent with the request.
|
|
57
|
+
* Only applicable for HTTP-based providers.
|
|
58
|
+
*/
|
|
59
59
|
headers?: Record<string, string | undefined>;
|
|
60
60
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ImageModelV2CallOptions } from './image-model-v2-call-options';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
5
|
-
some settings might not be supported, which can lead to suboptimal results.
|
|
4
|
+
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
5
|
+
* some settings might not be supported, which can lead to suboptimal results.
|
|
6
6
|
*/
|
|
7
7
|
export type ImageModelV2CallWarning =
|
|
8
8
|
| {
|
|
@@ -14,90 +14,90 @@ type GetMaxImagesPerCallFunction = (options: {
|
|
|
14
14
|
}) => PromiseLike<number | undefined> | number | undefined;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
Image generation model specification version 2.
|
|
17
|
+
* Image generation model specification version 2.
|
|
18
18
|
*/
|
|
19
19
|
export type ImageModelV2 = {
|
|
20
20
|
/**
|
|
21
|
-
The image model must specify which image model interface
|
|
22
|
-
version it implements. This will allow us to evolve the image
|
|
23
|
-
model interface and retain backwards compatibility. The different
|
|
24
|
-
implementation versions can be handled as a discriminated union
|
|
25
|
-
on our side.
|
|
21
|
+
* The image model must specify which image model interface
|
|
22
|
+
* version it implements. This will allow us to evolve the image
|
|
23
|
+
* model interface and retain backwards compatibility. The different
|
|
24
|
+
* implementation versions can be handled as a discriminated union
|
|
25
|
+
* on our side.
|
|
26
26
|
*/
|
|
27
27
|
readonly specificationVersion: 'v2';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
Name of the provider for logging purposes.
|
|
30
|
+
* Name of the provider for logging purposes.
|
|
31
31
|
*/
|
|
32
32
|
readonly provider: string;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
Provider-specific model ID for logging purposes.
|
|
35
|
+
* Provider-specific model ID for logging purposes.
|
|
36
36
|
*/
|
|
37
37
|
readonly modelId: string;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
Limit of how many images can be generated in a single API call.
|
|
41
|
-
Can be set to a number for a fixed limit, to undefined to use
|
|
42
|
-
the global limit, or a function that returns a number or undefined,
|
|
43
|
-
optionally as a promise.
|
|
40
|
+
* Limit of how many images can be generated in a single API call.
|
|
41
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
42
|
+
* the global limit, or a function that returns a number or undefined,
|
|
43
|
+
* optionally as a promise.
|
|
44
44
|
*/
|
|
45
45
|
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
Generates an array of images.
|
|
48
|
+
* Generates an array of images.
|
|
49
49
|
*/
|
|
50
50
|
doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
|
|
51
51
|
/**
|
|
52
|
-
Generated images as base64 encoded strings or binary data.
|
|
53
|
-
The images should be returned without any unnecessary conversion.
|
|
54
|
-
If the API returns base64 encoded strings, the images should be returned
|
|
55
|
-
as base64 encoded strings. If the API returns binary data, the images should
|
|
56
|
-
be returned as binary data.
|
|
52
|
+
* Generated images as base64 encoded strings or binary data.
|
|
53
|
+
* The images should be returned without any unnecessary conversion.
|
|
54
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
55
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
56
|
+
* be returned as binary data.
|
|
57
57
|
*/
|
|
58
58
|
images: Array<string> | Array<Uint8Array>;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
Warnings for the call, e.g. unsupported settings.
|
|
61
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
62
62
|
*/
|
|
63
63
|
warnings: Array<ImageModelV2CallWarning>;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
Additional provider-specific metadata. They are passed through
|
|
67
|
-
from the provider to the AI SDK and enable provider-specific
|
|
68
|
-
results that can be fully encapsulated in the provider.
|
|
69
|
-
|
|
70
|
-
The outer record is keyed by the provider name, and the inner
|
|
71
|
-
record is provider-specific metadata. It always includes an
|
|
72
|
-
`images` key with image-specific metadata
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
66
|
+
* Additional provider-specific metadata. They are passed through
|
|
67
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
68
|
+
* results that can be fully encapsulated in the provider.
|
|
69
|
+
*
|
|
70
|
+
* The outer record is keyed by the provider name, and the inner
|
|
71
|
+
* record is provider-specific metadata. It always includes an
|
|
72
|
+
* `images` key with image-specific metadata
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* {
|
|
76
|
+
* "openai": {
|
|
77
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
82
|
providerMetadata?: ImageModelV2ProviderMetadata;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
Response information for telemetry and debugging purposes.
|
|
85
|
+
* Response information for telemetry and debugging purposes.
|
|
86
86
|
*/
|
|
87
87
|
response: {
|
|
88
88
|
/**
|
|
89
|
-
Timestamp for the start of the generated response.
|
|
90
|
-
|
|
89
|
+
* Timestamp for the start of the generated response.
|
|
90
|
+
*/
|
|
91
91
|
timestamp: Date;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
The ID of the response model that was used to generate the response.
|
|
95
|
-
|
|
94
|
+
* The ID of the response model that was used to generate the response.
|
|
95
|
+
*/
|
|
96
96
|
modelId: string;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
Response headers.
|
|
100
|
-
|
|
99
|
+
* Response headers.
|
|
100
|
+
*/
|
|
101
101
|
headers: Record<string, string> | undefined;
|
|
102
102
|
};
|
|
103
103
|
}>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
Usage information for an image model call.
|
|
2
|
+
* Usage information for an image model call.
|
|
3
3
|
*/
|
|
4
4
|
export type ImageModelV3Usage = {
|
|
5
5
|
/**
|
|
6
|
-
|
|
6
|
+
* The number of input (prompt) tokens used.
|
|
7
7
|
*/
|
|
8
8
|
inputTokens: number | undefined;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
|
|
11
|
+
* The number of output tokens used, if reported by the provider.
|
|
12
12
|
*/
|
|
13
13
|
outputTokens: number | undefined;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
|
|
16
|
+
* The total number of tokens as reported by the provider.
|
|
17
17
|
*/
|
|
18
18
|
totalTokens: number | undefined;
|
|
19
19
|
};
|
|
@@ -15,95 +15,95 @@ type GetMaxImagesPerCallFunction = (options: {
|
|
|
15
15
|
}) => PromiseLike<number | undefined> | number | undefined;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
Image generation model specification version 3.
|
|
18
|
+
* Image generation model specification version 3.
|
|
19
19
|
*/
|
|
20
20
|
export type ImageModelV3 = {
|
|
21
21
|
/**
|
|
22
|
-
The image model must specify which image model interface
|
|
23
|
-
version it implements. This will allow us to evolve the image
|
|
24
|
-
model interface and retain backwards compatibility. The different
|
|
25
|
-
implementation versions can be handled as a discriminated union
|
|
26
|
-
on our side.
|
|
22
|
+
* The image model must specify which image model interface
|
|
23
|
+
* version it implements. This will allow us to evolve the image
|
|
24
|
+
* model interface and retain backwards compatibility. The different
|
|
25
|
+
* implementation versions can be handled as a discriminated union
|
|
26
|
+
* on our side.
|
|
27
27
|
*/
|
|
28
28
|
readonly specificationVersion: 'v3';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
Name of the provider for logging purposes.
|
|
31
|
+
* Name of the provider for logging purposes.
|
|
32
32
|
*/
|
|
33
33
|
readonly provider: string;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
Provider-specific model ID for logging purposes.
|
|
36
|
+
* Provider-specific model ID for logging purposes.
|
|
37
37
|
*/
|
|
38
38
|
readonly modelId: string;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
Limit of how many images can be generated in a single API call.
|
|
42
|
-
Can be set to a number for a fixed limit, to undefined to use
|
|
43
|
-
the global limit, or a function that returns a number or undefined,
|
|
44
|
-
optionally as a promise.
|
|
41
|
+
* Limit of how many images can be generated in a single API call.
|
|
42
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
43
|
+
* the global limit, or a function that returns a number or undefined,
|
|
44
|
+
* optionally as a promise.
|
|
45
45
|
*/
|
|
46
46
|
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
Generates an array of images.
|
|
49
|
+
* Generates an array of images.
|
|
50
50
|
*/
|
|
51
51
|
doGenerate(options: ImageModelV3CallOptions): PromiseLike<{
|
|
52
52
|
/**
|
|
53
|
-
Generated images as base64 encoded strings or binary data.
|
|
54
|
-
The images should be returned without any unnecessary conversion.
|
|
55
|
-
If the API returns base64 encoded strings, the images should be returned
|
|
56
|
-
as base64 encoded strings. If the API returns binary data, the images should
|
|
57
|
-
be returned as binary data.
|
|
53
|
+
* Generated images as base64 encoded strings or binary data.
|
|
54
|
+
* The images should be returned without any unnecessary conversion.
|
|
55
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
56
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
57
|
+
* be returned as binary data.
|
|
58
58
|
*/
|
|
59
59
|
images: Array<string> | Array<Uint8Array>;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
Warnings for the call, e.g. unsupported features.
|
|
62
|
+
* Warnings for the call, e.g. unsupported features.
|
|
63
63
|
*/
|
|
64
64
|
warnings: Array<SharedV3Warning>;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
Additional provider-specific metadata. They are passed through
|
|
68
|
-
from the provider to the AI SDK and enable provider-specific
|
|
69
|
-
results that can be fully encapsulated in the provider.
|
|
70
|
-
|
|
71
|
-
The outer record is keyed by the provider name, and the inner
|
|
72
|
-
record is provider-specific metadata. It always includes an
|
|
73
|
-
`images` key with image-specific metadata
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
67
|
+
* Additional provider-specific metadata. They are passed through
|
|
68
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
69
|
+
* results that can be fully encapsulated in the provider.
|
|
70
|
+
*
|
|
71
|
+
* The outer record is keyed by the provider name, and the inner
|
|
72
|
+
* record is provider-specific metadata. It always includes an
|
|
73
|
+
* `images` key with image-specific metadata
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* {
|
|
77
|
+
* "openai": {
|
|
78
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
83
|
providerMetadata?: ImageModelV3ProviderMetadata;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
Response information for telemetry and debugging purposes.
|
|
86
|
+
* Response information for telemetry and debugging purposes.
|
|
87
87
|
*/
|
|
88
88
|
response: {
|
|
89
89
|
/**
|
|
90
|
-
Timestamp for the start of the generated response.
|
|
91
|
-
|
|
90
|
+
* Timestamp for the start of the generated response.
|
|
91
|
+
*/
|
|
92
92
|
timestamp: Date;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
The ID of the response model that was used to generate the response.
|
|
96
|
-
|
|
95
|
+
* The ID of the response model that was used to generate the response.
|
|
96
|
+
*/
|
|
97
97
|
modelId: string;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
Response headers.
|
|
101
|
-
|
|
100
|
+
* Response headers.
|
|
101
|
+
*/
|
|
102
102
|
headers: Record<string, string> | undefined;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
|
|
106
|
+
* Optional token usage for the image generation call (if the provider reports it).
|
|
107
107
|
*/
|
|
108
108
|
usage?: ImageModelV3Usage;
|
|
109
109
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
A JSON value can be a string, number, boolean, object, array, or null.
|
|
3
|
-
JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
|
|
2
|
+
* A JSON value can be a string, number, boolean, object, array, or null.
|
|
3
|
+
* JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
|
|
4
4
|
*/
|
|
5
5
|
export type JSONValue =
|
|
6
6
|
| null
|