@ai-sdk/openai 2.0.44 → 2.0.46
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 +16 -0
- package/dist/index.d.mts +38 -65
- package/dist/index.d.ts +38 -65
- package/dist/index.js +1341 -1025
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1295 -934
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +101 -182
- package/dist/internal/index.d.ts +101 -182
- package/dist/internal/index.js +1338 -1020
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1307 -945
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/internal/index.ts
|
|
@@ -43,27 +53,27 @@ __export(internal_exports, {
|
|
|
43
53
|
openAITranscriptionProviderOptions: () => openAITranscriptionProviderOptions,
|
|
44
54
|
openaiChatLanguageModelOptions: () => openaiChatLanguageModelOptions,
|
|
45
55
|
openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
|
|
46
|
-
openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions
|
|
56
|
+
openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
|
|
57
|
+
openaiSpeechProviderOptionsSchema: () => openaiSpeechProviderOptionsSchema
|
|
47
58
|
});
|
|
48
59
|
module.exports = __toCommonJS(internal_exports);
|
|
49
60
|
|
|
50
61
|
// src/chat/openai-chat-language-model.ts
|
|
51
62
|
var import_provider3 = require("@ai-sdk/provider");
|
|
52
|
-
var
|
|
53
|
-
var import_v43 = require("zod/v4");
|
|
63
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
54
64
|
|
|
55
65
|
// src/openai-error.ts
|
|
56
|
-
var
|
|
66
|
+
var z = __toESM(require("zod/v4"));
|
|
57
67
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
58
|
-
var openaiErrorDataSchema =
|
|
59
|
-
error:
|
|
60
|
-
message:
|
|
68
|
+
var openaiErrorDataSchema = z.object({
|
|
69
|
+
error: z.object({
|
|
70
|
+
message: z.string(),
|
|
61
71
|
// The additional information below is handled loosely to support
|
|
62
72
|
// OpenAI-compatible providers that have slightly different error
|
|
63
73
|
// responses:
|
|
64
|
-
type:
|
|
65
|
-
param:
|
|
66
|
-
code:
|
|
74
|
+
type: z.string().nullish(),
|
|
75
|
+
param: z.any().nullish(),
|
|
76
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
67
77
|
})
|
|
68
78
|
});
|
|
69
79
|
var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
@@ -279,95 +289,240 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
279
289
|
}
|
|
280
290
|
}
|
|
281
291
|
|
|
292
|
+
// src/chat/openai-chat-api.ts
|
|
293
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
294
|
+
var z2 = __toESM(require("zod/v4"));
|
|
295
|
+
var openaiChatResponseSchema = (0, import_provider_utils3.lazyValidator)(
|
|
296
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
297
|
+
z2.object({
|
|
298
|
+
id: z2.string().nullish(),
|
|
299
|
+
created: z2.number().nullish(),
|
|
300
|
+
model: z2.string().nullish(),
|
|
301
|
+
choices: z2.array(
|
|
302
|
+
z2.object({
|
|
303
|
+
message: z2.object({
|
|
304
|
+
role: z2.literal("assistant").nullish(),
|
|
305
|
+
content: z2.string().nullish(),
|
|
306
|
+
tool_calls: z2.array(
|
|
307
|
+
z2.object({
|
|
308
|
+
id: z2.string().nullish(),
|
|
309
|
+
type: z2.literal("function"),
|
|
310
|
+
function: z2.object({
|
|
311
|
+
name: z2.string(),
|
|
312
|
+
arguments: z2.string()
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
).nullish(),
|
|
316
|
+
annotations: z2.array(
|
|
317
|
+
z2.object({
|
|
318
|
+
type: z2.literal("url_citation"),
|
|
319
|
+
start_index: z2.number(),
|
|
320
|
+
end_index: z2.number(),
|
|
321
|
+
url: z2.string(),
|
|
322
|
+
title: z2.string()
|
|
323
|
+
})
|
|
324
|
+
).nullish()
|
|
325
|
+
}),
|
|
326
|
+
index: z2.number(),
|
|
327
|
+
logprobs: z2.object({
|
|
328
|
+
content: z2.array(
|
|
329
|
+
z2.object({
|
|
330
|
+
token: z2.string(),
|
|
331
|
+
logprob: z2.number(),
|
|
332
|
+
top_logprobs: z2.array(
|
|
333
|
+
z2.object({
|
|
334
|
+
token: z2.string(),
|
|
335
|
+
logprob: z2.number()
|
|
336
|
+
})
|
|
337
|
+
)
|
|
338
|
+
})
|
|
339
|
+
).nullish()
|
|
340
|
+
}).nullish(),
|
|
341
|
+
finish_reason: z2.string().nullish()
|
|
342
|
+
})
|
|
343
|
+
),
|
|
344
|
+
usage: z2.object({
|
|
345
|
+
prompt_tokens: z2.number().nullish(),
|
|
346
|
+
completion_tokens: z2.number().nullish(),
|
|
347
|
+
total_tokens: z2.number().nullish(),
|
|
348
|
+
prompt_tokens_details: z2.object({
|
|
349
|
+
cached_tokens: z2.number().nullish()
|
|
350
|
+
}).nullish(),
|
|
351
|
+
completion_tokens_details: z2.object({
|
|
352
|
+
reasoning_tokens: z2.number().nullish(),
|
|
353
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
354
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
355
|
+
}).nullish()
|
|
356
|
+
}).nullish()
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
);
|
|
360
|
+
var openaiChatChunkSchema = (0, import_provider_utils3.lazyValidator)(
|
|
361
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
362
|
+
z2.union([
|
|
363
|
+
z2.object({
|
|
364
|
+
id: z2.string().nullish(),
|
|
365
|
+
created: z2.number().nullish(),
|
|
366
|
+
model: z2.string().nullish(),
|
|
367
|
+
choices: z2.array(
|
|
368
|
+
z2.object({
|
|
369
|
+
delta: z2.object({
|
|
370
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
371
|
+
content: z2.string().nullish(),
|
|
372
|
+
tool_calls: z2.array(
|
|
373
|
+
z2.object({
|
|
374
|
+
index: z2.number(),
|
|
375
|
+
id: z2.string().nullish(),
|
|
376
|
+
type: z2.literal("function").nullish(),
|
|
377
|
+
function: z2.object({
|
|
378
|
+
name: z2.string().nullish(),
|
|
379
|
+
arguments: z2.string().nullish()
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
).nullish(),
|
|
383
|
+
annotations: z2.array(
|
|
384
|
+
z2.object({
|
|
385
|
+
type: z2.literal("url_citation"),
|
|
386
|
+
start_index: z2.number(),
|
|
387
|
+
end_index: z2.number(),
|
|
388
|
+
url: z2.string(),
|
|
389
|
+
title: z2.string()
|
|
390
|
+
})
|
|
391
|
+
).nullish()
|
|
392
|
+
}).nullish(),
|
|
393
|
+
logprobs: z2.object({
|
|
394
|
+
content: z2.array(
|
|
395
|
+
z2.object({
|
|
396
|
+
token: z2.string(),
|
|
397
|
+
logprob: z2.number(),
|
|
398
|
+
top_logprobs: z2.array(
|
|
399
|
+
z2.object({
|
|
400
|
+
token: z2.string(),
|
|
401
|
+
logprob: z2.number()
|
|
402
|
+
})
|
|
403
|
+
)
|
|
404
|
+
})
|
|
405
|
+
).nullish()
|
|
406
|
+
}).nullish(),
|
|
407
|
+
finish_reason: z2.string().nullish(),
|
|
408
|
+
index: z2.number()
|
|
409
|
+
})
|
|
410
|
+
),
|
|
411
|
+
usage: z2.object({
|
|
412
|
+
prompt_tokens: z2.number().nullish(),
|
|
413
|
+
completion_tokens: z2.number().nullish(),
|
|
414
|
+
total_tokens: z2.number().nullish(),
|
|
415
|
+
prompt_tokens_details: z2.object({
|
|
416
|
+
cached_tokens: z2.number().nullish()
|
|
417
|
+
}).nullish(),
|
|
418
|
+
completion_tokens_details: z2.object({
|
|
419
|
+
reasoning_tokens: z2.number().nullish(),
|
|
420
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
421
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
422
|
+
}).nullish()
|
|
423
|
+
}).nullish()
|
|
424
|
+
}),
|
|
425
|
+
openaiErrorDataSchema
|
|
426
|
+
])
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
|
|
282
430
|
// src/chat/openai-chat-options.ts
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
431
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
432
|
+
var z3 = __toESM(require("zod/v4"));
|
|
433
|
+
var openaiChatLanguageModelOptions = (0, import_provider_utils4.lazyValidator)(
|
|
434
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
435
|
+
z3.object({
|
|
436
|
+
/**
|
|
437
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
438
|
+
*
|
|
439
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
440
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
441
|
+
*/
|
|
442
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
443
|
+
/**
|
|
444
|
+
* Return the log probabilities of the tokens.
|
|
445
|
+
*
|
|
446
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
447
|
+
* were generated.
|
|
448
|
+
*
|
|
449
|
+
* Setting to a number will return the log probabilities of the top n
|
|
450
|
+
* tokens that were generated.
|
|
451
|
+
*/
|
|
452
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
453
|
+
/**
|
|
454
|
+
* Whether to enable parallel function calling during tool use. Default to true.
|
|
455
|
+
*/
|
|
456
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
457
|
+
/**
|
|
458
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
459
|
+
* monitor and detect abuse.
|
|
460
|
+
*/
|
|
461
|
+
user: z3.string().optional(),
|
|
462
|
+
/**
|
|
463
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
464
|
+
*/
|
|
465
|
+
reasoningEffort: z3.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
466
|
+
/**
|
|
467
|
+
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
468
|
+
*/
|
|
469
|
+
maxCompletionTokens: z3.number().optional(),
|
|
470
|
+
/**
|
|
471
|
+
* Whether to enable persistence in responses API.
|
|
472
|
+
*/
|
|
473
|
+
store: z3.boolean().optional(),
|
|
474
|
+
/**
|
|
475
|
+
* Metadata to associate with the request.
|
|
476
|
+
*/
|
|
477
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
478
|
+
/**
|
|
479
|
+
* Parameters for prediction mode.
|
|
480
|
+
*/
|
|
481
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
482
|
+
/**
|
|
483
|
+
* Whether to use structured outputs.
|
|
484
|
+
*
|
|
485
|
+
* @default true
|
|
486
|
+
*/
|
|
487
|
+
structuredOutputs: z3.boolean().optional(),
|
|
488
|
+
/**
|
|
489
|
+
* Service tier for the request.
|
|
490
|
+
* - 'auto': Default service tier. The request will be processed with the service tier configured in the
|
|
491
|
+
* Project settings. Unless otherwise configured, the Project will use 'default'.
|
|
492
|
+
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
493
|
+
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
494
|
+
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
495
|
+
*
|
|
496
|
+
* @default 'auto'
|
|
497
|
+
*/
|
|
498
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
499
|
+
/**
|
|
500
|
+
* Whether to use strict JSON schema validation.
|
|
501
|
+
*
|
|
502
|
+
* @default false
|
|
503
|
+
*/
|
|
504
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
505
|
+
/**
|
|
506
|
+
* Controls the verbosity of the model's responses.
|
|
507
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
508
|
+
*/
|
|
509
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
510
|
+
/**
|
|
511
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
512
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
513
|
+
*/
|
|
514
|
+
promptCacheKey: z3.string().optional(),
|
|
515
|
+
/**
|
|
516
|
+
* A stable identifier used to help detect users of your application
|
|
517
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
518
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
519
|
+
* username or email address, in order to avoid sending us any identifying
|
|
520
|
+
* information.
|
|
521
|
+
*/
|
|
522
|
+
safetyIdentifier: z3.string().optional()
|
|
523
|
+
})
|
|
524
|
+
)
|
|
525
|
+
);
|
|
371
526
|
|
|
372
527
|
// src/chat/openai-chat-prepare-tools.ts
|
|
373
528
|
var import_provider2 = require("@ai-sdk/provider");
|
|
@@ -460,7 +615,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
460
615
|
}) {
|
|
461
616
|
var _a, _b, _c, _d;
|
|
462
617
|
const warnings = [];
|
|
463
|
-
const openaiOptions = (_a = await (0,
|
|
618
|
+
const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
464
619
|
provider: "openai",
|
|
465
620
|
providerOptions,
|
|
466
621
|
schema: openaiChatLanguageModelOptions
|
|
@@ -639,15 +794,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
639
794
|
responseHeaders,
|
|
640
795
|
value: response,
|
|
641
796
|
rawValue: rawResponse
|
|
642
|
-
} = await (0,
|
|
797
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
643
798
|
url: this.config.url({
|
|
644
799
|
path: "/chat/completions",
|
|
645
800
|
modelId: this.modelId
|
|
646
801
|
}),
|
|
647
|
-
headers: (0,
|
|
802
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
648
803
|
body,
|
|
649
804
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
650
|
-
successfulResponseHandler: (0,
|
|
805
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
651
806
|
openaiChatResponseSchema
|
|
652
807
|
),
|
|
653
808
|
abortSignal: options.abortSignal,
|
|
@@ -662,7 +817,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
662
817
|
for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
|
|
663
818
|
content.push({
|
|
664
819
|
type: "tool-call",
|
|
665
|
-
toolCallId: (_b = toolCall.id) != null ? _b : (0,
|
|
820
|
+
toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
|
|
666
821
|
toolName: toolCall.function.name,
|
|
667
822
|
input: toolCall.function.arguments
|
|
668
823
|
});
|
|
@@ -671,7 +826,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
671
826
|
content.push({
|
|
672
827
|
type: "source",
|
|
673
828
|
sourceType: "url",
|
|
674
|
-
id: (0,
|
|
829
|
+
id: (0, import_provider_utils5.generateId)(),
|
|
675
830
|
url: annotation.url,
|
|
676
831
|
title: annotation.title
|
|
677
832
|
});
|
|
@@ -717,15 +872,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
717
872
|
include_usage: true
|
|
718
873
|
}
|
|
719
874
|
};
|
|
720
|
-
const { responseHeaders, value: response } = await (0,
|
|
875
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
721
876
|
url: this.config.url({
|
|
722
877
|
path: "/chat/completions",
|
|
723
878
|
modelId: this.modelId
|
|
724
879
|
}),
|
|
725
|
-
headers: (0,
|
|
880
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
726
881
|
body,
|
|
727
882
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
728
|
-
successfulResponseHandler: (0,
|
|
883
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
729
884
|
openaiChatChunkSchema
|
|
730
885
|
),
|
|
731
886
|
abortSignal: options.abortSignal,
|
|
@@ -850,14 +1005,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
850
1005
|
delta: toolCall2.function.arguments
|
|
851
1006
|
});
|
|
852
1007
|
}
|
|
853
|
-
if ((0,
|
|
1008
|
+
if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
|
|
854
1009
|
controller.enqueue({
|
|
855
1010
|
type: "tool-input-end",
|
|
856
1011
|
id: toolCall2.id
|
|
857
1012
|
});
|
|
858
1013
|
controller.enqueue({
|
|
859
1014
|
type: "tool-call",
|
|
860
|
-
toolCallId: (_q = toolCall2.id) != null ? _q : (0,
|
|
1015
|
+
toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils5.generateId)(),
|
|
861
1016
|
toolName: toolCall2.function.name,
|
|
862
1017
|
input: toolCall2.function.arguments
|
|
863
1018
|
});
|
|
@@ -878,14 +1033,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
878
1033
|
id: toolCall.id,
|
|
879
1034
|
delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
|
|
880
1035
|
});
|
|
881
|
-
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0,
|
|
1036
|
+
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0, import_provider_utils5.isParsableJson)(toolCall.function.arguments)) {
|
|
882
1037
|
controller.enqueue({
|
|
883
1038
|
type: "tool-input-end",
|
|
884
1039
|
id: toolCall.id
|
|
885
1040
|
});
|
|
886
1041
|
controller.enqueue({
|
|
887
1042
|
type: "tool-call",
|
|
888
|
-
toolCallId: (_x = toolCall.id) != null ? _x : (0,
|
|
1043
|
+
toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils5.generateId)(),
|
|
889
1044
|
toolName: toolCall.function.name,
|
|
890
1045
|
input: toolCall.function.arguments
|
|
891
1046
|
});
|
|
@@ -898,7 +1053,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
898
1053
|
controller.enqueue({
|
|
899
1054
|
type: "source",
|
|
900
1055
|
sourceType: "url",
|
|
901
|
-
id: (0,
|
|
1056
|
+
id: (0, import_provider_utils5.generateId)(),
|
|
902
1057
|
url: annotation.url,
|
|
903
1058
|
title: annotation.title
|
|
904
1059
|
});
|
|
@@ -923,121 +1078,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
923
1078
|
};
|
|
924
1079
|
}
|
|
925
1080
|
};
|
|
926
|
-
var openaiTokenUsageSchema = import_v43.z.object({
|
|
927
|
-
prompt_tokens: import_v43.z.number().nullish(),
|
|
928
|
-
completion_tokens: import_v43.z.number().nullish(),
|
|
929
|
-
total_tokens: import_v43.z.number().nullish(),
|
|
930
|
-
prompt_tokens_details: import_v43.z.object({
|
|
931
|
-
cached_tokens: import_v43.z.number().nullish()
|
|
932
|
-
}).nullish(),
|
|
933
|
-
completion_tokens_details: import_v43.z.object({
|
|
934
|
-
reasoning_tokens: import_v43.z.number().nullish(),
|
|
935
|
-
accepted_prediction_tokens: import_v43.z.number().nullish(),
|
|
936
|
-
rejected_prediction_tokens: import_v43.z.number().nullish()
|
|
937
|
-
}).nullish()
|
|
938
|
-
}).nullish();
|
|
939
|
-
var openaiChatResponseSchema = import_v43.z.object({
|
|
940
|
-
id: import_v43.z.string().nullish(),
|
|
941
|
-
created: import_v43.z.number().nullish(),
|
|
942
|
-
model: import_v43.z.string().nullish(),
|
|
943
|
-
choices: import_v43.z.array(
|
|
944
|
-
import_v43.z.object({
|
|
945
|
-
message: import_v43.z.object({
|
|
946
|
-
role: import_v43.z.literal("assistant").nullish(),
|
|
947
|
-
content: import_v43.z.string().nullish(),
|
|
948
|
-
tool_calls: import_v43.z.array(
|
|
949
|
-
import_v43.z.object({
|
|
950
|
-
id: import_v43.z.string().nullish(),
|
|
951
|
-
type: import_v43.z.literal("function"),
|
|
952
|
-
function: import_v43.z.object({
|
|
953
|
-
name: import_v43.z.string(),
|
|
954
|
-
arguments: import_v43.z.string()
|
|
955
|
-
})
|
|
956
|
-
})
|
|
957
|
-
).nullish(),
|
|
958
|
-
annotations: import_v43.z.array(
|
|
959
|
-
import_v43.z.object({
|
|
960
|
-
type: import_v43.z.literal("url_citation"),
|
|
961
|
-
start_index: import_v43.z.number(),
|
|
962
|
-
end_index: import_v43.z.number(),
|
|
963
|
-
url: import_v43.z.string(),
|
|
964
|
-
title: import_v43.z.string()
|
|
965
|
-
})
|
|
966
|
-
).nullish()
|
|
967
|
-
}),
|
|
968
|
-
index: import_v43.z.number(),
|
|
969
|
-
logprobs: import_v43.z.object({
|
|
970
|
-
content: import_v43.z.array(
|
|
971
|
-
import_v43.z.object({
|
|
972
|
-
token: import_v43.z.string(),
|
|
973
|
-
logprob: import_v43.z.number(),
|
|
974
|
-
top_logprobs: import_v43.z.array(
|
|
975
|
-
import_v43.z.object({
|
|
976
|
-
token: import_v43.z.string(),
|
|
977
|
-
logprob: import_v43.z.number()
|
|
978
|
-
})
|
|
979
|
-
)
|
|
980
|
-
})
|
|
981
|
-
).nullish()
|
|
982
|
-
}).nullish(),
|
|
983
|
-
finish_reason: import_v43.z.string().nullish()
|
|
984
|
-
})
|
|
985
|
-
),
|
|
986
|
-
usage: openaiTokenUsageSchema
|
|
987
|
-
});
|
|
988
|
-
var openaiChatChunkSchema = import_v43.z.union([
|
|
989
|
-
import_v43.z.object({
|
|
990
|
-
id: import_v43.z.string().nullish(),
|
|
991
|
-
created: import_v43.z.number().nullish(),
|
|
992
|
-
model: import_v43.z.string().nullish(),
|
|
993
|
-
choices: import_v43.z.array(
|
|
994
|
-
import_v43.z.object({
|
|
995
|
-
delta: import_v43.z.object({
|
|
996
|
-
role: import_v43.z.enum(["assistant"]).nullish(),
|
|
997
|
-
content: import_v43.z.string().nullish(),
|
|
998
|
-
tool_calls: import_v43.z.array(
|
|
999
|
-
import_v43.z.object({
|
|
1000
|
-
index: import_v43.z.number(),
|
|
1001
|
-
id: import_v43.z.string().nullish(),
|
|
1002
|
-
type: import_v43.z.literal("function").nullish(),
|
|
1003
|
-
function: import_v43.z.object({
|
|
1004
|
-
name: import_v43.z.string().nullish(),
|
|
1005
|
-
arguments: import_v43.z.string().nullish()
|
|
1006
|
-
})
|
|
1007
|
-
})
|
|
1008
|
-
).nullish(),
|
|
1009
|
-
annotations: import_v43.z.array(
|
|
1010
|
-
import_v43.z.object({
|
|
1011
|
-
type: import_v43.z.literal("url_citation"),
|
|
1012
|
-
start_index: import_v43.z.number(),
|
|
1013
|
-
end_index: import_v43.z.number(),
|
|
1014
|
-
url: import_v43.z.string(),
|
|
1015
|
-
title: import_v43.z.string()
|
|
1016
|
-
})
|
|
1017
|
-
).nullish()
|
|
1018
|
-
}).nullish(),
|
|
1019
|
-
logprobs: import_v43.z.object({
|
|
1020
|
-
content: import_v43.z.array(
|
|
1021
|
-
import_v43.z.object({
|
|
1022
|
-
token: import_v43.z.string(),
|
|
1023
|
-
logprob: import_v43.z.number(),
|
|
1024
|
-
top_logprobs: import_v43.z.array(
|
|
1025
|
-
import_v43.z.object({
|
|
1026
|
-
token: import_v43.z.string(),
|
|
1027
|
-
logprob: import_v43.z.number()
|
|
1028
|
-
})
|
|
1029
|
-
)
|
|
1030
|
-
})
|
|
1031
|
-
).nullish()
|
|
1032
|
-
}).nullish(),
|
|
1033
|
-
finish_reason: import_v43.z.string().nullish(),
|
|
1034
|
-
index: import_v43.z.number()
|
|
1035
|
-
})
|
|
1036
|
-
),
|
|
1037
|
-
usage: openaiTokenUsageSchema
|
|
1038
|
-
}),
|
|
1039
|
-
openaiErrorDataSchema
|
|
1040
|
-
]);
|
|
1041
1081
|
function isReasoningModel(modelId) {
|
|
1042
1082
|
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
1043
1083
|
}
|
|
@@ -1088,8 +1128,7 @@ var reasoningModels = {
|
|
|
1088
1128
|
};
|
|
1089
1129
|
|
|
1090
1130
|
// src/completion/openai-completion-language-model.ts
|
|
1091
|
-
var
|
|
1092
|
-
var import_v45 = require("zod/v4");
|
|
1131
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1093
1132
|
|
|
1094
1133
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1095
1134
|
var import_provider4 = require("@ai-sdk/provider");
|
|
@@ -1196,48 +1235,111 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1196
1235
|
}
|
|
1197
1236
|
}
|
|
1198
1237
|
|
|
1238
|
+
// src/completion/openai-completion-api.ts
|
|
1239
|
+
var z4 = __toESM(require("zod/v4"));
|
|
1240
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1241
|
+
var openaiCompletionResponseSchema = (0, import_provider_utils6.lazyValidator)(
|
|
1242
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1243
|
+
z4.object({
|
|
1244
|
+
id: z4.string().nullish(),
|
|
1245
|
+
created: z4.number().nullish(),
|
|
1246
|
+
model: z4.string().nullish(),
|
|
1247
|
+
choices: z4.array(
|
|
1248
|
+
z4.object({
|
|
1249
|
+
text: z4.string(),
|
|
1250
|
+
finish_reason: z4.string(),
|
|
1251
|
+
logprobs: z4.object({
|
|
1252
|
+
tokens: z4.array(z4.string()),
|
|
1253
|
+
token_logprobs: z4.array(z4.number()),
|
|
1254
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1255
|
+
}).nullish()
|
|
1256
|
+
})
|
|
1257
|
+
),
|
|
1258
|
+
usage: z4.object({
|
|
1259
|
+
prompt_tokens: z4.number(),
|
|
1260
|
+
completion_tokens: z4.number(),
|
|
1261
|
+
total_tokens: z4.number()
|
|
1262
|
+
}).nullish()
|
|
1263
|
+
})
|
|
1264
|
+
)
|
|
1265
|
+
);
|
|
1266
|
+
var openaiCompletionChunkSchema = (0, import_provider_utils6.lazyValidator)(
|
|
1267
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1268
|
+
z4.union([
|
|
1269
|
+
z4.object({
|
|
1270
|
+
id: z4.string().nullish(),
|
|
1271
|
+
created: z4.number().nullish(),
|
|
1272
|
+
model: z4.string().nullish(),
|
|
1273
|
+
choices: z4.array(
|
|
1274
|
+
z4.object({
|
|
1275
|
+
text: z4.string(),
|
|
1276
|
+
finish_reason: z4.string().nullish(),
|
|
1277
|
+
index: z4.number(),
|
|
1278
|
+
logprobs: z4.object({
|
|
1279
|
+
tokens: z4.array(z4.string()),
|
|
1280
|
+
token_logprobs: z4.array(z4.number()),
|
|
1281
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1282
|
+
}).nullish()
|
|
1283
|
+
})
|
|
1284
|
+
),
|
|
1285
|
+
usage: z4.object({
|
|
1286
|
+
prompt_tokens: z4.number(),
|
|
1287
|
+
completion_tokens: z4.number(),
|
|
1288
|
+
total_tokens: z4.number()
|
|
1289
|
+
}).nullish()
|
|
1290
|
+
}),
|
|
1291
|
+
openaiErrorDataSchema
|
|
1292
|
+
])
|
|
1293
|
+
)
|
|
1294
|
+
);
|
|
1295
|
+
|
|
1199
1296
|
// src/completion/openai-completion-options.ts
|
|
1200
|
-
var
|
|
1201
|
-
var
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1297
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1298
|
+
var z5 = __toESM(require("zod/v4"));
|
|
1299
|
+
var openaiCompletionProviderOptions = (0, import_provider_utils7.lazyValidator)(
|
|
1300
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
1301
|
+
z5.object({
|
|
1302
|
+
/**
|
|
1303
|
+
Echo back the prompt in addition to the completion.
|
|
1304
|
+
*/
|
|
1305
|
+
echo: z5.boolean().optional(),
|
|
1306
|
+
/**
|
|
1307
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
1308
|
+
|
|
1309
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1310
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1311
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1312
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
1313
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
1314
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
1315
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
1316
|
+
|
|
1317
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1318
|
+
token from being generated.
|
|
1319
|
+
*/
|
|
1320
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1321
|
+
/**
|
|
1322
|
+
The suffix that comes after a completion of inserted text.
|
|
1323
|
+
*/
|
|
1324
|
+
suffix: z5.string().optional(),
|
|
1325
|
+
/**
|
|
1326
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1327
|
+
monitor and detect abuse. Learn more.
|
|
1328
|
+
*/
|
|
1329
|
+
user: z5.string().optional(),
|
|
1330
|
+
/**
|
|
1331
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1332
|
+
the response size and can slow down response times. However, it can
|
|
1333
|
+
be useful to better understand how the model is behaving.
|
|
1334
|
+
Setting to true will return the log probabilities of the tokens that
|
|
1335
|
+
were generated.
|
|
1336
|
+
Setting to a number will return the log probabilities of the top n
|
|
1337
|
+
tokens that were generated.
|
|
1338
|
+
*/
|
|
1339
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1340
|
+
})
|
|
1341
|
+
)
|
|
1342
|
+
);
|
|
1241
1343
|
|
|
1242
1344
|
// src/completion/openai-completion-language-model.ts
|
|
1243
1345
|
var OpenAICompletionLanguageModel = class {
|
|
@@ -1272,12 +1374,12 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1272
1374
|
}) {
|
|
1273
1375
|
const warnings = [];
|
|
1274
1376
|
const openaiOptions = {
|
|
1275
|
-
...await (0,
|
|
1377
|
+
...await (0, import_provider_utils8.parseProviderOptions)({
|
|
1276
1378
|
provider: "openai",
|
|
1277
1379
|
providerOptions,
|
|
1278
1380
|
schema: openaiCompletionProviderOptions
|
|
1279
1381
|
}),
|
|
1280
|
-
...await (0,
|
|
1382
|
+
...await (0, import_provider_utils8.parseProviderOptions)({
|
|
1281
1383
|
provider: this.providerOptionsName,
|
|
1282
1384
|
providerOptions,
|
|
1283
1385
|
schema: openaiCompletionProviderOptions
|
|
@@ -1333,15 +1435,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1333
1435
|
responseHeaders,
|
|
1334
1436
|
value: response,
|
|
1335
1437
|
rawValue: rawResponse
|
|
1336
|
-
} = await (0,
|
|
1438
|
+
} = await (0, import_provider_utils8.postJsonToApi)({
|
|
1337
1439
|
url: this.config.url({
|
|
1338
1440
|
path: "/completions",
|
|
1339
1441
|
modelId: this.modelId
|
|
1340
1442
|
}),
|
|
1341
|
-
headers: (0,
|
|
1443
|
+
headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
|
|
1342
1444
|
body: args,
|
|
1343
1445
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1344
|
-
successfulResponseHandler: (0,
|
|
1446
|
+
successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
|
|
1345
1447
|
openaiCompletionResponseSchema
|
|
1346
1448
|
),
|
|
1347
1449
|
abortSignal: options.abortSignal,
|
|
@@ -1379,15 +1481,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1379
1481
|
include_usage: true
|
|
1380
1482
|
}
|
|
1381
1483
|
};
|
|
1382
|
-
const { responseHeaders, value: response } = await (0,
|
|
1484
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
|
|
1383
1485
|
url: this.config.url({
|
|
1384
1486
|
path: "/completions",
|
|
1385
1487
|
modelId: this.modelId
|
|
1386
1488
|
}),
|
|
1387
|
-
headers: (0,
|
|
1489
|
+
headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
|
|
1388
1490
|
body,
|
|
1389
1491
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1390
|
-
successfulResponseHandler: (0,
|
|
1492
|
+
successfulResponseHandler: (0, import_provider_utils8.createEventSourceResponseHandler)(
|
|
1391
1493
|
openaiCompletionChunkSchema
|
|
1392
1494
|
),
|
|
1393
1495
|
abortSignal: options.abortSignal,
|
|
@@ -1468,69 +1570,42 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1468
1570
|
};
|
|
1469
1571
|
}
|
|
1470
1572
|
};
|
|
1471
|
-
var usageSchema = import_v45.z.object({
|
|
1472
|
-
prompt_tokens: import_v45.z.number(),
|
|
1473
|
-
completion_tokens: import_v45.z.number(),
|
|
1474
|
-
total_tokens: import_v45.z.number()
|
|
1475
|
-
});
|
|
1476
|
-
var openaiCompletionResponseSchema = import_v45.z.object({
|
|
1477
|
-
id: import_v45.z.string().nullish(),
|
|
1478
|
-
created: import_v45.z.number().nullish(),
|
|
1479
|
-
model: import_v45.z.string().nullish(),
|
|
1480
|
-
choices: import_v45.z.array(
|
|
1481
|
-
import_v45.z.object({
|
|
1482
|
-
text: import_v45.z.string(),
|
|
1483
|
-
finish_reason: import_v45.z.string(),
|
|
1484
|
-
logprobs: import_v45.z.object({
|
|
1485
|
-
tokens: import_v45.z.array(import_v45.z.string()),
|
|
1486
|
-
token_logprobs: import_v45.z.array(import_v45.z.number()),
|
|
1487
|
-
top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
|
|
1488
|
-
}).nullish()
|
|
1489
|
-
})
|
|
1490
|
-
),
|
|
1491
|
-
usage: usageSchema.nullish()
|
|
1492
|
-
});
|
|
1493
|
-
var openaiCompletionChunkSchema = import_v45.z.union([
|
|
1494
|
-
import_v45.z.object({
|
|
1495
|
-
id: import_v45.z.string().nullish(),
|
|
1496
|
-
created: import_v45.z.number().nullish(),
|
|
1497
|
-
model: import_v45.z.string().nullish(),
|
|
1498
|
-
choices: import_v45.z.array(
|
|
1499
|
-
import_v45.z.object({
|
|
1500
|
-
text: import_v45.z.string(),
|
|
1501
|
-
finish_reason: import_v45.z.string().nullish(),
|
|
1502
|
-
index: import_v45.z.number(),
|
|
1503
|
-
logprobs: import_v45.z.object({
|
|
1504
|
-
tokens: import_v45.z.array(import_v45.z.string()),
|
|
1505
|
-
token_logprobs: import_v45.z.array(import_v45.z.number()),
|
|
1506
|
-
top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
|
|
1507
|
-
}).nullish()
|
|
1508
|
-
})
|
|
1509
|
-
),
|
|
1510
|
-
usage: usageSchema.nullish()
|
|
1511
|
-
}),
|
|
1512
|
-
openaiErrorDataSchema
|
|
1513
|
-
]);
|
|
1514
1573
|
|
|
1515
1574
|
// src/embedding/openai-embedding-model.ts
|
|
1516
1575
|
var import_provider5 = require("@ai-sdk/provider");
|
|
1517
|
-
var
|
|
1518
|
-
var import_v47 = require("zod/v4");
|
|
1576
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1519
1577
|
|
|
1520
1578
|
// src/embedding/openai-embedding-options.ts
|
|
1521
|
-
var
|
|
1522
|
-
var
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1579
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1580
|
+
var z6 = __toESM(require("zod/v4"));
|
|
1581
|
+
var openaiEmbeddingProviderOptions = (0, import_provider_utils9.lazyValidator)(
|
|
1582
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1583
|
+
z6.object({
|
|
1584
|
+
/**
|
|
1585
|
+
The number of dimensions the resulting output embeddings should have.
|
|
1586
|
+
Only supported in text-embedding-3 and later models.
|
|
1587
|
+
*/
|
|
1588
|
+
dimensions: z6.number().optional(),
|
|
1589
|
+
/**
|
|
1590
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1591
|
+
monitor and detect abuse. Learn more.
|
|
1592
|
+
*/
|
|
1593
|
+
user: z6.string().optional()
|
|
1594
|
+
})
|
|
1595
|
+
)
|
|
1596
|
+
);
|
|
1597
|
+
|
|
1598
|
+
// src/embedding/openai-embedding-api.ts
|
|
1599
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1600
|
+
var z7 = __toESM(require("zod/v4"));
|
|
1601
|
+
var openaiTextEmbeddingResponseSchema = (0, import_provider_utils10.lazyValidator)(
|
|
1602
|
+
() => (0, import_provider_utils10.zodSchema)(
|
|
1603
|
+
z7.object({
|
|
1604
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1605
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1606
|
+
})
|
|
1607
|
+
)
|
|
1608
|
+
);
|
|
1534
1609
|
|
|
1535
1610
|
// src/embedding/openai-embedding-model.ts
|
|
1536
1611
|
var OpenAIEmbeddingModel = class {
|
|
@@ -1559,7 +1634,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1559
1634
|
values
|
|
1560
1635
|
});
|
|
1561
1636
|
}
|
|
1562
|
-
const openaiOptions = (_a = await (0,
|
|
1637
|
+
const openaiOptions = (_a = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1563
1638
|
provider: "openai",
|
|
1564
1639
|
providerOptions,
|
|
1565
1640
|
schema: openaiEmbeddingProviderOptions
|
|
@@ -1568,12 +1643,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1568
1643
|
responseHeaders,
|
|
1569
1644
|
value: response,
|
|
1570
1645
|
rawValue
|
|
1571
|
-
} = await (0,
|
|
1646
|
+
} = await (0, import_provider_utils11.postJsonToApi)({
|
|
1572
1647
|
url: this.config.url({
|
|
1573
1648
|
path: "/embeddings",
|
|
1574
1649
|
modelId: this.modelId
|
|
1575
1650
|
}),
|
|
1576
|
-
headers: (0,
|
|
1651
|
+
headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), headers),
|
|
1577
1652
|
body: {
|
|
1578
1653
|
model: this.modelId,
|
|
1579
1654
|
input: values,
|
|
@@ -1582,7 +1657,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1582
1657
|
user: openaiOptions.user
|
|
1583
1658
|
},
|
|
1584
1659
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1585
|
-
successfulResponseHandler: (0,
|
|
1660
|
+
successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
|
|
1586
1661
|
openaiTextEmbeddingResponseSchema
|
|
1587
1662
|
),
|
|
1588
1663
|
abortSignal,
|
|
@@ -1595,14 +1670,25 @@ var OpenAIEmbeddingModel = class {
|
|
|
1595
1670
|
};
|
|
1596
1671
|
}
|
|
1597
1672
|
};
|
|
1598
|
-
var openaiTextEmbeddingResponseSchema = import_v47.z.object({
|
|
1599
|
-
data: import_v47.z.array(import_v47.z.object({ embedding: import_v47.z.array(import_v47.z.number()) })),
|
|
1600
|
-
usage: import_v47.z.object({ prompt_tokens: import_v47.z.number() }).nullish()
|
|
1601
|
-
});
|
|
1602
1673
|
|
|
1603
1674
|
// src/image/openai-image-model.ts
|
|
1604
|
-
var
|
|
1605
|
-
|
|
1675
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1676
|
+
|
|
1677
|
+
// src/image/openai-image-api.ts
|
|
1678
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1679
|
+
var z8 = __toESM(require("zod/v4"));
|
|
1680
|
+
var openaiImageResponseSchema = (0, import_provider_utils12.lazyValidator)(
|
|
1681
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
1682
|
+
z8.object({
|
|
1683
|
+
data: z8.array(
|
|
1684
|
+
z8.object({
|
|
1685
|
+
b64_json: z8.string(),
|
|
1686
|
+
revised_prompt: z8.string().optional()
|
|
1687
|
+
})
|
|
1688
|
+
)
|
|
1689
|
+
})
|
|
1690
|
+
)
|
|
1691
|
+
);
|
|
1606
1692
|
|
|
1607
1693
|
// src/image/openai-image-options.ts
|
|
1608
1694
|
var modelMaxImagesPerCall = {
|
|
@@ -1653,12 +1739,12 @@ var OpenAIImageModel = class {
|
|
|
1653
1739
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
1654
1740
|
}
|
|
1655
1741
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1656
|
-
const { value: response, responseHeaders } = await (0,
|
|
1742
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils13.postJsonToApi)({
|
|
1657
1743
|
url: this.config.url({
|
|
1658
1744
|
path: "/images/generations",
|
|
1659
1745
|
modelId: this.modelId
|
|
1660
1746
|
}),
|
|
1661
|
-
headers: (0,
|
|
1747
|
+
headers: (0, import_provider_utils13.combineHeaders)(this.config.headers(), headers),
|
|
1662
1748
|
body: {
|
|
1663
1749
|
model: this.modelId,
|
|
1664
1750
|
prompt,
|
|
@@ -1668,7 +1754,7 @@ var OpenAIImageModel = class {
|
|
|
1668
1754
|
...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1669
1755
|
},
|
|
1670
1756
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1671
|
-
successfulResponseHandler: (0,
|
|
1757
|
+
successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
|
|
1672
1758
|
openaiImageResponseSchema
|
|
1673
1759
|
),
|
|
1674
1760
|
abortSignal,
|
|
@@ -1694,42 +1780,75 @@ var OpenAIImageModel = class {
|
|
|
1694
1780
|
};
|
|
1695
1781
|
}
|
|
1696
1782
|
};
|
|
1697
|
-
var openaiImageResponseSchema = import_v48.z.object({
|
|
1698
|
-
data: import_v48.z.array(
|
|
1699
|
-
import_v48.z.object({ b64_json: import_v48.z.string(), revised_prompt: import_v48.z.string().optional() })
|
|
1700
|
-
)
|
|
1701
|
-
});
|
|
1702
1783
|
|
|
1703
1784
|
// src/transcription/openai-transcription-model.ts
|
|
1704
|
-
var
|
|
1705
|
-
|
|
1785
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
1786
|
+
|
|
1787
|
+
// src/transcription/openai-transcription-api.ts
|
|
1788
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1789
|
+
var z9 = __toESM(require("zod/v4"));
|
|
1790
|
+
var openaiTranscriptionResponseSchema = (0, import_provider_utils14.lazyValidator)(
|
|
1791
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1792
|
+
z9.object({
|
|
1793
|
+
text: z9.string(),
|
|
1794
|
+
language: z9.string().nullish(),
|
|
1795
|
+
duration: z9.number().nullish(),
|
|
1796
|
+
words: z9.array(
|
|
1797
|
+
z9.object({
|
|
1798
|
+
word: z9.string(),
|
|
1799
|
+
start: z9.number(),
|
|
1800
|
+
end: z9.number()
|
|
1801
|
+
})
|
|
1802
|
+
).nullish(),
|
|
1803
|
+
segments: z9.array(
|
|
1804
|
+
z9.object({
|
|
1805
|
+
id: z9.number(),
|
|
1806
|
+
seek: z9.number(),
|
|
1807
|
+
start: z9.number(),
|
|
1808
|
+
end: z9.number(),
|
|
1809
|
+
text: z9.string(),
|
|
1810
|
+
tokens: z9.array(z9.number()),
|
|
1811
|
+
temperature: z9.number(),
|
|
1812
|
+
avg_logprob: z9.number(),
|
|
1813
|
+
compression_ratio: z9.number(),
|
|
1814
|
+
no_speech_prob: z9.number()
|
|
1815
|
+
})
|
|
1816
|
+
).nullish()
|
|
1817
|
+
})
|
|
1818
|
+
)
|
|
1819
|
+
);
|
|
1706
1820
|
|
|
1707
1821
|
// src/transcription/openai-transcription-options.ts
|
|
1708
|
-
var
|
|
1709
|
-
var
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1822
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1823
|
+
var z10 = __toESM(require("zod/v4"));
|
|
1824
|
+
var openAITranscriptionProviderOptions = (0, import_provider_utils15.lazyValidator)(
|
|
1825
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
1826
|
+
z10.object({
|
|
1827
|
+
/**
|
|
1828
|
+
* Additional information to include in the transcription response.
|
|
1829
|
+
*/
|
|
1830
|
+
include: z10.array(z10.string()).optional(),
|
|
1831
|
+
/**
|
|
1832
|
+
* The language of the input audio in ISO-639-1 format.
|
|
1833
|
+
*/
|
|
1834
|
+
language: z10.string().optional(),
|
|
1835
|
+
/**
|
|
1836
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
1837
|
+
*/
|
|
1838
|
+
prompt: z10.string().optional(),
|
|
1839
|
+
/**
|
|
1840
|
+
* The sampling temperature, between 0 and 1.
|
|
1841
|
+
* @default 0
|
|
1842
|
+
*/
|
|
1843
|
+
temperature: z10.number().min(0).max(1).default(0).optional(),
|
|
1844
|
+
/**
|
|
1845
|
+
* The timestamp granularities to populate for this transcription.
|
|
1846
|
+
* @default ['segment']
|
|
1847
|
+
*/
|
|
1848
|
+
timestampGranularities: z10.array(z10.enum(["word", "segment"])).default(["segment"]).optional()
|
|
1849
|
+
})
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1733
1852
|
|
|
1734
1853
|
// src/transcription/openai-transcription-model.ts
|
|
1735
1854
|
var languageMap = {
|
|
@@ -1806,15 +1925,15 @@ var OpenAITranscriptionModel = class {
|
|
|
1806
1925
|
providerOptions
|
|
1807
1926
|
}) {
|
|
1808
1927
|
const warnings = [];
|
|
1809
|
-
const openAIOptions = await (0,
|
|
1928
|
+
const openAIOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
1810
1929
|
provider: "openai",
|
|
1811
1930
|
providerOptions,
|
|
1812
1931
|
schema: openAITranscriptionProviderOptions
|
|
1813
1932
|
});
|
|
1814
1933
|
const formData = new FormData();
|
|
1815
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0,
|
|
1934
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils16.convertBase64ToUint8Array)(audio)]);
|
|
1816
1935
|
formData.append("model", this.modelId);
|
|
1817
|
-
const fileExtension = (0,
|
|
1936
|
+
const fileExtension = (0, import_provider_utils16.mediaTypeToExtension)(mediaType);
|
|
1818
1937
|
formData.append(
|
|
1819
1938
|
"file",
|
|
1820
1939
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -1859,15 +1978,15 @@ var OpenAITranscriptionModel = class {
|
|
|
1859
1978
|
value: response,
|
|
1860
1979
|
responseHeaders,
|
|
1861
1980
|
rawValue: rawResponse
|
|
1862
|
-
} = await (0,
|
|
1981
|
+
} = await (0, import_provider_utils16.postFormDataToApi)({
|
|
1863
1982
|
url: this.config.url({
|
|
1864
1983
|
path: "/audio/transcriptions",
|
|
1865
1984
|
modelId: this.modelId
|
|
1866
1985
|
}),
|
|
1867
|
-
headers: (0,
|
|
1986
|
+
headers: (0, import_provider_utils16.combineHeaders)(this.config.headers(), options.headers),
|
|
1868
1987
|
formData,
|
|
1869
1988
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1870
|
-
successfulResponseHandler: (0,
|
|
1989
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
1871
1990
|
openaiTranscriptionResponseSchema
|
|
1872
1991
|
),
|
|
1873
1992
|
abortSignal: options.abortSignal,
|
|
@@ -1897,40 +2016,23 @@ var OpenAITranscriptionModel = class {
|
|
|
1897
2016
|
};
|
|
1898
2017
|
}
|
|
1899
2018
|
};
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
import_v410.z.object({
|
|
1913
|
-
id: import_v410.z.number(),
|
|
1914
|
-
seek: import_v410.z.number(),
|
|
1915
|
-
start: import_v410.z.number(),
|
|
1916
|
-
end: import_v410.z.number(),
|
|
1917
|
-
text: import_v410.z.string(),
|
|
1918
|
-
tokens: import_v410.z.array(import_v410.z.number()),
|
|
1919
|
-
temperature: import_v410.z.number(),
|
|
1920
|
-
avg_logprob: import_v410.z.number(),
|
|
1921
|
-
compression_ratio: import_v410.z.number(),
|
|
1922
|
-
no_speech_prob: import_v410.z.number()
|
|
2019
|
+
|
|
2020
|
+
// src/speech/openai-speech-model.ts
|
|
2021
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
2022
|
+
|
|
2023
|
+
// src/speech/openai-speech-options.ts
|
|
2024
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2025
|
+
var z11 = __toESM(require("zod/v4"));
|
|
2026
|
+
var openaiSpeechProviderOptionsSchema = (0, import_provider_utils17.lazyValidator)(
|
|
2027
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
2028
|
+
z11.object({
|
|
2029
|
+
instructions: z11.string().nullish(),
|
|
2030
|
+
speed: z11.number().min(0.25).max(4).default(1).nullish()
|
|
1923
2031
|
})
|
|
1924
|
-
)
|
|
1925
|
-
|
|
2032
|
+
)
|
|
2033
|
+
);
|
|
1926
2034
|
|
|
1927
2035
|
// src/speech/openai-speech-model.ts
|
|
1928
|
-
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1929
|
-
var import_v411 = require("zod/v4");
|
|
1930
|
-
var OpenAIProviderOptionsSchema = import_v411.z.object({
|
|
1931
|
-
instructions: import_v411.z.string().nullish(),
|
|
1932
|
-
speed: import_v411.z.number().min(0.25).max(4).default(1).nullish()
|
|
1933
|
-
});
|
|
1934
2036
|
var OpenAISpeechModel = class {
|
|
1935
2037
|
constructor(modelId, config) {
|
|
1936
2038
|
this.modelId = modelId;
|
|
@@ -1950,10 +2052,10 @@ var OpenAISpeechModel = class {
|
|
|
1950
2052
|
providerOptions
|
|
1951
2053
|
}) {
|
|
1952
2054
|
const warnings = [];
|
|
1953
|
-
const openAIOptions = await (0,
|
|
2055
|
+
const openAIOptions = await (0, import_provider_utils18.parseProviderOptions)({
|
|
1954
2056
|
provider: "openai",
|
|
1955
2057
|
providerOptions,
|
|
1956
|
-
schema:
|
|
2058
|
+
schema: openaiSpeechProviderOptionsSchema
|
|
1957
2059
|
});
|
|
1958
2060
|
const requestBody = {
|
|
1959
2061
|
model: this.modelId,
|
|
@@ -2003,15 +2105,15 @@ var OpenAISpeechModel = class {
|
|
|
2003
2105
|
value: audio,
|
|
2004
2106
|
responseHeaders,
|
|
2005
2107
|
rawValue: rawResponse
|
|
2006
|
-
} = await (0,
|
|
2108
|
+
} = await (0, import_provider_utils18.postJsonToApi)({
|
|
2007
2109
|
url: this.config.url({
|
|
2008
2110
|
path: "/audio/speech",
|
|
2009
2111
|
modelId: this.modelId
|
|
2010
2112
|
}),
|
|
2011
|
-
headers: (0,
|
|
2113
|
+
headers: (0, import_provider_utils18.combineHeaders)(this.config.headers(), options.headers),
|
|
2012
2114
|
body: requestBody,
|
|
2013
2115
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2014
|
-
successfulResponseHandler: (0,
|
|
2116
|
+
successfulResponseHandler: (0, import_provider_utils18.createBinaryResponseHandler)(),
|
|
2015
2117
|
abortSignal: options.abortSignal,
|
|
2016
2118
|
fetch: this.config.fetch
|
|
2017
2119
|
});
|
|
@@ -2033,31 +2135,34 @@ var OpenAISpeechModel = class {
|
|
|
2033
2135
|
|
|
2034
2136
|
// src/responses/openai-responses-language-model.ts
|
|
2035
2137
|
var import_provider8 = require("@ai-sdk/provider");
|
|
2036
|
-
var
|
|
2037
|
-
var import_v419 = require("zod/v4");
|
|
2138
|
+
var import_provider_utils29 = require("@ai-sdk/provider-utils");
|
|
2038
2139
|
|
|
2039
2140
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2040
2141
|
var import_provider6 = require("@ai-sdk/provider");
|
|
2041
|
-
var
|
|
2042
|
-
var
|
|
2142
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
2143
|
+
var z13 = __toESM(require("zod/v4"));
|
|
2043
2144
|
|
|
2044
2145
|
// src/tool/local-shell.ts
|
|
2045
|
-
var
|
|
2046
|
-
var
|
|
2047
|
-
var localShellInputSchema =
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2146
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
2147
|
+
var z12 = __toESM(require("zod/v4"));
|
|
2148
|
+
var localShellInputSchema = (0, import_provider_utils19.lazySchema)(
|
|
2149
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
2150
|
+
z12.object({
|
|
2151
|
+
action: z12.object({
|
|
2152
|
+
type: z12.literal("exec"),
|
|
2153
|
+
command: z12.array(z12.string()),
|
|
2154
|
+
timeoutMs: z12.number().optional(),
|
|
2155
|
+
user: z12.string().optional(),
|
|
2156
|
+
workingDirectory: z12.string().optional(),
|
|
2157
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
2158
|
+
})
|
|
2159
|
+
})
|
|
2160
|
+
)
|
|
2161
|
+
);
|
|
2162
|
+
var localShellOutputSchema = (0, import_provider_utils19.lazySchema)(
|
|
2163
|
+
() => (0, import_provider_utils19.zodSchema)(z12.object({ output: z12.string() }))
|
|
2164
|
+
);
|
|
2165
|
+
var localShell = (0, import_provider_utils19.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
2061
2166
|
id: "openai.local_shell",
|
|
2062
2167
|
name: "local_shell",
|
|
2063
2168
|
inputSchema: localShellInputSchema,
|
|
@@ -2122,7 +2227,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2122
2227
|
return {
|
|
2123
2228
|
type: "input_image",
|
|
2124
2229
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2125
|
-
image_url: `data:${mediaType};base64,${(0,
|
|
2230
|
+
image_url: `data:${mediaType};base64,${(0, import_provider_utils20.convertToBase64)(part.data)}`
|
|
2126
2231
|
},
|
|
2127
2232
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2128
2233
|
};
|
|
@@ -2137,7 +2242,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2137
2242
|
type: "input_file",
|
|
2138
2243
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2139
2244
|
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2140
|
-
file_data: `data:application/pdf;base64,${(0,
|
|
2245
|
+
file_data: `data:application/pdf;base64,${(0, import_provider_utils20.convertToBase64)(part.data)}`
|
|
2141
2246
|
}
|
|
2142
2247
|
};
|
|
2143
2248
|
} else {
|
|
@@ -2170,7 +2275,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2170
2275
|
break;
|
|
2171
2276
|
}
|
|
2172
2277
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2173
|
-
const parsedInput =
|
|
2278
|
+
const parsedInput = await (0, import_provider_utils20.validateTypes)({
|
|
2279
|
+
value: part.input,
|
|
2280
|
+
schema: localShellInputSchema
|
|
2281
|
+
});
|
|
2174
2282
|
input.push({
|
|
2175
2283
|
type: "local_shell_call",
|
|
2176
2284
|
call_id: part.toolCallId,
|
|
@@ -2208,7 +2316,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2208
2316
|
break;
|
|
2209
2317
|
}
|
|
2210
2318
|
case "reasoning": {
|
|
2211
|
-
const providerOptions = await (0,
|
|
2319
|
+
const providerOptions = await (0, import_provider_utils20.parseProviderOptions)({
|
|
2212
2320
|
provider: "openai",
|
|
2213
2321
|
providerOptions: part.providerOptions,
|
|
2214
2322
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
@@ -2266,10 +2374,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2266
2374
|
for (const part of content) {
|
|
2267
2375
|
const output = part.output;
|
|
2268
2376
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2377
|
+
const parsedOutput = await (0, import_provider_utils20.validateTypes)({
|
|
2378
|
+
value: output.value,
|
|
2379
|
+
schema: localShellOutputSchema
|
|
2380
|
+
});
|
|
2269
2381
|
input.push({
|
|
2270
2382
|
type: "local_shell_call_output",
|
|
2271
2383
|
call_id: part.toolCallId,
|
|
2272
|
-
output:
|
|
2384
|
+
output: parsedOutput.output
|
|
2273
2385
|
});
|
|
2274
2386
|
break;
|
|
2275
2387
|
}
|
|
@@ -2301,9 +2413,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2301
2413
|
}
|
|
2302
2414
|
return { input, warnings };
|
|
2303
2415
|
}
|
|
2304
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2305
|
-
itemId:
|
|
2306
|
-
reasoningEncryptedContent:
|
|
2416
|
+
var openaiResponsesReasoningProviderOptionsSchema = z13.object({
|
|
2417
|
+
itemId: z13.string().nullish(),
|
|
2418
|
+
reasoningEncryptedContent: z13.string().nullish()
|
|
2307
2419
|
});
|
|
2308
2420
|
|
|
2309
2421
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2324,33 +2436,574 @@ function mapOpenAIResponseFinishReason({
|
|
|
2324
2436
|
}
|
|
2325
2437
|
}
|
|
2326
2438
|
|
|
2439
|
+
// src/responses/openai-responses-api.ts
|
|
2440
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
2441
|
+
var z14 = __toESM(require("zod/v4"));
|
|
2442
|
+
var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
|
|
2443
|
+
() => (0, import_provider_utils21.zodSchema)(
|
|
2444
|
+
z14.union([
|
|
2445
|
+
z14.object({
|
|
2446
|
+
type: z14.literal("response.output_text.delta"),
|
|
2447
|
+
item_id: z14.string(),
|
|
2448
|
+
delta: z14.string(),
|
|
2449
|
+
logprobs: z14.array(
|
|
2450
|
+
z14.object({
|
|
2451
|
+
token: z14.string(),
|
|
2452
|
+
logprob: z14.number(),
|
|
2453
|
+
top_logprobs: z14.array(
|
|
2454
|
+
z14.object({
|
|
2455
|
+
token: z14.string(),
|
|
2456
|
+
logprob: z14.number()
|
|
2457
|
+
})
|
|
2458
|
+
)
|
|
2459
|
+
})
|
|
2460
|
+
).nullish()
|
|
2461
|
+
}),
|
|
2462
|
+
z14.object({
|
|
2463
|
+
type: z14.enum(["response.completed", "response.incomplete"]),
|
|
2464
|
+
response: z14.object({
|
|
2465
|
+
incomplete_details: z14.object({ reason: z14.string() }).nullish(),
|
|
2466
|
+
usage: z14.object({
|
|
2467
|
+
input_tokens: z14.number(),
|
|
2468
|
+
input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
|
|
2469
|
+
output_tokens: z14.number(),
|
|
2470
|
+
output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
|
|
2471
|
+
}),
|
|
2472
|
+
service_tier: z14.string().nullish()
|
|
2473
|
+
})
|
|
2474
|
+
}),
|
|
2475
|
+
z14.object({
|
|
2476
|
+
type: z14.literal("response.created"),
|
|
2477
|
+
response: z14.object({
|
|
2478
|
+
id: z14.string(),
|
|
2479
|
+
created_at: z14.number(),
|
|
2480
|
+
model: z14.string(),
|
|
2481
|
+
service_tier: z14.string().nullish()
|
|
2482
|
+
})
|
|
2483
|
+
}),
|
|
2484
|
+
z14.object({
|
|
2485
|
+
type: z14.literal("response.output_item.added"),
|
|
2486
|
+
output_index: z14.number(),
|
|
2487
|
+
item: z14.discriminatedUnion("type", [
|
|
2488
|
+
z14.object({
|
|
2489
|
+
type: z14.literal("message"),
|
|
2490
|
+
id: z14.string()
|
|
2491
|
+
}),
|
|
2492
|
+
z14.object({
|
|
2493
|
+
type: z14.literal("reasoning"),
|
|
2494
|
+
id: z14.string(),
|
|
2495
|
+
encrypted_content: z14.string().nullish()
|
|
2496
|
+
}),
|
|
2497
|
+
z14.object({
|
|
2498
|
+
type: z14.literal("function_call"),
|
|
2499
|
+
id: z14.string(),
|
|
2500
|
+
call_id: z14.string(),
|
|
2501
|
+
name: z14.string(),
|
|
2502
|
+
arguments: z14.string()
|
|
2503
|
+
}),
|
|
2504
|
+
z14.object({
|
|
2505
|
+
type: z14.literal("web_search_call"),
|
|
2506
|
+
id: z14.string(),
|
|
2507
|
+
status: z14.string(),
|
|
2508
|
+
action: z14.object({
|
|
2509
|
+
type: z14.literal("search"),
|
|
2510
|
+
query: z14.string().optional()
|
|
2511
|
+
}).nullish()
|
|
2512
|
+
}),
|
|
2513
|
+
z14.object({
|
|
2514
|
+
type: z14.literal("computer_call"),
|
|
2515
|
+
id: z14.string(),
|
|
2516
|
+
status: z14.string()
|
|
2517
|
+
}),
|
|
2518
|
+
z14.object({
|
|
2519
|
+
type: z14.literal("file_search_call"),
|
|
2520
|
+
id: z14.string()
|
|
2521
|
+
}),
|
|
2522
|
+
z14.object({
|
|
2523
|
+
type: z14.literal("image_generation_call"),
|
|
2524
|
+
id: z14.string()
|
|
2525
|
+
}),
|
|
2526
|
+
z14.object({
|
|
2527
|
+
type: z14.literal("code_interpreter_call"),
|
|
2528
|
+
id: z14.string(),
|
|
2529
|
+
container_id: z14.string(),
|
|
2530
|
+
code: z14.string().nullable(),
|
|
2531
|
+
outputs: z14.array(
|
|
2532
|
+
z14.discriminatedUnion("type", [
|
|
2533
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2534
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2535
|
+
])
|
|
2536
|
+
).nullable(),
|
|
2537
|
+
status: z14.string()
|
|
2538
|
+
})
|
|
2539
|
+
])
|
|
2540
|
+
}),
|
|
2541
|
+
z14.object({
|
|
2542
|
+
type: z14.literal("response.output_item.done"),
|
|
2543
|
+
output_index: z14.number(),
|
|
2544
|
+
item: z14.discriminatedUnion("type", [
|
|
2545
|
+
z14.object({
|
|
2546
|
+
type: z14.literal("message"),
|
|
2547
|
+
id: z14.string()
|
|
2548
|
+
}),
|
|
2549
|
+
z14.object({
|
|
2550
|
+
type: z14.literal("reasoning"),
|
|
2551
|
+
id: z14.string(),
|
|
2552
|
+
encrypted_content: z14.string().nullish()
|
|
2553
|
+
}),
|
|
2554
|
+
z14.object({
|
|
2555
|
+
type: z14.literal("function_call"),
|
|
2556
|
+
id: z14.string(),
|
|
2557
|
+
call_id: z14.string(),
|
|
2558
|
+
name: z14.string(),
|
|
2559
|
+
arguments: z14.string(),
|
|
2560
|
+
status: z14.literal("completed")
|
|
2561
|
+
}),
|
|
2562
|
+
z14.object({
|
|
2563
|
+
type: z14.literal("code_interpreter_call"),
|
|
2564
|
+
id: z14.string(),
|
|
2565
|
+
code: z14.string().nullable(),
|
|
2566
|
+
container_id: z14.string(),
|
|
2567
|
+
outputs: z14.array(
|
|
2568
|
+
z14.discriminatedUnion("type", [
|
|
2569
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2570
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2571
|
+
])
|
|
2572
|
+
).nullable()
|
|
2573
|
+
}),
|
|
2574
|
+
z14.object({
|
|
2575
|
+
type: z14.literal("image_generation_call"),
|
|
2576
|
+
id: z14.string(),
|
|
2577
|
+
result: z14.string()
|
|
2578
|
+
}),
|
|
2579
|
+
z14.object({
|
|
2580
|
+
type: z14.literal("web_search_call"),
|
|
2581
|
+
id: z14.string(),
|
|
2582
|
+
status: z14.string(),
|
|
2583
|
+
action: z14.discriminatedUnion("type", [
|
|
2584
|
+
z14.object({
|
|
2585
|
+
type: z14.literal("search"),
|
|
2586
|
+
query: z14.string().nullish()
|
|
2587
|
+
}),
|
|
2588
|
+
z14.object({
|
|
2589
|
+
type: z14.literal("open_page"),
|
|
2590
|
+
url: z14.string()
|
|
2591
|
+
}),
|
|
2592
|
+
z14.object({
|
|
2593
|
+
type: z14.literal("find"),
|
|
2594
|
+
url: z14.string(),
|
|
2595
|
+
pattern: z14.string()
|
|
2596
|
+
})
|
|
2597
|
+
]).nullish()
|
|
2598
|
+
}),
|
|
2599
|
+
z14.object({
|
|
2600
|
+
type: z14.literal("file_search_call"),
|
|
2601
|
+
id: z14.string(),
|
|
2602
|
+
queries: z14.array(z14.string()),
|
|
2603
|
+
results: z14.array(
|
|
2604
|
+
z14.object({
|
|
2605
|
+
attributes: z14.record(z14.string(), z14.unknown()),
|
|
2606
|
+
file_id: z14.string(),
|
|
2607
|
+
filename: z14.string(),
|
|
2608
|
+
score: z14.number(),
|
|
2609
|
+
text: z14.string()
|
|
2610
|
+
})
|
|
2611
|
+
).nullish()
|
|
2612
|
+
}),
|
|
2613
|
+
z14.object({
|
|
2614
|
+
type: z14.literal("local_shell_call"),
|
|
2615
|
+
id: z14.string(),
|
|
2616
|
+
call_id: z14.string(),
|
|
2617
|
+
action: z14.object({
|
|
2618
|
+
type: z14.literal("exec"),
|
|
2619
|
+
command: z14.array(z14.string()),
|
|
2620
|
+
timeout_ms: z14.number().optional(),
|
|
2621
|
+
user: z14.string().optional(),
|
|
2622
|
+
working_directory: z14.string().optional(),
|
|
2623
|
+
env: z14.record(z14.string(), z14.string()).optional()
|
|
2624
|
+
})
|
|
2625
|
+
}),
|
|
2626
|
+
z14.object({
|
|
2627
|
+
type: z14.literal("computer_call"),
|
|
2628
|
+
id: z14.string(),
|
|
2629
|
+
status: z14.literal("completed")
|
|
2630
|
+
})
|
|
2631
|
+
])
|
|
2632
|
+
}),
|
|
2633
|
+
z14.object({
|
|
2634
|
+
type: z14.literal("response.function_call_arguments.delta"),
|
|
2635
|
+
item_id: z14.string(),
|
|
2636
|
+
output_index: z14.number(),
|
|
2637
|
+
delta: z14.string()
|
|
2638
|
+
}),
|
|
2639
|
+
z14.object({
|
|
2640
|
+
type: z14.literal("response.image_generation_call.partial_image"),
|
|
2641
|
+
item_id: z14.string(),
|
|
2642
|
+
output_index: z14.number(),
|
|
2643
|
+
partial_image_b64: z14.string()
|
|
2644
|
+
}),
|
|
2645
|
+
z14.object({
|
|
2646
|
+
type: z14.literal("response.code_interpreter_call_code.delta"),
|
|
2647
|
+
item_id: z14.string(),
|
|
2648
|
+
output_index: z14.number(),
|
|
2649
|
+
delta: z14.string()
|
|
2650
|
+
}),
|
|
2651
|
+
z14.object({
|
|
2652
|
+
type: z14.literal("response.code_interpreter_call_code.done"),
|
|
2653
|
+
item_id: z14.string(),
|
|
2654
|
+
output_index: z14.number(),
|
|
2655
|
+
code: z14.string()
|
|
2656
|
+
}),
|
|
2657
|
+
z14.object({
|
|
2658
|
+
type: z14.literal("response.output_text.annotation.added"),
|
|
2659
|
+
annotation: z14.discriminatedUnion("type", [
|
|
2660
|
+
z14.object({
|
|
2661
|
+
type: z14.literal("url_citation"),
|
|
2662
|
+
url: z14.string(),
|
|
2663
|
+
title: z14.string()
|
|
2664
|
+
}),
|
|
2665
|
+
z14.object({
|
|
2666
|
+
type: z14.literal("file_citation"),
|
|
2667
|
+
file_id: z14.string(),
|
|
2668
|
+
filename: z14.string().nullish(),
|
|
2669
|
+
index: z14.number().nullish(),
|
|
2670
|
+
start_index: z14.number().nullish(),
|
|
2671
|
+
end_index: z14.number().nullish(),
|
|
2672
|
+
quote: z14.string().nullish()
|
|
2673
|
+
})
|
|
2674
|
+
])
|
|
2675
|
+
}),
|
|
2676
|
+
z14.object({
|
|
2677
|
+
type: z14.literal("response.reasoning_summary_part.added"),
|
|
2678
|
+
item_id: z14.string(),
|
|
2679
|
+
summary_index: z14.number()
|
|
2680
|
+
}),
|
|
2681
|
+
z14.object({
|
|
2682
|
+
type: z14.literal("response.reasoning_summary_text.delta"),
|
|
2683
|
+
item_id: z14.string(),
|
|
2684
|
+
summary_index: z14.number(),
|
|
2685
|
+
delta: z14.string()
|
|
2686
|
+
}),
|
|
2687
|
+
z14.object({
|
|
2688
|
+
type: z14.literal("error"),
|
|
2689
|
+
code: z14.string(),
|
|
2690
|
+
message: z14.string(),
|
|
2691
|
+
param: z14.string().nullish(),
|
|
2692
|
+
sequence_number: z14.number()
|
|
2693
|
+
}),
|
|
2694
|
+
z14.object({ type: z14.string() }).loose().transform((value) => ({
|
|
2695
|
+
type: "unknown_chunk",
|
|
2696
|
+
message: value.type
|
|
2697
|
+
}))
|
|
2698
|
+
// fallback for unknown chunks
|
|
2699
|
+
])
|
|
2700
|
+
)
|
|
2701
|
+
);
|
|
2702
|
+
var openaiResponsesResponseSchema = (0, import_provider_utils21.lazyValidator)(
|
|
2703
|
+
() => (0, import_provider_utils21.zodSchema)(
|
|
2704
|
+
z14.object({
|
|
2705
|
+
id: z14.string(),
|
|
2706
|
+
created_at: z14.number(),
|
|
2707
|
+
error: z14.object({
|
|
2708
|
+
code: z14.string(),
|
|
2709
|
+
message: z14.string()
|
|
2710
|
+
}).nullish(),
|
|
2711
|
+
model: z14.string(),
|
|
2712
|
+
output: z14.array(
|
|
2713
|
+
z14.discriminatedUnion("type", [
|
|
2714
|
+
z14.object({
|
|
2715
|
+
type: z14.literal("message"),
|
|
2716
|
+
role: z14.literal("assistant"),
|
|
2717
|
+
id: z14.string(),
|
|
2718
|
+
content: z14.array(
|
|
2719
|
+
z14.object({
|
|
2720
|
+
type: z14.literal("output_text"),
|
|
2721
|
+
text: z14.string(),
|
|
2722
|
+
logprobs: z14.array(
|
|
2723
|
+
z14.object({
|
|
2724
|
+
token: z14.string(),
|
|
2725
|
+
logprob: z14.number(),
|
|
2726
|
+
top_logprobs: z14.array(
|
|
2727
|
+
z14.object({
|
|
2728
|
+
token: z14.string(),
|
|
2729
|
+
logprob: z14.number()
|
|
2730
|
+
})
|
|
2731
|
+
)
|
|
2732
|
+
})
|
|
2733
|
+
).nullish(),
|
|
2734
|
+
annotations: z14.array(
|
|
2735
|
+
z14.discriminatedUnion("type", [
|
|
2736
|
+
z14.object({
|
|
2737
|
+
type: z14.literal("url_citation"),
|
|
2738
|
+
start_index: z14.number(),
|
|
2739
|
+
end_index: z14.number(),
|
|
2740
|
+
url: z14.string(),
|
|
2741
|
+
title: z14.string()
|
|
2742
|
+
}),
|
|
2743
|
+
z14.object({
|
|
2744
|
+
type: z14.literal("file_citation"),
|
|
2745
|
+
file_id: z14.string(),
|
|
2746
|
+
filename: z14.string().nullish(),
|
|
2747
|
+
index: z14.number().nullish(),
|
|
2748
|
+
start_index: z14.number().nullish(),
|
|
2749
|
+
end_index: z14.number().nullish(),
|
|
2750
|
+
quote: z14.string().nullish()
|
|
2751
|
+
}),
|
|
2752
|
+
z14.object({
|
|
2753
|
+
type: z14.literal("container_file_citation")
|
|
2754
|
+
})
|
|
2755
|
+
])
|
|
2756
|
+
)
|
|
2757
|
+
})
|
|
2758
|
+
)
|
|
2759
|
+
}),
|
|
2760
|
+
z14.object({
|
|
2761
|
+
type: z14.literal("web_search_call"),
|
|
2762
|
+
id: z14.string(),
|
|
2763
|
+
status: z14.string(),
|
|
2764
|
+
action: z14.discriminatedUnion("type", [
|
|
2765
|
+
z14.object({
|
|
2766
|
+
type: z14.literal("search"),
|
|
2767
|
+
query: z14.string().nullish()
|
|
2768
|
+
}),
|
|
2769
|
+
z14.object({
|
|
2770
|
+
type: z14.literal("open_page"),
|
|
2771
|
+
url: z14.string()
|
|
2772
|
+
}),
|
|
2773
|
+
z14.object({
|
|
2774
|
+
type: z14.literal("find"),
|
|
2775
|
+
url: z14.string(),
|
|
2776
|
+
pattern: z14.string()
|
|
2777
|
+
})
|
|
2778
|
+
]).nullish()
|
|
2779
|
+
}),
|
|
2780
|
+
z14.object({
|
|
2781
|
+
type: z14.literal("file_search_call"),
|
|
2782
|
+
id: z14.string(),
|
|
2783
|
+
queries: z14.array(z14.string()),
|
|
2784
|
+
results: z14.array(
|
|
2785
|
+
z14.object({
|
|
2786
|
+
attributes: z14.record(z14.string(), z14.unknown()),
|
|
2787
|
+
file_id: z14.string(),
|
|
2788
|
+
filename: z14.string(),
|
|
2789
|
+
score: z14.number(),
|
|
2790
|
+
text: z14.string()
|
|
2791
|
+
})
|
|
2792
|
+
).nullish()
|
|
2793
|
+
}),
|
|
2794
|
+
z14.object({
|
|
2795
|
+
type: z14.literal("code_interpreter_call"),
|
|
2796
|
+
id: z14.string(),
|
|
2797
|
+
code: z14.string().nullable(),
|
|
2798
|
+
container_id: z14.string(),
|
|
2799
|
+
outputs: z14.array(
|
|
2800
|
+
z14.discriminatedUnion("type", [
|
|
2801
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2802
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2803
|
+
])
|
|
2804
|
+
).nullable()
|
|
2805
|
+
}),
|
|
2806
|
+
z14.object({
|
|
2807
|
+
type: z14.literal("image_generation_call"),
|
|
2808
|
+
id: z14.string(),
|
|
2809
|
+
result: z14.string()
|
|
2810
|
+
}),
|
|
2811
|
+
z14.object({
|
|
2812
|
+
type: z14.literal("local_shell_call"),
|
|
2813
|
+
id: z14.string(),
|
|
2814
|
+
call_id: z14.string(),
|
|
2815
|
+
action: z14.object({
|
|
2816
|
+
type: z14.literal("exec"),
|
|
2817
|
+
command: z14.array(z14.string()),
|
|
2818
|
+
timeout_ms: z14.number().optional(),
|
|
2819
|
+
user: z14.string().optional(),
|
|
2820
|
+
working_directory: z14.string().optional(),
|
|
2821
|
+
env: z14.record(z14.string(), z14.string()).optional()
|
|
2822
|
+
})
|
|
2823
|
+
}),
|
|
2824
|
+
z14.object({
|
|
2825
|
+
type: z14.literal("function_call"),
|
|
2826
|
+
call_id: z14.string(),
|
|
2827
|
+
name: z14.string(),
|
|
2828
|
+
arguments: z14.string(),
|
|
2829
|
+
id: z14.string()
|
|
2830
|
+
}),
|
|
2831
|
+
z14.object({
|
|
2832
|
+
type: z14.literal("computer_call"),
|
|
2833
|
+
id: z14.string(),
|
|
2834
|
+
status: z14.string().optional()
|
|
2835
|
+
}),
|
|
2836
|
+
z14.object({
|
|
2837
|
+
type: z14.literal("reasoning"),
|
|
2838
|
+
id: z14.string(),
|
|
2839
|
+
encrypted_content: z14.string().nullish(),
|
|
2840
|
+
summary: z14.array(
|
|
2841
|
+
z14.object({
|
|
2842
|
+
type: z14.literal("summary_text"),
|
|
2843
|
+
text: z14.string()
|
|
2844
|
+
})
|
|
2845
|
+
)
|
|
2846
|
+
})
|
|
2847
|
+
])
|
|
2848
|
+
),
|
|
2849
|
+
service_tier: z14.string().nullish(),
|
|
2850
|
+
incomplete_details: z14.object({ reason: z14.string() }).nullish(),
|
|
2851
|
+
usage: z14.object({
|
|
2852
|
+
input_tokens: z14.number(),
|
|
2853
|
+
input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
|
|
2854
|
+
output_tokens: z14.number(),
|
|
2855
|
+
output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
|
|
2856
|
+
})
|
|
2857
|
+
})
|
|
2858
|
+
)
|
|
2859
|
+
);
|
|
2860
|
+
|
|
2861
|
+
// src/responses/openai-responses-options.ts
|
|
2862
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
2863
|
+
var z15 = __toESM(require("zod/v4"));
|
|
2864
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2865
|
+
var openaiResponsesReasoningModelIds = [
|
|
2866
|
+
"o1",
|
|
2867
|
+
"o1-2024-12-17",
|
|
2868
|
+
"o3-mini",
|
|
2869
|
+
"o3-mini-2025-01-31",
|
|
2870
|
+
"o3",
|
|
2871
|
+
"o3-2025-04-16",
|
|
2872
|
+
"o4-mini",
|
|
2873
|
+
"o4-mini-2025-04-16",
|
|
2874
|
+
"codex-mini-latest",
|
|
2875
|
+
"computer-use-preview",
|
|
2876
|
+
"gpt-5",
|
|
2877
|
+
"gpt-5-2025-08-07",
|
|
2878
|
+
"gpt-5-codex",
|
|
2879
|
+
"gpt-5-mini",
|
|
2880
|
+
"gpt-5-mini-2025-08-07",
|
|
2881
|
+
"gpt-5-nano",
|
|
2882
|
+
"gpt-5-nano-2025-08-07",
|
|
2883
|
+
"gpt-5-pro",
|
|
2884
|
+
"gpt-5-pro-2025-10-06"
|
|
2885
|
+
];
|
|
2886
|
+
var openaiResponsesModelIds = [
|
|
2887
|
+
"gpt-4.1",
|
|
2888
|
+
"gpt-4.1-2025-04-14",
|
|
2889
|
+
"gpt-4.1-mini",
|
|
2890
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2891
|
+
"gpt-4.1-nano",
|
|
2892
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2893
|
+
"gpt-4o",
|
|
2894
|
+
"gpt-4o-2024-05-13",
|
|
2895
|
+
"gpt-4o-2024-08-06",
|
|
2896
|
+
"gpt-4o-2024-11-20",
|
|
2897
|
+
"gpt-4o-audio-preview",
|
|
2898
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2899
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2900
|
+
"gpt-4o-search-preview",
|
|
2901
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2902
|
+
"gpt-4o-mini-search-preview",
|
|
2903
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2904
|
+
"gpt-4o-mini",
|
|
2905
|
+
"gpt-4o-mini-2024-07-18",
|
|
2906
|
+
"gpt-4-turbo",
|
|
2907
|
+
"gpt-4-turbo-2024-04-09",
|
|
2908
|
+
"gpt-4-turbo-preview",
|
|
2909
|
+
"gpt-4-0125-preview",
|
|
2910
|
+
"gpt-4-1106-preview",
|
|
2911
|
+
"gpt-4",
|
|
2912
|
+
"gpt-4-0613",
|
|
2913
|
+
"gpt-4.5-preview",
|
|
2914
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2915
|
+
"gpt-3.5-turbo-0125",
|
|
2916
|
+
"gpt-3.5-turbo",
|
|
2917
|
+
"gpt-3.5-turbo-1106",
|
|
2918
|
+
"chatgpt-4o-latest",
|
|
2919
|
+
"gpt-5-chat-latest",
|
|
2920
|
+
...openaiResponsesReasoningModelIds
|
|
2921
|
+
];
|
|
2922
|
+
var openaiResponsesProviderOptionsSchema = (0, import_provider_utils22.lazyValidator)(
|
|
2923
|
+
() => (0, import_provider_utils22.zodSchema)(
|
|
2924
|
+
z15.object({
|
|
2925
|
+
include: z15.array(
|
|
2926
|
+
z15.enum([
|
|
2927
|
+
"reasoning.encrypted_content",
|
|
2928
|
+
"file_search_call.results",
|
|
2929
|
+
"message.output_text.logprobs"
|
|
2930
|
+
])
|
|
2931
|
+
).nullish(),
|
|
2932
|
+
instructions: z15.string().nullish(),
|
|
2933
|
+
/**
|
|
2934
|
+
* Return the log probabilities of the tokens.
|
|
2935
|
+
*
|
|
2936
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2937
|
+
* were generated.
|
|
2938
|
+
*
|
|
2939
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2940
|
+
* tokens that were generated.
|
|
2941
|
+
*
|
|
2942
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2943
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2944
|
+
*/
|
|
2945
|
+
logprobs: z15.union([z15.boolean(), z15.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2946
|
+
/**
|
|
2947
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2948
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2949
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2950
|
+
*/
|
|
2951
|
+
maxToolCalls: z15.number().nullish(),
|
|
2952
|
+
metadata: z15.any().nullish(),
|
|
2953
|
+
parallelToolCalls: z15.boolean().nullish(),
|
|
2954
|
+
previousResponseId: z15.string().nullish(),
|
|
2955
|
+
promptCacheKey: z15.string().nullish(),
|
|
2956
|
+
reasoningEffort: z15.string().nullish(),
|
|
2957
|
+
reasoningSummary: z15.string().nullish(),
|
|
2958
|
+
safetyIdentifier: z15.string().nullish(),
|
|
2959
|
+
serviceTier: z15.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
2960
|
+
store: z15.boolean().nullish(),
|
|
2961
|
+
strictJsonSchema: z15.boolean().nullish(),
|
|
2962
|
+
textVerbosity: z15.enum(["low", "medium", "high"]).nullish(),
|
|
2963
|
+
user: z15.string().nullish()
|
|
2964
|
+
})
|
|
2965
|
+
)
|
|
2966
|
+
);
|
|
2967
|
+
|
|
2327
2968
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2328
2969
|
var import_provider7 = require("@ai-sdk/provider");
|
|
2329
2970
|
|
|
2330
2971
|
// src/tool/code-interpreter.ts
|
|
2331
|
-
var
|
|
2332
|
-
var
|
|
2333
|
-
var codeInterpreterInputSchema =
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
outputs: import_v414.z.array(
|
|
2339
|
-
import_v414.z.discriminatedUnion("type", [
|
|
2340
|
-
import_v414.z.object({ type: import_v414.z.literal("logs"), logs: import_v414.z.string() }),
|
|
2341
|
-
import_v414.z.object({ type: import_v414.z.literal("image"), url: import_v414.z.string() })
|
|
2342
|
-
])
|
|
2343
|
-
).nullish()
|
|
2344
|
-
});
|
|
2345
|
-
var codeInterpreterArgsSchema = import_v414.z.object({
|
|
2346
|
-
container: import_v414.z.union([
|
|
2347
|
-
import_v414.z.string(),
|
|
2348
|
-
import_v414.z.object({
|
|
2349
|
-
fileIds: import_v414.z.array(import_v414.z.string()).optional()
|
|
2972
|
+
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
2973
|
+
var z16 = __toESM(require("zod/v4"));
|
|
2974
|
+
var codeInterpreterInputSchema = (0, import_provider_utils23.lazySchema)(
|
|
2975
|
+
() => (0, import_provider_utils23.zodSchema)(
|
|
2976
|
+
z16.object({
|
|
2977
|
+
code: z16.string().nullish(),
|
|
2978
|
+
containerId: z16.string()
|
|
2350
2979
|
})
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
var
|
|
2980
|
+
)
|
|
2981
|
+
);
|
|
2982
|
+
var codeInterpreterOutputSchema = (0, import_provider_utils23.lazySchema)(
|
|
2983
|
+
() => (0, import_provider_utils23.zodSchema)(
|
|
2984
|
+
z16.object({
|
|
2985
|
+
outputs: z16.array(
|
|
2986
|
+
z16.discriminatedUnion("type", [
|
|
2987
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2988
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2989
|
+
])
|
|
2990
|
+
).nullish()
|
|
2991
|
+
})
|
|
2992
|
+
)
|
|
2993
|
+
);
|
|
2994
|
+
var codeInterpreterArgsSchema = (0, import_provider_utils23.lazySchema)(
|
|
2995
|
+
() => (0, import_provider_utils23.zodSchema)(
|
|
2996
|
+
z16.object({
|
|
2997
|
+
container: z16.union([
|
|
2998
|
+
z16.string(),
|
|
2999
|
+
z16.object({
|
|
3000
|
+
fileIds: z16.array(z16.string()).optional()
|
|
3001
|
+
})
|
|
3002
|
+
]).optional()
|
|
3003
|
+
})
|
|
3004
|
+
)
|
|
3005
|
+
);
|
|
3006
|
+
var codeInterpreterToolFactory = (0, import_provider_utils23.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
2354
3007
|
id: "openai.code_interpreter",
|
|
2355
3008
|
name: "code_interpreter",
|
|
2356
3009
|
inputSchema: codeInterpreterInputSchema,
|
|
@@ -2361,168 +3014,200 @@ var codeInterpreter = (args = {}) => {
|
|
|
2361
3014
|
};
|
|
2362
3015
|
|
|
2363
3016
|
// src/tool/file-search.ts
|
|
2364
|
-
var
|
|
2365
|
-
var
|
|
2366
|
-
var comparisonFilterSchema =
|
|
2367
|
-
key:
|
|
2368
|
-
type:
|
|
2369
|
-
value:
|
|
3017
|
+
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
3018
|
+
var z17 = __toESM(require("zod/v4"));
|
|
3019
|
+
var comparisonFilterSchema = z17.object({
|
|
3020
|
+
key: z17.string(),
|
|
3021
|
+
type: z17.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
3022
|
+
value: z17.union([z17.string(), z17.number(), z17.boolean()])
|
|
2370
3023
|
});
|
|
2371
|
-
var compoundFilterSchema =
|
|
2372
|
-
type:
|
|
2373
|
-
filters:
|
|
2374
|
-
|
|
3024
|
+
var compoundFilterSchema = z17.object({
|
|
3025
|
+
type: z17.enum(["and", "or"]),
|
|
3026
|
+
filters: z17.array(
|
|
3027
|
+
z17.union([comparisonFilterSchema, z17.lazy(() => compoundFilterSchema)])
|
|
2375
3028
|
)
|
|
2376
3029
|
});
|
|
2377
|
-
var fileSearchArgsSchema =
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
})
|
|
2386
|
-
|
|
2387
|
-
queries: import_v415.z.array(import_v415.z.string()),
|
|
2388
|
-
results: import_v415.z.array(
|
|
2389
|
-
import_v415.z.object({
|
|
2390
|
-
attributes: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()),
|
|
2391
|
-
fileId: import_v415.z.string(),
|
|
2392
|
-
filename: import_v415.z.string(),
|
|
2393
|
-
score: import_v415.z.number(),
|
|
2394
|
-
text: import_v415.z.string()
|
|
3030
|
+
var fileSearchArgsSchema = (0, import_provider_utils24.lazySchema)(
|
|
3031
|
+
() => (0, import_provider_utils24.zodSchema)(
|
|
3032
|
+
z17.object({
|
|
3033
|
+
vectorStoreIds: z17.array(z17.string()),
|
|
3034
|
+
maxNumResults: z17.number().optional(),
|
|
3035
|
+
ranking: z17.object({
|
|
3036
|
+
ranker: z17.string().optional(),
|
|
3037
|
+
scoreThreshold: z17.number().optional()
|
|
3038
|
+
}).optional(),
|
|
3039
|
+
filters: z17.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2395
3040
|
})
|
|
2396
|
-
)
|
|
2397
|
-
|
|
2398
|
-
var
|
|
3041
|
+
)
|
|
3042
|
+
);
|
|
3043
|
+
var fileSearchOutputSchema = (0, import_provider_utils24.lazySchema)(
|
|
3044
|
+
() => (0, import_provider_utils24.zodSchema)(
|
|
3045
|
+
z17.object({
|
|
3046
|
+
queries: z17.array(z17.string()),
|
|
3047
|
+
results: z17.array(
|
|
3048
|
+
z17.object({
|
|
3049
|
+
attributes: z17.record(z17.string(), z17.unknown()),
|
|
3050
|
+
fileId: z17.string(),
|
|
3051
|
+
filename: z17.string(),
|
|
3052
|
+
score: z17.number(),
|
|
3053
|
+
text: z17.string()
|
|
3054
|
+
})
|
|
3055
|
+
).nullable()
|
|
3056
|
+
})
|
|
3057
|
+
)
|
|
3058
|
+
);
|
|
3059
|
+
var fileSearch = (0, import_provider_utils24.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
2399
3060
|
id: "openai.file_search",
|
|
2400
3061
|
name: "file_search",
|
|
2401
|
-
inputSchema:
|
|
3062
|
+
inputSchema: z17.object({}),
|
|
2402
3063
|
outputSchema: fileSearchOutputSchema
|
|
2403
3064
|
});
|
|
2404
3065
|
|
|
2405
3066
|
// src/tool/web-search.ts
|
|
2406
|
-
var
|
|
2407
|
-
var
|
|
2408
|
-
var webSearchArgsSchema =
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
3067
|
+
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
3068
|
+
var z18 = __toESM(require("zod/v4"));
|
|
3069
|
+
var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
|
|
3070
|
+
() => (0, import_provider_utils25.zodSchema)(
|
|
3071
|
+
z18.object({
|
|
3072
|
+
filters: z18.object({
|
|
3073
|
+
allowedDomains: z18.array(z18.string()).optional()
|
|
3074
|
+
}).optional(),
|
|
3075
|
+
searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
|
|
3076
|
+
userLocation: z18.object({
|
|
3077
|
+
type: z18.literal("approximate"),
|
|
3078
|
+
country: z18.string().optional(),
|
|
3079
|
+
city: z18.string().optional(),
|
|
3080
|
+
region: z18.string().optional(),
|
|
3081
|
+
timezone: z18.string().optional()
|
|
3082
|
+
}).optional()
|
|
3083
|
+
})
|
|
3084
|
+
)
|
|
3085
|
+
);
|
|
3086
|
+
var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(
|
|
3087
|
+
() => (0, import_provider_utils25.zodSchema)(
|
|
3088
|
+
z18.object({
|
|
3089
|
+
action: z18.discriminatedUnion("type", [
|
|
3090
|
+
z18.object({
|
|
3091
|
+
type: z18.literal("search"),
|
|
3092
|
+
query: z18.string().nullish()
|
|
3093
|
+
}),
|
|
3094
|
+
z18.object({
|
|
3095
|
+
type: z18.literal("open_page"),
|
|
3096
|
+
url: z18.string()
|
|
3097
|
+
}),
|
|
3098
|
+
z18.object({
|
|
3099
|
+
type: z18.literal("find"),
|
|
3100
|
+
url: z18.string(),
|
|
3101
|
+
pattern: z18.string()
|
|
3102
|
+
})
|
|
3103
|
+
]).nullish()
|
|
3104
|
+
})
|
|
3105
|
+
)
|
|
3106
|
+
);
|
|
3107
|
+
var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactory)({
|
|
2422
3108
|
id: "openai.web_search",
|
|
2423
3109
|
name: "web_search",
|
|
2424
|
-
inputSchema:
|
|
2425
|
-
action: import_v416.z.discriminatedUnion("type", [
|
|
2426
|
-
import_v416.z.object({
|
|
2427
|
-
type: import_v416.z.literal("search"),
|
|
2428
|
-
query: import_v416.z.string().nullish()
|
|
2429
|
-
}),
|
|
2430
|
-
import_v416.z.object({
|
|
2431
|
-
type: import_v416.z.literal("open_page"),
|
|
2432
|
-
url: import_v416.z.string()
|
|
2433
|
-
}),
|
|
2434
|
-
import_v416.z.object({
|
|
2435
|
-
type: import_v416.z.literal("find"),
|
|
2436
|
-
url: import_v416.z.string(),
|
|
2437
|
-
pattern: import_v416.z.string()
|
|
2438
|
-
})
|
|
2439
|
-
]).nullish()
|
|
2440
|
-
})
|
|
3110
|
+
inputSchema: webSearchInputSchema
|
|
2441
3111
|
});
|
|
2442
3112
|
|
|
2443
3113
|
// src/tool/web-search-preview.ts
|
|
2444
|
-
var
|
|
2445
|
-
var
|
|
2446
|
-
var webSearchPreviewArgsSchema =
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
3114
|
+
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
3115
|
+
var z19 = __toESM(require("zod/v4"));
|
|
3116
|
+
var webSearchPreviewArgsSchema = (0, import_provider_utils26.lazySchema)(
|
|
3117
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
3118
|
+
z19.object({
|
|
3119
|
+
/**
|
|
3120
|
+
* Search context size to use for the web search.
|
|
3121
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
3122
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
3123
|
+
* - low: Least context, lowest cost, fastest response
|
|
3124
|
+
*/
|
|
3125
|
+
searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
|
|
3126
|
+
/**
|
|
3127
|
+
* User location information to provide geographically relevant search results.
|
|
3128
|
+
*/
|
|
3129
|
+
userLocation: z19.object({
|
|
3130
|
+
/**
|
|
3131
|
+
* Type of location (always 'approximate')
|
|
3132
|
+
*/
|
|
3133
|
+
type: z19.literal("approximate"),
|
|
3134
|
+
/**
|
|
3135
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
3136
|
+
*/
|
|
3137
|
+
country: z19.string().optional(),
|
|
3138
|
+
/**
|
|
3139
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
3140
|
+
*/
|
|
3141
|
+
city: z19.string().optional(),
|
|
3142
|
+
/**
|
|
3143
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
3144
|
+
*/
|
|
3145
|
+
region: z19.string().optional(),
|
|
3146
|
+
/**
|
|
3147
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
3148
|
+
*/
|
|
3149
|
+
timezone: z19.string().optional()
|
|
3150
|
+
}).optional()
|
|
3151
|
+
})
|
|
3152
|
+
)
|
|
3153
|
+
);
|
|
3154
|
+
var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
|
|
3155
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
3156
|
+
z19.object({
|
|
3157
|
+
action: z19.discriminatedUnion("type", [
|
|
3158
|
+
z19.object({
|
|
3159
|
+
type: z19.literal("search"),
|
|
3160
|
+
query: z19.string().nullish()
|
|
3161
|
+
}),
|
|
3162
|
+
z19.object({
|
|
3163
|
+
type: z19.literal("open_page"),
|
|
3164
|
+
url: z19.string()
|
|
3165
|
+
}),
|
|
3166
|
+
z19.object({
|
|
3167
|
+
type: z19.literal("find"),
|
|
3168
|
+
url: z19.string(),
|
|
3169
|
+
pattern: z19.string()
|
|
3170
|
+
})
|
|
3171
|
+
]).nullish()
|
|
3172
|
+
})
|
|
3173
|
+
)
|
|
3174
|
+
);
|
|
3175
|
+
var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactory)({
|
|
2481
3176
|
id: "openai.web_search_preview",
|
|
2482
3177
|
name: "web_search_preview",
|
|
2483
|
-
inputSchema:
|
|
2484
|
-
action: import_v417.z.discriminatedUnion("type", [
|
|
2485
|
-
import_v417.z.object({
|
|
2486
|
-
type: import_v417.z.literal("search"),
|
|
2487
|
-
query: import_v417.z.string().nullish()
|
|
2488
|
-
}),
|
|
2489
|
-
import_v417.z.object({
|
|
2490
|
-
type: import_v417.z.literal("open_page"),
|
|
2491
|
-
url: import_v417.z.string()
|
|
2492
|
-
}),
|
|
2493
|
-
import_v417.z.object({
|
|
2494
|
-
type: import_v417.z.literal("find"),
|
|
2495
|
-
url: import_v417.z.string(),
|
|
2496
|
-
pattern: import_v417.z.string()
|
|
2497
|
-
})
|
|
2498
|
-
]).nullish()
|
|
2499
|
-
})
|
|
3178
|
+
inputSchema: webSearchPreviewInputSchema
|
|
2500
3179
|
});
|
|
2501
3180
|
|
|
2502
3181
|
// src/tool/image-generation.ts
|
|
2503
|
-
var
|
|
2504
|
-
var
|
|
2505
|
-
var imageGenerationArgsSchema =
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
})
|
|
2522
|
-
|
|
3182
|
+
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
3183
|
+
var z20 = __toESM(require("zod/v4"));
|
|
3184
|
+
var imageGenerationArgsSchema = (0, import_provider_utils27.lazySchema)(
|
|
3185
|
+
() => (0, import_provider_utils27.zodSchema)(
|
|
3186
|
+
z20.object({
|
|
3187
|
+
background: z20.enum(["auto", "opaque", "transparent"]).optional(),
|
|
3188
|
+
inputFidelity: z20.enum(["low", "high"]).optional(),
|
|
3189
|
+
inputImageMask: z20.object({
|
|
3190
|
+
fileId: z20.string().optional(),
|
|
3191
|
+
imageUrl: z20.string().optional()
|
|
3192
|
+
}).optional(),
|
|
3193
|
+
model: z20.string().optional(),
|
|
3194
|
+
moderation: z20.enum(["auto"]).optional(),
|
|
3195
|
+
outputCompression: z20.number().int().min(0).max(100).optional(),
|
|
3196
|
+
outputFormat: z20.enum(["png", "jpeg", "webp"]).optional(),
|
|
3197
|
+
partialImages: z20.number().int().min(0).max(3).optional(),
|
|
3198
|
+
quality: z20.enum(["auto", "low", "medium", "high"]).optional(),
|
|
3199
|
+
size: z20.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
3200
|
+
}).strict()
|
|
3201
|
+
)
|
|
3202
|
+
);
|
|
3203
|
+
var imageGenerationInputSchema = (0, import_provider_utils27.lazySchema)(() => (0, import_provider_utils27.zodSchema)(z20.object({})));
|
|
3204
|
+
var imageGenerationOutputSchema = (0, import_provider_utils27.lazySchema)(
|
|
3205
|
+
() => (0, import_provider_utils27.zodSchema)(z20.object({ result: z20.string() }))
|
|
3206
|
+
);
|
|
3207
|
+
var imageGenerationToolFactory = (0, import_provider_utils27.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
2523
3208
|
id: "openai.image_generation",
|
|
2524
3209
|
name: "image_generation",
|
|
2525
|
-
inputSchema:
|
|
3210
|
+
inputSchema: imageGenerationInputSchema,
|
|
2526
3211
|
outputSchema: imageGenerationOutputSchema
|
|
2527
3212
|
});
|
|
2528
3213
|
var imageGeneration = (args = {}) => {
|
|
@@ -2530,7 +3215,8 @@ var imageGeneration = (args = {}) => {
|
|
|
2530
3215
|
};
|
|
2531
3216
|
|
|
2532
3217
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2533
|
-
|
|
3218
|
+
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
3219
|
+
async function prepareResponsesTools({
|
|
2534
3220
|
tools,
|
|
2535
3221
|
toolChoice,
|
|
2536
3222
|
strictJsonSchema
|
|
@@ -2555,7 +3241,10 @@ function prepareResponsesTools({
|
|
|
2555
3241
|
case "provider-defined": {
|
|
2556
3242
|
switch (tool.id) {
|
|
2557
3243
|
case "openai.file_search": {
|
|
2558
|
-
const args =
|
|
3244
|
+
const args = await (0, import_provider_utils28.validateTypes)({
|
|
3245
|
+
value: tool.args,
|
|
3246
|
+
schema: fileSearchArgsSchema
|
|
3247
|
+
});
|
|
2559
3248
|
openaiTools.push({
|
|
2560
3249
|
type: "file_search",
|
|
2561
3250
|
vector_store_ids: args.vectorStoreIds,
|
|
@@ -2575,7 +3264,10 @@ function prepareResponsesTools({
|
|
|
2575
3264
|
break;
|
|
2576
3265
|
}
|
|
2577
3266
|
case "openai.web_search_preview": {
|
|
2578
|
-
const args =
|
|
3267
|
+
const args = await (0, import_provider_utils28.validateTypes)({
|
|
3268
|
+
value: tool.args,
|
|
3269
|
+
schema: webSearchPreviewArgsSchema
|
|
3270
|
+
});
|
|
2579
3271
|
openaiTools.push({
|
|
2580
3272
|
type: "web_search_preview",
|
|
2581
3273
|
search_context_size: args.searchContextSize,
|
|
@@ -2584,7 +3276,10 @@ function prepareResponsesTools({
|
|
|
2584
3276
|
break;
|
|
2585
3277
|
}
|
|
2586
3278
|
case "openai.web_search": {
|
|
2587
|
-
const args =
|
|
3279
|
+
const args = await (0, import_provider_utils28.validateTypes)({
|
|
3280
|
+
value: tool.args,
|
|
3281
|
+
schema: webSearchArgsSchema
|
|
3282
|
+
});
|
|
2588
3283
|
openaiTools.push({
|
|
2589
3284
|
type: "web_search",
|
|
2590
3285
|
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
@@ -2594,7 +3289,10 @@ function prepareResponsesTools({
|
|
|
2594
3289
|
break;
|
|
2595
3290
|
}
|
|
2596
3291
|
case "openai.code_interpreter": {
|
|
2597
|
-
const args =
|
|
3292
|
+
const args = await (0, import_provider_utils28.validateTypes)({
|
|
3293
|
+
value: tool.args,
|
|
3294
|
+
schema: codeInterpreterArgsSchema
|
|
3295
|
+
});
|
|
2598
3296
|
openaiTools.push({
|
|
2599
3297
|
type: "code_interpreter",
|
|
2600
3298
|
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
@@ -2602,7 +3300,10 @@ function prepareResponsesTools({
|
|
|
2602
3300
|
break;
|
|
2603
3301
|
}
|
|
2604
3302
|
case "openai.image_generation": {
|
|
2605
|
-
const args =
|
|
3303
|
+
const args = await (0, import_provider_utils28.validateTypes)({
|
|
3304
|
+
value: tool.args,
|
|
3305
|
+
schema: imageGenerationArgsSchema
|
|
3306
|
+
});
|
|
2606
3307
|
openaiTools.push({
|
|
2607
3308
|
type: "image_generation",
|
|
2608
3309
|
background: args.background,
|
|
@@ -2653,83 +3354,6 @@ function prepareResponsesTools({
|
|
|
2653
3354
|
}
|
|
2654
3355
|
|
|
2655
3356
|
// src/responses/openai-responses-language-model.ts
|
|
2656
|
-
var webSearchCallItem = import_v419.z.object({
|
|
2657
|
-
type: import_v419.z.literal("web_search_call"),
|
|
2658
|
-
id: import_v419.z.string(),
|
|
2659
|
-
status: import_v419.z.string(),
|
|
2660
|
-
action: import_v419.z.discriminatedUnion("type", [
|
|
2661
|
-
import_v419.z.object({
|
|
2662
|
-
type: import_v419.z.literal("search"),
|
|
2663
|
-
query: import_v419.z.string().nullish()
|
|
2664
|
-
}),
|
|
2665
|
-
import_v419.z.object({
|
|
2666
|
-
type: import_v419.z.literal("open_page"),
|
|
2667
|
-
url: import_v419.z.string()
|
|
2668
|
-
}),
|
|
2669
|
-
import_v419.z.object({
|
|
2670
|
-
type: import_v419.z.literal("find"),
|
|
2671
|
-
url: import_v419.z.string(),
|
|
2672
|
-
pattern: import_v419.z.string()
|
|
2673
|
-
})
|
|
2674
|
-
]).nullish()
|
|
2675
|
-
});
|
|
2676
|
-
var fileSearchCallItem = import_v419.z.object({
|
|
2677
|
-
type: import_v419.z.literal("file_search_call"),
|
|
2678
|
-
id: import_v419.z.string(),
|
|
2679
|
-
queries: import_v419.z.array(import_v419.z.string()),
|
|
2680
|
-
results: import_v419.z.array(
|
|
2681
|
-
import_v419.z.object({
|
|
2682
|
-
attributes: import_v419.z.record(import_v419.z.string(), import_v419.z.unknown()),
|
|
2683
|
-
file_id: import_v419.z.string(),
|
|
2684
|
-
filename: import_v419.z.string(),
|
|
2685
|
-
score: import_v419.z.number(),
|
|
2686
|
-
text: import_v419.z.string()
|
|
2687
|
-
})
|
|
2688
|
-
).nullish()
|
|
2689
|
-
});
|
|
2690
|
-
var codeInterpreterCallItem = import_v419.z.object({
|
|
2691
|
-
type: import_v419.z.literal("code_interpreter_call"),
|
|
2692
|
-
id: import_v419.z.string(),
|
|
2693
|
-
code: import_v419.z.string().nullable(),
|
|
2694
|
-
container_id: import_v419.z.string(),
|
|
2695
|
-
outputs: import_v419.z.array(
|
|
2696
|
-
import_v419.z.discriminatedUnion("type", [
|
|
2697
|
-
import_v419.z.object({ type: import_v419.z.literal("logs"), logs: import_v419.z.string() }),
|
|
2698
|
-
import_v419.z.object({ type: import_v419.z.literal("image"), url: import_v419.z.string() })
|
|
2699
|
-
])
|
|
2700
|
-
).nullable()
|
|
2701
|
-
});
|
|
2702
|
-
var localShellCallItem = import_v419.z.object({
|
|
2703
|
-
type: import_v419.z.literal("local_shell_call"),
|
|
2704
|
-
id: import_v419.z.string(),
|
|
2705
|
-
call_id: import_v419.z.string(),
|
|
2706
|
-
action: import_v419.z.object({
|
|
2707
|
-
type: import_v419.z.literal("exec"),
|
|
2708
|
-
command: import_v419.z.array(import_v419.z.string()),
|
|
2709
|
-
timeout_ms: import_v419.z.number().optional(),
|
|
2710
|
-
user: import_v419.z.string().optional(),
|
|
2711
|
-
working_directory: import_v419.z.string().optional(),
|
|
2712
|
-
env: import_v419.z.record(import_v419.z.string(), import_v419.z.string()).optional()
|
|
2713
|
-
})
|
|
2714
|
-
});
|
|
2715
|
-
var imageGenerationCallItem = import_v419.z.object({
|
|
2716
|
-
type: import_v419.z.literal("image_generation_call"),
|
|
2717
|
-
id: import_v419.z.string(),
|
|
2718
|
-
result: import_v419.z.string()
|
|
2719
|
-
});
|
|
2720
|
-
var TOP_LOGPROBS_MAX = 20;
|
|
2721
|
-
var LOGPROBS_SCHEMA = import_v419.z.array(
|
|
2722
|
-
import_v419.z.object({
|
|
2723
|
-
token: import_v419.z.string(),
|
|
2724
|
-
logprob: import_v419.z.number(),
|
|
2725
|
-
top_logprobs: import_v419.z.array(
|
|
2726
|
-
import_v419.z.object({
|
|
2727
|
-
token: import_v419.z.string(),
|
|
2728
|
-
logprob: import_v419.z.number()
|
|
2729
|
-
})
|
|
2730
|
-
)
|
|
2731
|
-
})
|
|
2732
|
-
);
|
|
2733
3357
|
var OpenAIResponsesLanguageModel = class {
|
|
2734
3358
|
constructor(modelId, config) {
|
|
2735
3359
|
this.specificationVersion = "v2";
|
|
@@ -2782,7 +3406,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2782
3406
|
if (stopSequences != null) {
|
|
2783
3407
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
2784
3408
|
}
|
|
2785
|
-
const openaiOptions = await (0,
|
|
3409
|
+
const openaiOptions = await (0, import_provider_utils29.parseProviderOptions)({
|
|
2786
3410
|
provider: "openai",
|
|
2787
3411
|
providerOptions,
|
|
2788
3412
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -2921,7 +3545,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2921
3545
|
tools: openaiTools,
|
|
2922
3546
|
toolChoice: openaiToolChoice,
|
|
2923
3547
|
toolWarnings
|
|
2924
|
-
} = prepareResponsesTools({
|
|
3548
|
+
} = await prepareResponsesTools({
|
|
2925
3549
|
tools,
|
|
2926
3550
|
toolChoice,
|
|
2927
3551
|
strictJsonSchema
|
|
@@ -2951,91 +3575,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2951
3575
|
responseHeaders,
|
|
2952
3576
|
value: response,
|
|
2953
3577
|
rawValue: rawResponse
|
|
2954
|
-
} = await (0,
|
|
3578
|
+
} = await (0, import_provider_utils29.postJsonToApi)({
|
|
2955
3579
|
url,
|
|
2956
|
-
headers: (0,
|
|
3580
|
+
headers: (0, import_provider_utils29.combineHeaders)(this.config.headers(), options.headers),
|
|
2957
3581
|
body,
|
|
2958
3582
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2959
|
-
successfulResponseHandler: (0,
|
|
2960
|
-
|
|
2961
|
-
id: import_v419.z.string(),
|
|
2962
|
-
created_at: import_v419.z.number(),
|
|
2963
|
-
error: import_v419.z.object({
|
|
2964
|
-
code: import_v419.z.string(),
|
|
2965
|
-
message: import_v419.z.string()
|
|
2966
|
-
}).nullish(),
|
|
2967
|
-
model: import_v419.z.string(),
|
|
2968
|
-
output: import_v419.z.array(
|
|
2969
|
-
import_v419.z.discriminatedUnion("type", [
|
|
2970
|
-
import_v419.z.object({
|
|
2971
|
-
type: import_v419.z.literal("message"),
|
|
2972
|
-
role: import_v419.z.literal("assistant"),
|
|
2973
|
-
id: import_v419.z.string(),
|
|
2974
|
-
content: import_v419.z.array(
|
|
2975
|
-
import_v419.z.object({
|
|
2976
|
-
type: import_v419.z.literal("output_text"),
|
|
2977
|
-
text: import_v419.z.string(),
|
|
2978
|
-
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2979
|
-
annotations: import_v419.z.array(
|
|
2980
|
-
import_v419.z.discriminatedUnion("type", [
|
|
2981
|
-
import_v419.z.object({
|
|
2982
|
-
type: import_v419.z.literal("url_citation"),
|
|
2983
|
-
start_index: import_v419.z.number(),
|
|
2984
|
-
end_index: import_v419.z.number(),
|
|
2985
|
-
url: import_v419.z.string(),
|
|
2986
|
-
title: import_v419.z.string()
|
|
2987
|
-
}),
|
|
2988
|
-
import_v419.z.object({
|
|
2989
|
-
type: import_v419.z.literal("file_citation"),
|
|
2990
|
-
file_id: import_v419.z.string(),
|
|
2991
|
-
filename: import_v419.z.string().nullish(),
|
|
2992
|
-
index: import_v419.z.number().nullish(),
|
|
2993
|
-
start_index: import_v419.z.number().nullish(),
|
|
2994
|
-
end_index: import_v419.z.number().nullish(),
|
|
2995
|
-
quote: import_v419.z.string().nullish()
|
|
2996
|
-
}),
|
|
2997
|
-
import_v419.z.object({
|
|
2998
|
-
type: import_v419.z.literal("container_file_citation")
|
|
2999
|
-
})
|
|
3000
|
-
])
|
|
3001
|
-
)
|
|
3002
|
-
})
|
|
3003
|
-
)
|
|
3004
|
-
}),
|
|
3005
|
-
webSearchCallItem,
|
|
3006
|
-
fileSearchCallItem,
|
|
3007
|
-
codeInterpreterCallItem,
|
|
3008
|
-
imageGenerationCallItem,
|
|
3009
|
-
localShellCallItem,
|
|
3010
|
-
import_v419.z.object({
|
|
3011
|
-
type: import_v419.z.literal("function_call"),
|
|
3012
|
-
call_id: import_v419.z.string(),
|
|
3013
|
-
name: import_v419.z.string(),
|
|
3014
|
-
arguments: import_v419.z.string(),
|
|
3015
|
-
id: import_v419.z.string()
|
|
3016
|
-
}),
|
|
3017
|
-
import_v419.z.object({
|
|
3018
|
-
type: import_v419.z.literal("computer_call"),
|
|
3019
|
-
id: import_v419.z.string(),
|
|
3020
|
-
status: import_v419.z.string().optional()
|
|
3021
|
-
}),
|
|
3022
|
-
import_v419.z.object({
|
|
3023
|
-
type: import_v419.z.literal("reasoning"),
|
|
3024
|
-
id: import_v419.z.string(),
|
|
3025
|
-
encrypted_content: import_v419.z.string().nullish(),
|
|
3026
|
-
summary: import_v419.z.array(
|
|
3027
|
-
import_v419.z.object({
|
|
3028
|
-
type: import_v419.z.literal("summary_text"),
|
|
3029
|
-
text: import_v419.z.string()
|
|
3030
|
-
})
|
|
3031
|
-
)
|
|
3032
|
-
})
|
|
3033
|
-
])
|
|
3034
|
-
),
|
|
3035
|
-
service_tier: import_v419.z.string().nullish(),
|
|
3036
|
-
incomplete_details: import_v419.z.object({ reason: import_v419.z.string() }).nullish(),
|
|
3037
|
-
usage: usageSchema2
|
|
3038
|
-
})
|
|
3583
|
+
successfulResponseHandler: (0, import_provider_utils29.createJsonResponseHandler)(
|
|
3584
|
+
openaiResponsesResponseSchema
|
|
3039
3585
|
),
|
|
3040
3586
|
abortSignal: options.abortSignal,
|
|
3041
3587
|
fetch: this.config.fetch
|
|
@@ -3098,7 +3644,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3098
3644
|
type: "tool-call",
|
|
3099
3645
|
toolCallId: part.call_id,
|
|
3100
3646
|
toolName: "local_shell",
|
|
3101
|
-
input: JSON.stringify({
|
|
3647
|
+
input: JSON.stringify({
|
|
3648
|
+
action: part.action
|
|
3649
|
+
}),
|
|
3102
3650
|
providerMetadata: {
|
|
3103
3651
|
openai: {
|
|
3104
3652
|
itemId: part.id
|
|
@@ -3126,7 +3674,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3126
3674
|
content.push({
|
|
3127
3675
|
type: "source",
|
|
3128
3676
|
sourceType: "url",
|
|
3129
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
3677
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils29.generateId)(),
|
|
3130
3678
|
url: annotation.url,
|
|
3131
3679
|
title: annotation.title
|
|
3132
3680
|
});
|
|
@@ -3134,7 +3682,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3134
3682
|
content.push({
|
|
3135
3683
|
type: "source",
|
|
3136
3684
|
sourceType: "document",
|
|
3137
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
3685
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils29.generateId)(),
|
|
3138
3686
|
mediaType: "text/plain",
|
|
3139
3687
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
3140
3688
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
@@ -3286,18 +3834,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3286
3834
|
warnings,
|
|
3287
3835
|
webSearchToolName
|
|
3288
3836
|
} = await this.getArgs(options);
|
|
3289
|
-
const { responseHeaders, value: response } = await (0,
|
|
3837
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils29.postJsonToApi)({
|
|
3290
3838
|
url: this.config.url({
|
|
3291
3839
|
path: "/responses",
|
|
3292
3840
|
modelId: this.modelId
|
|
3293
3841
|
}),
|
|
3294
|
-
headers: (0,
|
|
3842
|
+
headers: (0, import_provider_utils29.combineHeaders)(this.config.headers(), options.headers),
|
|
3295
3843
|
body: {
|
|
3296
3844
|
...body,
|
|
3297
3845
|
stream: true
|
|
3298
3846
|
},
|
|
3299
3847
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3300
|
-
successfulResponseHandler: (0,
|
|
3848
|
+
successfulResponseHandler: (0, import_provider_utils29.createEventSourceResponseHandler)(
|
|
3301
3849
|
openaiResponsesChunkSchema
|
|
3302
3850
|
),
|
|
3303
3851
|
abortSignal: options.abortSignal,
|
|
@@ -3674,7 +4222,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3674
4222
|
controller.enqueue({
|
|
3675
4223
|
type: "source",
|
|
3676
4224
|
sourceType: "url",
|
|
3677
|
-
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0,
|
|
4225
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils29.generateId)(),
|
|
3678
4226
|
url: value.annotation.url,
|
|
3679
4227
|
title: value.annotation.title
|
|
3680
4228
|
});
|
|
@@ -3682,7 +4230,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3682
4230
|
controller.enqueue({
|
|
3683
4231
|
type: "source",
|
|
3684
4232
|
sourceType: "document",
|
|
3685
|
-
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0,
|
|
4233
|
+
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils29.generateId)(),
|
|
3686
4234
|
mediaType: "text/plain",
|
|
3687
4235
|
title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
|
|
3688
4236
|
filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id
|
|
@@ -3718,196 +4266,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3718
4266
|
};
|
|
3719
4267
|
}
|
|
3720
4268
|
};
|
|
3721
|
-
var usageSchema2 = import_v419.z.object({
|
|
3722
|
-
input_tokens: import_v419.z.number(),
|
|
3723
|
-
input_tokens_details: import_v419.z.object({ cached_tokens: import_v419.z.number().nullish() }).nullish(),
|
|
3724
|
-
output_tokens: import_v419.z.number(),
|
|
3725
|
-
output_tokens_details: import_v419.z.object({ reasoning_tokens: import_v419.z.number().nullish() }).nullish()
|
|
3726
|
-
});
|
|
3727
|
-
var textDeltaChunkSchema = import_v419.z.object({
|
|
3728
|
-
type: import_v419.z.literal("response.output_text.delta"),
|
|
3729
|
-
item_id: import_v419.z.string(),
|
|
3730
|
-
delta: import_v419.z.string(),
|
|
3731
|
-
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3732
|
-
});
|
|
3733
|
-
var errorChunkSchema = import_v419.z.object({
|
|
3734
|
-
type: import_v419.z.literal("error"),
|
|
3735
|
-
code: import_v419.z.string(),
|
|
3736
|
-
message: import_v419.z.string(),
|
|
3737
|
-
param: import_v419.z.string().nullish(),
|
|
3738
|
-
sequence_number: import_v419.z.number()
|
|
3739
|
-
});
|
|
3740
|
-
var responseFinishedChunkSchema = import_v419.z.object({
|
|
3741
|
-
type: import_v419.z.enum(["response.completed", "response.incomplete"]),
|
|
3742
|
-
response: import_v419.z.object({
|
|
3743
|
-
incomplete_details: import_v419.z.object({ reason: import_v419.z.string() }).nullish(),
|
|
3744
|
-
usage: usageSchema2,
|
|
3745
|
-
service_tier: import_v419.z.string().nullish()
|
|
3746
|
-
})
|
|
3747
|
-
});
|
|
3748
|
-
var responseCreatedChunkSchema = import_v419.z.object({
|
|
3749
|
-
type: import_v419.z.literal("response.created"),
|
|
3750
|
-
response: import_v419.z.object({
|
|
3751
|
-
id: import_v419.z.string(),
|
|
3752
|
-
created_at: import_v419.z.number(),
|
|
3753
|
-
model: import_v419.z.string(),
|
|
3754
|
-
service_tier: import_v419.z.string().nullish()
|
|
3755
|
-
})
|
|
3756
|
-
});
|
|
3757
|
-
var responseOutputItemAddedSchema = import_v419.z.object({
|
|
3758
|
-
type: import_v419.z.literal("response.output_item.added"),
|
|
3759
|
-
output_index: import_v419.z.number(),
|
|
3760
|
-
item: import_v419.z.discriminatedUnion("type", [
|
|
3761
|
-
import_v419.z.object({
|
|
3762
|
-
type: import_v419.z.literal("message"),
|
|
3763
|
-
id: import_v419.z.string()
|
|
3764
|
-
}),
|
|
3765
|
-
import_v419.z.object({
|
|
3766
|
-
type: import_v419.z.literal("reasoning"),
|
|
3767
|
-
id: import_v419.z.string(),
|
|
3768
|
-
encrypted_content: import_v419.z.string().nullish()
|
|
3769
|
-
}),
|
|
3770
|
-
import_v419.z.object({
|
|
3771
|
-
type: import_v419.z.literal("function_call"),
|
|
3772
|
-
id: import_v419.z.string(),
|
|
3773
|
-
call_id: import_v419.z.string(),
|
|
3774
|
-
name: import_v419.z.string(),
|
|
3775
|
-
arguments: import_v419.z.string()
|
|
3776
|
-
}),
|
|
3777
|
-
import_v419.z.object({
|
|
3778
|
-
type: import_v419.z.literal("web_search_call"),
|
|
3779
|
-
id: import_v419.z.string(),
|
|
3780
|
-
status: import_v419.z.string(),
|
|
3781
|
-
action: import_v419.z.object({
|
|
3782
|
-
type: import_v419.z.literal("search"),
|
|
3783
|
-
query: import_v419.z.string().optional()
|
|
3784
|
-
}).nullish()
|
|
3785
|
-
}),
|
|
3786
|
-
import_v419.z.object({
|
|
3787
|
-
type: import_v419.z.literal("computer_call"),
|
|
3788
|
-
id: import_v419.z.string(),
|
|
3789
|
-
status: import_v419.z.string()
|
|
3790
|
-
}),
|
|
3791
|
-
import_v419.z.object({
|
|
3792
|
-
type: import_v419.z.literal("file_search_call"),
|
|
3793
|
-
id: import_v419.z.string()
|
|
3794
|
-
}),
|
|
3795
|
-
import_v419.z.object({
|
|
3796
|
-
type: import_v419.z.literal("image_generation_call"),
|
|
3797
|
-
id: import_v419.z.string()
|
|
3798
|
-
}),
|
|
3799
|
-
import_v419.z.object({
|
|
3800
|
-
type: import_v419.z.literal("code_interpreter_call"),
|
|
3801
|
-
id: import_v419.z.string(),
|
|
3802
|
-
container_id: import_v419.z.string(),
|
|
3803
|
-
code: import_v419.z.string().nullable(),
|
|
3804
|
-
outputs: import_v419.z.array(
|
|
3805
|
-
import_v419.z.discriminatedUnion("type", [
|
|
3806
|
-
import_v419.z.object({ type: import_v419.z.literal("logs"), logs: import_v419.z.string() }),
|
|
3807
|
-
import_v419.z.object({ type: import_v419.z.literal("image"), url: import_v419.z.string() })
|
|
3808
|
-
])
|
|
3809
|
-
).nullable(),
|
|
3810
|
-
status: import_v419.z.string()
|
|
3811
|
-
})
|
|
3812
|
-
])
|
|
3813
|
-
});
|
|
3814
|
-
var responseOutputItemDoneSchema = import_v419.z.object({
|
|
3815
|
-
type: import_v419.z.literal("response.output_item.done"),
|
|
3816
|
-
output_index: import_v419.z.number(),
|
|
3817
|
-
item: import_v419.z.discriminatedUnion("type", [
|
|
3818
|
-
import_v419.z.object({
|
|
3819
|
-
type: import_v419.z.literal("message"),
|
|
3820
|
-
id: import_v419.z.string()
|
|
3821
|
-
}),
|
|
3822
|
-
import_v419.z.object({
|
|
3823
|
-
type: import_v419.z.literal("reasoning"),
|
|
3824
|
-
id: import_v419.z.string(),
|
|
3825
|
-
encrypted_content: import_v419.z.string().nullish()
|
|
3826
|
-
}),
|
|
3827
|
-
import_v419.z.object({
|
|
3828
|
-
type: import_v419.z.literal("function_call"),
|
|
3829
|
-
id: import_v419.z.string(),
|
|
3830
|
-
call_id: import_v419.z.string(),
|
|
3831
|
-
name: import_v419.z.string(),
|
|
3832
|
-
arguments: import_v419.z.string(),
|
|
3833
|
-
status: import_v419.z.literal("completed")
|
|
3834
|
-
}),
|
|
3835
|
-
codeInterpreterCallItem,
|
|
3836
|
-
imageGenerationCallItem,
|
|
3837
|
-
webSearchCallItem,
|
|
3838
|
-
fileSearchCallItem,
|
|
3839
|
-
localShellCallItem,
|
|
3840
|
-
import_v419.z.object({
|
|
3841
|
-
type: import_v419.z.literal("computer_call"),
|
|
3842
|
-
id: import_v419.z.string(),
|
|
3843
|
-
status: import_v419.z.literal("completed")
|
|
3844
|
-
})
|
|
3845
|
-
])
|
|
3846
|
-
});
|
|
3847
|
-
var responseFunctionCallArgumentsDeltaSchema = import_v419.z.object({
|
|
3848
|
-
type: import_v419.z.literal("response.function_call_arguments.delta"),
|
|
3849
|
-
item_id: import_v419.z.string(),
|
|
3850
|
-
output_index: import_v419.z.number(),
|
|
3851
|
-
delta: import_v419.z.string()
|
|
3852
|
-
});
|
|
3853
|
-
var responseCodeInterpreterCallCodeDeltaSchema = import_v419.z.object({
|
|
3854
|
-
type: import_v419.z.literal("response.code_interpreter_call_code.delta"),
|
|
3855
|
-
item_id: import_v419.z.string(),
|
|
3856
|
-
output_index: import_v419.z.number(),
|
|
3857
|
-
delta: import_v419.z.string()
|
|
3858
|
-
});
|
|
3859
|
-
var responseCodeInterpreterCallCodeDoneSchema = import_v419.z.object({
|
|
3860
|
-
type: import_v419.z.literal("response.code_interpreter_call_code.done"),
|
|
3861
|
-
item_id: import_v419.z.string(),
|
|
3862
|
-
output_index: import_v419.z.number(),
|
|
3863
|
-
code: import_v419.z.string()
|
|
3864
|
-
});
|
|
3865
|
-
var responseAnnotationAddedSchema = import_v419.z.object({
|
|
3866
|
-
type: import_v419.z.literal("response.output_text.annotation.added"),
|
|
3867
|
-
annotation: import_v419.z.discriminatedUnion("type", [
|
|
3868
|
-
import_v419.z.object({
|
|
3869
|
-
type: import_v419.z.literal("url_citation"),
|
|
3870
|
-
url: import_v419.z.string(),
|
|
3871
|
-
title: import_v419.z.string()
|
|
3872
|
-
}),
|
|
3873
|
-
import_v419.z.object({
|
|
3874
|
-
type: import_v419.z.literal("file_citation"),
|
|
3875
|
-
file_id: import_v419.z.string(),
|
|
3876
|
-
filename: import_v419.z.string().nullish(),
|
|
3877
|
-
index: import_v419.z.number().nullish(),
|
|
3878
|
-
start_index: import_v419.z.number().nullish(),
|
|
3879
|
-
end_index: import_v419.z.number().nullish(),
|
|
3880
|
-
quote: import_v419.z.string().nullish()
|
|
3881
|
-
})
|
|
3882
|
-
])
|
|
3883
|
-
});
|
|
3884
|
-
var responseReasoningSummaryPartAddedSchema = import_v419.z.object({
|
|
3885
|
-
type: import_v419.z.literal("response.reasoning_summary_part.added"),
|
|
3886
|
-
item_id: import_v419.z.string(),
|
|
3887
|
-
summary_index: import_v419.z.number()
|
|
3888
|
-
});
|
|
3889
|
-
var responseReasoningSummaryTextDeltaSchema = import_v419.z.object({
|
|
3890
|
-
type: import_v419.z.literal("response.reasoning_summary_text.delta"),
|
|
3891
|
-
item_id: import_v419.z.string(),
|
|
3892
|
-
summary_index: import_v419.z.number(),
|
|
3893
|
-
delta: import_v419.z.string()
|
|
3894
|
-
});
|
|
3895
|
-
var openaiResponsesChunkSchema = import_v419.z.union([
|
|
3896
|
-
textDeltaChunkSchema,
|
|
3897
|
-
responseFinishedChunkSchema,
|
|
3898
|
-
responseCreatedChunkSchema,
|
|
3899
|
-
responseOutputItemAddedSchema,
|
|
3900
|
-
responseOutputItemDoneSchema,
|
|
3901
|
-
responseFunctionCallArgumentsDeltaSchema,
|
|
3902
|
-
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3903
|
-
responseCodeInterpreterCallCodeDoneSchema,
|
|
3904
|
-
responseAnnotationAddedSchema,
|
|
3905
|
-
responseReasoningSummaryPartAddedSchema,
|
|
3906
|
-
responseReasoningSummaryTextDeltaSchema,
|
|
3907
|
-
errorChunkSchema,
|
|
3908
|
-
import_v419.z.object({ type: import_v419.z.string() }).loose()
|
|
3909
|
-
// fallback for unknown chunks
|
|
3910
|
-
]);
|
|
3911
4269
|
function isTextDeltaChunk(chunk) {
|
|
3912
4270
|
return chunk.type === "response.output_text.delta";
|
|
3913
4271
|
}
|
|
@@ -3984,47 +4342,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
3984
4342
|
isReasoningModel: false
|
|
3985
4343
|
};
|
|
3986
4344
|
}
|
|
3987
|
-
var openaiResponsesProviderOptionsSchema = import_v419.z.object({
|
|
3988
|
-
include: import_v419.z.array(
|
|
3989
|
-
import_v419.z.enum([
|
|
3990
|
-
"reasoning.encrypted_content",
|
|
3991
|
-
"file_search_call.results",
|
|
3992
|
-
"message.output_text.logprobs"
|
|
3993
|
-
])
|
|
3994
|
-
).nullish(),
|
|
3995
|
-
instructions: import_v419.z.string().nullish(),
|
|
3996
|
-
/**
|
|
3997
|
-
* Return the log probabilities of the tokens.
|
|
3998
|
-
*
|
|
3999
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
4000
|
-
* were generated.
|
|
4001
|
-
*
|
|
4002
|
-
* Setting to a number will return the log probabilities of the top n
|
|
4003
|
-
* tokens that were generated.
|
|
4004
|
-
*
|
|
4005
|
-
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
4006
|
-
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
4007
|
-
*/
|
|
4008
|
-
logprobs: import_v419.z.union([import_v419.z.boolean(), import_v419.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
4009
|
-
/**
|
|
4010
|
-
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
4011
|
-
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
4012
|
-
* Any further attempts to call a tool by the model will be ignored.
|
|
4013
|
-
*/
|
|
4014
|
-
maxToolCalls: import_v419.z.number().nullish(),
|
|
4015
|
-
metadata: import_v419.z.any().nullish(),
|
|
4016
|
-
parallelToolCalls: import_v419.z.boolean().nullish(),
|
|
4017
|
-
previousResponseId: import_v419.z.string().nullish(),
|
|
4018
|
-
promptCacheKey: import_v419.z.string().nullish(),
|
|
4019
|
-
reasoningEffort: import_v419.z.string().nullish(),
|
|
4020
|
-
reasoningSummary: import_v419.z.string().nullish(),
|
|
4021
|
-
safetyIdentifier: import_v419.z.string().nullish(),
|
|
4022
|
-
serviceTier: import_v419.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
4023
|
-
store: import_v419.z.boolean().nullish(),
|
|
4024
|
-
strictJsonSchema: import_v419.z.boolean().nullish(),
|
|
4025
|
-
textVerbosity: import_v419.z.enum(["low", "medium", "high"]).nullish(),
|
|
4026
|
-
user: import_v419.z.string().nullish()
|
|
4027
|
-
});
|
|
4028
4345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4029
4346
|
0 && (module.exports = {
|
|
4030
4347
|
OpenAIChatLanguageModel,
|
|
@@ -4050,6 +4367,7 @@ var openaiResponsesProviderOptionsSchema = import_v419.z.object({
|
|
|
4050
4367
|
openAITranscriptionProviderOptions,
|
|
4051
4368
|
openaiChatLanguageModelOptions,
|
|
4052
4369
|
openaiCompletionProviderOptions,
|
|
4053
|
-
openaiEmbeddingProviderOptions
|
|
4370
|
+
openaiEmbeddingProviderOptions,
|
|
4371
|
+
openaiSpeechProviderOptionsSchema
|
|
4054
4372
|
});
|
|
4055
4373
|
//# sourceMappingURL=index.js.map
|