@ai-sdk/openai 1.3.22 → 2.0.0-alpha.1
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 +231 -45
- package/dist/index.d.mts +31 -183
- package/dist/index.d.ts +31 -183
- package/dist/index.js +947 -1114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +942 -1109
- package/dist/index.mjs.map +1 -1
- package/{internal/dist → dist/internal}/index.d.mts +157 -166
- package/{internal/dist → dist/internal}/index.d.ts +157 -166
- package/{internal/dist → dist/internal}/index.js +917 -1067
- package/dist/internal/index.js.map +1 -0
- package/{internal/dist → dist/internal}/index.mjs +914 -1068
- package/dist/internal/index.mjs.map +1 -0
- package/internal.d.ts +1 -0
- package/package.json +19 -18
- package/internal/dist/index.js.map +0 -1
- package/internal/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,113 +1,299 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0-alpha.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
- @ai-sdk/provider
|
|
7
|
+
- Updated dependencies [3f2f00c]
|
|
8
|
+
- @ai-sdk/provider@2.0.0-alpha.1
|
|
9
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.1
|
|
9
10
|
|
|
10
|
-
##
|
|
11
|
+
## 2.0.0-canary.20
|
|
11
12
|
|
|
12
13
|
### Patch Changes
|
|
13
14
|
|
|
14
|
-
-
|
|
15
|
+
- Updated dependencies [faf8446]
|
|
16
|
+
- @ai-sdk/provider-utils@3.0.0-canary.19
|
|
15
17
|
|
|
16
|
-
##
|
|
18
|
+
## 2.0.0-canary.19
|
|
17
19
|
|
|
18
20
|
### Patch Changes
|
|
19
21
|
|
|
20
|
-
-
|
|
22
|
+
- Updated dependencies [40acf9b]
|
|
23
|
+
- @ai-sdk/provider-utils@3.0.0-canary.18
|
|
21
24
|
|
|
22
|
-
##
|
|
25
|
+
## 2.0.0-canary.18
|
|
26
|
+
|
|
27
|
+
### Major Changes
|
|
28
|
+
|
|
29
|
+
- 516be5b: ### Move Image Model Settings into generate options
|
|
30
|
+
|
|
31
|
+
Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
|
|
32
|
+
|
|
33
|
+
Before
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
await generateImage({
|
|
37
|
+
model: luma.image('photon-flash-1', {
|
|
38
|
+
maxImagesPerCall: 5,
|
|
39
|
+
pollIntervalMillis: 500,
|
|
40
|
+
}),
|
|
41
|
+
prompt,
|
|
42
|
+
n: 10,
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
After
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
await generateImage({
|
|
50
|
+
model: luma.image('photon-flash-1'),
|
|
51
|
+
prompt,
|
|
52
|
+
n: 10,
|
|
53
|
+
maxImagesPerCall: 5,
|
|
54
|
+
providerOptions: {
|
|
55
|
+
luma: { pollIntervalMillis: 5 },
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Pull Request: https://github.com/vercel/ai/pull/6180
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [ea7a7c9]
|
|
65
|
+
- @ai-sdk/provider-utils@3.0.0-canary.17
|
|
66
|
+
|
|
67
|
+
## 2.0.0-canary.17
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- 52ce942: chore(providers/openai): remove & enable strict compatibility by default
|
|
72
|
+
- Updated dependencies [87b828f]
|
|
73
|
+
- @ai-sdk/provider-utils@3.0.0-canary.16
|
|
74
|
+
|
|
75
|
+
## 2.0.0-canary.16
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- 928fadf: fix(providers/openai): logprobs for stream alongside completion model
|
|
80
|
+
- 6f231db: fix(providers): always use optional instead of mix of nullish for providerOptions
|
|
81
|
+
- Updated dependencies [a571d6e]
|
|
82
|
+
- Updated dependencies [a8c8bd5]
|
|
83
|
+
- Updated dependencies [7979f7f]
|
|
84
|
+
- Updated dependencies [41fa418]
|
|
85
|
+
- @ai-sdk/provider-utils@3.0.0-canary.15
|
|
86
|
+
- @ai-sdk/provider@2.0.0-canary.14
|
|
87
|
+
|
|
88
|
+
## 2.0.0-canary.15
|
|
23
89
|
|
|
24
90
|
### Patch Changes
|
|
25
91
|
|
|
26
|
-
-
|
|
92
|
+
- 136819b: chore(providers/openai): re-introduce logprobs as providerMetadata
|
|
93
|
+
- 9bd5ab5: feat (provider): add providerMetadata to ImageModelV2 interface (#5977)
|
|
27
94
|
|
|
28
|
-
|
|
95
|
+
The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const prompt = 'Santa Claus driving a Cadillac';
|
|
99
|
+
|
|
100
|
+
const { providerMetadata } = await experimental_generateImage({
|
|
101
|
+
model: openai.image('dall-e-3'),
|
|
102
|
+
prompt,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const revisedPrompt = providerMetadata.openai.images[0]?.revisedPrompt;
|
|
106
|
+
|
|
107
|
+
console.log({
|
|
108
|
+
prompt,
|
|
109
|
+
revisedPrompt,
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- 284353f: fix(providers/openai): zod parse error with function
|
|
114
|
+
- Updated dependencies [957b739]
|
|
115
|
+
- Updated dependencies [9bd5ab5]
|
|
116
|
+
- @ai-sdk/provider-utils@3.0.0-canary.14
|
|
117
|
+
- @ai-sdk/provider@2.0.0-canary.13
|
|
118
|
+
|
|
119
|
+
## 2.0.0-canary.14
|
|
29
120
|
|
|
30
121
|
### Patch Changes
|
|
31
122
|
|
|
32
|
-
-
|
|
123
|
+
- fa758ea: feat(provider/openai): add o3 & o4-mini with developer systemMessageMode
|
|
124
|
+
- Updated dependencies [7b3ae3f]
|
|
125
|
+
- Updated dependencies [0ff02bb]
|
|
126
|
+
- @ai-sdk/provider@2.0.0-canary.12
|
|
127
|
+
- @ai-sdk/provider-utils@3.0.0-canary.13
|
|
33
128
|
|
|
34
|
-
##
|
|
129
|
+
## 2.0.0-canary.13
|
|
35
130
|
|
|
36
131
|
### Patch Changes
|
|
37
132
|
|
|
38
|
-
-
|
|
133
|
+
- 177526b: chore(providers/openai-transcription): switch to providerOptions
|
|
134
|
+
- c15dfbf: feat (providers/openai): add gpt-image-1 model id to image settings
|
|
135
|
+
- 9bf7291: chore(providers/openai): enable structuredOutputs by default & switch to provider option
|
|
136
|
+
- 4617fab: chore(embedding-models): remove remaining settings
|
|
137
|
+
- Updated dependencies [9bf7291]
|
|
138
|
+
- Updated dependencies [4617fab]
|
|
139
|
+
- Updated dependencies [e030615]
|
|
140
|
+
- @ai-sdk/provider@2.0.0-canary.11
|
|
141
|
+
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
39
142
|
|
|
40
|
-
##
|
|
143
|
+
## 2.0.0-canary.12
|
|
41
144
|
|
|
42
145
|
### Patch Changes
|
|
43
146
|
|
|
44
|
-
-
|
|
147
|
+
- db72adc: chore(providers/openai): update completion model to use providerOptions
|
|
148
|
+
- 66962ed: fix(packages): export node10 compatible types
|
|
149
|
+
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
|
150
|
+
- 7df7a25: feat (providers/openai): support gpt-image-1 image generation
|
|
151
|
+
- Updated dependencies [66962ed]
|
|
152
|
+
- Updated dependencies [9301f86]
|
|
153
|
+
- Updated dependencies [a3f768e]
|
|
154
|
+
- @ai-sdk/provider-utils@3.0.0-canary.11
|
|
155
|
+
- @ai-sdk/provider@2.0.0-canary.10
|
|
45
156
|
|
|
46
|
-
##
|
|
157
|
+
## 2.0.0-canary.11
|
|
47
158
|
|
|
48
159
|
### Patch Changes
|
|
49
160
|
|
|
50
|
-
-
|
|
161
|
+
- 8493141: feat (providers/openai): add support for reasoning summaries
|
|
162
|
+
- Updated dependencies [e86be6f]
|
|
163
|
+
- @ai-sdk/provider@2.0.0-canary.9
|
|
164
|
+
- @ai-sdk/provider-utils@3.0.0-canary.10
|
|
51
165
|
|
|
52
|
-
##
|
|
166
|
+
## 2.0.0-canary.10
|
|
53
167
|
|
|
54
168
|
### Patch Changes
|
|
55
169
|
|
|
56
|
-
-
|
|
170
|
+
- 3bd3c0b: chore(providers/openai): update embedding model to use providerOptions
|
|
171
|
+
- Updated dependencies [95857aa]
|
|
172
|
+
- Updated dependencies [7ea4132]
|
|
173
|
+
- @ai-sdk/provider@2.0.0-canary.8
|
|
174
|
+
- @ai-sdk/provider-utils@3.0.0-canary.9
|
|
57
175
|
|
|
58
|
-
##
|
|
176
|
+
## 2.0.0-canary.9
|
|
59
177
|
|
|
60
178
|
### Patch Changes
|
|
61
179
|
|
|
62
|
-
-
|
|
180
|
+
- d63bcbc: feat (provider/openai): o4 updates for responses api
|
|
181
|
+
- d2af019: feat (providers/openai): add gpt-4.1 models
|
|
182
|
+
- 870c5c0: feat (providers/openai): add o3 and o4-mini models
|
|
183
|
+
- 06bac05: fix (openai): structure output for responses model
|
|
63
184
|
|
|
64
|
-
##
|
|
185
|
+
## 2.0.0-canary.8
|
|
65
186
|
|
|
66
187
|
### Patch Changes
|
|
67
188
|
|
|
68
|
-
-
|
|
189
|
+
- 8aa9e20: feat: add speech with experimental_generateSpeech
|
|
190
|
+
- Updated dependencies [5d142ab]
|
|
191
|
+
- Updated dependencies [b6b43c7]
|
|
192
|
+
- Updated dependencies [8aa9e20]
|
|
193
|
+
- Updated dependencies [3795467]
|
|
194
|
+
- @ai-sdk/provider-utils@3.0.0-canary.8
|
|
195
|
+
- @ai-sdk/provider@2.0.0-canary.7
|
|
69
196
|
|
|
70
|
-
##
|
|
197
|
+
## 2.0.0-canary.7
|
|
71
198
|
|
|
72
199
|
### Patch Changes
|
|
73
200
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
201
|
+
- 26735b5: chore(embedding-model): add v2 interface
|
|
202
|
+
- 443d8ec: feat(embedding-model-v2): add response body field
|
|
203
|
+
- fd65bc6: chore(embedding-model-v2): rename rawResponse to response
|
|
204
|
+
- Updated dependencies [26735b5]
|
|
205
|
+
- Updated dependencies [443d8ec]
|
|
206
|
+
- Updated dependencies [14c9410]
|
|
207
|
+
- Updated dependencies [d9c98f4]
|
|
208
|
+
- Updated dependencies [c4a2fec]
|
|
209
|
+
- Updated dependencies [0054544]
|
|
210
|
+
- Updated dependencies [9e9c809]
|
|
211
|
+
- Updated dependencies [32831c6]
|
|
212
|
+
- Updated dependencies [d0f9495]
|
|
213
|
+
- Updated dependencies [fd65bc6]
|
|
214
|
+
- Updated dependencies [393138b]
|
|
215
|
+
- Updated dependencies [7182d14]
|
|
216
|
+
- @ai-sdk/provider@2.0.0-canary.6
|
|
217
|
+
- @ai-sdk/provider-utils@3.0.0-canary.7
|
|
78
218
|
|
|
79
|
-
##
|
|
219
|
+
## 2.0.0-canary.6
|
|
80
220
|
|
|
81
221
|
### Patch Changes
|
|
82
222
|
|
|
83
|
-
-
|
|
84
|
-
-
|
|
223
|
+
- 948b755: chore(providers/openai): convert to providerOptions
|
|
224
|
+
- 3b1ea10: adding support for gpt-4o-search-preview and handling unsupported parameters
|
|
225
|
+
- 442be08: fix: propagate openai transcription fixes
|
|
226
|
+
- 5147e6e: chore(openai): remove simulateStreaming
|
|
227
|
+
- c2b92cc: chore(openai): remove legacy function calling
|
|
228
|
+
- f10304b: feat(tool-calling): don't require the user to have to pass parameters
|
|
229
|
+
- Updated dependencies [411e483]
|
|
230
|
+
- Updated dependencies [79457bd]
|
|
231
|
+
- Updated dependencies [ad80501]
|
|
232
|
+
- Updated dependencies [1766ede]
|
|
233
|
+
- Updated dependencies [f10304b]
|
|
234
|
+
- @ai-sdk/provider@2.0.0-canary.5
|
|
235
|
+
- @ai-sdk/provider-utils@3.0.0-canary.6
|
|
85
236
|
|
|
86
|
-
##
|
|
237
|
+
## 2.0.0-canary.5
|
|
87
238
|
|
|
88
239
|
### Patch Changes
|
|
89
240
|
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
- @ai-sdk/provider@1.1.2
|
|
94
|
-
- @ai-sdk/provider-utils@2.2.6
|
|
241
|
+
- Updated dependencies [6f6bb89]
|
|
242
|
+
- @ai-sdk/provider@2.0.0-canary.4
|
|
243
|
+
- @ai-sdk/provider-utils@3.0.0-canary.5
|
|
95
244
|
|
|
96
|
-
##
|
|
245
|
+
## 2.0.0-canary.4
|
|
97
246
|
|
|
98
247
|
### Patch Changes
|
|
99
248
|
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
- @ai-sdk/provider-utils@
|
|
103
|
-
|
|
249
|
+
- Updated dependencies [d1a1aa1]
|
|
250
|
+
- @ai-sdk/provider@2.0.0-canary.3
|
|
251
|
+
- @ai-sdk/provider-utils@3.0.0-canary.4
|
|
252
|
+
|
|
253
|
+
## 2.0.0-canary.3
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- a166433: feat: add transcription with experimental_transcribe
|
|
258
|
+
- 0a87932: core (ai): change transcription model mimeType to mediaType
|
|
259
|
+
- 0a87932: fix (provider/openai): increase transcription model resilience
|
|
260
|
+
- Updated dependencies [a166433]
|
|
261
|
+
- Updated dependencies [abf9a79]
|
|
262
|
+
- Updated dependencies [9f95b35]
|
|
263
|
+
- Updated dependencies [0a87932]
|
|
264
|
+
- Updated dependencies [6dc848c]
|
|
265
|
+
- @ai-sdk/provider-utils@3.0.0-canary.3
|
|
266
|
+
- @ai-sdk/provider@2.0.0-canary.2
|
|
267
|
+
|
|
268
|
+
## 2.0.0-canary.2
|
|
269
|
+
|
|
270
|
+
### Patch Changes
|
|
271
|
+
|
|
272
|
+
- Updated dependencies [c57e248]
|
|
273
|
+
- Updated dependencies [33f4a6a]
|
|
274
|
+
- @ai-sdk/provider@2.0.0-canary.1
|
|
275
|
+
- @ai-sdk/provider-utils@3.0.0-canary.2
|
|
276
|
+
|
|
277
|
+
## 2.0.0-canary.1
|
|
278
|
+
|
|
279
|
+
### Patch Changes
|
|
280
|
+
|
|
281
|
+
- Updated dependencies [060370c]
|
|
282
|
+
- Updated dependencies [0c0c0b3]
|
|
283
|
+
- Updated dependencies [63d791d]
|
|
284
|
+
- @ai-sdk/provider-utils@3.0.0-canary.1
|
|
285
|
+
|
|
286
|
+
## 2.0.0-canary.0
|
|
287
|
+
|
|
288
|
+
### Major Changes
|
|
104
289
|
|
|
105
|
-
|
|
290
|
+
- d5f588f: AI SDK 5
|
|
106
291
|
|
|
107
292
|
### Patch Changes
|
|
108
293
|
|
|
109
|
-
- Updated dependencies [
|
|
110
|
-
- @ai-sdk/provider-utils@
|
|
294
|
+
- Updated dependencies [d5f588f]
|
|
295
|
+
- @ai-sdk/provider-utils@3.0.0-canary.0
|
|
296
|
+
- @ai-sdk/provider@2.0.0-canary.0
|
|
111
297
|
|
|
112
298
|
## 1.3.6
|
|
113
299
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,133 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV1, SpeechModelV1 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
6
|
-
interface OpenAIChatSettings {
|
|
7
|
-
/**
|
|
8
|
-
Modify the likelihood of specified tokens appearing in the completion.
|
|
9
|
-
|
|
10
|
-
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
11
|
-
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
12
|
-
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
13
|
-
the bias is added to the logits generated by the model prior to sampling.
|
|
14
|
-
The exact effect will vary per model, but values between -1 and 1 should
|
|
15
|
-
decrease or increase likelihood of selection; values like -100 or 100
|
|
16
|
-
should result in a ban or exclusive selection of the relevant token.
|
|
17
|
-
|
|
18
|
-
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
19
|
-
token from being generated.
|
|
20
|
-
*/
|
|
21
|
-
logitBias?: Record<number, number>;
|
|
22
|
-
/**
|
|
23
|
-
Return the log probabilities of the tokens. Including logprobs will increase
|
|
24
|
-
the response size and can slow down response times. However, it can
|
|
25
|
-
be useful to better understand how the model is behaving.
|
|
26
|
-
|
|
27
|
-
Setting to true will return the log probabilities of the tokens that
|
|
28
|
-
were generated.
|
|
29
|
-
|
|
30
|
-
Setting to a number will return the log probabilities of the top n
|
|
31
|
-
tokens that were generated.
|
|
32
|
-
*/
|
|
33
|
-
logprobs?: boolean | number;
|
|
34
|
-
/**
|
|
35
|
-
Whether to enable parallel function calling during tool use. Default to true.
|
|
36
|
-
*/
|
|
37
|
-
parallelToolCalls?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
Whether to use structured outputs. Defaults to false.
|
|
40
|
-
|
|
41
|
-
When enabled, tool calls and object generation will be strict and follow the provided schema.
|
|
42
|
-
*/
|
|
43
|
-
structuredOutputs?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
Whether to use legacy function calling. Defaults to false.
|
|
46
|
-
|
|
47
|
-
Required by some open source inference engines which do not support the `tools` API. May also
|
|
48
|
-
provide a workaround for `parallelToolCalls` resulting in the provider buffering tool calls,
|
|
49
|
-
which causes `streamObject` to be non-streaming.
|
|
50
|
-
|
|
51
|
-
Prefer setting `parallelToolCalls: false` over this option.
|
|
52
|
-
|
|
53
|
-
@deprecated this API is supported but deprecated by OpenAI.
|
|
54
|
-
*/
|
|
55
|
-
useLegacyFunctionCalling?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
A unique identifier representing your end-user, which can help OpenAI to
|
|
58
|
-
monitor and detect abuse. Learn more.
|
|
59
|
-
*/
|
|
60
|
-
user?: string;
|
|
61
|
-
/**
|
|
62
|
-
Automatically download images and pass the image as data to the model.
|
|
63
|
-
OpenAI supports image URLs for public models, so this is only needed for
|
|
64
|
-
private models or when the images are not publicly accessible.
|
|
65
|
-
|
|
66
|
-
Defaults to `false`.
|
|
67
|
-
*/
|
|
68
|
-
downloadImages?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
Simulates streaming by using a normal generate call and returning it as a stream.
|
|
71
|
-
Enable this if the model that you are using does not support streaming.
|
|
72
|
-
|
|
73
|
-
Defaults to `false`.
|
|
74
|
-
|
|
75
|
-
@deprecated Use `simulateStreamingMiddleware` instead.
|
|
76
|
-
*/
|
|
77
|
-
simulateStreaming?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
Reasoning effort for reasoning models. Defaults to `medium`.
|
|
80
|
-
*/
|
|
81
|
-
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
82
|
-
}
|
|
83
6
|
|
|
84
7
|
type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
|
|
85
|
-
interface OpenAICompletionSettings {
|
|
86
|
-
/**
|
|
87
|
-
Echo back the prompt in addition to the completion.
|
|
88
|
-
*/
|
|
89
|
-
echo?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
Modify the likelihood of specified tokens appearing in the completion.
|
|
92
|
-
|
|
93
|
-
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
94
|
-
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
95
|
-
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
96
|
-
the bias is added to the logits generated by the model prior to sampling.
|
|
97
|
-
The exact effect will vary per model, but values between -1 and 1 should
|
|
98
|
-
decrease or increase likelihood of selection; values like -100 or 100
|
|
99
|
-
should result in a ban or exclusive selection of the relevant token.
|
|
100
|
-
|
|
101
|
-
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
102
|
-
token from being generated.
|
|
103
|
-
*/
|
|
104
|
-
logitBias?: Record<number, number>;
|
|
105
|
-
/**
|
|
106
|
-
Return the log probabilities of the tokens. Including logprobs will increase
|
|
107
|
-
the response size and can slow down response times. However, it can
|
|
108
|
-
be useful to better understand how the model is behaving.
|
|
109
|
-
|
|
110
|
-
Setting to true will return the log probabilities of the tokens that
|
|
111
|
-
were generated.
|
|
112
|
-
|
|
113
|
-
Setting to a number will return the log probabilities of the top n
|
|
114
|
-
tokens that were generated.
|
|
115
|
-
*/
|
|
116
|
-
logprobs?: boolean | number;
|
|
117
|
-
/**
|
|
118
|
-
The suffix that comes after a completion of inserted text.
|
|
119
|
-
*/
|
|
120
|
-
suffix?: string;
|
|
121
|
-
/**
|
|
122
|
-
A unique identifier representing your end-user, which can help OpenAI to
|
|
123
|
-
monitor and detect abuse. Learn more.
|
|
124
|
-
*/
|
|
125
|
-
user?: string;
|
|
126
|
-
}
|
|
127
8
|
|
|
128
9
|
type OpenAICompletionConfig = {
|
|
129
10
|
provider: string;
|
|
130
|
-
compatibility: 'strict' | 'compatible';
|
|
131
11
|
headers: () => Record<string, string | undefined>;
|
|
132
12
|
url: (options: {
|
|
133
13
|
modelId: string;
|
|
@@ -135,53 +15,22 @@ type OpenAICompletionConfig = {
|
|
|
135
15
|
}) => string;
|
|
136
16
|
fetch?: FetchFunction;
|
|
137
17
|
};
|
|
138
|
-
declare class OpenAICompletionLanguageModel implements
|
|
139
|
-
readonly specificationVersion = "
|
|
140
|
-
readonly defaultObjectGenerationMode: undefined;
|
|
18
|
+
declare class OpenAICompletionLanguageModel implements LanguageModelV2 {
|
|
19
|
+
readonly specificationVersion = "v2";
|
|
141
20
|
readonly modelId: OpenAICompletionModelId;
|
|
142
|
-
readonly settings: OpenAICompletionSettings;
|
|
143
21
|
private readonly config;
|
|
144
|
-
|
|
22
|
+
private get providerOptionsName();
|
|
23
|
+
constructor(modelId: OpenAICompletionModelId, config: OpenAICompletionConfig);
|
|
145
24
|
get provider(): string;
|
|
25
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
146
26
|
private getArgs;
|
|
147
|
-
doGenerate(options: Parameters<
|
|
148
|
-
doStream(options: Parameters<
|
|
27
|
+
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
28
|
+
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
149
29
|
}
|
|
150
30
|
|
|
151
31
|
type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large' | 'text-embedding-ada-002' | (string & {});
|
|
152
|
-
interface OpenAIEmbeddingSettings {
|
|
153
|
-
/**
|
|
154
|
-
Override the maximum number of embeddings per call.
|
|
155
|
-
*/
|
|
156
|
-
maxEmbeddingsPerCall?: number;
|
|
157
|
-
/**
|
|
158
|
-
Override the parallelism of embedding calls.
|
|
159
|
-
*/
|
|
160
|
-
supportsParallelCalls?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
The number of dimensions the resulting output embeddings should have.
|
|
163
|
-
Only supported in text-embedding-3 and later models.
|
|
164
|
-
*/
|
|
165
|
-
dimensions?: number;
|
|
166
|
-
/**
|
|
167
|
-
A unique identifier representing your end-user, which can help OpenAI to
|
|
168
|
-
monitor and detect abuse. Learn more.
|
|
169
|
-
*/
|
|
170
|
-
user?: string;
|
|
171
|
-
}
|
|
172
32
|
|
|
173
33
|
type OpenAIImageModelId = 'gpt-image-1' | 'dall-e-3' | 'dall-e-2' | (string & {});
|
|
174
|
-
interface OpenAIImageSettings {
|
|
175
|
-
/**
|
|
176
|
-
Override the maximum number of images per call (default is dependent on the
|
|
177
|
-
model, or 1 for an unknown model).
|
|
178
|
-
*/
|
|
179
|
-
maxImagesPerCall?: number;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
|
|
183
|
-
|
|
184
|
-
type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
185
34
|
|
|
186
35
|
declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
187
36
|
declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
|
|
@@ -203,50 +52,55 @@ declare const openaiTools: {
|
|
|
203
52
|
webSearchPreview: typeof webSearchPreviewTool;
|
|
204
53
|
};
|
|
205
54
|
|
|
55
|
+
type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
|
|
56
|
+
|
|
57
|
+
type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
58
|
+
|
|
206
59
|
type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string & {});
|
|
207
60
|
|
|
208
|
-
interface OpenAIProvider extends
|
|
209
|
-
(modelId: 'gpt-3.5-turbo-instruct'
|
|
210
|
-
(modelId: OpenAIChatModelId
|
|
61
|
+
interface OpenAIProvider extends ProviderV2 {
|
|
62
|
+
(modelId: 'gpt-3.5-turbo-instruct'): OpenAICompletionLanguageModel;
|
|
63
|
+
(modelId: OpenAIChatModelId): LanguageModelV2;
|
|
211
64
|
/**
|
|
212
65
|
Creates an OpenAI model for text generation.
|
|
213
66
|
*/
|
|
214
|
-
languageModel(modelId: 'gpt-3.5-turbo-instruct'
|
|
215
|
-
languageModel(modelId: OpenAIChatModelId
|
|
67
|
+
languageModel(modelId: 'gpt-3.5-turbo-instruct'): OpenAICompletionLanguageModel;
|
|
68
|
+
languageModel(modelId: OpenAIChatModelId): LanguageModelV2;
|
|
216
69
|
/**
|
|
217
70
|
Creates an OpenAI chat model for text generation.
|
|
218
71
|
*/
|
|
219
|
-
chat(modelId: OpenAIChatModelId
|
|
72
|
+
chat(modelId: OpenAIChatModelId): LanguageModelV2;
|
|
220
73
|
/**
|
|
221
74
|
Creates an OpenAI responses API model for text generation.
|
|
222
75
|
*/
|
|
223
|
-
responses(modelId: OpenAIResponsesModelId):
|
|
76
|
+
responses(modelId: OpenAIResponsesModelId): LanguageModelV2;
|
|
224
77
|
/**
|
|
225
78
|
Creates an OpenAI completion model for text generation.
|
|
226
79
|
*/
|
|
227
|
-
completion(modelId: OpenAICompletionModelId
|
|
80
|
+
completion(modelId: OpenAICompletionModelId): LanguageModelV2;
|
|
228
81
|
/**
|
|
229
82
|
Creates a model for text embeddings.
|
|
230
83
|
*/
|
|
231
|
-
embedding(modelId: OpenAIEmbeddingModelId
|
|
84
|
+
embedding(modelId: OpenAIEmbeddingModelId): EmbeddingModelV2<string>;
|
|
232
85
|
/**
|
|
233
86
|
Creates a model for text embeddings.
|
|
234
87
|
|
|
235
88
|
@deprecated Use `textEmbeddingModel` instead.
|
|
236
89
|
*/
|
|
237
|
-
textEmbedding(modelId: OpenAIEmbeddingModelId
|
|
90
|
+
textEmbedding(modelId: OpenAIEmbeddingModelId): EmbeddingModelV2<string>;
|
|
238
91
|
/**
|
|
239
92
|
Creates a model for text embeddings.
|
|
240
93
|
*/
|
|
241
|
-
textEmbeddingModel(modelId: OpenAIEmbeddingModelId
|
|
94
|
+
textEmbeddingModel(modelId: OpenAIEmbeddingModelId): EmbeddingModelV2<string>;
|
|
242
95
|
/**
|
|
243
96
|
Creates a model for image generation.
|
|
97
|
+
@deprecated Use `imageModel` instead.
|
|
244
98
|
*/
|
|
245
|
-
image(modelId: OpenAIImageModelId
|
|
99
|
+
image(modelId: OpenAIImageModelId): ImageModelV2;
|
|
246
100
|
/**
|
|
247
101
|
Creates a model for image generation.
|
|
248
102
|
*/
|
|
249
|
-
imageModel(modelId: OpenAIImageModelId
|
|
103
|
+
imageModel(modelId: OpenAIImageModelId): ImageModelV2;
|
|
250
104
|
/**
|
|
251
105
|
Creates a model for transcription.
|
|
252
106
|
*/
|
|
@@ -282,12 +136,6 @@ interface OpenAIProviderSettings {
|
|
|
282
136
|
*/
|
|
283
137
|
headers?: Record<string, string>;
|
|
284
138
|
/**
|
|
285
|
-
OpenAI compatibility mode. Should be set to `strict` when using the OpenAI API,
|
|
286
|
-
and `compatible` when using 3rd party providers. In `compatible` mode, newer
|
|
287
|
-
information such as streamOptions are not being sent. Defaults to 'compatible'.
|
|
288
|
-
*/
|
|
289
|
-
compatibility?: 'strict' | 'compatible';
|
|
290
|
-
/**
|
|
291
139
|
Provider name. Overrides the `openai` default name for 3rd party providers.
|
|
292
140
|
*/
|
|
293
141
|
name?: string;
|
|
@@ -302,7 +150,7 @@ Create an OpenAI provider instance.
|
|
|
302
150
|
*/
|
|
303
151
|
declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
|
|
304
152
|
/**
|
|
305
|
-
Default OpenAI provider instance.
|
|
153
|
+
Default OpenAI provider instance.
|
|
306
154
|
*/
|
|
307
155
|
declare const openai: OpenAIProvider;
|
|
308
156
|
|
|
@@ -318,20 +166,20 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
|
|
|
318
166
|
reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
319
167
|
}, "strip", z.ZodTypeAny, {
|
|
320
168
|
user?: string | null | undefined;
|
|
169
|
+
parallelToolCalls?: boolean | null | undefined;
|
|
170
|
+
reasoningEffort?: string | null | undefined;
|
|
321
171
|
store?: boolean | null | undefined;
|
|
322
172
|
metadata?: any;
|
|
323
|
-
reasoningEffort?: string | null | undefined;
|
|
324
|
-
parallelToolCalls?: boolean | null | undefined;
|
|
325
173
|
previousResponseId?: string | null | undefined;
|
|
326
174
|
strictSchemas?: boolean | null | undefined;
|
|
327
175
|
instructions?: string | null | undefined;
|
|
328
176
|
reasoningSummary?: string | null | undefined;
|
|
329
177
|
}, {
|
|
330
178
|
user?: string | null | undefined;
|
|
179
|
+
parallelToolCalls?: boolean | null | undefined;
|
|
180
|
+
reasoningEffort?: string | null | undefined;
|
|
331
181
|
store?: boolean | null | undefined;
|
|
332
182
|
metadata?: any;
|
|
333
|
-
reasoningEffort?: string | null | undefined;
|
|
334
|
-
parallelToolCalls?: boolean | null | undefined;
|
|
335
183
|
previousResponseId?: string | null | undefined;
|
|
336
184
|
strictSchemas?: boolean | null | undefined;
|
|
337
185
|
instructions?: string | null | undefined;
|