@ai-sdk/provider 3.0.4 → 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.
Files changed (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +733 -715
  3. package/dist/index.d.ts +733 -715
  4. package/dist/index.js +32 -5
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +32 -5
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +5 -1
  9. package/src/embedding-model/v2/embedding-model-v2-embedding.ts +2 -2
  10. package/src/embedding-model/v2/embedding-model-v2.ts +39 -39
  11. package/src/embedding-model/v3/embedding-model-v3-call-options.ts +11 -11
  12. package/src/embedding-model/v3/embedding-model-v3-embedding.ts +2 -2
  13. package/src/embedding-model/v3/embedding-model-v3-result.ts +2 -2
  14. package/src/embedding-model/v3/embedding-model-v3.ts +19 -19
  15. package/src/errors/index.ts +1 -0
  16. package/src/errors/no-content-generated-error.ts +1 -1
  17. package/src/errors/type-validation-error.ts +63 -6
  18. package/src/image-model/v2/image-model-v2-call-options.ts +33 -33
  19. package/src/image-model/v2/image-model-v2-call-warning.ts +2 -2
  20. package/src/image-model/v2/image-model-v2.ts +42 -42
  21. package/src/image-model/v3/image-model-v3-usage.ts +4 -4
  22. package/src/image-model/v3/image-model-v3.ts +43 -43
  23. package/src/json-value/json-value.ts +2 -2
  24. package/src/language-model/v2/language-model-v2-call-options.ts +44 -44
  25. package/src/language-model/v2/language-model-v2-call-warning.ts +2 -2
  26. package/src/language-model/v2/language-model-v2-data-content.ts +2 -2
  27. package/src/language-model/v2/language-model-v2-file.ts +14 -14
  28. package/src/language-model/v2/language-model-v2-finish-reason.ts +10 -10
  29. package/src/language-model/v2/language-model-v2-function-tool.ts +11 -11
  30. package/src/language-model/v2/language-model-v2-prompt.ts +38 -38
  31. package/src/language-model/v2/language-model-v2-provider-defined-tool.ts +6 -6
  32. package/src/language-model/v2/language-model-v2-reasoning.ts +1 -1
  33. package/src/language-model/v2/language-model-v2-response-metadata.ts +6 -6
  34. package/src/language-model/v2/language-model-v2-source.ts +1 -1
  35. package/src/language-model/v2/language-model-v2-text.ts +2 -2
  36. package/src/language-model/v2/language-model-v2-tool-result.ts +1 -1
  37. package/src/language-model/v2/language-model-v2-usage.ts +11 -11
  38. package/src/language-model/v2/language-model-v2.ts +42 -42
  39. package/src/language-model/v3/language-model-v3-call-options.ts +44 -44
  40. package/src/language-model/v3/language-model-v3-data-content.ts +2 -2
  41. package/src/language-model/v3/language-model-v3-file.ts +14 -14
  42. package/src/language-model/v3/language-model-v3-function-tool.ts +11 -11
  43. package/src/language-model/v3/language-model-v3-prompt.ts +43 -43
  44. package/src/language-model/v3/language-model-v3-reasoning.ts +1 -1
  45. package/src/language-model/v3/language-model-v3-response-metadata.ts +6 -6
  46. package/src/language-model/v3/language-model-v3-source.ts +1 -1
  47. package/src/language-model/v3/language-model-v3-text.ts +2 -2
  48. package/src/language-model/v3/language-model-v3-tool-result.ts +1 -1
  49. package/src/language-model/v3/language-model-v3-usage.ts +1 -1
  50. package/src/provider/v2/provider-v2.ts +37 -37
  51. package/src/provider/v3/provider-v3.ts +55 -55
  52. package/src/transcription-model/v2/transcription-model-v2-call-options.ts +24 -24
  53. package/src/transcription-model/v2/transcription-model-v2-call-warning.ts +2 -2
  54. package/src/transcription-model/v2/transcription-model-v2.ts +25 -25
  55. package/src/transcription-model/v3/transcription-model-v3-call-options.ts +24 -24
  56. package/src/transcription-model/v3/transcription-model-v3.ts +25 -25
@@ -7,62 +7,62 @@ import { LanguageModelV2ToolChoice } from './language-model-v2-tool-choice';
7
7
 
8
8
  export type LanguageModelV2CallOptions = {
9
9
  /**
10
- A language mode prompt is a standardized prompt type.
11
-
12
- Note: This is **not** the user-facing prompt. The AI SDK methods will map the
13
- user-facing prompt types such as chat or instruction prompts to this format.
14
- That approach allows us to evolve the user facing prompts without breaking
15
- the language model interface.
10
+ * A language mode prompt is a standardized prompt type.
11
+ *
12
+ * Note: This is **not** the user-facing prompt. The AI SDK methods will map the
13
+ * user-facing prompt types such as chat or instruction prompts to this format.
14
+ * That approach allows us to evolve the user facing prompts without breaking
15
+ * the language model interface.
16
16
  */
17
17
  prompt: LanguageModelV2Prompt;
18
18
 
19
19
  /**
20
- Maximum number of tokens to generate.
20
+ * Maximum number of tokens to generate.
21
21
  */
22
22
  maxOutputTokens?: number;
23
23
 
24
24
  /**
25
- Temperature setting. The range depends on the provider and model.
26
- */
25
+ * Temperature setting. The range depends on the provider and model.
26
+ */
27
27
  temperature?: number;
28
28
 
29
29
  /**
30
- Stop sequences.
31
- If set, the model will stop generating text when one of the stop sequences is generated.
32
- Providers may have limits on the number of stop sequences.
33
- */
30
+ * Stop sequences.
31
+ * If set, the model will stop generating text when one of the stop sequences is generated.
32
+ * Providers may have limits on the number of stop sequences.
33
+ */
34
34
  stopSequences?: string[];
35
35
 
36
36
  /**
37
- Nucleus sampling.
38
- */
37
+ * Nucleus sampling.
38
+ */
39
39
  topP?: number;
40
40
 
41
41
  /**
42
- Only sample from the top K options for each subsequent token.
43
-
44
- Used to remove "long tail" low probability responses.
45
- Recommended for advanced use cases only. You usually only need to use temperature.
46
- */
42
+ * Only sample from the top K options for each subsequent token.
43
+ *
44
+ * Used to remove "long tail" low probability responses.
45
+ * Recommended for advanced use cases only. You usually only need to use temperature.
46
+ */
47
47
  topK?: number;
48
48
 
49
49
  /**
50
- Presence penalty setting. It affects the likelihood of the model to
51
- repeat information that is already in the prompt.
52
- */
50
+ * Presence penalty setting. It affects the likelihood of the model to
51
+ * repeat information that is already in the prompt.
52
+ */
53
53
  presencePenalty?: number;
54
54
 
55
55
  /**
56
- Frequency penalty setting. It affects the likelihood of the model
57
- to repeatedly use the same words or phrases.
58
- */
56
+ * Frequency penalty setting. It affects the likelihood of the model
57
+ * to repeatedly use the same words or phrases.
58
+ */
59
59
  frequencyPenalty?: number;
60
60
 
61
61
  /**
62
- Response format. The output can either be text or JSON. Default is text.
63
-
64
- If JSON is selected, a schema can optionally be provided to guide the LLM.
65
- */
62
+ * Response format. The output can either be text or JSON. Default is text.
63
+ *
64
+ * If JSON is selected, a schema can optionally be provided to guide the LLM.
65
+ */
66
66
  responseFormat?:
67
67
  | { type: 'text' }
68
68
  | {
@@ -85,37 +85,37 @@ If JSON is selected, a schema can optionally be provided to guide the LLM.
85
85
  };
86
86
 
87
87
  /**
88
- The seed (integer) to use for random sampling. If set and supported
89
- by the model, calls will generate deterministic results.
90
- */
88
+ * The seed (integer) to use for random sampling. If set and supported
89
+ * by the model, calls will generate deterministic results.
90
+ */
91
91
  seed?: number;
92
92
 
93
93
  /**
94
- The tools that are available for the model.
95
- */
94
+ * The tools that are available for the model.
95
+ */
96
96
  tools?: Array<
97
97
  LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool
98
98
  >;
99
99
 
100
100
  /**
101
- Specifies how the tool should be selected. Defaults to 'auto'.
102
- */
101
+ * Specifies how the tool should be selected. Defaults to 'auto'.
102
+ */
103
103
  toolChoice?: LanguageModelV2ToolChoice;
104
104
 
105
105
  /**
106
- Include raw chunks in the stream. Only applicable for streaming calls.
107
- */
106
+ * Include raw chunks in the stream. Only applicable for streaming calls.
107
+ */
108
108
  includeRawChunks?: boolean;
109
109
 
110
110
  /**
111
- Abort signal for cancelling the operation.
112
- */
111
+ * Abort signal for cancelling the operation.
112
+ */
113
113
  abortSignal?: AbortSignal;
114
114
 
115
115
  /**
116
- Additional HTTP headers to be sent with the request.
117
- Only applicable for HTTP-based providers.
118
- */
116
+ * Additional HTTP headers to be sent with the request.
117
+ * Only applicable for HTTP-based providers.
118
+ */
119
119
  headers?: Record<string, string | undefined>;
120
120
 
121
121
  /**
@@ -3,8 +3,8 @@ import { LanguageModelV2FunctionTool } from './language-model-v2-function-tool';
3
3
  import { LanguageModelV2ProviderDefinedTool } from './language-model-v2-provider-defined-tool';
4
4
 
5
5
  /**
6
- Warning from the model provider for this call. The call will proceed, but e.g.
7
- some settings might not be supported, which can lead to suboptimal results.
6
+ * Warning from the model provider for this call. The call will proceed, but e.g.
7
+ * some settings might not be supported, which can lead to suboptimal results.
8
8
  */
9
9
  export type LanguageModelV2CallWarning =
10
10
  | {
@@ -1,4 +1,4 @@
1
1
  /**
2
- Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
3
- */
2
+ * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
3
+ */
4
4
  export type LanguageModelV2DataContent = Uint8Array | string | URL;
@@ -1,25 +1,25 @@
1
1
  /**
2
- A file that has been generated by the model.
3
- Generated files as base64 encoded strings or binary data.
4
- The files should be returned without any unnecessary conversion.
2
+ * A file that has been generated by the model.
3
+ * Generated files as base64 encoded strings or binary data.
4
+ * The files should be returned without any unnecessary conversion.
5
5
  */
6
6
  export type LanguageModelV2File = {
7
7
  type: 'file';
8
8
 
9
9
  /**
10
- The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
11
-
12
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
13
- */
10
+ * The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
11
+ *
12
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
13
+ */
14
14
  mediaType: string;
15
15
 
16
16
  /**
17
- Generated file data as base64 encoded strings or binary data.
18
-
19
- The file data should be returned without any unnecessary conversion.
20
- If the API returns base64 encoded strings, the file data should be returned
21
- as base64 encoded strings. If the API returns binary data, the file data should
22
- be returned as binary data.
23
- */
17
+ * Generated file data as base64 encoded strings or binary data.
18
+ *
19
+ * The file data should be returned without any unnecessary conversion.
20
+ * If the API returns base64 encoded strings, the file data should be returned
21
+ * as base64 encoded strings. If the API returns binary data, the file data should
22
+ * be returned as binary data.
23
+ */
24
24
  data: string | Uint8Array;
25
25
  };
@@ -1,14 +1,14 @@
1
1
  /**
2
- Reason why a language model finished generating a response.
3
-
4
- Can be one of the following:
5
- - `stop`: model generated stop sequence
6
- - `length`: model generated maximum number of tokens
7
- - `content-filter`: content filter violation stopped the model
8
- - `tool-calls`: model triggered tool calls
9
- - `error`: model stopped because of an error
10
- - `other`: model stopped for other reasons
11
- - `unknown`: the model has not transmitted a finish reason
2
+ * Reason why a language model finished generating a response.
3
+ *
4
+ * Can be one of the following:
5
+ * - `stop`: model generated stop sequence
6
+ * - `length`: model generated maximum number of tokens
7
+ * - `content-filter`: content filter violation stopped the model
8
+ * - `tool-calls`: model triggered tool calls
9
+ * - `error`: model stopped because of an error
10
+ * - `other`: model stopped for other reasons
11
+ * - `unknown`: the model has not transmitted a finish reason
12
12
  */
13
13
  export type LanguageModelV2FinishReason =
14
14
  | 'stop' // model generated stop sequence
@@ -2,36 +2,36 @@ import { JSONSchema7 } from 'json-schema';
2
2
  import { SharedV2ProviderOptions } from '../../shared';
3
3
 
4
4
  /**
5
- A tool has a name, a description, and a set of parameters.
6
-
7
- Note: this is **not** the user-facing tool definition. The AI SDK methods will
8
- map the user-facing tool definitions to this format.
5
+ * A tool has a name, a description, and a set of parameters.
6
+ *
7
+ * Note: this is **not** the user-facing tool definition. The AI SDK methods will
8
+ * map the user-facing tool definitions to this format.
9
9
  */
10
10
  export type LanguageModelV2FunctionTool = {
11
11
  /**
12
- The type of the tool (always 'function').
12
+ * The type of the tool (always 'function').
13
13
  */
14
14
  type: 'function';
15
15
 
16
16
  /**
17
- The name of the tool. Unique within this model call.
17
+ * The name of the tool. Unique within this model call.
18
18
  */
19
19
  name: string;
20
20
 
21
21
  /**
22
- A description of the tool. The language model uses this to understand the
23
- tool's purpose and to provide better completion suggestions.
22
+ * A description of the tool. The language model uses this to understand the
23
+ * tool's purpose and to provide better completion suggestions.
24
24
  */
25
25
  description?: string;
26
26
 
27
27
  /**
28
- The parameters that the tool expects. The language model uses this to
29
- understand the tool's input requirements and to provide matching suggestions.
28
+ * The parameters that the tool expects. The language model uses this to
29
+ * understand the tool's input requirements and to provide matching suggestions.
30
30
  */
31
31
  inputSchema: JSONSchema7;
32
32
 
33
33
  /**
34
- The provider-specific options for the tool.
34
+ * The provider-specific options for the tool.
35
35
  */
36
36
  providerOptions?: SharedV2ProviderOptions;
37
37
  };
@@ -3,13 +3,13 @@ import { SharedV2ProviderOptions } from '../../shared/v2/shared-v2-provider-opti
3
3
  import { LanguageModelV2DataContent } from './language-model-v2-data-content';
4
4
 
5
5
  /**
6
- A prompt is a list of messages.
7
-
8
- Note: Not all models and prompt formats support multi-modal inputs and
9
- tool calls. The validation happens at runtime.
10
-
11
- Note: This is not a user-facing prompt. The AI SDK methods will map the
12
- user-facing prompt types such as chat or instruction prompts to this format.
6
+ * A prompt is a list of messages.
7
+ *
8
+ * Note: Not all models and prompt formats support multi-modal inputs and
9
+ * tool calls. The validation happens at runtime.
10
+ *
11
+ * Note: This is not a user-facing prompt. The AI SDK methods will map the
12
+ * user-facing prompt types such as chat or instruction prompts to this format.
13
13
  */
14
14
  export type LanguageModelV2Prompt = Array<LanguageModelV2Message>;
15
15
 
@@ -50,13 +50,13 @@ export type LanguageModelV2Message =
50
50
  };
51
51
 
52
52
  /**
53
- Text content part of a prompt. It contains a string of text.
53
+ * Text content part of a prompt. It contains a string of text.
54
54
  */
55
55
  export interface LanguageModelV2TextPart {
56
56
  type: 'text';
57
57
 
58
58
  /**
59
- The text content.
59
+ * The text content.
60
60
  */
61
61
  text: string;
62
62
 
@@ -69,13 +69,13 @@ The text content.
69
69
  }
70
70
 
71
71
  /**
72
- Reasoning content part of a prompt. It contains a string of reasoning text.
72
+ * Reasoning content part of a prompt. It contains a string of reasoning text.
73
73
  */
74
74
  export interface LanguageModelV2ReasoningPart {
75
75
  type: 'reasoning';
76
76
 
77
77
  /**
78
- The reasoning text.
78
+ * The reasoning text.
79
79
  */
80
80
  text: string;
81
81
 
@@ -88,7 +88,7 @@ The reasoning text.
88
88
  }
89
89
 
90
90
  /**
91
- File content part of a prompt. It contains a file.
91
+ * File content part of a prompt. It contains a file.
92
92
  */
93
93
  export interface LanguageModelV2FilePart {
94
94
  type: 'file';
@@ -99,16 +99,16 @@ export interface LanguageModelV2FilePart {
99
99
  filename?: string;
100
100
 
101
101
  /**
102
- File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
103
- */
102
+ * File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
103
+ */
104
104
  data: LanguageModelV2DataContent;
105
105
 
106
106
  /**
107
- IANA media type of the file.
108
-
109
- Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
110
-
111
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
107
+ * IANA media type of the file.
108
+ *
109
+ * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
110
+ *
111
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
112
112
  */
113
113
  mediaType: string;
114
114
 
@@ -121,23 +121,23 @@ Can support wildcards, e.g. `image/*` (in which case the provider needs to take
121
121
  }
122
122
 
123
123
  /**
124
- Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
124
+ * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
125
125
  */
126
126
  export interface LanguageModelV2ToolCallPart {
127
127
  type: 'tool-call';
128
128
 
129
129
  /**
130
- ID of the tool call. This ID is used to match the tool call with the tool result.
131
- */
130
+ * ID of the tool call. This ID is used to match the tool call with the tool result.
131
+ */
132
132
  toolCallId: string;
133
133
 
134
134
  /**
135
- Name of the tool that is being called.
136
- */
135
+ * Name of the tool that is being called.
136
+ */
137
137
  toolName: string;
138
138
 
139
139
  /**
140
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
140
+ * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
141
141
  */
142
142
  input: unknown;
143
143
 
@@ -156,23 +156,23 @@ Arguments of the tool call. This is a JSON-serializable object that matches the
156
156
  }
157
157
 
158
158
  /**
159
- Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
159
+ * Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
160
160
  */
161
161
  export interface LanguageModelV2ToolResultPart {
162
162
  type: 'tool-result';
163
163
 
164
164
  /**
165
- ID of the tool call that this result is associated with.
166
- */
165
+ * ID of the tool call that this result is associated with.
166
+ */
167
167
  toolCallId: string;
168
168
 
169
169
  /**
170
- Name of the tool that generated this result.
171
- */
170
+ * Name of the tool that generated this result.
171
+ */
172
172
  toolName: string;
173
173
 
174
174
  /**
175
- Result of the tool call.
175
+ * Result of the tool call.
176
176
  */
177
177
  output: LanguageModelV2ToolResultOutput;
178
178
 
@@ -196,22 +196,22 @@ export type LanguageModelV2ToolResultOutput =
196
196
  type: 'text';
197
197
 
198
198
  /**
199
- Text content.
200
- */
199
+ * Text content.
200
+ */
201
201
  text: string;
202
202
  }
203
203
  | {
204
204
  type: 'media';
205
205
 
206
206
  /**
207
- Base-64 encoded media data.
208
- */
207
+ * Base-64 encoded media data.
208
+ */
209
209
  data: string;
210
210
 
211
211
  /**
212
- IANA media type.
213
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
214
- */
212
+ * IANA media type.
213
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
214
+ */
215
215
  mediaType: string;
216
216
  }
217
217
  >;
@@ -1,24 +1,24 @@
1
1
  /**
2
- The configuration of a tool that is defined by the provider.
2
+ * The configuration of a tool that is defined by the provider.
3
3
  */
4
4
  export type LanguageModelV2ProviderDefinedTool = {
5
5
  /**
6
- The type of the tool (always 'provider-defined').
6
+ * The type of the tool (always 'provider-defined').
7
7
  */
8
8
  type: 'provider-defined';
9
9
 
10
10
  /**
11
- The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
11
+ * The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
12
12
  */
13
13
  id: `${string}.${string}`;
14
14
 
15
15
  /**
16
- The name of the tool that the user must use in the tool set.
16
+ * The name of the tool that the user must use in the tool set.
17
17
  */
18
18
  name: string;
19
19
 
20
20
  /**
21
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
22
- */
21
+ * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
22
+ */
23
23
  args: Record<string, unknown>;
24
24
  };
@@ -1,7 +1,7 @@
1
1
  import { SharedV2ProviderMetadata } from '../../shared';
2
2
 
3
3
  /**
4
- Reasoning that the model has generated.
4
+ * Reasoning that the model has generated.
5
5
  */
6
6
  export type LanguageModelV2Reasoning = {
7
7
  type: 'reasoning';
@@ -1,16 +1,16 @@
1
1
  export interface LanguageModelV2ResponseMetadata {
2
2
  /**
3
- ID for the generated response, if the provider sends one.
4
- */
3
+ * ID for the generated response, if the provider sends one.
4
+ */
5
5
  id?: string;
6
6
 
7
7
  /**
8
- Timestamp for the start of the generated response, if the provider sends one.
9
- */
8
+ * Timestamp for the start of the generated response, if the provider sends one.
9
+ */
10
10
  timestamp?: Date;
11
11
 
12
12
  /**
13
- The ID of the response model that was used to generate the response, if the provider sends one.
14
- */
13
+ * The ID of the response model that was used to generate the response, if the provider sends one.
14
+ */
15
15
  modelId?: string;
16
16
  }
@@ -1,7 +1,7 @@
1
1
  import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata';
2
2
 
3
3
  /**
4
- A source that has been used as input to generate the response.
4
+ * A source that has been used as input to generate the response.
5
5
  */
6
6
  export type LanguageModelV2Source =
7
7
  | {
@@ -1,13 +1,13 @@
1
1
  import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata';
2
2
 
3
3
  /**
4
- Text that the model has generated.
4
+ * Text that the model has generated.
5
5
  */
6
6
  export type LanguageModelV2Text = {
7
7
  type: 'text';
8
8
 
9
9
  /**
10
- The text content.
10
+ * The text content.
11
11
  */
12
12
  text: string;
13
13
 
@@ -1,7 +1,7 @@
1
1
  import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata';
2
2
 
3
3
  /**
4
- Result of a tool call that has been executed by the provider.
4
+ * Result of a tool call that has been executed by the provider.
5
5
  */
6
6
  export type LanguageModelV2ToolResult = {
7
7
  type: 'tool-result';
@@ -1,34 +1,34 @@
1
1
  /**
2
- Usage information for a language model call.
3
-
4
- If your API return additional usage information, you can add it to the
5
- provider metadata under your provider's key.
2
+ * Usage information for a language model call.
3
+ *
4
+ * If your API return additional usage information, you can add it to the
5
+ * provider metadata under your provider's key.
6
6
  */
7
7
  export type LanguageModelV2Usage = {
8
8
  /**
9
- The number of input (prompt) tokens used.
9
+ * The number of input (prompt) tokens used.
10
10
  */
11
11
  inputTokens: number | undefined;
12
12
 
13
13
  /**
14
- The number of output (completion) tokens used.
14
+ * The number of output (completion) tokens used.
15
15
  */
16
16
  outputTokens: number | undefined;
17
17
 
18
18
  /**
19
- The total number of tokens as reported by the provider.
20
- This number might be different from the sum of `inputTokens` and `outputTokens`
21
- and e.g. include reasoning tokens or other overhead.
19
+ * The total number of tokens as reported by the provider.
20
+ * This number might be different from the sum of `inputTokens` and `outputTokens`
21
+ * and e.g. include reasoning tokens or other overhead.
22
22
  */
23
23
  totalTokens: number | undefined;
24
24
 
25
25
  /**
26
- The number of reasoning tokens used.
26
+ * The number of reasoning tokens used.
27
27
  */
28
28
  reasoningTokens?: number | undefined;
29
29
 
30
30
  /**
31
- The number of cached input tokens.
31
+ * The number of cached input tokens.
32
32
  */
33
33
  cachedInputTokens?: number | undefined;
34
34
  };