@ai-sdk/openai 4.0.15 → 4.0.17

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.
@@ -300,7 +300,7 @@ The following OpenAI-specific metadata may be returned:
300
300
 
301
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
- ```ts highlight="8-9,16"
303
+ ```ts highlight="10-14,17-23"
304
304
  import {
305
305
  openai,
306
306
  type OpenAILanguageModelResponsesOptions,
@@ -1943,7 +1943,7 @@ They support additional settings and response metadata:
1943
1943
 
1944
1944
  - You can use the response `usage` to access the number of reasoning tokens that the model generated via `usage.outputTokenDetails.reasoningTokens`.
1945
1945
 
1946
- ```ts highlight="4,7-11,17"
1946
+ ```ts highlight="4,7-11,15"
1947
1947
  import { openai, type OpenAILanguageModelChatOptions } from '@ai-sdk/openai';
1948
1948
  import { generateText } from 'ai';
1949
1949
 
@@ -2201,7 +2201,7 @@ const result = streamText({
2201
2201
  OpenAI provides usage information for predicted outputs (`acceptedPredictionTokens` and `rejectedPredictionTokens`).
2202
2202
  You can access it in the `providerMetadata` object.
2203
2203
 
2204
- ```ts highlight="11"
2204
+ ```ts highlight="3-4"
2205
2205
  const openaiMetadata = (await result.providerMetadata)?.openai;
2206
2206
 
2207
2207
  const acceptedPredictionTokens = openaiMetadata?.acceptedPredictionTokens;
@@ -2296,7 +2296,7 @@ including `gpt-4o` and `gpt-4o-mini`.
2296
2296
  - For GPT-5.6 and later models, `usage.inputTokenDetails.cacheWriteTokens` reports tokens written to the cache.
2297
2297
  - For GPT-5.6 and later models, `promptCacheOptions.ttl` sets a minimum cache lifetime of 30 minutes. Earlier models generally retain in-memory prefixes for 5-10 minutes of inactivity, up to one hour.
2298
2298
 
2299
- ```ts highlight="11"
2299
+ ```ts highlight="9"
2300
2300
  import { openai } from '@ai-sdk/openai';
2301
2301
  import { generateText } from 'ai';
2302
2302
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "4.0.15",
3
+ "version": "4.0.17",
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.3",
39
- "@ai-sdk/provider-utils": "5.0.10"
39
+ "@ai-sdk/provider-utils": "5.0.12"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "22.19.19",
@@ -654,6 +654,21 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
654
654
  });
655
655
  }
656
656
 
657
+ if (response.output == null) {
658
+ const detail = response.incomplete_details?.reason;
659
+ throw new APICallError({
660
+ message: detail
661
+ ? `Responses API returned no output (${detail})`
662
+ : 'Responses API returned no output',
663
+ url,
664
+ requestBodyValues: body,
665
+ statusCode: 500,
666
+ responseHeaders,
667
+ responseBody: rawResponse as string,
668
+ isRetryable: false,
669
+ });
670
+ }
671
+
657
672
  const content: Array<LanguageModelV4Content> = [];
658
673
  const logprobs: Array<OpenAIResponsesLogprobs> = [];
659
674
 
@@ -661,8 +676,8 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
661
676
  let hasFunctionCall = false;
662
677
  const hostedToolSearchCallIds: string[] = [];
663
678
 
664
- // map response content to content array (defined when there is no error)
665
- for (const part of response.output!) {
679
+ // map response content to content array
680
+ for (const part of response.output) {
666
681
  switch (part.type) {
667
682
  case 'reasoning': {
668
683
  // when there are no summary parts, we need to add an empty reasoning part: