@ai-sdk/openai 1.3.7 → 2.0.0-canary.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.
package/dist/index.mjs CHANGED
@@ -360,7 +360,7 @@ function prepareTools({
360
360
  // src/openai-chat-language-model.ts
361
361
  var OpenAIChatLanguageModel = class {
362
362
  constructor(modelId, settings, config) {
363
- this.specificationVersion = "v1";
363
+ this.specificationVersion = "v2";
364
364
  this.modelId = modelId;
365
365
  this.settings = settings;
366
366
  this.config = config;
@@ -1183,7 +1183,7 @@ function mapOpenAICompletionLogProbs(logprobs) {
1183
1183
  // src/openai-completion-language-model.ts
1184
1184
  var OpenAICompletionLanguageModel = class {
1185
1185
  constructor(modelId, settings, config) {
1186
- this.specificationVersion = "v1";
1186
+ this.specificationVersion = "v2";
1187
1187
  this.defaultObjectGenerationMode = void 0;
1188
1188
  this.modelId = modelId;
1189
1189
  this.settings = settings;
@@ -1611,6 +1611,27 @@ var openaiImageResponseSchema = z5.object({
1611
1611
  data: z5.array(z5.object({ b64_json: z5.string() }))
1612
1612
  });
1613
1613
 
1614
+ // src/openai-tools.ts
1615
+ import { z as z6 } from "zod";
1616
+ var WebSearchPreviewParameters = z6.object({});
1617
+ function webSearchPreviewTool({
1618
+ searchContextSize,
1619
+ userLocation
1620
+ } = {}) {
1621
+ return {
1622
+ type: "provider-defined",
1623
+ id: "openai.web_search_preview",
1624
+ args: {
1625
+ searchContextSize,
1626
+ userLocation
1627
+ },
1628
+ parameters: WebSearchPreviewParameters
1629
+ };
1630
+ }
1631
+ var openaiTools = {
1632
+ webSearchPreview: webSearchPreviewTool
1633
+ };
1634
+
1614
1635
  // src/responses/openai-responses-language-model.ts
1615
1636
  import {
1616
1637
  combineHeaders as combineHeaders5,
@@ -1620,7 +1641,7 @@ import {
1620
1641
  parseProviderOptions,
1621
1642
  postJsonToApi as postJsonToApi5
1622
1643
  } from "@ai-sdk/provider-utils";
1623
- import { z as z6 } from "zod";
1644
+ import { z as z7 } from "zod";
1624
1645
 
1625
1646
  // src/responses/convert-to-openai-responses-messages.ts
1626
1647
  import {
@@ -1850,7 +1871,7 @@ function prepareResponsesTools({
1850
1871
  // src/responses/openai-responses-language-model.ts
1851
1872
  var OpenAIResponsesLanguageModel = class {
1852
1873
  constructor(modelId, config) {
1853
- this.specificationVersion = "v1";
1874
+ this.specificationVersion = "v2";
1854
1875
  this.defaultObjectGenerationMode = "json";
1855
1876
  this.modelId = modelId;
1856
1877
  this.config = config;
@@ -2040,49 +2061,49 @@ var OpenAIResponsesLanguageModel = class {
2040
2061
  body,
2041
2062
  failedResponseHandler: openaiFailedResponseHandler,
2042
2063
  successfulResponseHandler: createJsonResponseHandler5(
2043
- z6.object({
2044
- id: z6.string(),
2045
- created_at: z6.number(),
2046
- model: z6.string(),
2047
- output: z6.array(
2048
- z6.discriminatedUnion("type", [
2049
- z6.object({
2050
- type: z6.literal("message"),
2051
- role: z6.literal("assistant"),
2052
- content: z6.array(
2053
- z6.object({
2054
- type: z6.literal("output_text"),
2055
- text: z6.string(),
2056
- annotations: z6.array(
2057
- z6.object({
2058
- type: z6.literal("url_citation"),
2059
- start_index: z6.number(),
2060
- end_index: z6.number(),
2061
- url: z6.string(),
2062
- title: z6.string()
2064
+ z7.object({
2065
+ id: z7.string(),
2066
+ created_at: z7.number(),
2067
+ model: z7.string(),
2068
+ output: z7.array(
2069
+ z7.discriminatedUnion("type", [
2070
+ z7.object({
2071
+ type: z7.literal("message"),
2072
+ role: z7.literal("assistant"),
2073
+ content: z7.array(
2074
+ z7.object({
2075
+ type: z7.literal("output_text"),
2076
+ text: z7.string(),
2077
+ annotations: z7.array(
2078
+ z7.object({
2079
+ type: z7.literal("url_citation"),
2080
+ start_index: z7.number(),
2081
+ end_index: z7.number(),
2082
+ url: z7.string(),
2083
+ title: z7.string()
2063
2084
  })
2064
2085
  )
2065
2086
  })
2066
2087
  )
2067
2088
  }),
2068
- z6.object({
2069
- type: z6.literal("function_call"),
2070
- call_id: z6.string(),
2071
- name: z6.string(),
2072
- arguments: z6.string()
2089
+ z7.object({
2090
+ type: z7.literal("function_call"),
2091
+ call_id: z7.string(),
2092
+ name: z7.string(),
2093
+ arguments: z7.string()
2073
2094
  }),
2074
- z6.object({
2075
- type: z6.literal("web_search_call")
2095
+ z7.object({
2096
+ type: z7.literal("web_search_call")
2076
2097
  }),
2077
- z6.object({
2078
- type: z6.literal("computer_call")
2098
+ z7.object({
2099
+ type: z7.literal("computer_call")
2079
2100
  }),
2080
- z6.object({
2081
- type: z6.literal("reasoning")
2101
+ z7.object({
2102
+ type: z7.literal("reasoning")
2082
2103
  })
2083
2104
  ])
2084
2105
  ),
2085
- incomplete_details: z6.object({ reason: z6.string() }).nullable(),
2106
+ incomplete_details: z7.object({ reason: z7.string() }).nullable(),
2086
2107
  usage: usageSchema
2087
2108
  })
2088
2109
  ),
@@ -2280,79 +2301,79 @@ var OpenAIResponsesLanguageModel = class {
2280
2301
  };
2281
2302
  }
2282
2303
  };
2283
- var usageSchema = z6.object({
2284
- input_tokens: z6.number(),
2285
- input_tokens_details: z6.object({ cached_tokens: z6.number().nullish() }).nullish(),
2286
- output_tokens: z6.number(),
2287
- output_tokens_details: z6.object({ reasoning_tokens: z6.number().nullish() }).nullish()
2304
+ var usageSchema = z7.object({
2305
+ input_tokens: z7.number(),
2306
+ input_tokens_details: z7.object({ cached_tokens: z7.number().nullish() }).nullish(),
2307
+ output_tokens: z7.number(),
2308
+ output_tokens_details: z7.object({ reasoning_tokens: z7.number().nullish() }).nullish()
2288
2309
  });
2289
- var textDeltaChunkSchema = z6.object({
2290
- type: z6.literal("response.output_text.delta"),
2291
- delta: z6.string()
2310
+ var textDeltaChunkSchema = z7.object({
2311
+ type: z7.literal("response.output_text.delta"),
2312
+ delta: z7.string()
2292
2313
  });
2293
- var responseFinishedChunkSchema = z6.object({
2294
- type: z6.enum(["response.completed", "response.incomplete"]),
2295
- response: z6.object({
2296
- incomplete_details: z6.object({ reason: z6.string() }).nullish(),
2314
+ var responseFinishedChunkSchema = z7.object({
2315
+ type: z7.enum(["response.completed", "response.incomplete"]),
2316
+ response: z7.object({
2317
+ incomplete_details: z7.object({ reason: z7.string() }).nullish(),
2297
2318
  usage: usageSchema
2298
2319
  })
2299
2320
  });
2300
- var responseCreatedChunkSchema = z6.object({
2301
- type: z6.literal("response.created"),
2302
- response: z6.object({
2303
- id: z6.string(),
2304
- created_at: z6.number(),
2305
- model: z6.string()
2321
+ var responseCreatedChunkSchema = z7.object({
2322
+ type: z7.literal("response.created"),
2323
+ response: z7.object({
2324
+ id: z7.string(),
2325
+ created_at: z7.number(),
2326
+ model: z7.string()
2306
2327
  })
2307
2328
  });
2308
- var responseOutputItemDoneSchema = z6.object({
2309
- type: z6.literal("response.output_item.done"),
2310
- output_index: z6.number(),
2311
- item: z6.discriminatedUnion("type", [
2312
- z6.object({
2313
- type: z6.literal("message")
2329
+ var responseOutputItemDoneSchema = z7.object({
2330
+ type: z7.literal("response.output_item.done"),
2331
+ output_index: z7.number(),
2332
+ item: z7.discriminatedUnion("type", [
2333
+ z7.object({
2334
+ type: z7.literal("message")
2314
2335
  }),
2315
- z6.object({
2316
- type: z6.literal("function_call"),
2317
- id: z6.string(),
2318
- call_id: z6.string(),
2319
- name: z6.string(),
2320
- arguments: z6.string(),
2321
- status: z6.literal("completed")
2336
+ z7.object({
2337
+ type: z7.literal("function_call"),
2338
+ id: z7.string(),
2339
+ call_id: z7.string(),
2340
+ name: z7.string(),
2341
+ arguments: z7.string(),
2342
+ status: z7.literal("completed")
2322
2343
  })
2323
2344
  ])
2324
2345
  });
2325
- var responseFunctionCallArgumentsDeltaSchema = z6.object({
2326
- type: z6.literal("response.function_call_arguments.delta"),
2327
- item_id: z6.string(),
2328
- output_index: z6.number(),
2329
- delta: z6.string()
2346
+ var responseFunctionCallArgumentsDeltaSchema = z7.object({
2347
+ type: z7.literal("response.function_call_arguments.delta"),
2348
+ item_id: z7.string(),
2349
+ output_index: z7.number(),
2350
+ delta: z7.string()
2330
2351
  });
2331
- var responseOutputItemAddedSchema = z6.object({
2332
- type: z6.literal("response.output_item.added"),
2333
- output_index: z6.number(),
2334
- item: z6.discriminatedUnion("type", [
2335
- z6.object({
2336
- type: z6.literal("message")
2352
+ var responseOutputItemAddedSchema = z7.object({
2353
+ type: z7.literal("response.output_item.added"),
2354
+ output_index: z7.number(),
2355
+ item: z7.discriminatedUnion("type", [
2356
+ z7.object({
2357
+ type: z7.literal("message")
2337
2358
  }),
2338
- z6.object({
2339
- type: z6.literal("function_call"),
2340
- id: z6.string(),
2341
- call_id: z6.string(),
2342
- name: z6.string(),
2343
- arguments: z6.string()
2359
+ z7.object({
2360
+ type: z7.literal("function_call"),
2361
+ id: z7.string(),
2362
+ call_id: z7.string(),
2363
+ name: z7.string(),
2364
+ arguments: z7.string()
2344
2365
  })
2345
2366
  ])
2346
2367
  });
2347
- var responseAnnotationAddedSchema = z6.object({
2348
- type: z6.literal("response.output_text.annotation.added"),
2349
- annotation: z6.object({
2350
- type: z6.literal("url_citation"),
2351
- url: z6.string(),
2352
- title: z6.string()
2368
+ var responseAnnotationAddedSchema = z7.object({
2369
+ type: z7.literal("response.output_text.annotation.added"),
2370
+ annotation: z7.object({
2371
+ type: z7.literal("url_citation"),
2372
+ url: z7.string(),
2373
+ title: z7.string()
2353
2374
  })
2354
2375
  });
2355
- var openaiResponsesChunkSchema = z6.union([
2376
+ var openaiResponsesChunkSchema = z7.union([
2356
2377
  textDeltaChunkSchema,
2357
2378
  responseFinishedChunkSchema,
2358
2379
  responseCreatedChunkSchema,
@@ -2360,7 +2381,7 @@ var openaiResponsesChunkSchema = z6.union([
2360
2381
  responseFunctionCallArgumentsDeltaSchema,
2361
2382
  responseOutputItemAddedSchema,
2362
2383
  responseAnnotationAddedSchema,
2363
- z6.object({ type: z6.string() }).passthrough()
2384
+ z7.object({ type: z7.string() }).passthrough()
2364
2385
  // fallback for unknown chunks
2365
2386
  ]);
2366
2387
  function isTextDeltaChunk(chunk) {
@@ -2405,38 +2426,17 @@ function getResponsesModelConfig(modelId) {
2405
2426
  requiredAutoTruncation: false
2406
2427
  };
2407
2428
  }
2408
- var openaiResponsesProviderOptionsSchema = z6.object({
2409
- metadata: z6.any().nullish(),
2410
- parallelToolCalls: z6.boolean().nullish(),
2411
- previousResponseId: z6.string().nullish(),
2412
- store: z6.boolean().nullish(),
2413
- user: z6.string().nullish(),
2414
- reasoningEffort: z6.string().nullish(),
2415
- strictSchemas: z6.boolean().nullish(),
2416
- instructions: z6.string().nullish()
2429
+ var openaiResponsesProviderOptionsSchema = z7.object({
2430
+ metadata: z7.any().nullish(),
2431
+ parallelToolCalls: z7.boolean().nullish(),
2432
+ previousResponseId: z7.string().nullish(),
2433
+ store: z7.boolean().nullish(),
2434
+ user: z7.string().nullish(),
2435
+ reasoningEffort: z7.string().nullish(),
2436
+ strictSchemas: z7.boolean().nullish(),
2437
+ instructions: z7.string().nullish()
2417
2438
  });
2418
2439
 
2419
- // src/openai-tools.ts
2420
- import { z as z7 } from "zod";
2421
- var WebSearchPreviewParameters = z7.object({});
2422
- function webSearchPreviewTool({
2423
- searchContextSize,
2424
- userLocation
2425
- } = {}) {
2426
- return {
2427
- type: "provider-defined",
2428
- id: "openai.web_search_preview",
2429
- args: {
2430
- searchContextSize,
2431
- userLocation
2432
- },
2433
- parameters: WebSearchPreviewParameters
2434
- };
2435
- }
2436
- var openaiTools = {
2437
- webSearchPreview: webSearchPreviewTool
2438
- };
2439
-
2440
2440
  // src/openai-provider.ts
2441
2441
  function createOpenAI(options = {}) {
2442
2442
  var _a, _b, _c;