@ai-sdk/openai 4.0.0-canary.73 → 4.0.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.
@@ -298,7 +298,7 @@ The following OpenAI-specific metadata may be returned:
298
298
 
299
299
  #### Reasoning Output
300
300
 
301
- For reasoning models like `gpt-5`, 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.
301
+ For reasoning models like `gpt-5`, 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.
302
302
 
303
303
  ```ts highlight="8-9,16"
304
304
  import {
@@ -2503,7 +2503,7 @@ const model = openai.image('dall-e-3');
2503
2503
 
2504
2504
  ### Image Editing
2505
2505
 
2506
- OpenAI's `gpt-image-1` model supports powerful image editing capabilities. Pass input images via `prompt.images` to transform, combine, or edit existing images.
2506
+ OpenAI's `gpt-image-*` models support powerful image editing capabilities. Pass input images via `prompt.images` to transform, combine, or edit existing images.
2507
2507
 
2508
2508
  #### Basic Image Editing
2509
2509
 
@@ -2513,7 +2513,7 @@ Transform an existing image using text prompts:
2513
2513
  const imageBuffer = readFileSync('./input-image.png');
2514
2514
 
2515
2515
  const { images } = await generateImage({
2516
- model: openai.image('gpt-image-1'),
2516
+ model: openai.image('gpt-image-2'),
2517
2517
  prompt: {
2518
2518
  text: 'Turn the cat into a dog but retain the style of the original image',
2519
2519
  images: [imageBuffer],
@@ -2530,7 +2530,7 @@ const image = readFileSync('./input-image.png');
2530
2530
  const mask = readFileSync('./mask.png'); // Transparent areas = edit regions
2531
2531
 
2532
2532
  const { images } = await generateImage({
2533
- model: openai.image('gpt-image-1'),
2533
+ model: openai.image('gpt-image-2'),
2534
2534
  prompt: {
2535
2535
  text: 'A sunlit indoor lounge area with a pool containing a flamingo',
2536
2536
  images: [image],
@@ -2541,7 +2541,7 @@ const { images } = await generateImage({
2541
2541
 
2542
2542
  #### Background Removal
2543
2543
 
2544
- Remove the background from an image by setting `background` to `transparent`:
2544
+ Remove the background from an image by setting `background` to `transparent` on a model that supports transparent backgrounds:
2545
2545
 
2546
2546
  ```ts
2547
2547
  import { openai, type OpenAIImageModelEditOptions } from '@ai-sdk/openai';
@@ -2550,7 +2550,7 @@ import { generateImage } from 'ai';
2550
2550
  const imageBuffer = readFileSync('./input-image.png');
2551
2551
 
2552
2552
  const { images } = await generateImage({
2553
- model: openai.image('gpt-image-1'),
2553
+ model: openai.image('gpt-image-1.5'),
2554
2554
  prompt: {
2555
2555
  text: 'do not change anything',
2556
2556
  images: [imageBuffer],
@@ -2566,7 +2566,7 @@ const { images } = await generateImage({
2566
2566
 
2567
2567
  #### Multi-Image Combining
2568
2568
 
2569
- Combine multiple reference images into a single output. `gpt-image-1` supports up to 16 input images:
2569
+ Combine multiple reference images into a single output. `gpt-image-*` models support up to 16 input images:
2570
2570
 
2571
2571
  ```ts
2572
2572
  const cat = readFileSync('./cat.png');
@@ -2575,7 +2575,7 @@ const owl = readFileSync('./owl.png');
2575
2575
  const bear = readFileSync('./bear.png');
2576
2576
 
2577
2577
  const { images } = await generateImage({
2578
- model: openai.image('gpt-image-1'),
2578
+ model: openai.image('gpt-image-2'),
2579
2579
  prompt: {
2580
2580
  text: 'Combine these animals into a group photo, retaining the original style',
2581
2581
  images: [cat, dog, owl, bear],
@@ -2585,28 +2585,29 @@ const { images } = await generateImage({
2585
2585
 
2586
2586
  <Note>
2587
2587
  Input images can be provided as `Buffer`, `ArrayBuffer`, `Uint8Array`, or
2588
- base64-encoded strings. For `gpt-image-1`, each image should be a `png`,
2589
- `webp`, or `jpg` file less than 50MB.
2588
+ base64-encoded strings. For `gpt-image-*` models, each image should be a
2589
+ `png`, `webp`, or `jpg` file less than 50MB.
2590
2590
  </Note>
2591
2591
 
2592
2592
  ### Model Capabilities
2593
2593
 
2594
2594
  | Model | Sizes |
2595
2595
  | ------------------ | ------------------------------- |
2596
+ | `gpt-image-2` | 1024x1024, 1536x1024, 1024x1536 |
2596
2597
  | `gpt-image-1.5` | 1024x1024, 1536x1024, 1024x1536 |
2597
2598
  | `gpt-image-1-mini` | 1024x1024, 1536x1024, 1024x1536 |
2598
2599
  | `gpt-image-1` | 1024x1024, 1536x1024, 1024x1536 |
2599
2600
  | `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 |
2600
2601
  | `dall-e-2` | 256x256, 512x512, 1024x1024 |
2601
2602
 
2602
- You can pass optional `providerOptions` to the image model. These are prone to change by OpenAI and are model dependent. For example, the `gpt-image-1` model supports the `quality` option:
2603
+ You can pass optional `providerOptions` to the image model. These are prone to change by OpenAI and are model dependent. For example, the `gpt-image-*` models support the `quality` option:
2603
2604
 
2604
2605
  ```ts
2605
2606
  import { openai, type OpenAIImageModelGenerationOptions } from '@ai-sdk/openai';
2606
2607
  import { generateImage } from 'ai';
2607
2608
 
2608
2609
  const { image, providerMetadata } = await generateImage({
2609
- model: openai.image('gpt-image-1.5'),
2610
+ model: openai.image('gpt-image-2'),
2610
2611
  prompt: 'A salamander at sunrise in a forest pond in the Seychelles.',
2611
2612
  providerOptions: {
2612
2613
  openai: { quality: 'high' } satisfies OpenAIImageModelGenerationOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "4.0.0-canary.73",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,15 +35,15 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.0-canary.18",
39
- "@ai-sdk/provider-utils": "5.0.0-canary.48"
38
+ "@ai-sdk/provider": "4.0.0",
39
+ "@ai-sdk/provider-utils": "5.0.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "22.19.19",
43
43
  "tsup": "^8.5.1",
44
44
  "typescript": "5.8.3",
45
45
  "zod": "3.25.76",
46
- "@ai-sdk/test-server": "2.0.0-canary.6",
46
+ "@ai-sdk/test-server": "2.0.0",
47
47
  "@vercel/ai-tsconfig": "0.0.0"
48
48
  },
49
49
  "peerDependencies": {
@@ -5,9 +5,12 @@ export type OpenAIResponsesUsage = {
5
5
  output_tokens: number;
6
6
  input_tokens_details?: {
7
7
  cached_tokens?: number | null;
8
+ orchestration_input_tokens?: number | null;
9
+ orchestration_input_cached_tokens?: number | null;
8
10
  } | null;
9
11
  output_tokens_details?: {
10
12
  reasoning_tokens?: number | null;
13
+ orchestration_output_tokens?: number | null;
11
14
  } | null;
12
15
  };
13
16
 
@@ -43,6 +43,7 @@ export type OpenAIResponsesInputItem =
43
43
 
44
44
  export type OpenAIResponsesIncludeValue =
45
45
  | 'web_search_call.action.sources'
46
+ | 'web_search_call.results'
46
47
  | 'code_interpreter_call.outputs'
47
48
  | 'computer_call_output.output.image_url'
48
49
  | 'file_search_call.results'
@@ -531,11 +532,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
531
532
  usage: z.object({
532
533
  input_tokens: z.number(),
533
534
  input_tokens_details: z
534
- .object({ cached_tokens: z.number().nullish() })
535
+ .object({
536
+ cached_tokens: z.number().nullish(),
537
+ orchestration_input_tokens: z.number().nullish(),
538
+ orchestration_input_cached_tokens: z.number().nullish(),
539
+ })
535
540
  .nullish(),
536
541
  output_tokens: z.number(),
537
542
  output_tokens_details: z
538
- .object({ reasoning_tokens: z.number().nullish() })
543
+ .object({
544
+ reasoning_tokens: z.number().nullish(),
545
+ orchestration_output_tokens: z.number().nullish(),
546
+ })
539
547
  .nullish(),
540
548
  }),
541
549
  service_tier: z.string().nullish(),
@@ -556,11 +564,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
556
564
  .object({
557
565
  input_tokens: z.number(),
558
566
  input_tokens_details: z
559
- .object({ cached_tokens: z.number().nullish() })
567
+ .object({
568
+ cached_tokens: z.number().nullish(),
569
+ orchestration_input_tokens: z.number().nullish(),
570
+ orchestration_input_cached_tokens: z.number().nullish(),
571
+ })
560
572
  .nullish(),
561
573
  output_tokens: z.number(),
562
574
  output_tokens_details: z
563
- .object({ reasoning_tokens: z.number().nullish() })
575
+ .object({
576
+ reasoning_tokens: z.number().nullish(),
577
+ orchestration_output_tokens: z.number().nullish(),
578
+ })
564
579
  .nullish(),
565
580
  })
566
581
  .nullish(),
@@ -1416,11 +1431,18 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
1416
1431
  .object({
1417
1432
  input_tokens: z.number(),
1418
1433
  input_tokens_details: z
1419
- .object({ cached_tokens: z.number().nullish() })
1434
+ .object({
1435
+ cached_tokens: z.number().nullish(),
1436
+ orchestration_input_tokens: z.number().nullish(),
1437
+ orchestration_input_cached_tokens: z.number().nullish(),
1438
+ })
1420
1439
  .nullish(),
1421
1440
  output_tokens: z.number(),
1422
1441
  output_tokens_details: z
1423
- .object({ reasoning_tokens: z.number().nullish() })
1442
+ .object({
1443
+ reasoning_tokens: z.number().nullish(),
1444
+ orchestration_output_tokens: z.number().nullish(),
1445
+ })
1424
1446
  .nullish(),
1425
1447
  })
1426
1448
  .optional(),
@@ -156,13 +156,14 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
156
156
 
157
157
  /**
158
158
  * The set of extra fields to include in the response (advanced, usually not needed).
159
- * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
159
+ * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'web_search_call.results', 'message.output_text.logprobs'.
160
160
  */
161
161
  include: z
162
162
  .array(
163
163
  z.enum([
164
164
  'reasoning.encrypted_content', // handled internally by default, only needed for unknown reasoning models
165
165
  'file_search_call.results',
166
+ 'web_search_call.results',
166
167
  'message.output_text.logprobs',
167
168
  ]),
168
169
  )
@@ -198,6 +198,12 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
198
198
  const resolvedReasoningEffort =
199
199
  openaiOptions?.reasoningEffort ??
200
200
  (isCustomReasoning(reasoning) ? reasoning : undefined);
201
+ const resolvedReasoningSummary =
202
+ openaiOptions?.reasoningSummary !== undefined
203
+ ? openaiOptions.reasoningSummary
204
+ : resolvedReasoningEffort != null && resolvedReasoningEffort !== 'none'
205
+ ? 'detailed'
206
+ : undefined;
201
207
 
202
208
  const isReasoningModel =
203
209
  openaiOptions?.forceReasoning ?? modelCapabilities.isReasoningModel;
@@ -377,13 +383,13 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
377
383
  // model-specific settings:
378
384
  ...(isReasoningModel &&
379
385
  (resolvedReasoningEffort != null ||
380
- openaiOptions?.reasoningSummary != null) && {
386
+ resolvedReasoningSummary != null) && {
381
387
  reasoning: {
382
388
  ...(resolvedReasoningEffort != null && {
383
389
  effort: resolvedReasoningEffort,
384
390
  }),
385
- ...(openaiOptions?.reasoningSummary != null && {
386
- summary: openaiOptions.reasoningSummary,
391
+ ...(resolvedReasoningSummary != null && {
392
+ summary: resolvedReasoningSummary,
387
393
  }),
388
394
  },
389
395
  }),