@ai-sdk/openai 4.0.73 → 4.0.75
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 +17 -0
- package/README.md +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1384 -1315
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +1573 -1504
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +156 -93
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/responses/convert-to-openai-responses-input.ts +39 -0
- package/src/responses/openai-responses-api.ts +1 -1
- package/src/responses/openai-responses-language-model-options.ts +22 -0
- package/src/responses/openai-responses-language-model.ts +77 -25
- package/src/responses/openai-responses-prepare-tools.ts +0 -1
package/docs/03-openai.mdx
CHANGED
|
@@ -80,14 +80,14 @@ You can use the following optional settings to customize the OpenAI provider ins
|
|
|
80
80
|
The OpenAI provider instance is a function that you can invoke to create a language model:
|
|
81
81
|
|
|
82
82
|
```ts
|
|
83
|
-
const model = openai('gpt-
|
|
83
|
+
const model = openai('gpt-6-astra');
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
It automatically selects the correct API based on the model id.
|
|
87
87
|
You can also pass additional settings in the second argument:
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
|
-
const model = openai('gpt-
|
|
90
|
+
const model = openai('gpt-6-astra', {
|
|
91
91
|
// additional settings
|
|
92
92
|
});
|
|
93
93
|
```
|
|
@@ -109,7 +109,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
109
109
|
import { generateText } from 'ai';
|
|
110
110
|
|
|
111
111
|
const { text } = await generateText({
|
|
112
|
-
model: openai('gpt-
|
|
112
|
+
model: openai('gpt-6-astra'),
|
|
113
113
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
114
114
|
});
|
|
115
115
|
```
|
|
@@ -123,7 +123,7 @@ and support structured data generation with [`Output`](/docs/reference/ai-sdk-co
|
|
|
123
123
|
You can use the OpenAI responses API with the `openai(modelId)` or `openai.responses(modelId)` factory methods. It is the default API that is used by the OpenAI provider (since AI SDK 5).
|
|
124
124
|
|
|
125
125
|
```ts
|
|
126
|
-
const model = openai('gpt-
|
|
126
|
+
const model = openai('gpt-6-astra');
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
Further configuration can be done using OpenAI provider options.
|
|
@@ -134,7 +134,7 @@ import { openai, OpenAILanguageModelResponsesOptions } from '@ai-sdk/openai';
|
|
|
134
134
|
import { generateText } from 'ai';
|
|
135
135
|
|
|
136
136
|
const result = await generateText({
|
|
137
|
-
model: openai('gpt-
|
|
137
|
+
model: openai('gpt-6-astra'), // or openai.responses('gpt-6-astra')
|
|
138
138
|
providerOptions: {
|
|
139
139
|
openai: {
|
|
140
140
|
parallelToolCalls: false,
|
|
@@ -292,7 +292,7 @@ import { openai, type OpenaiResponsesProviderMetadata } from '@ai-sdk/openai';
|
|
|
292
292
|
import { generateText } from 'ai';
|
|
293
293
|
|
|
294
294
|
const result = await generateText({
|
|
295
|
-
model: openai('gpt-
|
|
295
|
+
model: openai('gpt-6-astra'),
|
|
296
296
|
});
|
|
297
297
|
|
|
298
298
|
const providerMetadata = result.providerMetadata as
|
|
@@ -319,58 +319,121 @@ The following OpenAI-specific metadata may be returned:
|
|
|
319
319
|
|
|
320
320
|
#### Changing Reasoning Effort Mid-Conversation
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
`reasoningEffortUpdate` as an OpenAI `configuration_update` input item before
|
|
325
|
-
the next user message. Keeping the request-level effort unchanged preserves the
|
|
326
|
-
original prompt prefix for prompt caching.
|
|
322
|
+
You can increase reasoning effort for difficult work or reduce it for routine
|
|
323
|
+
follow-ups while preserving the conversation prefix for prompt caching:
|
|
327
324
|
|
|
328
|
-
|
|
325
|
+
- Set the initial effort with request-level `reasoning` and keep that setting
|
|
326
|
+
unchanged throughout the conversation.
|
|
327
|
+
- For later changes, add a message-level `reasoningEffortUpdate` before the next
|
|
328
|
+
user message, following
|
|
329
|
+
[OpenAI's configuration update guidance](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation).
|
|
330
|
+
|
|
331
|
+
The new effort applies until another update changes it. When sending conversation
|
|
332
|
+
history in `messages`, include earlier effort updates along with the other messages.
|
|
333
|
+
|
|
334
|
+
Represent an update as an empty system message with
|
|
335
|
+
`providerOptions.openai.reasoningEffortUpdate`.
|
|
336
|
+
|
|
337
|
+
You **must** set `allowSystemInMessages: true` to allow these trusted system messages.
|
|
338
|
+
|
|
339
|
+
In this example, the conversation starts at low effort and switches to high
|
|
340
|
+
effort for the follow-up. Both requests keep `reasoning: 'low'`.
|
|
341
|
+
|
|
342
|
+
```ts
|
|
329
343
|
import {
|
|
330
344
|
openai,
|
|
331
|
-
type
|
|
332
|
-
type OpenaiResponsesProviderMetadata,
|
|
345
|
+
type OpenAIResponsesSystemMessageOptions,
|
|
333
346
|
} from '@ai-sdk/openai';
|
|
334
|
-
import { generateText } from 'ai';
|
|
347
|
+
import { generateText, type ModelMessage } from 'ai';
|
|
348
|
+
|
|
349
|
+
const messages: ModelMessage[] = [
|
|
350
|
+
{ role: 'user', content: 'Draft a migration plan.' },
|
|
351
|
+
];
|
|
335
352
|
|
|
336
353
|
const first = await generateText({
|
|
337
354
|
model: openai.responses('gpt-6-astra'),
|
|
338
355
|
reasoning: 'low',
|
|
339
|
-
|
|
356
|
+
messages,
|
|
340
357
|
});
|
|
341
358
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
359
|
+
messages.push(...first.responseMessages);
|
|
360
|
+
messages.push(
|
|
361
|
+
{
|
|
362
|
+
role: 'system',
|
|
363
|
+
content: '',
|
|
364
|
+
providerOptions: {
|
|
365
|
+
openai: {
|
|
366
|
+
reasoningEffortUpdate: 'high',
|
|
367
|
+
} satisfies OpenAIResponsesSystemMessageOptions,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{ role: 'user', content: 'Analyze the failure modes.' },
|
|
371
|
+
);
|
|
350
372
|
|
|
351
373
|
const second = await generateText({
|
|
352
374
|
model: openai.responses('gpt-6-astra'),
|
|
353
375
|
reasoning: 'low',
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
openai: {
|
|
357
|
-
previousResponseId,
|
|
358
|
-
reasoningEffortUpdate: 'high',
|
|
359
|
-
} satisfies OpenAILanguageModelResponsesOptions,
|
|
360
|
-
},
|
|
376
|
+
allowSystemInMessages: true,
|
|
377
|
+
messages,
|
|
361
378
|
});
|
|
379
|
+
|
|
380
|
+
messages.push(...second.responseMessages);
|
|
362
381
|
```
|
|
363
382
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
383
|
+
<Note>
|
|
384
|
+
The OpenAI Responses provider sends each message-level effort update as a
|
|
385
|
+
`configuration_update` input item.
|
|
386
|
+
</Note>
|
|
387
|
+
|
|
388
|
+
Message-level updates also work with `streamText` and `previousResponseId`.
|
|
389
|
+
|
|
390
|
+
##### Restrictions
|
|
391
|
+
|
|
392
|
+
Effort updates are supported on GPT-6-family models with these settings:
|
|
393
|
+
|
|
394
|
+
| Setting | Required value |
|
|
395
|
+
| ------------------- | ---------------------- |
|
|
396
|
+
| `reasoningMode` | `'standard'` (default) |
|
|
397
|
+
| `contextManagement` | Omitted |
|
|
398
|
+
| `truncation` | `'disabled'` (default) |
|
|
399
|
+
|
|
400
|
+
- Each update **must** use exactly `content: ''`.
|
|
401
|
+
- Updates cannot be consecutive, even with the same effort. This also applies
|
|
402
|
+
across the boundary with history referenced by previousResponseId or
|
|
403
|
+
conversation.
|
|
404
|
+
|
|
405
|
+
Requests that violate these restrictions are rejected.
|
|
406
|
+
|
|
407
|
+
<Note>
|
|
408
|
+
Effort update messages are sent even if `systemMessageMode` is set to
|
|
409
|
+
`remove`.
|
|
410
|
+
</Note>
|
|
411
|
+
|
|
412
|
+
##### Compaction
|
|
413
|
+
|
|
414
|
+
**Effort updates are incompatible with automatic compaction through
|
|
415
|
+
`providerOptions.openai.contextManagement` or compaction through OpenAI's
|
|
416
|
+
`/responses/compact` endpoint.**
|
|
417
|
+
|
|
418
|
+
To compact conversations containing effort updates, use [explicit
|
|
419
|
+
compaction](#explicit-compaction) with
|
|
420
|
+
`providerOptions.openai.compactionTrigger`.
|
|
421
|
+
|
|
422
|
+
After compaction, add a fresh effort update before the next user message,
|
|
423
|
+
[as OpenAI recommends](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation). Keep request-level `reasoning` unchanged.
|
|
424
|
+
|
|
425
|
+
##### Request-Level Update Option
|
|
426
|
+
|
|
427
|
+
The request-level `providerOptions.openai.reasoningEffortUpdate` option is a
|
|
428
|
+
convenience that prepends a configuration update to the input. When using
|
|
429
|
+
message-level updates, omit this option.
|
|
430
|
+
|
|
431
|
+
The request-level option continues to warn and omit updates for unsupported
|
|
432
|
+
models or configurations.
|
|
370
433
|
|
|
371
434
|
#### Reasoning Output
|
|
372
435
|
|
|
373
|
-
For reasoning models like `gpt-
|
|
436
|
+
For reasoning models like `gpt-6-astra`, you can enable reasoning summaries to see the model's thought process. Different models support different summarizers—for example, `o4-mini` supports detailed summaries. Set `reasoningSummary: "auto"` to automatically receive the richest level available. When `reasoningEffort` is set to a value other than `'none'`, the OpenAI Responses provider defaults `reasoningSummary` to `'detailed'`; set `reasoningSummary: null` to omit reasoning summaries.
|
|
374
437
|
|
|
375
438
|
```ts highlight="10-14,17-23"
|
|
376
439
|
import {
|
|
@@ -380,7 +443,7 @@ import {
|
|
|
380
443
|
import { streamText } from 'ai';
|
|
381
444
|
|
|
382
445
|
const result = streamText({
|
|
383
|
-
model: openai('gpt-
|
|
446
|
+
model: openai('gpt-6-astra'),
|
|
384
447
|
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
|
|
385
448
|
providerOptions: {
|
|
386
449
|
openai: {
|
|
@@ -408,7 +471,7 @@ import {
|
|
|
408
471
|
import { generateText } from 'ai';
|
|
409
472
|
|
|
410
473
|
const result = await generateText({
|
|
411
|
-
model: openai('gpt-
|
|
474
|
+
model: openai('gpt-6-astra'),
|
|
412
475
|
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
|
|
413
476
|
providerOptions: {
|
|
414
477
|
openai: {
|
|
@@ -445,7 +508,7 @@ const wsFetch = createWebSocketFetch();
|
|
|
445
508
|
const openai = createOpenAI({ fetch: wsFetch });
|
|
446
509
|
|
|
447
510
|
const result = streamText({
|
|
448
|
-
model: openai('gpt-
|
|
511
|
+
model: openai('gpt-6-luna'),
|
|
449
512
|
prompt: 'Hello!',
|
|
450
513
|
tools: {
|
|
451
514
|
// ...
|
|
@@ -481,7 +544,7 @@ import {
|
|
|
481
544
|
import { generateText } from 'ai';
|
|
482
545
|
|
|
483
546
|
const result = await generateText({
|
|
484
|
-
model: openai('gpt-
|
|
547
|
+
model: openai('gpt-6-luna'),
|
|
485
548
|
prompt: 'Write a poem about a boy and his first pet dog.',
|
|
486
549
|
providerOptions: {
|
|
487
550
|
openai: {
|
|
@@ -591,7 +654,7 @@ import { generateText, isStepCount, tool } from 'ai';
|
|
|
591
654
|
import { z } from 'zod';
|
|
592
655
|
|
|
593
656
|
const result = await generateText({
|
|
594
|
-
model: openai('gpt-
|
|
657
|
+
model: openai('gpt-6-astra'),
|
|
595
658
|
stopWhen: isStepCount(10),
|
|
596
659
|
prompt: 'Compare inventory with demand for sku_123.',
|
|
597
660
|
tools: {
|
|
@@ -646,7 +709,7 @@ The OpenAI responses API supports web search through the `openai.tools.webSearch
|
|
|
646
709
|
|
|
647
710
|
```ts
|
|
648
711
|
const result = await generateText({
|
|
649
|
-
model: openai('gpt-
|
|
712
|
+
model: openai('gpt-6-astra'),
|
|
650
713
|
prompt: 'What happened in San Francisco last week?',
|
|
651
714
|
tools: {
|
|
652
715
|
web_search: openai.tools.webSearch({
|
|
@@ -702,7 +765,7 @@ You can force the use of the file search tool by setting the `toolChoice` parame
|
|
|
702
765
|
|
|
703
766
|
```ts
|
|
704
767
|
const result = await generateText({
|
|
705
|
-
model: openai('gpt-
|
|
768
|
+
model: openai('gpt-6-astra'),
|
|
706
769
|
prompt: 'What does the document say about user authentication?',
|
|
707
770
|
tools: {
|
|
708
771
|
file_search: openai.tools.fileSearch({
|
|
@@ -784,7 +847,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
784
847
|
import { generateText } from 'ai';
|
|
785
848
|
|
|
786
849
|
const result = await generateText({
|
|
787
|
-
model: openai('gpt-
|
|
850
|
+
model: openai('gpt-6-astra'),
|
|
788
851
|
prompt:
|
|
789
852
|
'Generate an image of an echidna swimming across the Mozambique channel.',
|
|
790
853
|
tools: {
|
|
@@ -804,7 +867,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
804
867
|
import { streamText } from 'ai';
|
|
805
868
|
|
|
806
869
|
const result = streamText({
|
|
807
|
-
model: openai('gpt-
|
|
870
|
+
model: openai('gpt-6-astra'),
|
|
808
871
|
prompt:
|
|
809
872
|
'Generate an image of an echidna swimming across the Mozambique channel.',
|
|
810
873
|
tools: {
|
|
@@ -854,7 +917,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
854
917
|
import { generateText } from 'ai';
|
|
855
918
|
|
|
856
919
|
const result = await generateText({
|
|
857
|
-
model: openai('gpt-
|
|
920
|
+
model: openai('gpt-6-astra'),
|
|
858
921
|
prompt: 'Write and run Python code to calculate the factorial of 10',
|
|
859
922
|
tools: {
|
|
860
923
|
code_interpreter: openai.tools.codeInterpreter({
|
|
@@ -887,7 +950,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
887
950
|
import { generateText } from 'ai';
|
|
888
951
|
|
|
889
952
|
const result = await generateText({
|
|
890
|
-
model: openai('gpt-
|
|
953
|
+
model: openai('gpt-6-astra'),
|
|
891
954
|
prompt: 'Search the web for the latest news about AI developments',
|
|
892
955
|
tools: {
|
|
893
956
|
mcp: openai.tools.mcp({
|
|
@@ -979,7 +1042,7 @@ import { generateText, isStepCount } from 'ai';
|
|
|
979
1042
|
import { captureScreenshot, executeComputerAction } from '@/utils/computer-use';
|
|
980
1043
|
|
|
981
1044
|
const result = await generateText({
|
|
982
|
-
model: openai.responses('gpt-
|
|
1045
|
+
model: openai.responses('gpt-6-astra'),
|
|
983
1046
|
tools: {
|
|
984
1047
|
computer: openai.tools.computer({
|
|
985
1048
|
needsApproval: ({ pendingSafetyChecks }) =>
|
|
@@ -1101,7 +1164,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
1101
1164
|
import { generateText } from 'ai';
|
|
1102
1165
|
|
|
1103
1166
|
const result = await generateText({
|
|
1104
|
-
model: openai('gpt-
|
|
1167
|
+
model: openai('gpt-6-astra'),
|
|
1105
1168
|
tools: {
|
|
1106
1169
|
shell: openai.tools.shell({
|
|
1107
1170
|
execute: async ({ action }) => {
|
|
@@ -1120,7 +1183,7 @@ Set `environment.type` to `'containerAuto'` to run commands in an OpenAI-hosted
|
|
|
1120
1183
|
|
|
1121
1184
|
```ts
|
|
1122
1185
|
const result = await generateText({
|
|
1123
|
-
model: openai('gpt-
|
|
1186
|
+
model: openai('gpt-6-astra'),
|
|
1124
1187
|
tools: {
|
|
1125
1188
|
shell: openai.tools.shell({
|
|
1126
1189
|
environment: {
|
|
@@ -1153,7 +1216,7 @@ Set `environment.type` to `'containerReference'` to use an existing container by
|
|
|
1153
1216
|
|
|
1154
1217
|
```ts
|
|
1155
1218
|
const result = await generateText({
|
|
1156
|
-
model: openai('gpt-
|
|
1219
|
+
model: openai('gpt-6-astra'),
|
|
1157
1220
|
tools: {
|
|
1158
1221
|
shell: openai.tools.shell({
|
|
1159
1222
|
environment: {
|
|
@@ -1182,7 +1245,7 @@ For local execution (default or `type: 'local'`), your execute function must ret
|
|
|
1182
1245
|
|
|
1183
1246
|
```ts
|
|
1184
1247
|
const result = await generateText({
|
|
1185
|
-
model: openai('gpt-
|
|
1248
|
+
model: openai('gpt-6-astra'),
|
|
1186
1249
|
tools: {
|
|
1187
1250
|
shell: openai.tools.shell({
|
|
1188
1251
|
environment: {
|
|
@@ -1213,7 +1276,7 @@ const result = await generateText({
|
|
|
1213
1276
|
|
|
1214
1277
|
```ts
|
|
1215
1278
|
const result = await generateText({
|
|
1216
|
-
model: openai('gpt-
|
|
1279
|
+
model: openai('gpt-6-astra'),
|
|
1217
1280
|
tools: {
|
|
1218
1281
|
shell: openai.tools.shell({
|
|
1219
1282
|
execute: async ({ action }) => {
|
|
@@ -1251,7 +1314,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
1251
1314
|
import { generateText, isStepCount } from 'ai';
|
|
1252
1315
|
|
|
1253
1316
|
const result = await generateText({
|
|
1254
|
-
model: openai('gpt-
|
|
1317
|
+
model: openai('gpt-6-astra'),
|
|
1255
1318
|
tools: {
|
|
1256
1319
|
apply_patch: openai.tools.applyPatch({
|
|
1257
1320
|
execute: async ({ callId, operation }) => {
|
|
@@ -1292,7 +1355,7 @@ import { generateText, tool, isStepCount } from 'ai';
|
|
|
1292
1355
|
import { z } from 'zod';
|
|
1293
1356
|
|
|
1294
1357
|
const result = await generateText({
|
|
1295
|
-
model: openai.responses('gpt-
|
|
1358
|
+
model: openai.responses('gpt-6-astra'),
|
|
1296
1359
|
prompt: 'What is the weather in San Francisco?',
|
|
1297
1360
|
stopWhen: isStepCount(10),
|
|
1298
1361
|
tools: {
|
|
@@ -1344,7 +1407,7 @@ const crmNamespace = {
|
|
|
1344
1407
|
};
|
|
1345
1408
|
|
|
1346
1409
|
const result = await generateText({
|
|
1347
|
-
model: openai.responses('gpt-
|
|
1410
|
+
model: openai.responses('gpt-6-astra'),
|
|
1348
1411
|
prompt: 'List open orders for customer cust_123.',
|
|
1349
1412
|
tools: {
|
|
1350
1413
|
toolSearch: openai.tools.toolSearch(),
|
|
@@ -1389,7 +1452,7 @@ import { generateText, tool, isStepCount } from 'ai';
|
|
|
1389
1452
|
import { z } from 'zod';
|
|
1390
1453
|
|
|
1391
1454
|
const result = await generateText({
|
|
1392
|
-
model: openai.responses('gpt-
|
|
1455
|
+
model: openai.responses('gpt-6-astra'),
|
|
1393
1456
|
prompt: 'What is the weather in San Francisco?',
|
|
1394
1457
|
stopWhen: isStepCount(10),
|
|
1395
1458
|
tools: {
|
|
@@ -1468,7 +1531,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
1468
1531
|
import { generateText, isStepCount } from 'ai';
|
|
1469
1532
|
|
|
1470
1533
|
const result = await generateText({
|
|
1471
|
-
model: openai.responses('gpt-
|
|
1534
|
+
model: openai.responses('gpt-6-sol'),
|
|
1472
1535
|
tools: {
|
|
1473
1536
|
write_sql: openai.tools.customTool({
|
|
1474
1537
|
description: 'Write a SQL SELECT query to answer the user question.',
|
|
@@ -1497,7 +1560,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
1497
1560
|
import { streamText } from 'ai';
|
|
1498
1561
|
|
|
1499
1562
|
const result = streamText({
|
|
1500
|
-
model: openai.responses('gpt-
|
|
1563
|
+
model: openai.responses('gpt-6-sol'),
|
|
1501
1564
|
tools: {
|
|
1502
1565
|
write_sql: openai.tools.customTool({
|
|
1503
1566
|
description: 'Write a SQL SELECT query to answer the user question.',
|
|
@@ -1543,7 +1606,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
1543
1606
|
import { generateText } from 'ai';
|
|
1544
1607
|
|
|
1545
1608
|
const result = await generateText({
|
|
1546
|
-
model: openai.responses('gpt-
|
|
1609
|
+
model: openai.responses('gpt-6-astra'),
|
|
1547
1610
|
tools: {
|
|
1548
1611
|
weather: weatherTool,
|
|
1549
1612
|
cityAttractions: cityAttractionsTool,
|
|
@@ -1594,7 +1657,7 @@ You can pass Image files as part of the message content using the 'image' type:
|
|
|
1594
1657
|
|
|
1595
1658
|
```ts
|
|
1596
1659
|
const result = await generateText({
|
|
1597
|
-
model: openai('gpt-
|
|
1660
|
+
model: openai('gpt-6-astra'),
|
|
1598
1661
|
messages: [
|
|
1599
1662
|
{
|
|
1600
1663
|
role: 'user',
|
|
@@ -1644,7 +1707,7 @@ You can pass PDF files as part of the message content using the `file` type:
|
|
|
1644
1707
|
|
|
1645
1708
|
```ts
|
|
1646
1709
|
const result = await generateText({
|
|
1647
|
-
model: openai('gpt-
|
|
1710
|
+
model: openai('gpt-6-astra'),
|
|
1648
1711
|
messages: [
|
|
1649
1712
|
{
|
|
1650
1713
|
role: 'user',
|
|
@@ -1697,7 +1760,7 @@ The OpenAI Responses API supports structured outputs. You can use `generateText`
|
|
|
1697
1760
|
|
|
1698
1761
|
```ts
|
|
1699
1762
|
const result = await generateText({
|
|
1700
|
-
model: openai('gpt-
|
|
1763
|
+
model: openai('gpt-6-astra'),
|
|
1701
1764
|
output: Output.object({
|
|
1702
1765
|
schema: z.object({
|
|
1703
1766
|
recipe: z.object({
|
|
@@ -1751,7 +1814,7 @@ import {
|
|
|
1751
1814
|
import { generateText } from 'ai';
|
|
1752
1815
|
|
|
1753
1816
|
const result = await generateText({
|
|
1754
|
-
model: openai('gpt-
|
|
1817
|
+
model: openai('gpt-6-luna'),
|
|
1755
1818
|
prompt:
|
|
1756
1819
|
'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results. Also save the result to a file.',
|
|
1757
1820
|
tools: {
|
|
@@ -1831,7 +1894,7 @@ import {
|
|
|
1831
1894
|
import { generateText } from 'ai';
|
|
1832
1895
|
|
|
1833
1896
|
const result = await generateText({
|
|
1834
|
-
model: openai('gpt-
|
|
1897
|
+
model: openai('gpt-6-astra'),
|
|
1835
1898
|
prompt: 'How many "r"s are in the word "strawberry"?',
|
|
1836
1899
|
providerOptions: {
|
|
1837
1900
|
openai: {
|
|
@@ -1874,7 +1937,7 @@ import {
|
|
|
1874
1937
|
import { generateText } from 'ai';
|
|
1875
1938
|
|
|
1876
1939
|
const result = await generateText({
|
|
1877
|
-
model: openai('gpt-
|
|
1940
|
+
model: openai('gpt-6-luna'),
|
|
1878
1941
|
prompt:
|
|
1879
1942
|
'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results. Also save the result to a file.',
|
|
1880
1943
|
tools: {
|
|
@@ -1942,7 +2005,7 @@ import {
|
|
|
1942
2005
|
import { generateText } from 'ai';
|
|
1943
2006
|
|
|
1944
2007
|
const result = await generateText({
|
|
1945
|
-
model: openai.responses('gpt-
|
|
2008
|
+
model: openai.responses('gpt-6-astra'),
|
|
1946
2009
|
messages: conversationHistory,
|
|
1947
2010
|
providerOptions: {
|
|
1948
2011
|
openai: {
|
|
@@ -2007,7 +2070,7 @@ import {
|
|
|
2007
2070
|
import { streamText } from 'ai';
|
|
2008
2071
|
|
|
2009
2072
|
const result = streamText({
|
|
2010
|
-
model: openai.responses('gpt-
|
|
2073
|
+
model: openai.responses('gpt-6-astra'),
|
|
2011
2074
|
messages: conversationHistory,
|
|
2012
2075
|
providerOptions: {
|
|
2013
2076
|
openai: {
|
|
@@ -2105,13 +2168,13 @@ models differ.
|
|
|
2105
2168
|
### Chat Models
|
|
2106
2169
|
|
|
2107
2170
|
You can create models that call the [OpenAI chat API](https://platform.openai.com/docs/api-reference/chat) using the `.chat()` factory method.
|
|
2108
|
-
The first argument is the model id, e.g. `gpt-
|
|
2171
|
+
The first argument is the model id, e.g. `gpt-6-astra`.
|
|
2109
2172
|
The OpenAI chat models support tool calls and some have multi-modal capabilities.
|
|
2110
2173
|
Use this factory when a custom `baseURL` points at an OpenAI-compatible endpoint
|
|
2111
2174
|
that implements Chat Completions but not the Responses API.
|
|
2112
2175
|
|
|
2113
2176
|
```ts
|
|
2114
|
-
const model = openai.chat('gpt-
|
|
2177
|
+
const model = openai.chat('gpt-6-astra');
|
|
2115
2178
|
```
|
|
2116
2179
|
|
|
2117
2180
|
OpenAI chat models support also some model specific provider options that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
|
|
@@ -2261,7 +2324,7 @@ import { openai, type OpenAILanguageModelChatOptions } from '@ai-sdk/openai';
|
|
|
2261
2324
|
import { generateText } from 'ai';
|
|
2262
2325
|
|
|
2263
2326
|
const { text, usage } = await generateText({
|
|
2264
|
-
model: openai.chat('gpt-
|
|
2327
|
+
model: openai.chat('gpt-6-astra'),
|
|
2265
2328
|
prompt: 'Invent a new holiday and describe its traditions.',
|
|
2266
2329
|
providerOptions: {
|
|
2267
2330
|
openai: {
|
|
@@ -2289,7 +2352,7 @@ import { openai, type OpenAILanguageModelChatOptions } from '@ai-sdk/openai';
|
|
|
2289
2352
|
import { generateText } from 'ai';
|
|
2290
2353
|
|
|
2291
2354
|
const result = await generateText({
|
|
2292
|
-
model: openai.chat('gpt-
|
|
2355
|
+
model: openai.chat('gpt-6-astra'),
|
|
2293
2356
|
messages: [
|
|
2294
2357
|
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
2295
2358
|
{ role: 'user', content: 'Tell me a joke.' },
|
|
@@ -2324,7 +2387,7 @@ import { generateText, Output } from 'ai';
|
|
|
2324
2387
|
import { z } from 'zod';
|
|
2325
2388
|
|
|
2326
2389
|
const result = await generateText({
|
|
2327
|
-
model: openai.chat('gpt-
|
|
2390
|
+
model: openai.chat('gpt-6-astra'),
|
|
2328
2391
|
providerOptions: {
|
|
2329
2392
|
openai: {
|
|
2330
2393
|
strictJsonSchema: false,
|
|
@@ -2394,7 +2457,7 @@ You can pass Image files as part of the message content using the 'image' type:
|
|
|
2394
2457
|
|
|
2395
2458
|
```ts
|
|
2396
2459
|
const result = await generateText({
|
|
2397
|
-
model: openai.chat('gpt-
|
|
2460
|
+
model: openai.chat('gpt-6-astra'),
|
|
2398
2461
|
messages: [
|
|
2399
2462
|
{
|
|
2400
2463
|
role: 'user',
|
|
@@ -2434,7 +2497,7 @@ You can pass PDF files as part of the message content using the `file` type:
|
|
|
2434
2497
|
|
|
2435
2498
|
```ts
|
|
2436
2499
|
const result = await generateText({
|
|
2437
|
-
model: openai.chat('gpt-
|
|
2500
|
+
model: openai.chat('gpt-6-astra'),
|
|
2438
2501
|
messages: [
|
|
2439
2502
|
{
|
|
2440
2503
|
role: 'user',
|
|
@@ -2489,7 +2552,7 @@ You can enable predicted outputs by adding the `prediction` option to the `provi
|
|
|
2489
2552
|
|
|
2490
2553
|
```ts highlight="15-18"
|
|
2491
2554
|
const result = streamText({
|
|
2492
|
-
model: openai.chat('gpt-
|
|
2555
|
+
model: openai.chat('gpt-4o'),
|
|
2493
2556
|
messages: [
|
|
2494
2557
|
{
|
|
2495
2558
|
role: 'user',
|
|
@@ -2533,7 +2596,7 @@ You can use the `openai` provider option to set the [image input detail](https:/
|
|
|
2533
2596
|
|
|
2534
2597
|
```ts highlight="13-16"
|
|
2535
2598
|
const result = await generateText({
|
|
2536
|
-
model: openai.chat('gpt-
|
|
2599
|
+
model: openai.chat('gpt-6-astra'),
|
|
2537
2600
|
messages: [
|
|
2538
2601
|
{
|
|
2539
2602
|
role: 'user',
|
|
@@ -2614,7 +2677,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
2614
2677
|
import { generateText } from 'ai';
|
|
2615
2678
|
|
|
2616
2679
|
const { text, usage } = await generateText({
|
|
2617
|
-
model: openai.chat('gpt-
|
|
2680
|
+
model: openai.chat('gpt-6-luna'),
|
|
2618
2681
|
prompt: `A 1024-token or longer prompt...`,
|
|
2619
2682
|
});
|
|
2620
2683
|
|
|
@@ -2628,7 +2691,7 @@ import { openai, type OpenAILanguageModelChatOptions } from '@ai-sdk/openai';
|
|
|
2628
2691
|
import { generateText } from 'ai';
|
|
2629
2692
|
|
|
2630
2693
|
const { text, usage } = await generateText({
|
|
2631
|
-
model: openai.chat('gpt-
|
|
2694
|
+
model: openai.chat('gpt-6-astra'),
|
|
2632
2695
|
prompt: `A 1024-token or longer prompt...`,
|
|
2633
2696
|
providerOptions: {
|
|
2634
2697
|
openai: {
|
|
@@ -2650,7 +2713,7 @@ import {
|
|
|
2650
2713
|
import { generateText } from 'ai';
|
|
2651
2714
|
|
|
2652
2715
|
const { usage } = await generateText({
|
|
2653
|
-
model: openai('gpt-
|
|
2716
|
+
model: openai('gpt-6-astra'),
|
|
2654
2717
|
providerOptions: {
|
|
2655
2718
|
openai: {
|
|
2656
2719
|
promptCacheKey: 'tenant:acme:support-v1',
|
|
@@ -2689,7 +2752,7 @@ import { openai, type OpenAILanguageModelChatOptions } from '@ai-sdk/openai';
|
|
|
2689
2752
|
import { generateText } from 'ai';
|
|
2690
2753
|
|
|
2691
2754
|
const { text, usage } = await generateText({
|
|
2692
|
-
model: openai.chat('gpt-
|
|
2755
|
+
model: openai.chat('gpt-6-astra'),
|
|
2693
2756
|
prompt: `A 1024-token or longer prompt...`,
|
|
2694
2757
|
providerOptions: {
|
|
2695
2758
|
openai: {
|
|
@@ -3022,7 +3085,7 @@ You can create models that call the [OpenAI image generation API](https://platfo
|
|
|
3022
3085
|
using the `.image()` factory method.
|
|
3023
3086
|
|
|
3024
3087
|
```ts
|
|
3025
|
-
const model = openai.image('
|
|
3088
|
+
const model = openai.image('gpt-image-2.5-sunburst');
|
|
3026
3089
|
```
|
|
3027
3090
|
|
|
3028
3091
|
<Note>
|
|
@@ -3189,10 +3252,10 @@ For more information on the available OpenAI image model options, see the [OpenA
|
|
|
3189
3252
|
You can create models that call the [OpenAI transcription API](https://platform.openai.com/docs/api-reference/audio/transcribe)
|
|
3190
3253
|
using the `.transcription()` factory method.
|
|
3191
3254
|
|
|
3192
|
-
The first argument is the model id e.g. `
|
|
3255
|
+
The first argument is the model id e.g. `gpt-4o-transcribe`.
|
|
3193
3256
|
|
|
3194
3257
|
```ts
|
|
3195
|
-
const model = openai.transcription('
|
|
3258
|
+
const model = openai.transcription('gpt-4o-transcribe');
|
|
3196
3259
|
```
|
|
3197
3260
|
|
|
3198
3261
|
You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying the input language in ISO-639-1 (e.g. `en`) format will improve accuracy and latency.
|
|
@@ -3202,7 +3265,7 @@ import { transcribe } from 'ai';
|
|
|
3202
3265
|
import { openai, type OpenAITranscriptionModelOptions } from '@ai-sdk/openai';
|
|
3203
3266
|
|
|
3204
3267
|
const result = await transcribe({
|
|
3205
|
-
model: openai.transcription('
|
|
3268
|
+
model: openai.transcription('gpt-4o-transcribe'),
|
|
3206
3269
|
audio: new Uint8Array([1, 2, 3, 4]),
|
|
3207
3270
|
providerOptions: {
|
|
3208
3271
|
openai: { language: 'en' } satisfies OpenAITranscriptionModelOptions,
|
|
@@ -3344,10 +3407,10 @@ Unsupported source and output settings surface as call warnings.
|
|
|
3344
3407
|
You can create models that call the [OpenAI speech API](https://platform.openai.com/docs/api-reference/audio/speech)
|
|
3345
3408
|
using the `.speech()` factory method.
|
|
3346
3409
|
|
|
3347
|
-
The first argument is the model id e.g. `tts
|
|
3410
|
+
The first argument is the model id e.g. `gpt-4o-mini-tts`.
|
|
3348
3411
|
|
|
3349
3412
|
```ts
|
|
3350
|
-
const model = openai.speech('tts
|
|
3413
|
+
const model = openai.speech('gpt-4o-mini-tts');
|
|
3351
3414
|
```
|
|
3352
3415
|
|
|
3353
3416
|
The `voice` argument can be set to one of OpenAI's available voices: `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, or `shimmer`.
|
|
@@ -3357,7 +3420,7 @@ import { generateSpeech } from 'ai';
|
|
|
3357
3420
|
import { openai } from '@ai-sdk/openai';
|
|
3358
3421
|
|
|
3359
3422
|
const result = await generateSpeech({
|
|
3360
|
-
model: openai.speech('tts
|
|
3423
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
3361
3424
|
text: 'Hello, world!',
|
|
3362
3425
|
voice: 'alloy', // OpenAI voice ID
|
|
3363
3426
|
});
|
|
@@ -3370,7 +3433,7 @@ import { generateSpeech } from 'ai';
|
|
|
3370
3433
|
import { openai, type OpenAISpeechModelOptions } from '@ai-sdk/openai';
|
|
3371
3434
|
|
|
3372
3435
|
const result = await generateSpeech({
|
|
3373
|
-
model: openai.speech('tts
|
|
3436
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
3374
3437
|
text: 'Hello, world!',
|
|
3375
3438
|
voice: 'alloy',
|
|
3376
3439
|
providerOptions: {
|
|
@@ -3404,14 +3467,14 @@ const result = await generateSpeech({
|
|
|
3404
3467
|
|
|
3405
3468
|
Create an experimental evaluation model with `openai.evaluationModel(modelId)`.
|
|
3406
3469
|
It uses the Responses API with structured output to answer Choice, Score, and
|
|
3407
|
-
Boolean questions. Choose a model that supports structured output, such as `gpt-
|
|
3470
|
+
Boolean questions. Choose a model that supports structured output, such as `gpt-6-luna`.
|
|
3408
3471
|
|
|
3409
3472
|
```ts
|
|
3410
3473
|
import { openai } from '@ai-sdk/openai';
|
|
3411
3474
|
import { experimental_evaluate } from 'ai';
|
|
3412
3475
|
|
|
3413
3476
|
const { answers } = await experimental_evaluate({
|
|
3414
|
-
model: openai.evaluationModel('gpt-
|
|
3477
|
+
model: openai.evaluationModel('gpt-6-luna'),
|
|
3415
3478
|
state: 'I was charged twice.',
|
|
3416
3479
|
questions: {
|
|
3417
3480
|
requestsRefund: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.18",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.47"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.1",
|