@ai-sdk/openai 4.0.0-beta.4 → 4.0.0-beta.40
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 +387 -22
- package/README.md +2 -0
- package/dist/index.d.ts +162 -45
- package/dist/index.js +2341 -1572
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +174 -51
- package/dist/internal/index.js +2110 -1593
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +274 -9
- package/package.json +13 -14
- package/src/chat/convert-openai-chat-usage.ts +2 -2
- package/src/chat/convert-to-openai-chat-messages.ts +33 -18
- package/src/chat/map-openai-finish-reason.ts +2 -2
- package/src/chat/openai-chat-language-model.ts +62 -158
- package/src/chat/openai-chat-options.ts +5 -0
- package/src/chat/openai-chat-prepare-tools.ts +6 -6
- package/src/completion/convert-openai-completion-usage.ts +2 -2
- package/src/completion/convert-to-openai-completion-prompt.ts +2 -2
- package/src/completion/map-openai-finish-reason.ts +2 -2
- package/src/completion/openai-completion-language-model.ts +40 -23
- package/src/embedding/openai-embedding-model.ts +23 -6
- package/src/files/openai-files-api.ts +17 -0
- package/src/files/openai-files-options.ts +18 -0
- package/src/files/openai-files.ts +102 -0
- package/src/image/openai-image-model.ts +28 -11
- package/src/image/openai-image-options.ts +3 -0
- package/src/index.ts +2 -0
- package/src/openai-config.ts +6 -6
- package/src/openai-language-model-capabilities.ts +3 -2
- package/src/openai-provider.ts +54 -21
- package/src/openai-tools.ts +12 -1
- package/src/responses/convert-openai-responses-usage.ts +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +194 -39
- package/src/responses/map-openai-responses-finish-reason.ts +2 -2
- package/src/responses/openai-responses-api.ts +136 -2
- package/src/responses/openai-responses-language-model.ts +252 -39
- package/src/responses/openai-responses-options.ts +24 -2
- package/src/responses/openai-responses-prepare-tools.ts +47 -14
- package/src/responses/openai-responses-provider-metadata.ts +10 -0
- package/src/skills/openai-skills-api.ts +31 -0
- package/src/skills/openai-skills.ts +87 -0
- package/src/speech/openai-speech-model.ts +25 -8
- package/src/tool/apply-patch.ts +33 -32
- package/src/tool/code-interpreter.ts +40 -41
- package/src/tool/custom.ts +2 -8
- package/src/tool/file-search.ts +2 -2
- package/src/tool/image-generation.ts +2 -2
- package/src/tool/local-shell.ts +2 -2
- package/src/tool/mcp.ts +2 -2
- package/src/tool/shell.ts +9 -4
- package/src/tool/tool-search.ts +98 -0
- package/src/tool/web-search-preview.ts +2 -2
- package/src/tool/web-search.ts +2 -2
- package/src/transcription/openai-transcription-model.ts +26 -9
- package/dist/index.d.mts +0 -1107
- package/dist/index.mjs +0 -6508
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -1137
- package/dist/internal/index.mjs +0 -6321
- package/dist/internal/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,370 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.40
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
8
|
+
- Updated dependencies [9f0e36c]
|
|
9
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
11
|
+
|
|
12
|
+
## 4.0.0-beta.39
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 58a2ad7: fix: more precise default message for tool execution denial
|
|
17
|
+
- f9acbc0: feat(provider/openai): add gpt-image-2 model support
|
|
18
|
+
- Updated dependencies [785fe16]
|
|
19
|
+
- Updated dependencies [67df0a0]
|
|
20
|
+
- Updated dependencies [befb78c]
|
|
21
|
+
- Updated dependencies [0458559]
|
|
22
|
+
- Updated dependencies [5852c0a]
|
|
23
|
+
- Updated dependencies [fc92055]
|
|
24
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
25
|
+
|
|
26
|
+
## 4.0.0-beta.38
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- bfb756d: patch - send content: null instead of empty string for tool-only assistant messages
|
|
31
|
+
- Updated dependencies [2e98477]
|
|
32
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
33
|
+
|
|
34
|
+
## 4.0.0-beta.37
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [eea8d98]
|
|
39
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
40
|
+
|
|
41
|
+
## 4.0.0-beta.36
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- f807e45: Extract shared `StreamingToolCallTracker` class into `@ai-sdk/provider-utils` to deduplicate streaming tool call handling across OpenAI-compatible providers. Also adds missing `generateId()` fallback for `toolCallId` in Alibaba's `doGenerate` path and ensures all providers finalize unfinished tool calls during stream flush.
|
|
46
|
+
- Updated dependencies [f807e45]
|
|
47
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
48
|
+
|
|
49
|
+
## 4.0.0-beta.35
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [350ea38]
|
|
54
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
55
|
+
|
|
56
|
+
## 4.0.0-beta.34
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [083947b]
|
|
61
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
62
|
+
|
|
63
|
+
## 4.0.0-beta.33
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [add1126]
|
|
68
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
69
|
+
|
|
70
|
+
## 4.0.0-beta.32
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 0c4ac8a: fix(openai): default undefined tool-call input to empty object before serializing tool arguments
|
|
75
|
+
|
|
76
|
+
## 4.0.0-beta.31
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
81
|
+
|
|
82
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
83
|
+
|
|
84
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
85
|
+
|
|
86
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
87
|
+
|
|
88
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
89
|
+
- Updated dependencies [b3976a2]
|
|
90
|
+
- Updated dependencies [ff5eba1]
|
|
91
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
92
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
93
|
+
|
|
94
|
+
## 4.0.0-beta.30
|
|
95
|
+
|
|
96
|
+
### Major Changes
|
|
97
|
+
|
|
98
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [ef992f8]
|
|
103
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
104
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
105
|
+
|
|
106
|
+
## 4.0.0-beta.29
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
111
|
+
- Updated dependencies [90e2d8a]
|
|
112
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
113
|
+
|
|
114
|
+
## 4.0.0-beta.28
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [3ae1786]
|
|
119
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
120
|
+
|
|
121
|
+
## 4.0.0-beta.27
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies [176466a]
|
|
126
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
127
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
128
|
+
|
|
129
|
+
## 4.0.0-beta.26
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
|
|
134
|
+
- Updated dependencies [e311194]
|
|
135
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
136
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
137
|
+
|
|
138
|
+
## 4.0.0-beta.25
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
|
|
143
|
+
- Updated dependencies [34bd95d]
|
|
144
|
+
- Updated dependencies [008271d]
|
|
145
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
146
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
147
|
+
|
|
148
|
+
## 4.0.0-beta.24
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [b0c2869]
|
|
153
|
+
- Updated dependencies [7e26e81]
|
|
154
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
155
|
+
|
|
156
|
+
## 4.0.0-beta.23
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [46d1149]
|
|
161
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
162
|
+
|
|
163
|
+
## 4.0.0-beta.22
|
|
164
|
+
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
|
|
168
|
+
- Updated dependencies [6fd51c0]
|
|
169
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
170
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
171
|
+
|
|
172
|
+
## 4.0.0-beta.21
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
177
|
+
- Updated dependencies [c29a26f]
|
|
178
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
179
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
180
|
+
|
|
181
|
+
## 4.0.0-beta.20
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
186
|
+
|
|
187
|
+
## 4.0.0-beta.19
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- Updated dependencies [2e17091]
|
|
192
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
193
|
+
|
|
194
|
+
## 4.0.0-beta.18
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- Updated dependencies [986c6fd]
|
|
199
|
+
- Updated dependencies [493295c]
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
201
|
+
|
|
202
|
+
## 4.0.0-beta.17
|
|
203
|
+
|
|
204
|
+
### Patch Changes
|
|
205
|
+
|
|
206
|
+
- 817a1a6: fix(openai): support file-url parts in tool output content
|
|
207
|
+
|
|
208
|
+
## 4.0.0-beta.16
|
|
209
|
+
|
|
210
|
+
### Patch Changes
|
|
211
|
+
|
|
212
|
+
- 1f509d4: fix(ai): force template check on 'kind' param
|
|
213
|
+
- Updated dependencies [1f509d4]
|
|
214
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
215
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
216
|
+
|
|
217
|
+
## 4.0.0-beta.15
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- 365da1a: Add `gpt-5.4-mini`, `gpt-5.4-mini-2026-03-17`, `gpt-5.4-nano`, and `gpt-5.4-nano-2026-03-17` models.
|
|
222
|
+
|
|
223
|
+
## 4.0.0-beta.14
|
|
224
|
+
|
|
225
|
+
### Patch Changes
|
|
226
|
+
|
|
227
|
+
- e6376c2: fix(openai): preserve raw finish reason for failed responses stream events
|
|
228
|
+
|
|
229
|
+
Handle `response.failed` chunks in Responses API streaming so `finishReason.raw` is preserved from `incomplete_details.reason` (e.g. `max_output_tokens`), and map failed-without-reason cases to unified `error` instead of `other`.
|
|
230
|
+
|
|
231
|
+
## 4.0.0-beta.13
|
|
232
|
+
|
|
233
|
+
### Patch Changes
|
|
234
|
+
|
|
235
|
+
- 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
|
|
236
|
+
- Updated dependencies [3887c70]
|
|
237
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
238
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
239
|
+
|
|
240
|
+
## 4.0.0-beta.12
|
|
241
|
+
|
|
242
|
+
### Patch Changes
|
|
243
|
+
|
|
244
|
+
- d9a1e9a: feat(openai): add server side compaction for openai
|
|
245
|
+
|
|
246
|
+
## 4.0.0-beta.11
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- Updated dependencies [776b617]
|
|
251
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
252
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
253
|
+
|
|
254
|
+
## 4.0.0-beta.10
|
|
255
|
+
|
|
256
|
+
### Major Changes
|
|
257
|
+
|
|
258
|
+
- 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
|
|
259
|
+
|
|
260
|
+
`openai.tools.customTool()` no longer accepts a `name` field. the tool name is now derived from the sdk tool key (the object key in the `tools` object).
|
|
261
|
+
|
|
262
|
+
migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
|
|
263
|
+
|
|
264
|
+
before:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
tools: {
|
|
268
|
+
write_sql: openai.tools.customTool({
|
|
269
|
+
name: 'write_sql',
|
|
270
|
+
description: '...',
|
|
271
|
+
}),
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
after:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
tools: {
|
|
279
|
+
write_sql: openai.tools.customTool({
|
|
280
|
+
description: '...',
|
|
281
|
+
}),
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
|
|
286
|
+
|
|
287
|
+
before: tool name can be set dynamically
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
const toolNameMapping = createToolNameMapping({
|
|
291
|
+
tools,
|
|
292
|
+
providerToolNames: {
|
|
293
|
+
"openai.code_interpreter": "code_interpreter",
|
|
294
|
+
"openai.file_search": "file_search",
|
|
295
|
+
"openai.image_generation": "image_generation",
|
|
296
|
+
"openai.local_shell": "local_shell",
|
|
297
|
+
"openai.shell": "shell",
|
|
298
|
+
"openai.web_search": "web_search",
|
|
299
|
+
"openai.web_search_preview": "web_search_preview",
|
|
300
|
+
"openai.mcp": "mcp",
|
|
301
|
+
"openai.apply_patch": "apply_patch",
|
|
302
|
+
},
|
|
303
|
+
resolveProviderToolName: (tool) =>
|
|
304
|
+
tool.id === "openai.custom"
|
|
305
|
+
? (tool.args as { name?: string }).name
|
|
306
|
+
: undefined,
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
after: tool name is static based on `tools` keys
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
const toolNameMapping = createToolNameMapping({
|
|
314
|
+
tools,
|
|
315
|
+
providerToolNames: {
|
|
316
|
+
'openai.code_interpreter': 'code_interpreter',
|
|
317
|
+
'openai.file_search': 'file_search',
|
|
318
|
+
'openai.image_generation': 'image_generation',
|
|
319
|
+
'openai.local_shell': 'local_shell',
|
|
320
|
+
'openai.shell': 'shell',
|
|
321
|
+
'openai.web_search': 'web_search',
|
|
322
|
+
'openai.web_search_preview': 'web_search_preview',
|
|
323
|
+
'openai.mcp': 'mcp',
|
|
324
|
+
'openai.apply_patch': 'apply_patch',
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Patch Changes
|
|
330
|
+
|
|
331
|
+
- Updated dependencies [61753c3]
|
|
332
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
333
|
+
|
|
334
|
+
## 4.0.0-beta.9
|
|
335
|
+
|
|
336
|
+
### Patch Changes
|
|
337
|
+
|
|
338
|
+
- 156cdf0: feat(openai): add new tool search tool
|
|
339
|
+
|
|
340
|
+
## 4.0.0-beta.8
|
|
341
|
+
|
|
342
|
+
### Patch Changes
|
|
343
|
+
|
|
344
|
+
- Updated dependencies [f7d4f01]
|
|
345
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
346
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
347
|
+
|
|
348
|
+
## 4.0.0-beta.7
|
|
349
|
+
|
|
350
|
+
### Patch Changes
|
|
351
|
+
|
|
352
|
+
- Updated dependencies [5c2a5a2]
|
|
353
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
354
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
355
|
+
|
|
356
|
+
## 4.0.0-beta.6
|
|
357
|
+
|
|
358
|
+
### Patch Changes
|
|
359
|
+
|
|
360
|
+
- 83f9d04: feat(openai): upgrade v3 specs to v4
|
|
361
|
+
|
|
362
|
+
## 4.0.0-beta.5
|
|
363
|
+
|
|
364
|
+
### Patch Changes
|
|
365
|
+
|
|
366
|
+
- ac18f89: feat(provider/openai): add `gpt-5.3-chat-latest`
|
|
367
|
+
|
|
3
368
|
## 4.0.0-beta.4
|
|
4
369
|
|
|
5
370
|
### Patch Changes
|
|
@@ -376,13 +741,13 @@
|
|
|
376
741
|
Before
|
|
377
742
|
|
|
378
743
|
```ts
|
|
379
|
-
model.textEmbeddingModel(
|
|
744
|
+
model.textEmbeddingModel("my-model-id");
|
|
380
745
|
```
|
|
381
746
|
|
|
382
747
|
After
|
|
383
748
|
|
|
384
749
|
```ts
|
|
385
|
-
model.embeddingModel(
|
|
750
|
+
model.embeddingModel("my-model-id");
|
|
386
751
|
```
|
|
387
752
|
|
|
388
753
|
- 60f4775: fix: remove code for unsuported o1-mini and o1-preview models
|
|
@@ -392,15 +757,15 @@
|
|
|
392
757
|
- 2e86082: feat(provider/openai): `OpenAIChatLanguageModelOptions` type
|
|
393
758
|
|
|
394
759
|
```ts
|
|
395
|
-
import { openai, type OpenAIChatLanguageModelOptions } from
|
|
396
|
-
import { generateText } from
|
|
760
|
+
import { openai, type OpenAIChatLanguageModelOptions } from "@ai-sdk/openai";
|
|
761
|
+
import { generateText } from "ai";
|
|
397
762
|
|
|
398
763
|
await generateText({
|
|
399
|
-
model: openai.chat(
|
|
400
|
-
prompt:
|
|
764
|
+
model: openai.chat("gpt-4o"),
|
|
765
|
+
prompt: "Invent a new holiday and describe its traditions.",
|
|
401
766
|
providerOptions: {
|
|
402
767
|
openai: {
|
|
403
|
-
user:
|
|
768
|
+
user: "user-123",
|
|
404
769
|
} satisfies OpenAIChatLanguageModelOptions,
|
|
405
770
|
},
|
|
406
771
|
});
|
|
@@ -801,13 +1166,13 @@
|
|
|
801
1166
|
Before
|
|
802
1167
|
|
|
803
1168
|
```ts
|
|
804
|
-
model.textEmbeddingModel(
|
|
1169
|
+
model.textEmbeddingModel("my-model-id");
|
|
805
1170
|
```
|
|
806
1171
|
|
|
807
1172
|
After
|
|
808
1173
|
|
|
809
1174
|
```ts
|
|
810
|
-
model.embeddingModel(
|
|
1175
|
+
model.embeddingModel("my-model-id");
|
|
811
1176
|
```
|
|
812
1177
|
|
|
813
1178
|
- Updated dependencies [8d9e8ad]
|
|
@@ -1277,15 +1642,15 @@
|
|
|
1277
1642
|
- 2e86082: feat(provider/openai): `OpenAIChatLanguageModelOptions` type
|
|
1278
1643
|
|
|
1279
1644
|
```ts
|
|
1280
|
-
import { openai, type OpenAIChatLanguageModelOptions } from
|
|
1281
|
-
import { generateText } from
|
|
1645
|
+
import { openai, type OpenAIChatLanguageModelOptions } from "@ai-sdk/openai";
|
|
1646
|
+
import { generateText } from "ai";
|
|
1282
1647
|
|
|
1283
1648
|
await generateText({
|
|
1284
|
-
model: openai.chat(
|
|
1285
|
-
prompt:
|
|
1649
|
+
model: openai.chat("gpt-4o"),
|
|
1650
|
+
prompt: "Invent a new holiday and describe its traditions.",
|
|
1286
1651
|
providerOptions: {
|
|
1287
1652
|
openai: {
|
|
1288
|
-
user:
|
|
1653
|
+
user: "user-123",
|
|
1289
1654
|
} satisfies OpenAIChatLanguageModelOptions,
|
|
1290
1655
|
},
|
|
1291
1656
|
});
|
|
@@ -1581,7 +1946,7 @@
|
|
|
1581
1946
|
|
|
1582
1947
|
```js
|
|
1583
1948
|
await generateImage({
|
|
1584
|
-
model: luma.image(
|
|
1949
|
+
model: luma.image("photon-flash-1", {
|
|
1585
1950
|
maxImagesPerCall: 5,
|
|
1586
1951
|
pollIntervalMillis: 500,
|
|
1587
1952
|
}),
|
|
@@ -1594,7 +1959,7 @@
|
|
|
1594
1959
|
|
|
1595
1960
|
```js
|
|
1596
1961
|
await generateImage({
|
|
1597
|
-
model: luma.image(
|
|
1962
|
+
model: luma.image("photon-flash-1"),
|
|
1598
1963
|
prompt,
|
|
1599
1964
|
n: 10,
|
|
1600
1965
|
maxImagesPerCall: 5,
|
|
@@ -1656,10 +2021,10 @@
|
|
|
1656
2021
|
The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models.
|
|
1657
2022
|
|
|
1658
2023
|
```js
|
|
1659
|
-
const prompt =
|
|
2024
|
+
const prompt = "Santa Claus driving a Cadillac";
|
|
1660
2025
|
|
|
1661
2026
|
const { providerMetadata } = await experimental_generateImage({
|
|
1662
|
-
model: openai.image(
|
|
2027
|
+
model: openai.image("dall-e-3"),
|
|
1663
2028
|
prompt,
|
|
1664
2029
|
});
|
|
1665
2030
|
|
|
@@ -1958,7 +2323,7 @@
|
|
|
1958
2323
|
|
|
1959
2324
|
```js
|
|
1960
2325
|
await generateImage({
|
|
1961
|
-
model: luma.image(
|
|
2326
|
+
model: luma.image("photon-flash-1", {
|
|
1962
2327
|
maxImagesPerCall: 5,
|
|
1963
2328
|
pollIntervalMillis: 500,
|
|
1964
2329
|
}),
|
|
@@ -1971,7 +2336,7 @@
|
|
|
1971
2336
|
|
|
1972
2337
|
```js
|
|
1973
2338
|
await generateImage({
|
|
1974
|
-
model: luma.image(
|
|
2339
|
+
model: luma.image("photon-flash-1"),
|
|
1975
2340
|
prompt,
|
|
1976
2341
|
n: 10,
|
|
1977
2342
|
maxImagesPerCall: 5,
|
|
@@ -2016,10 +2381,10 @@
|
|
|
2016
2381
|
The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models.
|
|
2017
2382
|
|
|
2018
2383
|
```js
|
|
2019
|
-
const prompt =
|
|
2384
|
+
const prompt = "Santa Claus driving a Cadillac";
|
|
2020
2385
|
|
|
2021
2386
|
const { providerMetadata } = await experimental_generateImage({
|
|
2022
|
-
model: openai.image(
|
|
2387
|
+
model: openai.image("dall-e-3"),
|
|
2023
2388
|
prompt,
|
|
2024
2389
|
});
|
|
2025
2390
|
|
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
The **[OpenAI provider](https://ai-sdk.dev/providers/ai-sdk-providers/openai)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
4
|
contains language model support for the OpenAI chat and completion APIs and embedding model support for the OpenAI embeddings API.
|
|
5
5
|
|
|
6
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access OpenAI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
The OpenAI provider is available in the `@ai-sdk/openai` module. You can install it with
|