@ai-sdk/openai 2.0.0-beta.3 → 2.0.0-beta.5

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/dist/index.mjs CHANGED
@@ -1883,24 +1883,30 @@ var openaiTranscriptionResponseSchema = z12.object({
1883
1883
  });
1884
1884
 
1885
1885
  // src/responses/openai-responses-language-model.ts
1886
+ import {
1887
+ APICallError
1888
+ } from "@ai-sdk/provider";
1886
1889
  import {
1887
1890
  combineHeaders as combineHeaders6,
1888
1891
  createEventSourceResponseHandler as createEventSourceResponseHandler3,
1889
1892
  createJsonResponseHandler as createJsonResponseHandler6,
1890
1893
  generateId as generateId2,
1891
- parseProviderOptions as parseProviderOptions5,
1894
+ parseProviderOptions as parseProviderOptions6,
1892
1895
  postJsonToApi as postJsonToApi5
1893
1896
  } from "@ai-sdk/provider-utils";
1894
- import { z as z13 } from "zod/v4";
1897
+ import { z as z14 } from "zod/v4";
1895
1898
 
1896
1899
  // src/responses/convert-to-openai-responses-messages.ts
1897
1900
  import {
1898
1901
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
1899
1902
  } from "@ai-sdk/provider";
1900
- function convertToOpenAIResponsesMessages({
1903
+ import { parseProviderOptions as parseProviderOptions5 } from "@ai-sdk/provider-utils";
1904
+ import { z as z13 } from "zod/v4";
1905
+ async function convertToOpenAIResponsesMessages({
1901
1906
  prompt,
1902
1907
  systemMessageMode
1903
1908
  }) {
1909
+ var _a, _b;
1904
1910
  const messages = [];
1905
1911
  const warnings = [];
1906
1912
  for (const { role, content } of prompt) {
@@ -1935,7 +1941,7 @@ function convertToOpenAIResponsesMessages({
1935
1941
  messages.push({
1936
1942
  role: "user",
1937
1943
  content: content.map((part, index) => {
1938
- var _a, _b, _c;
1944
+ var _a2, _b2, _c;
1939
1945
  switch (part.type) {
1940
1946
  case "text": {
1941
1947
  return { type: "input_text", text: part.text };
@@ -1947,7 +1953,7 @@ function convertToOpenAIResponsesMessages({
1947
1953
  type: "input_image",
1948
1954
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
1949
1955
  // OpenAI specific extension: image detail
1950
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
1956
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
1951
1957
  };
1952
1958
  } else if (part.mediaType === "application/pdf") {
1953
1959
  if (part.data instanceof URL) {
@@ -1972,6 +1978,7 @@ function convertToOpenAIResponsesMessages({
1972
1978
  break;
1973
1979
  }
1974
1980
  case "assistant": {
1981
+ const reasoningMessages = {};
1975
1982
  for (const part of content) {
1976
1983
  switch (part.type) {
1977
1984
  case "text": {
@@ -2000,6 +2007,43 @@ function convertToOpenAIResponsesMessages({
2000
2007
  });
2001
2008
  break;
2002
2009
  }
2010
+ case "reasoning": {
2011
+ const providerOptions = await parseProviderOptions5({
2012
+ provider: "openai",
2013
+ providerOptions: part.providerOptions,
2014
+ schema: openaiResponsesReasoningProviderOptionsSchema
2015
+ });
2016
+ const reasoningId = (_a = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _a.id;
2017
+ if (reasoningId != null) {
2018
+ const existingReasoningMessage = reasoningMessages[reasoningId];
2019
+ const summaryParts = [];
2020
+ if (part.text.length > 0) {
2021
+ summaryParts.push({ type: "summary_text", text: part.text });
2022
+ } else if (existingReasoningMessage !== void 0) {
2023
+ warnings.push({
2024
+ type: "other",
2025
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
2026
+ });
2027
+ }
2028
+ if (existingReasoningMessage === void 0) {
2029
+ reasoningMessages[reasoningId] = {
2030
+ type: "reasoning",
2031
+ id: reasoningId,
2032
+ encrypted_content: (_b = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _b.encryptedContent,
2033
+ summary: summaryParts
2034
+ };
2035
+ messages.push(reasoningMessages[reasoningId]);
2036
+ } else {
2037
+ existingReasoningMessage.summary.push(...summaryParts);
2038
+ }
2039
+ } else {
2040
+ warnings.push({
2041
+ type: "other",
2042
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
2043
+ });
2044
+ }
2045
+ break;
2046
+ }
2003
2047
  }
2004
2048
  }
2005
2049
  break;
@@ -2035,6 +2079,12 @@ function convertToOpenAIResponsesMessages({
2035
2079
  }
2036
2080
  return { messages, warnings };
2037
2081
  }
2082
+ var openaiResponsesReasoningProviderOptionsSchema = z13.object({
2083
+ reasoning: z13.object({
2084
+ id: z13.string().nullish(),
2085
+ encryptedContent: z13.string().nullish()
2086
+ }).nullish()
2087
+ });
2038
2088
 
2039
2089
  // src/responses/map-openai-responses-finish-reason.ts
2040
2090
  function mapOpenAIResponseFinishReason({
@@ -2175,12 +2225,12 @@ var OpenAIResponsesLanguageModel = class {
2175
2225
  if (stopSequences != null) {
2176
2226
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2177
2227
  }
2178
- const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
2228
+ const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2179
2229
  prompt,
2180
2230
  systemMessageMode: modelConfig.systemMessageMode
2181
2231
  });
2182
2232
  warnings.push(...messageWarnings);
2183
- const openaiOptions = await parseProviderOptions5({
2233
+ const openaiOptions = await parseProviderOptions6({
2184
2234
  provider: "openai",
2185
2235
  providerOptions,
2186
2236
  schema: openaiResponsesProviderOptionsSchema
@@ -2211,6 +2261,7 @@ var OpenAIResponsesLanguageModel = class {
2211
2261
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2212
2262
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2213
2263
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2264
+ include: openaiOptions == null ? void 0 : openaiOptions.include,
2214
2265
  // model-specific settings:
2215
2266
  ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2216
2267
  reasoning: {
@@ -2243,6 +2294,21 @@ var OpenAIResponsesLanguageModel = class {
2243
2294
  details: "topP is not supported for reasoning models"
2244
2295
  });
2245
2296
  }
2297
+ } else {
2298
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
2299
+ warnings.push({
2300
+ type: "unsupported-setting",
2301
+ setting: "reasoningEffort",
2302
+ details: "reasoningEffort is not supported for non-reasoning models"
2303
+ });
2304
+ }
2305
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) {
2306
+ warnings.push({
2307
+ type: "unsupported-setting",
2308
+ setting: "reasoningSummary",
2309
+ details: "reasoningSummary is not supported for non-reasoning models"
2310
+ });
2311
+ }
2246
2312
  }
2247
2313
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !supportsFlexProcessing2(this.modelId)) {
2248
2314
  warnings.push({
@@ -2271,88 +2337,119 @@ var OpenAIResponsesLanguageModel = class {
2271
2337
  };
2272
2338
  }
2273
2339
  async doGenerate(options) {
2274
- var _a, _b, _c, _d, _e, _f, _g, _h;
2340
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2275
2341
  const { args: body, warnings } = await this.getArgs(options);
2342
+ const url = this.config.url({
2343
+ path: "/responses",
2344
+ modelId: this.modelId
2345
+ });
2276
2346
  const {
2277
2347
  responseHeaders,
2278
2348
  value: response,
2279
2349
  rawValue: rawResponse
2280
2350
  } = await postJsonToApi5({
2281
- url: this.config.url({
2282
- path: "/responses",
2283
- modelId: this.modelId
2284
- }),
2351
+ url,
2285
2352
  headers: combineHeaders6(this.config.headers(), options.headers),
2286
2353
  body,
2287
2354
  failedResponseHandler: openaiFailedResponseHandler,
2288
2355
  successfulResponseHandler: createJsonResponseHandler6(
2289
- z13.object({
2290
- id: z13.string(),
2291
- created_at: z13.number(),
2292
- model: z13.string(),
2293
- output: z13.array(
2294
- z13.discriminatedUnion("type", [
2295
- z13.object({
2296
- type: z13.literal("message"),
2297
- role: z13.literal("assistant"),
2298
- content: z13.array(
2299
- z13.object({
2300
- type: z13.literal("output_text"),
2301
- text: z13.string(),
2302
- annotations: z13.array(
2303
- z13.object({
2304
- type: z13.literal("url_citation"),
2305
- start_index: z13.number(),
2306
- end_index: z13.number(),
2307
- url: z13.string(),
2308
- title: z13.string()
2356
+ z14.object({
2357
+ id: z14.string(),
2358
+ created_at: z14.number(),
2359
+ error: z14.object({
2360
+ code: z14.string(),
2361
+ message: z14.string()
2362
+ }).nullish(),
2363
+ model: z14.string(),
2364
+ output: z14.array(
2365
+ z14.discriminatedUnion("type", [
2366
+ z14.object({
2367
+ type: z14.literal("message"),
2368
+ role: z14.literal("assistant"),
2369
+ content: z14.array(
2370
+ z14.object({
2371
+ type: z14.literal("output_text"),
2372
+ text: z14.string(),
2373
+ annotations: z14.array(
2374
+ z14.object({
2375
+ type: z14.literal("url_citation"),
2376
+ start_index: z14.number(),
2377
+ end_index: z14.number(),
2378
+ url: z14.string(),
2379
+ title: z14.string()
2309
2380
  })
2310
2381
  )
2311
2382
  })
2312
2383
  )
2313
2384
  }),
2314
- z13.object({
2315
- type: z13.literal("function_call"),
2316
- call_id: z13.string(),
2317
- name: z13.string(),
2318
- arguments: z13.string()
2385
+ z14.object({
2386
+ type: z14.literal("function_call"),
2387
+ call_id: z14.string(),
2388
+ name: z14.string(),
2389
+ arguments: z14.string()
2319
2390
  }),
2320
- z13.object({
2321
- type: z13.literal("web_search_call"),
2322
- id: z13.string(),
2323
- status: z13.string().optional()
2391
+ z14.object({
2392
+ type: z14.literal("web_search_call"),
2393
+ id: z14.string(),
2394
+ status: z14.string().optional()
2324
2395
  }),
2325
- z13.object({
2326
- type: z13.literal("computer_call"),
2327
- id: z13.string(),
2328
- status: z13.string().optional()
2396
+ z14.object({
2397
+ type: z14.literal("computer_call"),
2398
+ id: z14.string(),
2399
+ status: z14.string().optional()
2329
2400
  }),
2330
- z13.object({
2331
- type: z13.literal("reasoning"),
2332
- summary: z13.array(
2333
- z13.object({
2334
- type: z13.literal("summary_text"),
2335
- text: z13.string()
2401
+ z14.object({
2402
+ type: z14.literal("reasoning"),
2403
+ id: z14.string(),
2404
+ encrypted_content: z14.string().nullish(),
2405
+ summary: z14.array(
2406
+ z14.object({
2407
+ type: z14.literal("summary_text"),
2408
+ text: z14.string()
2336
2409
  })
2337
2410
  )
2338
2411
  })
2339
2412
  ])
2340
2413
  ),
2341
- incomplete_details: z13.object({ reason: z13.string() }).nullable(),
2414
+ incomplete_details: z14.object({ reason: z14.string() }).nullable(),
2342
2415
  usage: usageSchema2
2343
2416
  })
2344
2417
  ),
2345
2418
  abortSignal: options.abortSignal,
2346
2419
  fetch: this.config.fetch
2347
2420
  });
2421
+ if (response.error) {
2422
+ throw new APICallError({
2423
+ message: response.error.message,
2424
+ url,
2425
+ requestBodyValues: body,
2426
+ statusCode: 400,
2427
+ responseHeaders,
2428
+ responseBody: rawResponse,
2429
+ isRetryable: false
2430
+ });
2431
+ }
2348
2432
  const content = [];
2349
2433
  for (const part of response.output) {
2350
2434
  switch (part.type) {
2351
2435
  case "reasoning": {
2352
- content.push({
2353
- type: "reasoning",
2354
- text: part.summary.map((summary) => summary.text).join()
2355
- });
2436
+ if (part.summary.length === 0) {
2437
+ part.summary.push({ type: "summary_text", text: "" });
2438
+ }
2439
+ for (const summary of part.summary) {
2440
+ content.push({
2441
+ type: "reasoning",
2442
+ text: summary.text,
2443
+ providerMetadata: {
2444
+ openai: {
2445
+ reasoning: {
2446
+ id: part.id,
2447
+ encryptedContent: (_a = part.encrypted_content) != null ? _a : null
2448
+ }
2449
+ }
2450
+ }
2451
+ });
2452
+ }
2356
2453
  break;
2357
2454
  }
2358
2455
  case "message": {
@@ -2365,7 +2462,7 @@ var OpenAIResponsesLanguageModel = class {
2365
2462
  content.push({
2366
2463
  type: "source",
2367
2464
  sourceType: "url",
2368
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : generateId2(),
2465
+ id: (_d = (_c = (_b = this.config).generateId) == null ? void 0 : _c.call(_b)) != null ? _d : generateId2(),
2369
2466
  url: annotation.url,
2370
2467
  title: annotation.title
2371
2468
  });
@@ -2424,15 +2521,15 @@ var OpenAIResponsesLanguageModel = class {
2424
2521
  return {
2425
2522
  content,
2426
2523
  finishReason: mapOpenAIResponseFinishReason({
2427
- finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
2524
+ finishReason: (_e = response.incomplete_details) == null ? void 0 : _e.reason,
2428
2525
  hasToolCalls: content.some((part) => part.type === "tool-call")
2429
2526
  }),
2430
2527
  usage: {
2431
2528
  inputTokens: response.usage.input_tokens,
2432
2529
  outputTokens: response.usage.output_tokens,
2433
2530
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
2434
- reasoningTokens: (_f = (_e = response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : void 0,
2435
- cachedInputTokens: (_h = (_g = response.usage.input_tokens_details) == null ? void 0 : _g.cached_tokens) != null ? _h : void 0
2531
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : void 0,
2532
+ cachedInputTokens: (_i = (_h = response.usage.input_tokens_details) == null ? void 0 : _h.cached_tokens) != null ? _i : void 0
2436
2533
  },
2437
2534
  request: { body },
2438
2535
  response: {
@@ -2486,7 +2583,7 @@ var OpenAIResponsesLanguageModel = class {
2486
2583
  controller.enqueue({ type: "stream-start", warnings });
2487
2584
  },
2488
2585
  transform(chunk, controller) {
2489
- var _a, _b, _c, _d, _e, _f, _g, _h;
2586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2490
2587
  if (options.includeRawChunks) {
2491
2588
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2492
2589
  }
@@ -2535,7 +2632,15 @@ var OpenAIResponsesLanguageModel = class {
2535
2632
  } else if (value.item.type === "reasoning") {
2536
2633
  controller.enqueue({
2537
2634
  type: "reasoning-start",
2538
- id: value.item.id
2635
+ id: value.item.id,
2636
+ providerMetadata: {
2637
+ openai: {
2638
+ reasoning: {
2639
+ id: value.item.id,
2640
+ encryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
2641
+ }
2642
+ }
2643
+ }
2539
2644
  });
2540
2645
  }
2541
2646
  } else if (isResponseOutputItemDoneChunk(value)) {
@@ -2608,7 +2713,15 @@ var OpenAIResponsesLanguageModel = class {
2608
2713
  } else if (value.item.type === "reasoning") {
2609
2714
  controller.enqueue({
2610
2715
  type: "reasoning-end",
2611
- id: value.item.id
2716
+ id: value.item.id,
2717
+ providerMetadata: {
2718
+ openai: {
2719
+ reasoning: {
2720
+ id: value.item.id,
2721
+ encryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
2722
+ }
2723
+ }
2724
+ }
2612
2725
  });
2613
2726
  }
2614
2727
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
@@ -2637,27 +2750,29 @@ var OpenAIResponsesLanguageModel = class {
2637
2750
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2638
2751
  controller.enqueue({
2639
2752
  type: "reasoning-delta",
2640
- delta: value.delta,
2641
- id: value.item_id
2753
+ id: value.item_id,
2754
+ delta: value.delta
2642
2755
  });
2643
2756
  } else if (isResponseFinishedChunk(value)) {
2644
2757
  finishReason = mapOpenAIResponseFinishReason({
2645
- finishReason: (_a = value.response.incomplete_details) == null ? void 0 : _a.reason,
2758
+ finishReason: (_c = value.response.incomplete_details) == null ? void 0 : _c.reason,
2646
2759
  hasToolCalls
2647
2760
  });
2648
2761
  usage.inputTokens = value.response.usage.input_tokens;
2649
2762
  usage.outputTokens = value.response.usage.output_tokens;
2650
2763
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
2651
- usage.reasoningTokens = (_c = (_b = value.response.usage.output_tokens_details) == null ? void 0 : _b.reasoning_tokens) != null ? _c : void 0;
2652
- usage.cachedInputTokens = (_e = (_d = value.response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : void 0;
2764
+ usage.reasoningTokens = (_e = (_d = value.response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
2765
+ usage.cachedInputTokens = (_g = (_f = value.response.usage.input_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
2653
2766
  } else if (isResponseAnnotationAddedChunk(value)) {
2654
2767
  controller.enqueue({
2655
2768
  type: "source",
2656
2769
  sourceType: "url",
2657
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : generateId2(),
2770
+ id: (_j = (_i = (_h = self.config).generateId) == null ? void 0 : _i.call(_h)) != null ? _j : generateId2(),
2658
2771
  url: value.annotation.url,
2659
2772
  title: value.annotation.title
2660
2773
  });
2774
+ } else if (isErrorChunk(value)) {
2775
+ controller.enqueue({ type: "error", error: value });
2661
2776
  }
2662
2777
  },
2663
2778
  flush(controller) {
@@ -2679,124 +2794,136 @@ var OpenAIResponsesLanguageModel = class {
2679
2794
  };
2680
2795
  }
2681
2796
  };
2682
- var usageSchema2 = z13.object({
2683
- input_tokens: z13.number(),
2684
- input_tokens_details: z13.object({ cached_tokens: z13.number().nullish() }).nullish(),
2685
- output_tokens: z13.number(),
2686
- output_tokens_details: z13.object({ reasoning_tokens: z13.number().nullish() }).nullish()
2797
+ var usageSchema2 = z14.object({
2798
+ input_tokens: z14.number(),
2799
+ input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
2800
+ output_tokens: z14.number(),
2801
+ output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
2802
+ });
2803
+ var textDeltaChunkSchema = z14.object({
2804
+ type: z14.literal("response.output_text.delta"),
2805
+ item_id: z14.string(),
2806
+ delta: z14.string()
2687
2807
  });
2688
- var textDeltaChunkSchema = z13.object({
2689
- type: z13.literal("response.output_text.delta"),
2690
- item_id: z13.string(),
2691
- delta: z13.string()
2808
+ var errorChunkSchema = z14.object({
2809
+ type: z14.literal("error"),
2810
+ code: z14.string(),
2811
+ message: z14.string(),
2812
+ param: z14.string().nullish(),
2813
+ sequence_number: z14.number()
2692
2814
  });
2693
- var responseFinishedChunkSchema = z13.object({
2694
- type: z13.enum(["response.completed", "response.incomplete"]),
2695
- response: z13.object({
2696
- incomplete_details: z13.object({ reason: z13.string() }).nullish(),
2815
+ var responseFinishedChunkSchema = z14.object({
2816
+ type: z14.enum(["response.completed", "response.incomplete"]),
2817
+ response: z14.object({
2818
+ incomplete_details: z14.object({ reason: z14.string() }).nullish(),
2697
2819
  usage: usageSchema2
2698
2820
  })
2699
2821
  });
2700
- var responseCreatedChunkSchema = z13.object({
2701
- type: z13.literal("response.created"),
2702
- response: z13.object({
2703
- id: z13.string(),
2704
- created_at: z13.number(),
2705
- model: z13.string()
2822
+ var responseCreatedChunkSchema = z14.object({
2823
+ type: z14.literal("response.created"),
2824
+ response: z14.object({
2825
+ id: z14.string(),
2826
+ created_at: z14.number(),
2827
+ model: z14.string()
2706
2828
  })
2707
2829
  });
2708
- var responseOutputItemAddedSchema = z13.object({
2709
- type: z13.literal("response.output_item.added"),
2710
- output_index: z13.number(),
2711
- item: z13.discriminatedUnion("type", [
2712
- z13.object({
2713
- type: z13.literal("message"),
2714
- id: z13.string()
2830
+ var responseOutputItemAddedSchema = z14.object({
2831
+ type: z14.literal("response.output_item.added"),
2832
+ output_index: z14.number(),
2833
+ item: z14.discriminatedUnion("type", [
2834
+ z14.object({
2835
+ type: z14.literal("message"),
2836
+ id: z14.string()
2715
2837
  }),
2716
- z13.object({
2717
- type: z13.literal("reasoning"),
2718
- id: z13.string()
2838
+ z14.object({
2839
+ type: z14.literal("reasoning"),
2840
+ id: z14.string(),
2841
+ encrypted_content: z14.string().nullish(),
2842
+ summary: z14.array(
2843
+ z14.object({
2844
+ type: z14.literal("summary_text"),
2845
+ text: z14.string()
2846
+ })
2847
+ )
2719
2848
  }),
2720
- z13.object({
2721
- type: z13.literal("function_call"),
2722
- id: z13.string(),
2723
- call_id: z13.string(),
2724
- name: z13.string(),
2725
- arguments: z13.string()
2849
+ z14.object({
2850
+ type: z14.literal("function_call"),
2851
+ id: z14.string(),
2852
+ call_id: z14.string(),
2853
+ name: z14.string(),
2854
+ arguments: z14.string()
2726
2855
  }),
2727
- z13.object({
2728
- type: z13.literal("web_search_call"),
2729
- id: z13.string(),
2730
- status: z13.string()
2856
+ z14.object({
2857
+ type: z14.literal("web_search_call"),
2858
+ id: z14.string(),
2859
+ status: z14.string()
2731
2860
  }),
2732
- z13.object({
2733
- type: z13.literal("computer_call"),
2734
- id: z13.string(),
2735
- status: z13.string()
2861
+ z14.object({
2862
+ type: z14.literal("computer_call"),
2863
+ id: z14.string(),
2864
+ status: z14.string()
2736
2865
  })
2737
2866
  ])
2738
2867
  });
2739
- var responseOutputItemDoneSchema = z13.object({
2740
- type: z13.literal("response.output_item.done"),
2741
- output_index: z13.number(),
2742
- item: z13.discriminatedUnion("type", [
2743
- z13.object({
2744
- type: z13.literal("message"),
2745
- id: z13.string()
2868
+ var responseOutputItemDoneSchema = z14.object({
2869
+ type: z14.literal("response.output_item.done"),
2870
+ output_index: z14.number(),
2871
+ item: z14.discriminatedUnion("type", [
2872
+ z14.object({
2873
+ type: z14.literal("message"),
2874
+ id: z14.string()
2746
2875
  }),
2747
- z13.object({
2748
- type: z13.literal("reasoning"),
2749
- id: z13.string()
2876
+ z14.object({
2877
+ type: z14.literal("reasoning"),
2878
+ id: z14.string(),
2879
+ encrypted_content: z14.string().nullish(),
2880
+ summary: z14.array(
2881
+ z14.object({
2882
+ type: z14.literal("summary_text"),
2883
+ text: z14.string()
2884
+ })
2885
+ )
2750
2886
  }),
2751
- z13.object({
2752
- type: z13.literal("function_call"),
2753
- id: z13.string(),
2754
- call_id: z13.string(),
2755
- name: z13.string(),
2756
- arguments: z13.string(),
2757
- status: z13.literal("completed")
2887
+ z14.object({
2888
+ type: z14.literal("function_call"),
2889
+ id: z14.string(),
2890
+ call_id: z14.string(),
2891
+ name: z14.string(),
2892
+ arguments: z14.string(),
2893
+ status: z14.literal("completed")
2758
2894
  }),
2759
- z13.object({
2760
- type: z13.literal("web_search_call"),
2761
- id: z13.string(),
2762
- status: z13.literal("completed")
2895
+ z14.object({
2896
+ type: z14.literal("web_search_call"),
2897
+ id: z14.string(),
2898
+ status: z14.literal("completed")
2763
2899
  }),
2764
- z13.object({
2765
- type: z13.literal("computer_call"),
2766
- id: z13.string(),
2767
- status: z13.literal("completed")
2900
+ z14.object({
2901
+ type: z14.literal("computer_call"),
2902
+ id: z14.string(),
2903
+ status: z14.literal("completed")
2768
2904
  })
2769
2905
  ])
2770
2906
  });
2771
- var responseFunctionCallArgumentsDeltaSchema = z13.object({
2772
- type: z13.literal("response.function_call_arguments.delta"),
2773
- item_id: z13.string(),
2774
- output_index: z13.number(),
2775
- delta: z13.string()
2907
+ var responseFunctionCallArgumentsDeltaSchema = z14.object({
2908
+ type: z14.literal("response.function_call_arguments.delta"),
2909
+ item_id: z14.string(),
2910
+ output_index: z14.number(),
2911
+ delta: z14.string()
2776
2912
  });
2777
- var responseAnnotationAddedSchema = z13.object({
2778
- type: z13.literal("response.output_text.annotation.added"),
2779
- annotation: z13.object({
2780
- type: z13.literal("url_citation"),
2781
- url: z13.string(),
2782
- title: z13.string()
2913
+ var responseAnnotationAddedSchema = z14.object({
2914
+ type: z14.literal("response.output_text.annotation.added"),
2915
+ annotation: z14.object({
2916
+ type: z14.literal("url_citation"),
2917
+ url: z14.string(),
2918
+ title: z14.string()
2783
2919
  })
2784
2920
  });
2785
- var responseReasoningSummaryTextDeltaSchema = z13.object({
2786
- type: z13.literal("response.reasoning_summary_text.delta"),
2787
- item_id: z13.string(),
2788
- output_index: z13.number(),
2789
- summary_index: z13.number(),
2790
- delta: z13.string()
2921
+ var responseReasoningSummaryTextDeltaSchema = z14.object({
2922
+ type: z14.literal("response.reasoning_summary_text.delta"),
2923
+ item_id: z14.string(),
2924
+ delta: z14.string()
2791
2925
  });
2792
- var responseReasoningSummaryPartDoneSchema = z13.object({
2793
- type: z13.literal("response.reasoning_summary_part.done"),
2794
- item_id: z13.string(),
2795
- output_index: z13.number(),
2796
- summary_index: z13.number(),
2797
- part: z13.unknown().nullish()
2798
- });
2799
- var openaiResponsesChunkSchema = z13.union([
2926
+ var openaiResponsesChunkSchema = z14.union([
2800
2927
  textDeltaChunkSchema,
2801
2928
  responseFinishedChunkSchema,
2802
2929
  responseCreatedChunkSchema,
@@ -2805,8 +2932,8 @@ var openaiResponsesChunkSchema = z13.union([
2805
2932
  responseFunctionCallArgumentsDeltaSchema,
2806
2933
  responseAnnotationAddedSchema,
2807
2934
  responseReasoningSummaryTextDeltaSchema,
2808
- responseReasoningSummaryPartDoneSchema,
2809
- z13.object({ type: z13.string() }).passthrough()
2935
+ errorChunkSchema,
2936
+ z14.object({ type: z14.string() }).loose()
2810
2937
  // fallback for unknown chunks
2811
2938
  ]);
2812
2939
  function isTextDeltaChunk(chunk) {
@@ -2833,8 +2960,11 @@ function isResponseAnnotationAddedChunk(chunk) {
2833
2960
  function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2834
2961
  return chunk.type === "response.reasoning_summary_text.delta";
2835
2962
  }
2963
+ function isErrorChunk(chunk) {
2964
+ return chunk.type === "error";
2965
+ }
2836
2966
  function getResponsesModelConfig(modelId) {
2837
- if (modelId.startsWith("o")) {
2967
+ if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
2838
2968
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
2839
2969
  return {
2840
2970
  isReasoningModel: true,
@@ -2857,30 +2987,31 @@ function getResponsesModelConfig(modelId) {
2857
2987
  function supportsFlexProcessing2(modelId) {
2858
2988
  return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
2859
2989
  }
2860
- var openaiResponsesProviderOptionsSchema = z13.object({
2861
- metadata: z13.any().nullish(),
2862
- parallelToolCalls: z13.boolean().nullish(),
2863
- previousResponseId: z13.string().nullish(),
2864
- store: z13.boolean().nullish(),
2865
- user: z13.string().nullish(),
2866
- reasoningEffort: z13.string().nullish(),
2867
- strictJsonSchema: z13.boolean().nullish(),
2868
- instructions: z13.string().nullish(),
2869
- reasoningSummary: z13.string().nullish(),
2870
- serviceTier: z13.enum(["auto", "flex"]).nullish()
2990
+ var openaiResponsesProviderOptionsSchema = z14.object({
2991
+ metadata: z14.any().nullish(),
2992
+ parallelToolCalls: z14.boolean().nullish(),
2993
+ previousResponseId: z14.string().nullish(),
2994
+ store: z14.boolean().nullish(),
2995
+ user: z14.string().nullish(),
2996
+ reasoningEffort: z14.string().nullish(),
2997
+ strictJsonSchema: z14.boolean().nullish(),
2998
+ instructions: z14.string().nullish(),
2999
+ reasoningSummary: z14.string().nullish(),
3000
+ serviceTier: z14.enum(["auto", "flex"]).nullish(),
3001
+ include: z14.array(z14.enum(["reasoning.encrypted_content"])).nullish()
2871
3002
  });
2872
3003
 
2873
3004
  // src/openai-speech-model.ts
2874
3005
  import {
2875
3006
  combineHeaders as combineHeaders7,
2876
3007
  createBinaryResponseHandler,
2877
- parseProviderOptions as parseProviderOptions6,
3008
+ parseProviderOptions as parseProviderOptions7,
2878
3009
  postJsonToApi as postJsonToApi6
2879
3010
  } from "@ai-sdk/provider-utils";
2880
- import { z as z14 } from "zod/v4";
2881
- var OpenAIProviderOptionsSchema = z14.object({
2882
- instructions: z14.string().nullish(),
2883
- speed: z14.number().min(0.25).max(4).default(1).nullish()
3011
+ import { z as z15 } from "zod/v4";
3012
+ var OpenAIProviderOptionsSchema = z15.object({
3013
+ instructions: z15.string().nullish(),
3014
+ speed: z15.number().min(0.25).max(4).default(1).nullish()
2884
3015
  });
2885
3016
  var OpenAISpeechModel = class {
2886
3017
  constructor(modelId, config) {
@@ -2901,7 +3032,7 @@ var OpenAISpeechModel = class {
2901
3032
  providerOptions
2902
3033
  }) {
2903
3034
  const warnings = [];
2904
- const openAIOptions = await parseProviderOptions6({
3035
+ const openAIOptions = await parseProviderOptions7({
2905
3036
  provider: "openai",
2906
3037
  providerOptions,
2907
3038
  schema: OpenAIProviderOptionsSchema