@ai-sdk/openai 3.0.136 → 3.0.138

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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.138
4
+
5
+ ### Patch Changes
6
+
7
+ - c6d995a: fix(openai): surface Chat Completions refusals as text content
8
+
9
+ The Chat Completions model ignored `message.refusal` (non-streaming) and `delta.refusal` (streaming). When the model refused to answer, `content` was `null`, so the AI SDK returned empty text with a `stop` finish reason and silently dropped the refusal. Refusal text is now emitted as text content in both `generateText` and `streamText` results, and it is emitted in addition to content when the API returns both. A refusal with a `stop` finish reason is now reported as a `content-filter` finish reason, matching the Anthropic provider and the Responses API.
10
+
11
+ - 98eb47b: fix(openai,openai-compatible): surface refusal logprobs and openai-compatible refusals
12
+
13
+ `@ai-sdk/openai`: Chat Completions responses that contain a refusal can return `logprobs.refusal` next to `logprobs.content`. The provider previously read only `logprobs.content`, so `providerMetadata.openai.logprobs` was empty or missing for refusals. Refusal logprobs are now included in emission order (content logprobs followed by refusal logprobs) in both `generateText` and `streamText`.
14
+
15
+ Streaming logprobs are now collected across all chunks in `streamText`: previously only the logprobs of the last streamed chunk were reported. This applies to content logprobs as well, so `providerMetadata.openai.logprobs` now contains the logprobs of every streamed token instead of only the last chunk's tokens. Explicitly empty logprobs (`logprobs: { content: [], refusal: null }`) are reported as an empty array, as before.
16
+
17
+ A refusal that arrives in the same streamed chunk as the `finish_reason` is now taken into account: such a response is reported with a `content-filter` finish reason instead of `stop`.
18
+
19
+ `@ai-sdk/openai-compatible`: Chat Completions responses that carry `message.refusal` (non-streaming) or `delta.refusal` (streaming) were ignored, so providers such as OpenAI served through `createOpenAICompatible` lost the refusal text and reported an empty `stop` response. Refusals are now returned as text content after any content text, and a non-empty refusal with a `stop` finish reason is reported as a `content-filter` finish reason. This also applies when the refusal and the finish reason arrive in the same streamed chunk. Non-string refusals (for example `refusal: false` from servers that use booleans) are ignored instead of failing the response.
20
+
21
+ - c21fadf: fix(openai): handle refusal content parts in the Responses API
22
+
23
+ The Responses API returns a `refusal` content part instead of `output_text` when the model declines a request. The response schema rejected these parts, so non-streaming calls failed with an `APICallError` ("Invalid JSON response"), and streamed `response.refusal.delta` / `response.refusal.done` events were dropped, producing empty text. Refusal content parts and stream events are now parsed: the refusal explanation is surfaced as text and the finish reason is mapped to `content-filter`. When the response also contains a client-side function call, the finish reason stays `tool-calls` so the tools are still executed.
24
+
25
+ ## 3.0.137
26
+
27
+ ### Patch Changes
28
+
29
+ - afde897: feat(openai): support GPT Image 2.6 models with `complexity`, markup-guided edits (`markup`), animated GIF output (`outputFormat: 'gif'`, `frameCount`, `frameDurationMs`), and `safetyIdentifier` for image models
30
+
3
31
  ## 3.0.136
4
32
 
5
33
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -46,22 +46,28 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
46
46
  }>;
47
47
  type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
48
48
 
49
- type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
49
+ type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
50
50
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
51
51
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
52
52
  background?: "auto" | "transparent" | "opaque" | undefined;
53
53
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
54
+ complexity?: "low" | "medium" | "high" | undefined;
54
55
  outputCompression?: number | undefined;
55
56
  user?: string | undefined;
57
+ safetyIdentifier?: string | undefined;
56
58
  }>;
57
59
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
58
60
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
59
61
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
60
62
  background?: "auto" | "transparent" | "opaque" | undefined;
61
- outputFormat?: "png" | "jpeg" | "webp" | undefined;
63
+ complexity?: "low" | "medium" | "high" | undefined;
62
64
  outputCompression?: number | undefined;
63
65
  user?: string | undefined;
66
+ safetyIdentifier?: string | undefined;
64
67
  style?: "vivid" | "natural" | undefined;
68
+ outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
69
+ frameCount?: number | undefined;
70
+ frameDurationMs?: number | undefined;
65
71
  moderation?: "low" | "auto" | undefined;
66
72
  }>;
67
73
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
@@ -69,9 +75,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
69
75
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
70
76
  background?: "auto" | "transparent" | "opaque" | undefined;
71
77
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
78
+ complexity?: "low" | "medium" | "high" | undefined;
72
79
  outputCompression?: number | undefined;
73
80
  user?: string | undefined;
81
+ safetyIdentifier?: string | undefined;
74
82
  inputFidelity?: "low" | "high" | undefined;
83
+ markup?: string | undefined;
75
84
  }>;
76
85
  type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
77
86
 
@@ -232,6 +241,18 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
232
241
  logprob: number;
233
242
  }[];
234
243
  }[] | null | undefined;
244
+ } | {
245
+ type: "response.refusal.delta";
246
+ item_id: string;
247
+ delta: string;
248
+ output_index?: number | null | undefined;
249
+ content_index?: number | null | undefined;
250
+ } | {
251
+ type: "response.refusal.done";
252
+ item_id: string;
253
+ refusal: string;
254
+ output_index?: number | null | undefined;
255
+ content_index?: number | null | undefined;
235
256
  } | {
236
257
  type: "response.completed" | "response.incomplete";
237
258
  response: {
package/dist/index.d.ts CHANGED
@@ -46,22 +46,28 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
46
46
  }>;
47
47
  type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
48
48
 
49
- type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
49
+ type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
50
50
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
51
51
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
52
52
  background?: "auto" | "transparent" | "opaque" | undefined;
53
53
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
54
+ complexity?: "low" | "medium" | "high" | undefined;
54
55
  outputCompression?: number | undefined;
55
56
  user?: string | undefined;
57
+ safetyIdentifier?: string | undefined;
56
58
  }>;
57
59
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
58
60
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
59
61
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
60
62
  background?: "auto" | "transparent" | "opaque" | undefined;
61
- outputFormat?: "png" | "jpeg" | "webp" | undefined;
63
+ complexity?: "low" | "medium" | "high" | undefined;
62
64
  outputCompression?: number | undefined;
63
65
  user?: string | undefined;
66
+ safetyIdentifier?: string | undefined;
64
67
  style?: "vivid" | "natural" | undefined;
68
+ outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
69
+ frameCount?: number | undefined;
70
+ frameDurationMs?: number | undefined;
65
71
  moderation?: "low" | "auto" | undefined;
66
72
  }>;
67
73
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
@@ -69,9 +75,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
69
75
  quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
70
76
  background?: "auto" | "transparent" | "opaque" | undefined;
71
77
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
78
+ complexity?: "low" | "medium" | "high" | undefined;
72
79
  outputCompression?: number | undefined;
73
80
  user?: string | undefined;
81
+ safetyIdentifier?: string | undefined;
74
82
  inputFidelity?: "low" | "high" | undefined;
83
+ markup?: string | undefined;
75
84
  }>;
76
85
  type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
77
86
 
@@ -232,6 +241,18 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
232
241
  logprob: number;
233
242
  }[];
234
243
  }[] | null | undefined;
244
+ } | {
245
+ type: "response.refusal.delta";
246
+ item_id: string;
247
+ delta: string;
248
+ output_index?: number | null | undefined;
249
+ content_index?: number | null | undefined;
250
+ } | {
251
+ type: "response.refusal.done";
252
+ item_id: string;
253
+ refusal: string;
254
+ output_index?: number | null | undefined;
255
+ content_index?: number | null | undefined;
235
256
  } | {
236
257
  type: "response.completed" | "response.incomplete";
237
258
  response: {