@ai-sdk/openai 3.0.110 → 3.0.111
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 +7 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +10 -3
- package/dist/internal/index.d.ts +10 -3
- package/dist/internal/index.js +10 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +10 -0
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +21 -12
- package/package.json +1 -1
- package/src/image/openai-image-model-options.ts +8 -0
- package/src/openai-config.ts +5 -0
- package/src/responses/convert-to-openai-responses-input.ts +6 -0
- package/src/responses/openai-responses-api.ts +3 -0
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/tool/image-generation.ts +4 -2
package/docs/03-openai.mdx
CHANGED
|
@@ -2619,7 +2619,7 @@ Transform an existing image using text prompts:
|
|
|
2619
2619
|
const imageBuffer = readFileSync('./input-image.png');
|
|
2620
2620
|
|
|
2621
2621
|
const { images } = await generateImage({
|
|
2622
|
-
model: openai.image('gpt-image-2'),
|
|
2622
|
+
model: openai.image('gpt-image-2.5-sunburst'),
|
|
2623
2623
|
prompt: {
|
|
2624
2624
|
text: 'Turn the cat into a dog but retain the style of the original image',
|
|
2625
2625
|
images: [imageBuffer],
|
|
@@ -2636,7 +2636,7 @@ const image = readFileSync('./input-image.png');
|
|
|
2636
2636
|
const mask = readFileSync('./mask.png'); // Transparent areas = edit regions
|
|
2637
2637
|
|
|
2638
2638
|
const { images } = await generateImage({
|
|
2639
|
-
model: openai.image('gpt-image-2'),
|
|
2639
|
+
model: openai.image('gpt-image-2.5-sunburst'),
|
|
2640
2640
|
prompt: {
|
|
2641
2641
|
text: 'A sunlit indoor lounge area with a pool containing a flamingo',
|
|
2642
2642
|
images: [image],
|
|
@@ -2681,7 +2681,7 @@ const owl = readFileSync('./owl.png');
|
|
|
2681
2681
|
const bear = readFileSync('./bear.png');
|
|
2682
2682
|
|
|
2683
2683
|
const { images } = await generateImage({
|
|
2684
|
-
model: openai.image('gpt-image-2'),
|
|
2684
|
+
model: openai.image('gpt-image-2.5-sunburst'),
|
|
2685
2685
|
prompt: {
|
|
2686
2686
|
text: 'Combine these animals into a group photo, retaining the original style',
|
|
2687
2687
|
images: [cat, dog, owl, bear],
|
|
@@ -2697,14 +2697,23 @@ const { images } = await generateImage({
|
|
|
2697
2697
|
|
|
2698
2698
|
### Model Capabilities
|
|
2699
2699
|
|
|
2700
|
-
| Model
|
|
2701
|
-
|
|
|
2702
|
-
| `gpt-image-2`
|
|
2703
|
-
| `gpt-image-
|
|
2704
|
-
| `gpt-image-
|
|
2705
|
-
| `gpt-image-1`
|
|
2706
|
-
| `
|
|
2707
|
-
| `
|
|
2700
|
+
| Model | Sizes |
|
|
2701
|
+
| ------------------------ | -------------------------------------- |
|
|
2702
|
+
| `gpt-image-2.5-flare` | Standard presets and custom dimensions |
|
|
2703
|
+
| `gpt-image-2.5-sunburst` | Standard presets and custom dimensions |
|
|
2704
|
+
| `gpt-image-2` | 1024x1024, 1536x1024, 1024x1536 |
|
|
2705
|
+
| `gpt-image-1.5` | 1024x1024, 1536x1024, 1024x1536 |
|
|
2706
|
+
| `gpt-image-1-mini` | 1024x1024, 1536x1024, 1024x1536 |
|
|
2707
|
+
| `gpt-image-1` | 1024x1024, 1536x1024, 1024x1536 |
|
|
2708
|
+
| `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 |
|
|
2709
|
+
| `dall-e-2` | 256x256, 512x512, 1024x1024 |
|
|
2710
|
+
|
|
2711
|
+
Use `gpt-image-2.5-flare` for fast, general-purpose image generation and
|
|
2712
|
+
`gpt-image-2.5-sunburst` when editing precision and instruction following are
|
|
2713
|
+
the priority. Both models accept custom `WIDTHxHEIGHT` sizes whose dimensions
|
|
2714
|
+
are multiples of 16, with aspect ratios from 1:3 through 3:1, no edge longer
|
|
2715
|
+
than 3840 pixels, and a total area from 655,360 through 8,294,400 pixels.
|
|
2716
|
+
Resolutions above 2560x1440 are experimental.
|
|
2708
2717
|
|
|
2709
2718
|
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:
|
|
2710
2719
|
|
|
@@ -2716,7 +2725,7 @@ import {
|
|
|
2716
2725
|
import { generateImage } from 'ai';
|
|
2717
2726
|
|
|
2718
2727
|
const { image, providerMetadata } = await generateImage({
|
|
2719
|
-
model: openai.image('gpt-image-2'),
|
|
2728
|
+
model: openai.image('gpt-image-2.5-flare'),
|
|
2720
2729
|
prompt: 'A salamander at sunrise in a forest pond in the Seychelles.',
|
|
2721
2730
|
providerOptions: {
|
|
2722
2731
|
openai: { quality: 'high' } satisfies OpenAIImageModelGenerationOptions,
|
package/package.json
CHANGED
|
@@ -12,6 +12,10 @@ export type OpenAIImageModelId =
|
|
|
12
12
|
| 'gpt-image-1-mini'
|
|
13
13
|
| 'gpt-image-1.5'
|
|
14
14
|
| 'gpt-image-2'
|
|
15
|
+
| 'gpt-image-2.5-flare'
|
|
16
|
+
| 'gpt-image-2.5-flare-2026-09-08'
|
|
17
|
+
| 'gpt-image-2.5-sunburst'
|
|
18
|
+
| 'gpt-image-2.5-sunburst-2026-09-08'
|
|
15
19
|
| 'chatgpt-image-latest'
|
|
16
20
|
| (string & {});
|
|
17
21
|
|
|
@@ -23,6 +27,10 @@ export const modelMaxImagesPerCall: Record<OpenAIImageModelId, number> = {
|
|
|
23
27
|
'gpt-image-1-mini': 10,
|
|
24
28
|
'gpt-image-1.5': 10,
|
|
25
29
|
'gpt-image-2': 10,
|
|
30
|
+
'gpt-image-2.5-flare': 10,
|
|
31
|
+
'gpt-image-2.5-flare-2026-09-08': 10,
|
|
32
|
+
'gpt-image-2.5-sunburst': 10,
|
|
33
|
+
'gpt-image-2.5-sunburst-2026-09-08': 10,
|
|
26
34
|
'chatgpt-image-latest': 10,
|
|
27
35
|
};
|
|
28
36
|
|
package/src/openai-config.ts
CHANGED
|
@@ -6,6 +6,11 @@ export type OpenAIConfig = {
|
|
|
6
6
|
headers: () => Record<string, string | undefined>;
|
|
7
7
|
fetch?: FetchFunction;
|
|
8
8
|
generateId?: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether Responses API message input items must include an explicit
|
|
11
|
+
* `type: 'message'` discriminator.
|
|
12
|
+
*/
|
|
13
|
+
explicitMessageItemType?: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* File ID prefixes used to identify file IDs in Responses API.
|
|
11
16
|
* When undefined, all file data is treated as base64 content.
|
|
@@ -296,6 +296,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
296
296
|
toolNameMapping,
|
|
297
297
|
systemMessageMode,
|
|
298
298
|
providerOptionsName,
|
|
299
|
+
explicitMessageItemType = false,
|
|
299
300
|
fileIdPrefixes,
|
|
300
301
|
passThroughUnsupportedFiles = false,
|
|
301
302
|
store,
|
|
@@ -311,6 +312,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
311
312
|
toolNameMapping: ToolNameMapping;
|
|
312
313
|
systemMessageMode: 'system' | 'developer' | 'remove';
|
|
313
314
|
providerOptionsName: string;
|
|
315
|
+
explicitMessageItemType?: boolean;
|
|
314
316
|
fileIdPrefixes?: readonly string[];
|
|
315
317
|
passThroughUnsupportedFiles?: boolean;
|
|
316
318
|
store: boolean;
|
|
@@ -348,6 +350,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
348
350
|
providerOptionsName,
|
|
349
351
|
);
|
|
350
352
|
input.push({
|
|
353
|
+
...(explicitMessageItemType && { type: 'message' as const }),
|
|
351
354
|
role: 'system',
|
|
352
355
|
content:
|
|
353
356
|
promptCacheBreakpoint == null
|
|
@@ -368,6 +371,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
368
371
|
providerOptionsName,
|
|
369
372
|
);
|
|
370
373
|
input.push({
|
|
374
|
+
...(explicitMessageItemType && { type: 'message' as const }),
|
|
371
375
|
role: 'developer',
|
|
372
376
|
content:
|
|
373
377
|
promptCacheBreakpoint == null
|
|
@@ -401,6 +405,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
401
405
|
|
|
402
406
|
case 'user': {
|
|
403
407
|
input.push({
|
|
408
|
+
...(explicitMessageItemType && { type: 'message' as const }),
|
|
404
409
|
role: 'user',
|
|
405
410
|
content: content.map((part, index) => {
|
|
406
411
|
switch (part.type) {
|
|
@@ -514,6 +519,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
514
519
|
}
|
|
515
520
|
|
|
516
521
|
input.push({
|
|
522
|
+
...(explicitMessageItemType && { type: 'message' as const }),
|
|
517
523
|
role: 'assistant',
|
|
518
524
|
content: [{ type: 'output_text', text: part.text }],
|
|
519
525
|
id,
|
|
@@ -121,6 +121,7 @@ export type OpenAIResponsesApplyPatchOperationDiffDoneChunk = {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
export type OpenAIResponsesSystemMessage = {
|
|
124
|
+
type?: 'message';
|
|
124
125
|
role: 'system' | 'developer';
|
|
125
126
|
content:
|
|
126
127
|
| string
|
|
@@ -132,6 +133,7 @@ export type OpenAIResponsesSystemMessage = {
|
|
|
132
133
|
};
|
|
133
134
|
|
|
134
135
|
export type OpenAIResponsesUserMessage = {
|
|
136
|
+
type?: 'message';
|
|
135
137
|
role: 'user';
|
|
136
138
|
content: Array<
|
|
137
139
|
| {
|
|
@@ -169,6 +171,7 @@ export type OpenAIResponsesUserMessage = {
|
|
|
169
171
|
};
|
|
170
172
|
|
|
171
173
|
export type OpenAIResponsesAssistantMessage = {
|
|
174
|
+
type?: 'message';
|
|
172
175
|
role: 'assistant';
|
|
173
176
|
content: Array<{ type: 'output_text'; text: string }>;
|
|
174
177
|
id?: string;
|
|
@@ -256,6 +256,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|
|
256
256
|
? 'developer'
|
|
257
257
|
: modelCapabilities.systemMessageMode),
|
|
258
258
|
providerOptionsName,
|
|
259
|
+
explicitMessageItemType: this.config.explicitMessageItemType,
|
|
259
260
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
260
261
|
passThroughUnsupportedFiles:
|
|
261
262
|
openaiOptions?.passThroughUnsupportedFiles ?? false,
|
|
@@ -101,10 +101,12 @@ type ImageGenerationArgs = {
|
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* The size of the generated image.
|
|
104
|
-
* One of 1024x1024, 1024x1536, 1536x1024, or auto.
|
|
104
|
+
* One of 1024x1024, 1024x1536, 1536x1024, or auto. GPT Image 2 and 2.5
|
|
105
|
+
* models also accept arbitrary WIDTHxHEIGHT sizes where both are divisible
|
|
106
|
+
* by 16, e.g. 1536x864.
|
|
105
107
|
* Default: auto.
|
|
106
108
|
*/
|
|
107
|
-
size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';
|
|
109
|
+
size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {});
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
|