@ai-sdk/openai 3.0.0-beta.17 → 3.0.0-beta.18
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 +10 -0
- package/dist/index.d.mts +38 -65
- package/dist/index.d.ts +38 -65
- package/dist/index.js +1339 -1033
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1293 -942
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +101 -183
- package/dist/internal/index.d.ts +101 -183
- package/dist/internal/index.js +1336 -1028
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1305 -953
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -19,10 +19,9 @@ import {
|
|
|
19
19
|
parseProviderOptions,
|
|
20
20
|
postJsonToApi
|
|
21
21
|
} from "@ai-sdk/provider-utils";
|
|
22
|
-
import { z as z3 } from "zod/v4";
|
|
23
22
|
|
|
24
23
|
// src/openai-error.ts
|
|
25
|
-
import
|
|
24
|
+
import * as z from "zod/v4";
|
|
26
25
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
27
26
|
var openaiErrorDataSchema = z.object({
|
|
28
27
|
error: z.object({
|
|
@@ -254,95 +253,244 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
254
253
|
}
|
|
255
254
|
}
|
|
256
255
|
|
|
256
|
+
// src/chat/openai-chat-api.ts
|
|
257
|
+
import {
|
|
258
|
+
lazyValidator,
|
|
259
|
+
zodSchema
|
|
260
|
+
} from "@ai-sdk/provider-utils";
|
|
261
|
+
import * as z2 from "zod/v4";
|
|
262
|
+
var openaiChatResponseSchema = lazyValidator(
|
|
263
|
+
() => zodSchema(
|
|
264
|
+
z2.object({
|
|
265
|
+
id: z2.string().nullish(),
|
|
266
|
+
created: z2.number().nullish(),
|
|
267
|
+
model: z2.string().nullish(),
|
|
268
|
+
choices: z2.array(
|
|
269
|
+
z2.object({
|
|
270
|
+
message: z2.object({
|
|
271
|
+
role: z2.literal("assistant").nullish(),
|
|
272
|
+
content: z2.string().nullish(),
|
|
273
|
+
tool_calls: z2.array(
|
|
274
|
+
z2.object({
|
|
275
|
+
id: z2.string().nullish(),
|
|
276
|
+
type: z2.literal("function"),
|
|
277
|
+
function: z2.object({
|
|
278
|
+
name: z2.string(),
|
|
279
|
+
arguments: z2.string()
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
).nullish(),
|
|
283
|
+
annotations: z2.array(
|
|
284
|
+
z2.object({
|
|
285
|
+
type: z2.literal("url_citation"),
|
|
286
|
+
start_index: z2.number(),
|
|
287
|
+
end_index: z2.number(),
|
|
288
|
+
url: z2.string(),
|
|
289
|
+
title: z2.string()
|
|
290
|
+
})
|
|
291
|
+
).nullish()
|
|
292
|
+
}),
|
|
293
|
+
index: z2.number(),
|
|
294
|
+
logprobs: z2.object({
|
|
295
|
+
content: z2.array(
|
|
296
|
+
z2.object({
|
|
297
|
+
token: z2.string(),
|
|
298
|
+
logprob: z2.number(),
|
|
299
|
+
top_logprobs: z2.array(
|
|
300
|
+
z2.object({
|
|
301
|
+
token: z2.string(),
|
|
302
|
+
logprob: z2.number()
|
|
303
|
+
})
|
|
304
|
+
)
|
|
305
|
+
})
|
|
306
|
+
).nullish()
|
|
307
|
+
}).nullish(),
|
|
308
|
+
finish_reason: z2.string().nullish()
|
|
309
|
+
})
|
|
310
|
+
),
|
|
311
|
+
usage: z2.object({
|
|
312
|
+
prompt_tokens: z2.number().nullish(),
|
|
313
|
+
completion_tokens: z2.number().nullish(),
|
|
314
|
+
total_tokens: z2.number().nullish(),
|
|
315
|
+
prompt_tokens_details: z2.object({
|
|
316
|
+
cached_tokens: z2.number().nullish()
|
|
317
|
+
}).nullish(),
|
|
318
|
+
completion_tokens_details: z2.object({
|
|
319
|
+
reasoning_tokens: z2.number().nullish(),
|
|
320
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
321
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
322
|
+
}).nullish()
|
|
323
|
+
}).nullish()
|
|
324
|
+
})
|
|
325
|
+
)
|
|
326
|
+
);
|
|
327
|
+
var openaiChatChunkSchema = lazyValidator(
|
|
328
|
+
() => zodSchema(
|
|
329
|
+
z2.union([
|
|
330
|
+
z2.object({
|
|
331
|
+
id: z2.string().nullish(),
|
|
332
|
+
created: z2.number().nullish(),
|
|
333
|
+
model: z2.string().nullish(),
|
|
334
|
+
choices: z2.array(
|
|
335
|
+
z2.object({
|
|
336
|
+
delta: z2.object({
|
|
337
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
338
|
+
content: z2.string().nullish(),
|
|
339
|
+
tool_calls: z2.array(
|
|
340
|
+
z2.object({
|
|
341
|
+
index: z2.number(),
|
|
342
|
+
id: z2.string().nullish(),
|
|
343
|
+
type: z2.literal("function").nullish(),
|
|
344
|
+
function: z2.object({
|
|
345
|
+
name: z2.string().nullish(),
|
|
346
|
+
arguments: z2.string().nullish()
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
).nullish(),
|
|
350
|
+
annotations: z2.array(
|
|
351
|
+
z2.object({
|
|
352
|
+
type: z2.literal("url_citation"),
|
|
353
|
+
start_index: z2.number(),
|
|
354
|
+
end_index: z2.number(),
|
|
355
|
+
url: z2.string(),
|
|
356
|
+
title: z2.string()
|
|
357
|
+
})
|
|
358
|
+
).nullish()
|
|
359
|
+
}).nullish(),
|
|
360
|
+
logprobs: z2.object({
|
|
361
|
+
content: z2.array(
|
|
362
|
+
z2.object({
|
|
363
|
+
token: z2.string(),
|
|
364
|
+
logprob: z2.number(),
|
|
365
|
+
top_logprobs: z2.array(
|
|
366
|
+
z2.object({
|
|
367
|
+
token: z2.string(),
|
|
368
|
+
logprob: z2.number()
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
})
|
|
372
|
+
).nullish()
|
|
373
|
+
}).nullish(),
|
|
374
|
+
finish_reason: z2.string().nullish(),
|
|
375
|
+
index: z2.number()
|
|
376
|
+
})
|
|
377
|
+
),
|
|
378
|
+
usage: z2.object({
|
|
379
|
+
prompt_tokens: z2.number().nullish(),
|
|
380
|
+
completion_tokens: z2.number().nullish(),
|
|
381
|
+
total_tokens: z2.number().nullish(),
|
|
382
|
+
prompt_tokens_details: z2.object({
|
|
383
|
+
cached_tokens: z2.number().nullish()
|
|
384
|
+
}).nullish(),
|
|
385
|
+
completion_tokens_details: z2.object({
|
|
386
|
+
reasoning_tokens: z2.number().nullish(),
|
|
387
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
388
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
389
|
+
}).nullish()
|
|
390
|
+
}).nullish()
|
|
391
|
+
}),
|
|
392
|
+
openaiErrorDataSchema
|
|
393
|
+
])
|
|
394
|
+
)
|
|
395
|
+
);
|
|
396
|
+
|
|
257
397
|
// src/chat/openai-chat-options.ts
|
|
258
|
-
import {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
398
|
+
import {
|
|
399
|
+
lazyValidator as lazyValidator2,
|
|
400
|
+
zodSchema as zodSchema2
|
|
401
|
+
} from "@ai-sdk/provider-utils";
|
|
402
|
+
import * as z3 from "zod/v4";
|
|
403
|
+
var openaiChatLanguageModelOptions = lazyValidator2(
|
|
404
|
+
() => zodSchema2(
|
|
405
|
+
z3.object({
|
|
406
|
+
/**
|
|
407
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
408
|
+
*
|
|
409
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
410
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
411
|
+
*/
|
|
412
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
413
|
+
/**
|
|
414
|
+
* Return the log probabilities of the tokens.
|
|
415
|
+
*
|
|
416
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
417
|
+
* were generated.
|
|
418
|
+
*
|
|
419
|
+
* Setting to a number will return the log probabilities of the top n
|
|
420
|
+
* tokens that were generated.
|
|
421
|
+
*/
|
|
422
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
423
|
+
/**
|
|
424
|
+
* Whether to enable parallel function calling during tool use. Default to true.
|
|
425
|
+
*/
|
|
426
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
427
|
+
/**
|
|
428
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
429
|
+
* monitor and detect abuse.
|
|
430
|
+
*/
|
|
431
|
+
user: z3.string().optional(),
|
|
432
|
+
/**
|
|
433
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
434
|
+
*/
|
|
435
|
+
reasoningEffort: z3.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
436
|
+
/**
|
|
437
|
+
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
438
|
+
*/
|
|
439
|
+
maxCompletionTokens: z3.number().optional(),
|
|
440
|
+
/**
|
|
441
|
+
* Whether to enable persistence in responses API.
|
|
442
|
+
*/
|
|
443
|
+
store: z3.boolean().optional(),
|
|
444
|
+
/**
|
|
445
|
+
* Metadata to associate with the request.
|
|
446
|
+
*/
|
|
447
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
448
|
+
/**
|
|
449
|
+
* Parameters for prediction mode.
|
|
450
|
+
*/
|
|
451
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
452
|
+
/**
|
|
453
|
+
* Whether to use structured outputs.
|
|
454
|
+
*
|
|
455
|
+
* @default true
|
|
456
|
+
*/
|
|
457
|
+
structuredOutputs: z3.boolean().optional(),
|
|
458
|
+
/**
|
|
459
|
+
* Service tier for the request.
|
|
460
|
+
* - 'auto': Default service tier
|
|
461
|
+
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
462
|
+
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
463
|
+
*
|
|
464
|
+
* @default 'auto'
|
|
465
|
+
*/
|
|
466
|
+
serviceTier: z3.enum(["auto", "flex", "priority"]).optional(),
|
|
467
|
+
/**
|
|
468
|
+
* Whether to use strict JSON schema validation.
|
|
469
|
+
*
|
|
470
|
+
* @default false
|
|
471
|
+
*/
|
|
472
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
473
|
+
/**
|
|
474
|
+
* Controls the verbosity of the model's responses.
|
|
475
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
476
|
+
*/
|
|
477
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
478
|
+
/**
|
|
479
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
480
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
481
|
+
*/
|
|
482
|
+
promptCacheKey: z3.string().optional(),
|
|
483
|
+
/**
|
|
484
|
+
* A stable identifier used to help detect users of your application
|
|
485
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
486
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
487
|
+
* username or email address, in order to avoid sending us any identifying
|
|
488
|
+
* information.
|
|
489
|
+
*/
|
|
490
|
+
safetyIdentifier: z3.string().optional()
|
|
491
|
+
})
|
|
492
|
+
)
|
|
493
|
+
);
|
|
346
494
|
|
|
347
495
|
// src/chat/openai-chat-prepare-tools.ts
|
|
348
496
|
import {
|
|
@@ -900,121 +1048,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
900
1048
|
};
|
|
901
1049
|
}
|
|
902
1050
|
};
|
|
903
|
-
var openaiTokenUsageSchema = z3.object({
|
|
904
|
-
prompt_tokens: z3.number().nullish(),
|
|
905
|
-
completion_tokens: z3.number().nullish(),
|
|
906
|
-
total_tokens: z3.number().nullish(),
|
|
907
|
-
prompt_tokens_details: z3.object({
|
|
908
|
-
cached_tokens: z3.number().nullish()
|
|
909
|
-
}).nullish(),
|
|
910
|
-
completion_tokens_details: z3.object({
|
|
911
|
-
reasoning_tokens: z3.number().nullish(),
|
|
912
|
-
accepted_prediction_tokens: z3.number().nullish(),
|
|
913
|
-
rejected_prediction_tokens: z3.number().nullish()
|
|
914
|
-
}).nullish()
|
|
915
|
-
}).nullish();
|
|
916
|
-
var openaiChatResponseSchema = z3.object({
|
|
917
|
-
id: z3.string().nullish(),
|
|
918
|
-
created: z3.number().nullish(),
|
|
919
|
-
model: z3.string().nullish(),
|
|
920
|
-
choices: z3.array(
|
|
921
|
-
z3.object({
|
|
922
|
-
message: z3.object({
|
|
923
|
-
role: z3.literal("assistant").nullish(),
|
|
924
|
-
content: z3.string().nullish(),
|
|
925
|
-
tool_calls: z3.array(
|
|
926
|
-
z3.object({
|
|
927
|
-
id: z3.string().nullish(),
|
|
928
|
-
type: z3.literal("function"),
|
|
929
|
-
function: z3.object({
|
|
930
|
-
name: z3.string(),
|
|
931
|
-
arguments: z3.string()
|
|
932
|
-
})
|
|
933
|
-
})
|
|
934
|
-
).nullish(),
|
|
935
|
-
annotations: z3.array(
|
|
936
|
-
z3.object({
|
|
937
|
-
type: z3.literal("url_citation"),
|
|
938
|
-
start_index: z3.number(),
|
|
939
|
-
end_index: z3.number(),
|
|
940
|
-
url: z3.string(),
|
|
941
|
-
title: z3.string()
|
|
942
|
-
})
|
|
943
|
-
).nullish()
|
|
944
|
-
}),
|
|
945
|
-
index: z3.number(),
|
|
946
|
-
logprobs: z3.object({
|
|
947
|
-
content: z3.array(
|
|
948
|
-
z3.object({
|
|
949
|
-
token: z3.string(),
|
|
950
|
-
logprob: z3.number(),
|
|
951
|
-
top_logprobs: z3.array(
|
|
952
|
-
z3.object({
|
|
953
|
-
token: z3.string(),
|
|
954
|
-
logprob: z3.number()
|
|
955
|
-
})
|
|
956
|
-
)
|
|
957
|
-
})
|
|
958
|
-
).nullish()
|
|
959
|
-
}).nullish(),
|
|
960
|
-
finish_reason: z3.string().nullish()
|
|
961
|
-
})
|
|
962
|
-
),
|
|
963
|
-
usage: openaiTokenUsageSchema
|
|
964
|
-
});
|
|
965
|
-
var openaiChatChunkSchema = z3.union([
|
|
966
|
-
z3.object({
|
|
967
|
-
id: z3.string().nullish(),
|
|
968
|
-
created: z3.number().nullish(),
|
|
969
|
-
model: z3.string().nullish(),
|
|
970
|
-
choices: z3.array(
|
|
971
|
-
z3.object({
|
|
972
|
-
delta: z3.object({
|
|
973
|
-
role: z3.enum(["assistant"]).nullish(),
|
|
974
|
-
content: z3.string().nullish(),
|
|
975
|
-
tool_calls: z3.array(
|
|
976
|
-
z3.object({
|
|
977
|
-
index: z3.number(),
|
|
978
|
-
id: z3.string().nullish(),
|
|
979
|
-
type: z3.literal("function").nullish(),
|
|
980
|
-
function: z3.object({
|
|
981
|
-
name: z3.string().nullish(),
|
|
982
|
-
arguments: z3.string().nullish()
|
|
983
|
-
})
|
|
984
|
-
})
|
|
985
|
-
).nullish(),
|
|
986
|
-
annotations: z3.array(
|
|
987
|
-
z3.object({
|
|
988
|
-
type: z3.literal("url_citation"),
|
|
989
|
-
start_index: z3.number(),
|
|
990
|
-
end_index: z3.number(),
|
|
991
|
-
url: z3.string(),
|
|
992
|
-
title: z3.string()
|
|
993
|
-
})
|
|
994
|
-
).nullish()
|
|
995
|
-
}).nullish(),
|
|
996
|
-
logprobs: z3.object({
|
|
997
|
-
content: z3.array(
|
|
998
|
-
z3.object({
|
|
999
|
-
token: z3.string(),
|
|
1000
|
-
logprob: z3.number(),
|
|
1001
|
-
top_logprobs: z3.array(
|
|
1002
|
-
z3.object({
|
|
1003
|
-
token: z3.string(),
|
|
1004
|
-
logprob: z3.number()
|
|
1005
|
-
})
|
|
1006
|
-
)
|
|
1007
|
-
})
|
|
1008
|
-
).nullish()
|
|
1009
|
-
}).nullish(),
|
|
1010
|
-
finish_reason: z3.string().nullish(),
|
|
1011
|
-
index: z3.number()
|
|
1012
|
-
})
|
|
1013
|
-
),
|
|
1014
|
-
usage: openaiTokenUsageSchema
|
|
1015
|
-
}),
|
|
1016
|
-
openaiErrorDataSchema
|
|
1017
|
-
]);
|
|
1018
1051
|
function isReasoningModel(modelId) {
|
|
1019
1052
|
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
1020
1053
|
}
|
|
@@ -1072,7 +1105,6 @@ import {
|
|
|
1072
1105
|
parseProviderOptions as parseProviderOptions2,
|
|
1073
1106
|
postJsonToApi as postJsonToApi2
|
|
1074
1107
|
} from "@ai-sdk/provider-utils";
|
|
1075
|
-
import { z as z5 } from "zod/v4";
|
|
1076
1108
|
|
|
1077
1109
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1078
1110
|
import {
|
|
@@ -1182,48 +1214,117 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1182
1214
|
}
|
|
1183
1215
|
}
|
|
1184
1216
|
|
|
1217
|
+
// src/completion/openai-completion-api.ts
|
|
1218
|
+
import * as z4 from "zod/v4";
|
|
1219
|
+
import {
|
|
1220
|
+
lazyValidator as lazyValidator3,
|
|
1221
|
+
zodSchema as zodSchema3
|
|
1222
|
+
} from "@ai-sdk/provider-utils";
|
|
1223
|
+
var openaiCompletionResponseSchema = lazyValidator3(
|
|
1224
|
+
() => zodSchema3(
|
|
1225
|
+
z4.object({
|
|
1226
|
+
id: z4.string().nullish(),
|
|
1227
|
+
created: z4.number().nullish(),
|
|
1228
|
+
model: z4.string().nullish(),
|
|
1229
|
+
choices: z4.array(
|
|
1230
|
+
z4.object({
|
|
1231
|
+
text: z4.string(),
|
|
1232
|
+
finish_reason: z4.string(),
|
|
1233
|
+
logprobs: z4.object({
|
|
1234
|
+
tokens: z4.array(z4.string()),
|
|
1235
|
+
token_logprobs: z4.array(z4.number()),
|
|
1236
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1237
|
+
}).nullish()
|
|
1238
|
+
})
|
|
1239
|
+
),
|
|
1240
|
+
usage: z4.object({
|
|
1241
|
+
prompt_tokens: z4.number(),
|
|
1242
|
+
completion_tokens: z4.number(),
|
|
1243
|
+
total_tokens: z4.number()
|
|
1244
|
+
}).nullish()
|
|
1245
|
+
})
|
|
1246
|
+
)
|
|
1247
|
+
);
|
|
1248
|
+
var openaiCompletionChunkSchema = lazyValidator3(
|
|
1249
|
+
() => zodSchema3(
|
|
1250
|
+
z4.union([
|
|
1251
|
+
z4.object({
|
|
1252
|
+
id: z4.string().nullish(),
|
|
1253
|
+
created: z4.number().nullish(),
|
|
1254
|
+
model: z4.string().nullish(),
|
|
1255
|
+
choices: z4.array(
|
|
1256
|
+
z4.object({
|
|
1257
|
+
text: z4.string(),
|
|
1258
|
+
finish_reason: z4.string().nullish(),
|
|
1259
|
+
index: z4.number(),
|
|
1260
|
+
logprobs: z4.object({
|
|
1261
|
+
tokens: z4.array(z4.string()),
|
|
1262
|
+
token_logprobs: z4.array(z4.number()),
|
|
1263
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1264
|
+
}).nullish()
|
|
1265
|
+
})
|
|
1266
|
+
),
|
|
1267
|
+
usage: z4.object({
|
|
1268
|
+
prompt_tokens: z4.number(),
|
|
1269
|
+
completion_tokens: z4.number(),
|
|
1270
|
+
total_tokens: z4.number()
|
|
1271
|
+
}).nullish()
|
|
1272
|
+
}),
|
|
1273
|
+
openaiErrorDataSchema
|
|
1274
|
+
])
|
|
1275
|
+
)
|
|
1276
|
+
);
|
|
1277
|
+
|
|
1185
1278
|
// src/completion/openai-completion-options.ts
|
|
1186
|
-
import {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
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
|
-
|
|
1279
|
+
import {
|
|
1280
|
+
lazyValidator as lazyValidator4,
|
|
1281
|
+
zodSchema as zodSchema4
|
|
1282
|
+
} from "@ai-sdk/provider-utils";
|
|
1283
|
+
import * as z5 from "zod/v4";
|
|
1284
|
+
var openaiCompletionProviderOptions = lazyValidator4(
|
|
1285
|
+
() => zodSchema4(
|
|
1286
|
+
z5.object({
|
|
1287
|
+
/**
|
|
1288
|
+
Echo back the prompt in addition to the completion.
|
|
1289
|
+
*/
|
|
1290
|
+
echo: z5.boolean().optional(),
|
|
1291
|
+
/**
|
|
1292
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
1293
|
+
|
|
1294
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1295
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1296
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1297
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
1298
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
1299
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
1300
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
1301
|
+
|
|
1302
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1303
|
+
token from being generated.
|
|
1304
|
+
*/
|
|
1305
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1306
|
+
/**
|
|
1307
|
+
The suffix that comes after a completion of inserted text.
|
|
1308
|
+
*/
|
|
1309
|
+
suffix: z5.string().optional(),
|
|
1310
|
+
/**
|
|
1311
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1312
|
+
monitor and detect abuse. Learn more.
|
|
1313
|
+
*/
|
|
1314
|
+
user: z5.string().optional(),
|
|
1315
|
+
/**
|
|
1316
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1317
|
+
the response size and can slow down response times. However, it can
|
|
1318
|
+
be useful to better understand how the model is behaving.
|
|
1319
|
+
Setting to true will return the log probabilities of the tokens that
|
|
1320
|
+
were generated.
|
|
1321
|
+
Setting to a number will return the log probabilities of the top n
|
|
1322
|
+
tokens that were generated.
|
|
1323
|
+
*/
|
|
1324
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1325
|
+
})
|
|
1326
|
+
)
|
|
1327
|
+
);
|
|
1227
1328
|
|
|
1228
1329
|
// src/completion/openai-completion-language-model.ts
|
|
1229
1330
|
var OpenAICompletionLanguageModel = class {
|
|
@@ -1454,49 +1555,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1454
1555
|
};
|
|
1455
1556
|
}
|
|
1456
1557
|
};
|
|
1457
|
-
var usageSchema = z5.object({
|
|
1458
|
-
prompt_tokens: z5.number(),
|
|
1459
|
-
completion_tokens: z5.number(),
|
|
1460
|
-
total_tokens: z5.number()
|
|
1461
|
-
});
|
|
1462
|
-
var openaiCompletionResponseSchema = z5.object({
|
|
1463
|
-
id: z5.string().nullish(),
|
|
1464
|
-
created: z5.number().nullish(),
|
|
1465
|
-
model: z5.string().nullish(),
|
|
1466
|
-
choices: z5.array(
|
|
1467
|
-
z5.object({
|
|
1468
|
-
text: z5.string(),
|
|
1469
|
-
finish_reason: z5.string(),
|
|
1470
|
-
logprobs: z5.object({
|
|
1471
|
-
tokens: z5.array(z5.string()),
|
|
1472
|
-
token_logprobs: z5.array(z5.number()),
|
|
1473
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1474
|
-
}).nullish()
|
|
1475
|
-
})
|
|
1476
|
-
),
|
|
1477
|
-
usage: usageSchema.nullish()
|
|
1478
|
-
});
|
|
1479
|
-
var openaiCompletionChunkSchema = z5.union([
|
|
1480
|
-
z5.object({
|
|
1481
|
-
id: z5.string().nullish(),
|
|
1482
|
-
created: z5.number().nullish(),
|
|
1483
|
-
model: z5.string().nullish(),
|
|
1484
|
-
choices: z5.array(
|
|
1485
|
-
z5.object({
|
|
1486
|
-
text: z5.string(),
|
|
1487
|
-
finish_reason: z5.string().nullish(),
|
|
1488
|
-
index: z5.number(),
|
|
1489
|
-
logprobs: z5.object({
|
|
1490
|
-
tokens: z5.array(z5.string()),
|
|
1491
|
-
token_logprobs: z5.array(z5.number()),
|
|
1492
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1493
|
-
}).nullish()
|
|
1494
|
-
})
|
|
1495
|
-
),
|
|
1496
|
-
usage: usageSchema.nullish()
|
|
1497
|
-
}),
|
|
1498
|
-
openaiErrorDataSchema
|
|
1499
|
-
]);
|
|
1500
1558
|
|
|
1501
1559
|
// src/embedding/openai-embedding-model.ts
|
|
1502
1560
|
import {
|
|
@@ -1508,22 +1566,41 @@ import {
|
|
|
1508
1566
|
parseProviderOptions as parseProviderOptions3,
|
|
1509
1567
|
postJsonToApi as postJsonToApi3
|
|
1510
1568
|
} from "@ai-sdk/provider-utils";
|
|
1511
|
-
import { z as z7 } from "zod/v4";
|
|
1512
1569
|
|
|
1513
1570
|
// src/embedding/openai-embedding-options.ts
|
|
1514
|
-
import {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1571
|
+
import {
|
|
1572
|
+
lazyValidator as lazyValidator5,
|
|
1573
|
+
zodSchema as zodSchema5
|
|
1574
|
+
} from "@ai-sdk/provider-utils";
|
|
1575
|
+
import * as z6 from "zod/v4";
|
|
1576
|
+
var openaiEmbeddingProviderOptions = lazyValidator5(
|
|
1577
|
+
() => zodSchema5(
|
|
1578
|
+
z6.object({
|
|
1579
|
+
/**
|
|
1580
|
+
The number of dimensions the resulting output embeddings should have.
|
|
1581
|
+
Only supported in text-embedding-3 and later models.
|
|
1582
|
+
*/
|
|
1583
|
+
dimensions: z6.number().optional(),
|
|
1584
|
+
/**
|
|
1585
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1586
|
+
monitor and detect abuse. Learn more.
|
|
1587
|
+
*/
|
|
1588
|
+
user: z6.string().optional()
|
|
1589
|
+
})
|
|
1590
|
+
)
|
|
1591
|
+
);
|
|
1592
|
+
|
|
1593
|
+
// src/embedding/openai-embedding-api.ts
|
|
1594
|
+
import { lazyValidator as lazyValidator6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1595
|
+
import * as z7 from "zod/v4";
|
|
1596
|
+
var openaiTextEmbeddingResponseSchema = lazyValidator6(
|
|
1597
|
+
() => zodSchema6(
|
|
1598
|
+
z7.object({
|
|
1599
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1600
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1601
|
+
})
|
|
1602
|
+
)
|
|
1603
|
+
);
|
|
1527
1604
|
|
|
1528
1605
|
// src/embedding/openai-embedding-model.ts
|
|
1529
1606
|
var OpenAIEmbeddingModel = class {
|
|
@@ -1588,10 +1665,6 @@ var OpenAIEmbeddingModel = class {
|
|
|
1588
1665
|
};
|
|
1589
1666
|
}
|
|
1590
1667
|
};
|
|
1591
|
-
var openaiTextEmbeddingResponseSchema = z7.object({
|
|
1592
|
-
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1593
|
-
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1594
|
-
});
|
|
1595
1668
|
|
|
1596
1669
|
// src/image/openai-image-model.ts
|
|
1597
1670
|
import {
|
|
@@ -1599,7 +1672,22 @@ import {
|
|
|
1599
1672
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1600
1673
|
postJsonToApi as postJsonToApi4
|
|
1601
1674
|
} from "@ai-sdk/provider-utils";
|
|
1602
|
-
|
|
1675
|
+
|
|
1676
|
+
// src/image/openai-image-api.ts
|
|
1677
|
+
import { lazyValidator as lazyValidator7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1678
|
+
import * as z8 from "zod/v4";
|
|
1679
|
+
var openaiImageResponseSchema = lazyValidator7(
|
|
1680
|
+
() => zodSchema7(
|
|
1681
|
+
z8.object({
|
|
1682
|
+
data: z8.array(
|
|
1683
|
+
z8.object({
|
|
1684
|
+
b64_json: z8.string(),
|
|
1685
|
+
revised_prompt: z8.string().optional()
|
|
1686
|
+
})
|
|
1687
|
+
)
|
|
1688
|
+
})
|
|
1689
|
+
)
|
|
1690
|
+
);
|
|
1603
1691
|
|
|
1604
1692
|
// src/image/openai-image-options.ts
|
|
1605
1693
|
var modelMaxImagesPerCall = {
|
|
@@ -1691,35 +1779,46 @@ var OpenAIImageModel = class {
|
|
|
1691
1779
|
};
|
|
1692
1780
|
}
|
|
1693
1781
|
};
|
|
1694
|
-
var openaiImageResponseSchema = z8.object({
|
|
1695
|
-
data: z8.array(
|
|
1696
|
-
z8.object({ b64_json: z8.string(), revised_prompt: z8.string().optional() })
|
|
1697
|
-
)
|
|
1698
|
-
});
|
|
1699
1782
|
|
|
1700
1783
|
// src/tool/code-interpreter.ts
|
|
1701
|
-
import {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
var
|
|
1708
|
-
|
|
1709
|
-
z9.discriminatedUnion("type", [
|
|
1710
|
-
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1711
|
-
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1712
|
-
])
|
|
1713
|
-
).nullish()
|
|
1714
|
-
});
|
|
1715
|
-
var codeInterpreterArgsSchema = z9.object({
|
|
1716
|
-
container: z9.union([
|
|
1717
|
-
z9.string(),
|
|
1784
|
+
import {
|
|
1785
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
1786
|
+
lazySchema,
|
|
1787
|
+
zodSchema as zodSchema8
|
|
1788
|
+
} from "@ai-sdk/provider-utils";
|
|
1789
|
+
import * as z9 from "zod/v4";
|
|
1790
|
+
var codeInterpreterInputSchema = lazySchema(
|
|
1791
|
+
() => zodSchema8(
|
|
1718
1792
|
z9.object({
|
|
1719
|
-
|
|
1793
|
+
code: z9.string().nullish(),
|
|
1794
|
+
containerId: z9.string()
|
|
1720
1795
|
})
|
|
1721
|
-
|
|
1722
|
-
|
|
1796
|
+
)
|
|
1797
|
+
);
|
|
1798
|
+
var codeInterpreterOutputSchema = lazySchema(
|
|
1799
|
+
() => zodSchema8(
|
|
1800
|
+
z9.object({
|
|
1801
|
+
outputs: z9.array(
|
|
1802
|
+
z9.discriminatedUnion("type", [
|
|
1803
|
+
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1804
|
+
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1805
|
+
])
|
|
1806
|
+
).nullish()
|
|
1807
|
+
})
|
|
1808
|
+
)
|
|
1809
|
+
);
|
|
1810
|
+
var codeInterpreterArgsSchema = lazySchema(
|
|
1811
|
+
() => zodSchema8(
|
|
1812
|
+
z9.object({
|
|
1813
|
+
container: z9.union([
|
|
1814
|
+
z9.string(),
|
|
1815
|
+
z9.object({
|
|
1816
|
+
fileIds: z9.array(z9.string()).optional()
|
|
1817
|
+
})
|
|
1818
|
+
]).optional()
|
|
1819
|
+
})
|
|
1820
|
+
)
|
|
1821
|
+
);
|
|
1723
1822
|
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
1724
1823
|
id: "openai.code_interpreter",
|
|
1725
1824
|
name: "code_interpreter",
|
|
@@ -1731,8 +1830,12 @@ var codeInterpreter = (args = {}) => {
|
|
|
1731
1830
|
};
|
|
1732
1831
|
|
|
1733
1832
|
// src/tool/file-search.ts
|
|
1734
|
-
import {
|
|
1735
|
-
|
|
1833
|
+
import {
|
|
1834
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
1835
|
+
lazySchema as lazySchema2,
|
|
1836
|
+
zodSchema as zodSchema9
|
|
1837
|
+
} from "@ai-sdk/provider-utils";
|
|
1838
|
+
import * as z10 from "zod/v4";
|
|
1736
1839
|
var comparisonFilterSchema = z10.object({
|
|
1737
1840
|
key: z10.string(),
|
|
1738
1841
|
type: z10.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
@@ -1744,27 +1847,35 @@ var compoundFilterSchema = z10.object({
|
|
|
1744
1847
|
z10.union([comparisonFilterSchema, z10.lazy(() => compoundFilterSchema)])
|
|
1745
1848
|
)
|
|
1746
1849
|
});
|
|
1747
|
-
var fileSearchArgsSchema =
|
|
1748
|
-
|
|
1749
|
-
maxNumResults: z10.number().optional(),
|
|
1750
|
-
ranking: z10.object({
|
|
1751
|
-
ranker: z10.string().optional(),
|
|
1752
|
-
scoreThreshold: z10.number().optional()
|
|
1753
|
-
}).optional(),
|
|
1754
|
-
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1755
|
-
});
|
|
1756
|
-
var fileSearchOutputSchema = z10.object({
|
|
1757
|
-
queries: z10.array(z10.string()),
|
|
1758
|
-
results: z10.array(
|
|
1850
|
+
var fileSearchArgsSchema = lazySchema2(
|
|
1851
|
+
() => zodSchema9(
|
|
1759
1852
|
z10.object({
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1853
|
+
vectorStoreIds: z10.array(z10.string()),
|
|
1854
|
+
maxNumResults: z10.number().optional(),
|
|
1855
|
+
ranking: z10.object({
|
|
1856
|
+
ranker: z10.string().optional(),
|
|
1857
|
+
scoreThreshold: z10.number().optional()
|
|
1858
|
+
}).optional(),
|
|
1859
|
+
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1765
1860
|
})
|
|
1766
|
-
)
|
|
1767
|
-
|
|
1861
|
+
)
|
|
1862
|
+
);
|
|
1863
|
+
var fileSearchOutputSchema = lazySchema2(
|
|
1864
|
+
() => zodSchema9(
|
|
1865
|
+
z10.object({
|
|
1866
|
+
queries: z10.array(z10.string()),
|
|
1867
|
+
results: z10.array(
|
|
1868
|
+
z10.object({
|
|
1869
|
+
attributes: z10.record(z10.string(), z10.unknown()),
|
|
1870
|
+
fileId: z10.string(),
|
|
1871
|
+
filename: z10.string(),
|
|
1872
|
+
score: z10.number(),
|
|
1873
|
+
text: z10.string()
|
|
1874
|
+
})
|
|
1875
|
+
).nullable()
|
|
1876
|
+
})
|
|
1877
|
+
)
|
|
1878
|
+
);
|
|
1768
1879
|
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
1769
1880
|
id: "openai.file_search",
|
|
1770
1881
|
name: "file_search",
|
|
@@ -1773,30 +1884,39 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
|
1773
1884
|
});
|
|
1774
1885
|
|
|
1775
1886
|
// src/tool/image-generation.ts
|
|
1776
|
-
import {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1887
|
+
import {
|
|
1888
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
|
|
1889
|
+
lazySchema as lazySchema3,
|
|
1890
|
+
zodSchema as zodSchema10
|
|
1891
|
+
} from "@ai-sdk/provider-utils";
|
|
1892
|
+
import * as z11 from "zod/v4";
|
|
1893
|
+
var imageGenerationArgsSchema = lazySchema3(
|
|
1894
|
+
() => zodSchema10(
|
|
1895
|
+
z11.object({
|
|
1896
|
+
background: z11.enum(["auto", "opaque", "transparent"]).optional(),
|
|
1897
|
+
inputFidelity: z11.enum(["low", "high"]).optional(),
|
|
1898
|
+
inputImageMask: z11.object({
|
|
1899
|
+
fileId: z11.string().optional(),
|
|
1900
|
+
imageUrl: z11.string().optional()
|
|
1901
|
+
}).optional(),
|
|
1902
|
+
model: z11.string().optional(),
|
|
1903
|
+
moderation: z11.enum(["auto"]).optional(),
|
|
1904
|
+
outputCompression: z11.number().int().min(0).max(100).optional(),
|
|
1905
|
+
outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
|
|
1906
|
+
partialImages: z11.number().int().min(0).max(3).optional(),
|
|
1907
|
+
quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1908
|
+
size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1909
|
+
}).strict()
|
|
1910
|
+
)
|
|
1911
|
+
);
|
|
1912
|
+
var imageGenerationInputSchema = lazySchema3(() => zodSchema10(z11.object({})));
|
|
1913
|
+
var imageGenerationOutputSchema = lazySchema3(
|
|
1914
|
+
() => zodSchema10(z11.object({ result: z11.string() }))
|
|
1915
|
+
);
|
|
1796
1916
|
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
1797
1917
|
id: "openai.image_generation",
|
|
1798
1918
|
name: "image_generation",
|
|
1799
|
-
inputSchema:
|
|
1919
|
+
inputSchema: imageGenerationInputSchema,
|
|
1800
1920
|
outputSchema: imageGenerationOutputSchema
|
|
1801
1921
|
});
|
|
1802
1922
|
var imageGeneration = (args = {}) => {
|
|
@@ -1804,21 +1924,29 @@ var imageGeneration = (args = {}) => {
|
|
|
1804
1924
|
};
|
|
1805
1925
|
|
|
1806
1926
|
// src/tool/local-shell.ts
|
|
1807
|
-
import {
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1927
|
+
import {
|
|
1928
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
1929
|
+
lazySchema as lazySchema4,
|
|
1930
|
+
zodSchema as zodSchema11
|
|
1931
|
+
} from "@ai-sdk/provider-utils";
|
|
1932
|
+
import * as z12 from "zod/v4";
|
|
1933
|
+
var localShellInputSchema = lazySchema4(
|
|
1934
|
+
() => zodSchema11(
|
|
1935
|
+
z12.object({
|
|
1936
|
+
action: z12.object({
|
|
1937
|
+
type: z12.literal("exec"),
|
|
1938
|
+
command: z12.array(z12.string()),
|
|
1939
|
+
timeoutMs: z12.number().optional(),
|
|
1940
|
+
user: z12.string().optional(),
|
|
1941
|
+
workingDirectory: z12.string().optional(),
|
|
1942
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
1943
|
+
})
|
|
1944
|
+
})
|
|
1945
|
+
)
|
|
1946
|
+
);
|
|
1947
|
+
var localShellOutputSchema = lazySchema4(
|
|
1948
|
+
() => zodSchema11(z12.object({ output: z12.string() }))
|
|
1949
|
+
);
|
|
1822
1950
|
var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1823
1951
|
id: "openai.local_shell",
|
|
1824
1952
|
name: "local_shell",
|
|
@@ -1827,103 +1955,129 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
1827
1955
|
});
|
|
1828
1956
|
|
|
1829
1957
|
// src/tool/web-search.ts
|
|
1830
|
-
import {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1958
|
+
import {
|
|
1959
|
+
createProviderDefinedToolFactory,
|
|
1960
|
+
lazySchema as lazySchema5,
|
|
1961
|
+
zodSchema as zodSchema12
|
|
1962
|
+
} from "@ai-sdk/provider-utils";
|
|
1963
|
+
import * as z13 from "zod/v4";
|
|
1964
|
+
var webSearchArgsSchema = lazySchema5(
|
|
1965
|
+
() => zodSchema12(
|
|
1966
|
+
z13.object({
|
|
1967
|
+
filters: z13.object({
|
|
1968
|
+
allowedDomains: z13.array(z13.string()).optional()
|
|
1969
|
+
}).optional(),
|
|
1970
|
+
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1971
|
+
userLocation: z13.object({
|
|
1972
|
+
type: z13.literal("approximate"),
|
|
1973
|
+
country: z13.string().optional(),
|
|
1974
|
+
city: z13.string().optional(),
|
|
1975
|
+
region: z13.string().optional(),
|
|
1976
|
+
timezone: z13.string().optional()
|
|
1977
|
+
}).optional()
|
|
1978
|
+
})
|
|
1979
|
+
)
|
|
1980
|
+
);
|
|
1981
|
+
var webSearchInputSchema = lazySchema5(
|
|
1982
|
+
() => zodSchema12(
|
|
1983
|
+
z13.object({
|
|
1984
|
+
action: z13.discriminatedUnion("type", [
|
|
1985
|
+
z13.object({
|
|
1986
|
+
type: z13.literal("search"),
|
|
1987
|
+
query: z13.string().nullish()
|
|
1988
|
+
}),
|
|
1989
|
+
z13.object({
|
|
1990
|
+
type: z13.literal("open_page"),
|
|
1991
|
+
url: z13.string()
|
|
1992
|
+
}),
|
|
1993
|
+
z13.object({
|
|
1994
|
+
type: z13.literal("find"),
|
|
1995
|
+
url: z13.string(),
|
|
1996
|
+
pattern: z13.string()
|
|
1997
|
+
})
|
|
1998
|
+
]).nullish()
|
|
1999
|
+
})
|
|
2000
|
+
)
|
|
2001
|
+
);
|
|
1845
2002
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
1846
2003
|
id: "openai.web_search",
|
|
1847
2004
|
name: "web_search",
|
|
1848
|
-
inputSchema:
|
|
1849
|
-
action: z13.discriminatedUnion("type", [
|
|
1850
|
-
z13.object({
|
|
1851
|
-
type: z13.literal("search"),
|
|
1852
|
-
query: z13.string().nullish()
|
|
1853
|
-
}),
|
|
1854
|
-
z13.object({
|
|
1855
|
-
type: z13.literal("open_page"),
|
|
1856
|
-
url: z13.string()
|
|
1857
|
-
}),
|
|
1858
|
-
z13.object({
|
|
1859
|
-
type: z13.literal("find"),
|
|
1860
|
-
url: z13.string(),
|
|
1861
|
-
pattern: z13.string()
|
|
1862
|
-
})
|
|
1863
|
-
]).nullish()
|
|
1864
|
-
})
|
|
2005
|
+
inputSchema: webSearchInputSchema
|
|
1865
2006
|
});
|
|
1866
2007
|
var webSearch = (args = {}) => {
|
|
1867
2008
|
return webSearchToolFactory(args);
|
|
1868
2009
|
};
|
|
1869
2010
|
|
|
1870
2011
|
// src/tool/web-search-preview.ts
|
|
1871
|
-
import {
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
2012
|
+
import {
|
|
2013
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2014
|
+
lazySchema as lazySchema6,
|
|
2015
|
+
zodSchema as zodSchema13
|
|
2016
|
+
} from "@ai-sdk/provider-utils";
|
|
2017
|
+
import * as z14 from "zod/v4";
|
|
2018
|
+
var webSearchPreviewArgsSchema = lazySchema6(
|
|
2019
|
+
() => zodSchema13(
|
|
2020
|
+
z14.object({
|
|
2021
|
+
/**
|
|
2022
|
+
* Search context size to use for the web search.
|
|
2023
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
2024
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
2025
|
+
* - low: Least context, lowest cost, fastest response
|
|
2026
|
+
*/
|
|
2027
|
+
searchContextSize: z14.enum(["low", "medium", "high"]).optional(),
|
|
2028
|
+
/**
|
|
2029
|
+
* User location information to provide geographically relevant search results.
|
|
2030
|
+
*/
|
|
2031
|
+
userLocation: z14.object({
|
|
2032
|
+
/**
|
|
2033
|
+
* Type of location (always 'approximate')
|
|
2034
|
+
*/
|
|
2035
|
+
type: z14.literal("approximate"),
|
|
2036
|
+
/**
|
|
2037
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2038
|
+
*/
|
|
2039
|
+
country: z14.string().optional(),
|
|
2040
|
+
/**
|
|
2041
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
2042
|
+
*/
|
|
2043
|
+
city: z14.string().optional(),
|
|
2044
|
+
/**
|
|
2045
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
2046
|
+
*/
|
|
2047
|
+
region: z14.string().optional(),
|
|
2048
|
+
/**
|
|
2049
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
2050
|
+
*/
|
|
2051
|
+
timezone: z14.string().optional()
|
|
2052
|
+
}).optional()
|
|
2053
|
+
})
|
|
2054
|
+
)
|
|
2055
|
+
);
|
|
2056
|
+
var webSearchPreviewInputSchema = lazySchema6(
|
|
2057
|
+
() => zodSchema13(
|
|
2058
|
+
z14.object({
|
|
2059
|
+
action: z14.discriminatedUnion("type", [
|
|
2060
|
+
z14.object({
|
|
2061
|
+
type: z14.literal("search"),
|
|
2062
|
+
query: z14.string().nullish()
|
|
2063
|
+
}),
|
|
2064
|
+
z14.object({
|
|
2065
|
+
type: z14.literal("open_page"),
|
|
2066
|
+
url: z14.string()
|
|
2067
|
+
}),
|
|
2068
|
+
z14.object({
|
|
2069
|
+
type: z14.literal("find"),
|
|
2070
|
+
url: z14.string(),
|
|
2071
|
+
pattern: z14.string()
|
|
2072
|
+
})
|
|
2073
|
+
]).nullish()
|
|
2074
|
+
})
|
|
2075
|
+
)
|
|
2076
|
+
);
|
|
1907
2077
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
1908
2078
|
id: "openai.web_search_preview",
|
|
1909
2079
|
name: "web_search_preview",
|
|
1910
|
-
inputSchema:
|
|
1911
|
-
action: z14.discriminatedUnion("type", [
|
|
1912
|
-
z14.object({
|
|
1913
|
-
type: z14.literal("search"),
|
|
1914
|
-
query: z14.string().nullish()
|
|
1915
|
-
}),
|
|
1916
|
-
z14.object({
|
|
1917
|
-
type: z14.literal("open_page"),
|
|
1918
|
-
url: z14.string()
|
|
1919
|
-
}),
|
|
1920
|
-
z14.object({
|
|
1921
|
-
type: z14.literal("find"),
|
|
1922
|
-
url: z14.string(),
|
|
1923
|
-
pattern: z14.string()
|
|
1924
|
-
})
|
|
1925
|
-
]).nullish()
|
|
1926
|
-
})
|
|
2080
|
+
inputSchema: webSearchPreviewInputSchema
|
|
1927
2081
|
});
|
|
1928
2082
|
|
|
1929
2083
|
// src/openai-tools.ts
|
|
@@ -2016,14 +2170,17 @@ import {
|
|
|
2016
2170
|
parseProviderOptions as parseProviderOptions5,
|
|
2017
2171
|
postJsonToApi as postJsonToApi5
|
|
2018
2172
|
} from "@ai-sdk/provider-utils";
|
|
2019
|
-
import { z as z16 } from "zod/v4";
|
|
2020
2173
|
|
|
2021
2174
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2022
2175
|
import {
|
|
2023
2176
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2024
2177
|
} from "@ai-sdk/provider";
|
|
2025
|
-
import {
|
|
2026
|
-
|
|
2178
|
+
import {
|
|
2179
|
+
convertToBase64 as convertToBase642,
|
|
2180
|
+
parseProviderOptions as parseProviderOptions4,
|
|
2181
|
+
validateTypes
|
|
2182
|
+
} from "@ai-sdk/provider-utils";
|
|
2183
|
+
import * as z15 from "zod/v4";
|
|
2027
2184
|
function isFileId(data, prefixes) {
|
|
2028
2185
|
if (!prefixes) return false;
|
|
2029
2186
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2129,7 +2286,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2129
2286
|
break;
|
|
2130
2287
|
}
|
|
2131
2288
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2132
|
-
const parsedInput =
|
|
2289
|
+
const parsedInput = await validateTypes({
|
|
2290
|
+
value: part.input,
|
|
2291
|
+
schema: localShellInputSchema
|
|
2292
|
+
});
|
|
2133
2293
|
input.push({
|
|
2134
2294
|
type: "local_shell_call",
|
|
2135
2295
|
call_id: part.toolCallId,
|
|
@@ -2225,10 +2385,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2225
2385
|
for (const part of content) {
|
|
2226
2386
|
const output = part.output;
|
|
2227
2387
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2388
|
+
const parsedOutput = await validateTypes({
|
|
2389
|
+
value: output.value,
|
|
2390
|
+
schema: localShellOutputSchema
|
|
2391
|
+
});
|
|
2228
2392
|
input.push({
|
|
2229
2393
|
type: "local_shell_call_output",
|
|
2230
2394
|
call_id: part.toolCallId,
|
|
2231
|
-
output:
|
|
2395
|
+
output: parsedOutput.output
|
|
2232
2396
|
});
|
|
2233
2397
|
break;
|
|
2234
2398
|
}
|
|
@@ -2286,11 +2450,547 @@ function mapOpenAIResponseFinishReason({
|
|
|
2286
2450
|
}
|
|
2287
2451
|
}
|
|
2288
2452
|
|
|
2453
|
+
// src/responses/openai-responses-api.ts
|
|
2454
|
+
import {
|
|
2455
|
+
lazyValidator as lazyValidator8,
|
|
2456
|
+
zodSchema as zodSchema14
|
|
2457
|
+
} from "@ai-sdk/provider-utils";
|
|
2458
|
+
import * as z16 from "zod/v4";
|
|
2459
|
+
var openaiResponsesChunkSchema = lazyValidator8(
|
|
2460
|
+
() => zodSchema14(
|
|
2461
|
+
z16.union([
|
|
2462
|
+
z16.object({
|
|
2463
|
+
type: z16.literal("response.output_text.delta"),
|
|
2464
|
+
item_id: z16.string(),
|
|
2465
|
+
delta: z16.string(),
|
|
2466
|
+
logprobs: z16.array(
|
|
2467
|
+
z16.object({
|
|
2468
|
+
token: z16.string(),
|
|
2469
|
+
logprob: z16.number(),
|
|
2470
|
+
top_logprobs: z16.array(
|
|
2471
|
+
z16.object({
|
|
2472
|
+
token: z16.string(),
|
|
2473
|
+
logprob: z16.number()
|
|
2474
|
+
})
|
|
2475
|
+
)
|
|
2476
|
+
})
|
|
2477
|
+
).nullish()
|
|
2478
|
+
}),
|
|
2479
|
+
z16.object({
|
|
2480
|
+
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
2481
|
+
response: z16.object({
|
|
2482
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2483
|
+
usage: z16.object({
|
|
2484
|
+
input_tokens: z16.number(),
|
|
2485
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2486
|
+
output_tokens: z16.number(),
|
|
2487
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2488
|
+
}),
|
|
2489
|
+
service_tier: z16.string().nullish()
|
|
2490
|
+
})
|
|
2491
|
+
}),
|
|
2492
|
+
z16.object({
|
|
2493
|
+
type: z16.literal("response.created"),
|
|
2494
|
+
response: z16.object({
|
|
2495
|
+
id: z16.string(),
|
|
2496
|
+
created_at: z16.number(),
|
|
2497
|
+
model: z16.string(),
|
|
2498
|
+
service_tier: z16.string().nullish()
|
|
2499
|
+
})
|
|
2500
|
+
}),
|
|
2501
|
+
z16.object({
|
|
2502
|
+
type: z16.literal("response.output_item.added"),
|
|
2503
|
+
output_index: z16.number(),
|
|
2504
|
+
item: z16.discriminatedUnion("type", [
|
|
2505
|
+
z16.object({
|
|
2506
|
+
type: z16.literal("message"),
|
|
2507
|
+
id: z16.string()
|
|
2508
|
+
}),
|
|
2509
|
+
z16.object({
|
|
2510
|
+
type: z16.literal("reasoning"),
|
|
2511
|
+
id: z16.string(),
|
|
2512
|
+
encrypted_content: z16.string().nullish()
|
|
2513
|
+
}),
|
|
2514
|
+
z16.object({
|
|
2515
|
+
type: z16.literal("function_call"),
|
|
2516
|
+
id: z16.string(),
|
|
2517
|
+
call_id: z16.string(),
|
|
2518
|
+
name: z16.string(),
|
|
2519
|
+
arguments: z16.string()
|
|
2520
|
+
}),
|
|
2521
|
+
z16.object({
|
|
2522
|
+
type: z16.literal("web_search_call"),
|
|
2523
|
+
id: z16.string(),
|
|
2524
|
+
status: z16.string(),
|
|
2525
|
+
action: z16.object({
|
|
2526
|
+
type: z16.literal("search"),
|
|
2527
|
+
query: z16.string().optional()
|
|
2528
|
+
}).nullish()
|
|
2529
|
+
}),
|
|
2530
|
+
z16.object({
|
|
2531
|
+
type: z16.literal("computer_call"),
|
|
2532
|
+
id: z16.string(),
|
|
2533
|
+
status: z16.string()
|
|
2534
|
+
}),
|
|
2535
|
+
z16.object({
|
|
2536
|
+
type: z16.literal("file_search_call"),
|
|
2537
|
+
id: z16.string()
|
|
2538
|
+
}),
|
|
2539
|
+
z16.object({
|
|
2540
|
+
type: z16.literal("image_generation_call"),
|
|
2541
|
+
id: z16.string()
|
|
2542
|
+
}),
|
|
2543
|
+
z16.object({
|
|
2544
|
+
type: z16.literal("code_interpreter_call"),
|
|
2545
|
+
id: z16.string(),
|
|
2546
|
+
container_id: z16.string(),
|
|
2547
|
+
code: z16.string().nullable(),
|
|
2548
|
+
outputs: z16.array(
|
|
2549
|
+
z16.discriminatedUnion("type", [
|
|
2550
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2551
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2552
|
+
])
|
|
2553
|
+
).nullable(),
|
|
2554
|
+
status: z16.string()
|
|
2555
|
+
})
|
|
2556
|
+
])
|
|
2557
|
+
}),
|
|
2558
|
+
z16.object({
|
|
2559
|
+
type: z16.literal("response.output_item.done"),
|
|
2560
|
+
output_index: z16.number(),
|
|
2561
|
+
item: z16.discriminatedUnion("type", [
|
|
2562
|
+
z16.object({
|
|
2563
|
+
type: z16.literal("message"),
|
|
2564
|
+
id: z16.string()
|
|
2565
|
+
}),
|
|
2566
|
+
z16.object({
|
|
2567
|
+
type: z16.literal("reasoning"),
|
|
2568
|
+
id: z16.string(),
|
|
2569
|
+
encrypted_content: z16.string().nullish()
|
|
2570
|
+
}),
|
|
2571
|
+
z16.object({
|
|
2572
|
+
type: z16.literal("function_call"),
|
|
2573
|
+
id: z16.string(),
|
|
2574
|
+
call_id: z16.string(),
|
|
2575
|
+
name: z16.string(),
|
|
2576
|
+
arguments: z16.string(),
|
|
2577
|
+
status: z16.literal("completed")
|
|
2578
|
+
}),
|
|
2579
|
+
z16.object({
|
|
2580
|
+
type: z16.literal("code_interpreter_call"),
|
|
2581
|
+
id: z16.string(),
|
|
2582
|
+
code: z16.string().nullable(),
|
|
2583
|
+
container_id: z16.string(),
|
|
2584
|
+
outputs: z16.array(
|
|
2585
|
+
z16.discriminatedUnion("type", [
|
|
2586
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2587
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2588
|
+
])
|
|
2589
|
+
).nullable()
|
|
2590
|
+
}),
|
|
2591
|
+
z16.object({
|
|
2592
|
+
type: z16.literal("image_generation_call"),
|
|
2593
|
+
id: z16.string(),
|
|
2594
|
+
result: z16.string()
|
|
2595
|
+
}),
|
|
2596
|
+
z16.object({
|
|
2597
|
+
type: z16.literal("web_search_call"),
|
|
2598
|
+
id: z16.string(),
|
|
2599
|
+
status: z16.string(),
|
|
2600
|
+
action: z16.discriminatedUnion("type", [
|
|
2601
|
+
z16.object({
|
|
2602
|
+
type: z16.literal("search"),
|
|
2603
|
+
query: z16.string().nullish()
|
|
2604
|
+
}),
|
|
2605
|
+
z16.object({
|
|
2606
|
+
type: z16.literal("open_page"),
|
|
2607
|
+
url: z16.string()
|
|
2608
|
+
}),
|
|
2609
|
+
z16.object({
|
|
2610
|
+
type: z16.literal("find"),
|
|
2611
|
+
url: z16.string(),
|
|
2612
|
+
pattern: z16.string()
|
|
2613
|
+
})
|
|
2614
|
+
]).nullish()
|
|
2615
|
+
}),
|
|
2616
|
+
z16.object({
|
|
2617
|
+
type: z16.literal("file_search_call"),
|
|
2618
|
+
id: z16.string(),
|
|
2619
|
+
queries: z16.array(z16.string()),
|
|
2620
|
+
results: z16.array(
|
|
2621
|
+
z16.object({
|
|
2622
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2623
|
+
file_id: z16.string(),
|
|
2624
|
+
filename: z16.string(),
|
|
2625
|
+
score: z16.number(),
|
|
2626
|
+
text: z16.string()
|
|
2627
|
+
})
|
|
2628
|
+
).nullish()
|
|
2629
|
+
}),
|
|
2630
|
+
z16.object({
|
|
2631
|
+
type: z16.literal("local_shell_call"),
|
|
2632
|
+
id: z16.string(),
|
|
2633
|
+
call_id: z16.string(),
|
|
2634
|
+
action: z16.object({
|
|
2635
|
+
type: z16.literal("exec"),
|
|
2636
|
+
command: z16.array(z16.string()),
|
|
2637
|
+
timeout_ms: z16.number().optional(),
|
|
2638
|
+
user: z16.string().optional(),
|
|
2639
|
+
working_directory: z16.string().optional(),
|
|
2640
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2641
|
+
})
|
|
2642
|
+
}),
|
|
2643
|
+
z16.object({
|
|
2644
|
+
type: z16.literal("computer_call"),
|
|
2645
|
+
id: z16.string(),
|
|
2646
|
+
status: z16.literal("completed")
|
|
2647
|
+
})
|
|
2648
|
+
])
|
|
2649
|
+
}),
|
|
2650
|
+
z16.object({
|
|
2651
|
+
type: z16.literal("response.function_call_arguments.delta"),
|
|
2652
|
+
item_id: z16.string(),
|
|
2653
|
+
output_index: z16.number(),
|
|
2654
|
+
delta: z16.string()
|
|
2655
|
+
}),
|
|
2656
|
+
z16.object({
|
|
2657
|
+
type: z16.literal("response.image_generation_call.partial_image"),
|
|
2658
|
+
item_id: z16.string(),
|
|
2659
|
+
output_index: z16.number(),
|
|
2660
|
+
partial_image_b64: z16.string()
|
|
2661
|
+
}),
|
|
2662
|
+
z16.object({
|
|
2663
|
+
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
2664
|
+
item_id: z16.string(),
|
|
2665
|
+
output_index: z16.number(),
|
|
2666
|
+
delta: z16.string()
|
|
2667
|
+
}),
|
|
2668
|
+
z16.object({
|
|
2669
|
+
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
2670
|
+
item_id: z16.string(),
|
|
2671
|
+
output_index: z16.number(),
|
|
2672
|
+
code: z16.string()
|
|
2673
|
+
}),
|
|
2674
|
+
z16.object({
|
|
2675
|
+
type: z16.literal("response.output_text.annotation.added"),
|
|
2676
|
+
annotation: z16.discriminatedUnion("type", [
|
|
2677
|
+
z16.object({
|
|
2678
|
+
type: z16.literal("url_citation"),
|
|
2679
|
+
url: z16.string(),
|
|
2680
|
+
title: z16.string()
|
|
2681
|
+
}),
|
|
2682
|
+
z16.object({
|
|
2683
|
+
type: z16.literal("file_citation"),
|
|
2684
|
+
file_id: z16.string(),
|
|
2685
|
+
filename: z16.string().nullish(),
|
|
2686
|
+
index: z16.number().nullish(),
|
|
2687
|
+
start_index: z16.number().nullish(),
|
|
2688
|
+
end_index: z16.number().nullish(),
|
|
2689
|
+
quote: z16.string().nullish()
|
|
2690
|
+
})
|
|
2691
|
+
])
|
|
2692
|
+
}),
|
|
2693
|
+
z16.object({
|
|
2694
|
+
type: z16.literal("response.reasoning_summary_part.added"),
|
|
2695
|
+
item_id: z16.string(),
|
|
2696
|
+
summary_index: z16.number()
|
|
2697
|
+
}),
|
|
2698
|
+
z16.object({
|
|
2699
|
+
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
2700
|
+
item_id: z16.string(),
|
|
2701
|
+
summary_index: z16.number(),
|
|
2702
|
+
delta: z16.string()
|
|
2703
|
+
}),
|
|
2704
|
+
z16.object({
|
|
2705
|
+
type: z16.literal("error"),
|
|
2706
|
+
code: z16.string(),
|
|
2707
|
+
message: z16.string(),
|
|
2708
|
+
param: z16.string().nullish(),
|
|
2709
|
+
sequence_number: z16.number()
|
|
2710
|
+
}),
|
|
2711
|
+
z16.object({ type: z16.string() }).loose().transform((value) => ({
|
|
2712
|
+
type: "unknown_chunk",
|
|
2713
|
+
message: value.type
|
|
2714
|
+
}))
|
|
2715
|
+
// fallback for unknown chunks
|
|
2716
|
+
])
|
|
2717
|
+
)
|
|
2718
|
+
);
|
|
2719
|
+
var openaiResponsesResponseSchema = lazyValidator8(
|
|
2720
|
+
() => zodSchema14(
|
|
2721
|
+
z16.object({
|
|
2722
|
+
id: z16.string(),
|
|
2723
|
+
created_at: z16.number(),
|
|
2724
|
+
error: z16.object({
|
|
2725
|
+
code: z16.string(),
|
|
2726
|
+
message: z16.string()
|
|
2727
|
+
}).nullish(),
|
|
2728
|
+
model: z16.string(),
|
|
2729
|
+
output: z16.array(
|
|
2730
|
+
z16.discriminatedUnion("type", [
|
|
2731
|
+
z16.object({
|
|
2732
|
+
type: z16.literal("message"),
|
|
2733
|
+
role: z16.literal("assistant"),
|
|
2734
|
+
id: z16.string(),
|
|
2735
|
+
content: z16.array(
|
|
2736
|
+
z16.object({
|
|
2737
|
+
type: z16.literal("output_text"),
|
|
2738
|
+
text: z16.string(),
|
|
2739
|
+
logprobs: z16.array(
|
|
2740
|
+
z16.object({
|
|
2741
|
+
token: z16.string(),
|
|
2742
|
+
logprob: z16.number(),
|
|
2743
|
+
top_logprobs: z16.array(
|
|
2744
|
+
z16.object({
|
|
2745
|
+
token: z16.string(),
|
|
2746
|
+
logprob: z16.number()
|
|
2747
|
+
})
|
|
2748
|
+
)
|
|
2749
|
+
})
|
|
2750
|
+
).nullish(),
|
|
2751
|
+
annotations: z16.array(
|
|
2752
|
+
z16.discriminatedUnion("type", [
|
|
2753
|
+
z16.object({
|
|
2754
|
+
type: z16.literal("url_citation"),
|
|
2755
|
+
start_index: z16.number(),
|
|
2756
|
+
end_index: z16.number(),
|
|
2757
|
+
url: z16.string(),
|
|
2758
|
+
title: z16.string()
|
|
2759
|
+
}),
|
|
2760
|
+
z16.object({
|
|
2761
|
+
type: z16.literal("file_citation"),
|
|
2762
|
+
file_id: z16.string(),
|
|
2763
|
+
filename: z16.string().nullish(),
|
|
2764
|
+
index: z16.number().nullish(),
|
|
2765
|
+
start_index: z16.number().nullish(),
|
|
2766
|
+
end_index: z16.number().nullish(),
|
|
2767
|
+
quote: z16.string().nullish()
|
|
2768
|
+
}),
|
|
2769
|
+
z16.object({
|
|
2770
|
+
type: z16.literal("container_file_citation")
|
|
2771
|
+
})
|
|
2772
|
+
])
|
|
2773
|
+
)
|
|
2774
|
+
})
|
|
2775
|
+
)
|
|
2776
|
+
}),
|
|
2777
|
+
z16.object({
|
|
2778
|
+
type: z16.literal("web_search_call"),
|
|
2779
|
+
id: z16.string(),
|
|
2780
|
+
status: z16.string(),
|
|
2781
|
+
action: z16.discriminatedUnion("type", [
|
|
2782
|
+
z16.object({
|
|
2783
|
+
type: z16.literal("search"),
|
|
2784
|
+
query: z16.string().nullish()
|
|
2785
|
+
}),
|
|
2786
|
+
z16.object({
|
|
2787
|
+
type: z16.literal("open_page"),
|
|
2788
|
+
url: z16.string()
|
|
2789
|
+
}),
|
|
2790
|
+
z16.object({
|
|
2791
|
+
type: z16.literal("find"),
|
|
2792
|
+
url: z16.string(),
|
|
2793
|
+
pattern: z16.string()
|
|
2794
|
+
})
|
|
2795
|
+
]).nullish()
|
|
2796
|
+
}),
|
|
2797
|
+
z16.object({
|
|
2798
|
+
type: z16.literal("file_search_call"),
|
|
2799
|
+
id: z16.string(),
|
|
2800
|
+
queries: z16.array(z16.string()),
|
|
2801
|
+
results: z16.array(
|
|
2802
|
+
z16.object({
|
|
2803
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2804
|
+
file_id: z16.string(),
|
|
2805
|
+
filename: z16.string(),
|
|
2806
|
+
score: z16.number(),
|
|
2807
|
+
text: z16.string()
|
|
2808
|
+
})
|
|
2809
|
+
).nullish()
|
|
2810
|
+
}),
|
|
2811
|
+
z16.object({
|
|
2812
|
+
type: z16.literal("code_interpreter_call"),
|
|
2813
|
+
id: z16.string(),
|
|
2814
|
+
code: z16.string().nullable(),
|
|
2815
|
+
container_id: z16.string(),
|
|
2816
|
+
outputs: z16.array(
|
|
2817
|
+
z16.discriminatedUnion("type", [
|
|
2818
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2819
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2820
|
+
])
|
|
2821
|
+
).nullable()
|
|
2822
|
+
}),
|
|
2823
|
+
z16.object({
|
|
2824
|
+
type: z16.literal("image_generation_call"),
|
|
2825
|
+
id: z16.string(),
|
|
2826
|
+
result: z16.string()
|
|
2827
|
+
}),
|
|
2828
|
+
z16.object({
|
|
2829
|
+
type: z16.literal("local_shell_call"),
|
|
2830
|
+
id: z16.string(),
|
|
2831
|
+
call_id: z16.string(),
|
|
2832
|
+
action: z16.object({
|
|
2833
|
+
type: z16.literal("exec"),
|
|
2834
|
+
command: z16.array(z16.string()),
|
|
2835
|
+
timeout_ms: z16.number().optional(),
|
|
2836
|
+
user: z16.string().optional(),
|
|
2837
|
+
working_directory: z16.string().optional(),
|
|
2838
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2839
|
+
})
|
|
2840
|
+
}),
|
|
2841
|
+
z16.object({
|
|
2842
|
+
type: z16.literal("function_call"),
|
|
2843
|
+
call_id: z16.string(),
|
|
2844
|
+
name: z16.string(),
|
|
2845
|
+
arguments: z16.string(),
|
|
2846
|
+
id: z16.string()
|
|
2847
|
+
}),
|
|
2848
|
+
z16.object({
|
|
2849
|
+
type: z16.literal("computer_call"),
|
|
2850
|
+
id: z16.string(),
|
|
2851
|
+
status: z16.string().optional()
|
|
2852
|
+
}),
|
|
2853
|
+
z16.object({
|
|
2854
|
+
type: z16.literal("reasoning"),
|
|
2855
|
+
id: z16.string(),
|
|
2856
|
+
encrypted_content: z16.string().nullish(),
|
|
2857
|
+
summary: z16.array(
|
|
2858
|
+
z16.object({
|
|
2859
|
+
type: z16.literal("summary_text"),
|
|
2860
|
+
text: z16.string()
|
|
2861
|
+
})
|
|
2862
|
+
)
|
|
2863
|
+
})
|
|
2864
|
+
])
|
|
2865
|
+
),
|
|
2866
|
+
service_tier: z16.string().nullish(),
|
|
2867
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2868
|
+
usage: z16.object({
|
|
2869
|
+
input_tokens: z16.number(),
|
|
2870
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2871
|
+
output_tokens: z16.number(),
|
|
2872
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2873
|
+
})
|
|
2874
|
+
})
|
|
2875
|
+
)
|
|
2876
|
+
);
|
|
2877
|
+
|
|
2878
|
+
// src/responses/openai-responses-options.ts
|
|
2879
|
+
import {
|
|
2880
|
+
lazyValidator as lazyValidator9,
|
|
2881
|
+
zodSchema as zodSchema15
|
|
2882
|
+
} from "@ai-sdk/provider-utils";
|
|
2883
|
+
import * as z17 from "zod/v4";
|
|
2884
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2885
|
+
var openaiResponsesReasoningModelIds = [
|
|
2886
|
+
"o1",
|
|
2887
|
+
"o1-2024-12-17",
|
|
2888
|
+
"o3-mini",
|
|
2889
|
+
"o3-mini-2025-01-31",
|
|
2890
|
+
"o3",
|
|
2891
|
+
"o3-2025-04-16",
|
|
2892
|
+
"o4-mini",
|
|
2893
|
+
"o4-mini-2025-04-16",
|
|
2894
|
+
"codex-mini-latest",
|
|
2895
|
+
"computer-use-preview",
|
|
2896
|
+
"gpt-5",
|
|
2897
|
+
"gpt-5-2025-08-07",
|
|
2898
|
+
"gpt-5-codex",
|
|
2899
|
+
"gpt-5-mini",
|
|
2900
|
+
"gpt-5-mini-2025-08-07",
|
|
2901
|
+
"gpt-5-nano",
|
|
2902
|
+
"gpt-5-nano-2025-08-07",
|
|
2903
|
+
"gpt-5-pro",
|
|
2904
|
+
"gpt-5-pro-2025-10-06"
|
|
2905
|
+
];
|
|
2906
|
+
var openaiResponsesModelIds = [
|
|
2907
|
+
"gpt-4.1",
|
|
2908
|
+
"gpt-4.1-2025-04-14",
|
|
2909
|
+
"gpt-4.1-mini",
|
|
2910
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2911
|
+
"gpt-4.1-nano",
|
|
2912
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2913
|
+
"gpt-4o",
|
|
2914
|
+
"gpt-4o-2024-05-13",
|
|
2915
|
+
"gpt-4o-2024-08-06",
|
|
2916
|
+
"gpt-4o-2024-11-20",
|
|
2917
|
+
"gpt-4o-audio-preview",
|
|
2918
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2919
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2920
|
+
"gpt-4o-search-preview",
|
|
2921
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2922
|
+
"gpt-4o-mini-search-preview",
|
|
2923
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2924
|
+
"gpt-4o-mini",
|
|
2925
|
+
"gpt-4o-mini-2024-07-18",
|
|
2926
|
+
"gpt-4-turbo",
|
|
2927
|
+
"gpt-4-turbo-2024-04-09",
|
|
2928
|
+
"gpt-4-turbo-preview",
|
|
2929
|
+
"gpt-4-0125-preview",
|
|
2930
|
+
"gpt-4-1106-preview",
|
|
2931
|
+
"gpt-4",
|
|
2932
|
+
"gpt-4-0613",
|
|
2933
|
+
"gpt-4.5-preview",
|
|
2934
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2935
|
+
"gpt-3.5-turbo-0125",
|
|
2936
|
+
"gpt-3.5-turbo",
|
|
2937
|
+
"gpt-3.5-turbo-1106",
|
|
2938
|
+
"chatgpt-4o-latest",
|
|
2939
|
+
"gpt-5-chat-latest",
|
|
2940
|
+
...openaiResponsesReasoningModelIds
|
|
2941
|
+
];
|
|
2942
|
+
var openaiResponsesProviderOptionsSchema = lazyValidator9(
|
|
2943
|
+
() => zodSchema15(
|
|
2944
|
+
z17.object({
|
|
2945
|
+
include: z17.array(
|
|
2946
|
+
z17.enum([
|
|
2947
|
+
"reasoning.encrypted_content",
|
|
2948
|
+
"file_search_call.results",
|
|
2949
|
+
"message.output_text.logprobs"
|
|
2950
|
+
])
|
|
2951
|
+
).nullish(),
|
|
2952
|
+
instructions: z17.string().nullish(),
|
|
2953
|
+
/**
|
|
2954
|
+
* Return the log probabilities of the tokens.
|
|
2955
|
+
*
|
|
2956
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2957
|
+
* were generated.
|
|
2958
|
+
*
|
|
2959
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2960
|
+
* tokens that were generated.
|
|
2961
|
+
*
|
|
2962
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2963
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2964
|
+
*/
|
|
2965
|
+
logprobs: z17.union([z17.boolean(), z17.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2966
|
+
/**
|
|
2967
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2968
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2969
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2970
|
+
*/
|
|
2971
|
+
maxToolCalls: z17.number().nullish(),
|
|
2972
|
+
metadata: z17.any().nullish(),
|
|
2973
|
+
parallelToolCalls: z17.boolean().nullish(),
|
|
2974
|
+
previousResponseId: z17.string().nullish(),
|
|
2975
|
+
promptCacheKey: z17.string().nullish(),
|
|
2976
|
+
reasoningEffort: z17.string().nullish(),
|
|
2977
|
+
reasoningSummary: z17.string().nullish(),
|
|
2978
|
+
safetyIdentifier: z17.string().nullish(),
|
|
2979
|
+
serviceTier: z17.enum(["auto", "flex", "priority"]).nullish(),
|
|
2980
|
+
store: z17.boolean().nullish(),
|
|
2981
|
+
strictJsonSchema: z17.boolean().nullish(),
|
|
2982
|
+
textVerbosity: z17.enum(["low", "medium", "high"]).nullish(),
|
|
2983
|
+
user: z17.string().nullish()
|
|
2984
|
+
})
|
|
2985
|
+
)
|
|
2986
|
+
);
|
|
2987
|
+
|
|
2289
2988
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2290
2989
|
import {
|
|
2291
2990
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
2292
2991
|
} from "@ai-sdk/provider";
|
|
2293
|
-
|
|
2992
|
+
import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
|
|
2993
|
+
async function prepareResponsesTools({
|
|
2294
2994
|
tools,
|
|
2295
2995
|
toolChoice,
|
|
2296
2996
|
strictJsonSchema
|
|
@@ -2315,7 +3015,10 @@ function prepareResponsesTools({
|
|
|
2315
3015
|
case "provider-defined": {
|
|
2316
3016
|
switch (tool.id) {
|
|
2317
3017
|
case "openai.file_search": {
|
|
2318
|
-
const args =
|
|
3018
|
+
const args = await validateTypes2({
|
|
3019
|
+
value: tool.args,
|
|
3020
|
+
schema: fileSearchArgsSchema
|
|
3021
|
+
});
|
|
2319
3022
|
openaiTools2.push({
|
|
2320
3023
|
type: "file_search",
|
|
2321
3024
|
vector_store_ids: args.vectorStoreIds,
|
|
@@ -2335,7 +3038,10 @@ function prepareResponsesTools({
|
|
|
2335
3038
|
break;
|
|
2336
3039
|
}
|
|
2337
3040
|
case "openai.web_search_preview": {
|
|
2338
|
-
const args =
|
|
3041
|
+
const args = await validateTypes2({
|
|
3042
|
+
value: tool.args,
|
|
3043
|
+
schema: webSearchPreviewArgsSchema
|
|
3044
|
+
});
|
|
2339
3045
|
openaiTools2.push({
|
|
2340
3046
|
type: "web_search_preview",
|
|
2341
3047
|
search_context_size: args.searchContextSize,
|
|
@@ -2344,7 +3050,10 @@ function prepareResponsesTools({
|
|
|
2344
3050
|
break;
|
|
2345
3051
|
}
|
|
2346
3052
|
case "openai.web_search": {
|
|
2347
|
-
const args =
|
|
3053
|
+
const args = await validateTypes2({
|
|
3054
|
+
value: tool.args,
|
|
3055
|
+
schema: webSearchArgsSchema
|
|
3056
|
+
});
|
|
2348
3057
|
openaiTools2.push({
|
|
2349
3058
|
type: "web_search",
|
|
2350
3059
|
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
@@ -2354,7 +3063,10 @@ function prepareResponsesTools({
|
|
|
2354
3063
|
break;
|
|
2355
3064
|
}
|
|
2356
3065
|
case "openai.code_interpreter": {
|
|
2357
|
-
const args =
|
|
3066
|
+
const args = await validateTypes2({
|
|
3067
|
+
value: tool.args,
|
|
3068
|
+
schema: codeInterpreterArgsSchema
|
|
3069
|
+
});
|
|
2358
3070
|
openaiTools2.push({
|
|
2359
3071
|
type: "code_interpreter",
|
|
2360
3072
|
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
@@ -2362,7 +3074,10 @@ function prepareResponsesTools({
|
|
|
2362
3074
|
break;
|
|
2363
3075
|
}
|
|
2364
3076
|
case "openai.image_generation": {
|
|
2365
|
-
const args =
|
|
3077
|
+
const args = await validateTypes2({
|
|
3078
|
+
value: tool.args,
|
|
3079
|
+
schema: imageGenerationArgsSchema
|
|
3080
|
+
});
|
|
2366
3081
|
openaiTools2.push({
|
|
2367
3082
|
type: "image_generation",
|
|
2368
3083
|
background: args.background,
|
|
@@ -2414,83 +3129,6 @@ function prepareResponsesTools({
|
|
|
2414
3129
|
}
|
|
2415
3130
|
|
|
2416
3131
|
// src/responses/openai-responses-language-model.ts
|
|
2417
|
-
var webSearchCallItem = z16.object({
|
|
2418
|
-
type: z16.literal("web_search_call"),
|
|
2419
|
-
id: z16.string(),
|
|
2420
|
-
status: z16.string(),
|
|
2421
|
-
action: z16.discriminatedUnion("type", [
|
|
2422
|
-
z16.object({
|
|
2423
|
-
type: z16.literal("search"),
|
|
2424
|
-
query: z16.string().nullish()
|
|
2425
|
-
}),
|
|
2426
|
-
z16.object({
|
|
2427
|
-
type: z16.literal("open_page"),
|
|
2428
|
-
url: z16.string()
|
|
2429
|
-
}),
|
|
2430
|
-
z16.object({
|
|
2431
|
-
type: z16.literal("find"),
|
|
2432
|
-
url: z16.string(),
|
|
2433
|
-
pattern: z16.string()
|
|
2434
|
-
})
|
|
2435
|
-
]).nullish()
|
|
2436
|
-
});
|
|
2437
|
-
var fileSearchCallItem = z16.object({
|
|
2438
|
-
type: z16.literal("file_search_call"),
|
|
2439
|
-
id: z16.string(),
|
|
2440
|
-
queries: z16.array(z16.string()),
|
|
2441
|
-
results: z16.array(
|
|
2442
|
-
z16.object({
|
|
2443
|
-
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2444
|
-
file_id: z16.string(),
|
|
2445
|
-
filename: z16.string(),
|
|
2446
|
-
score: z16.number(),
|
|
2447
|
-
text: z16.string()
|
|
2448
|
-
})
|
|
2449
|
-
).nullish()
|
|
2450
|
-
});
|
|
2451
|
-
var codeInterpreterCallItem = z16.object({
|
|
2452
|
-
type: z16.literal("code_interpreter_call"),
|
|
2453
|
-
id: z16.string(),
|
|
2454
|
-
code: z16.string().nullable(),
|
|
2455
|
-
container_id: z16.string(),
|
|
2456
|
-
outputs: z16.array(
|
|
2457
|
-
z16.discriminatedUnion("type", [
|
|
2458
|
-
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2459
|
-
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2460
|
-
])
|
|
2461
|
-
).nullable()
|
|
2462
|
-
});
|
|
2463
|
-
var localShellCallItem = z16.object({
|
|
2464
|
-
type: z16.literal("local_shell_call"),
|
|
2465
|
-
id: z16.string(),
|
|
2466
|
-
call_id: z16.string(),
|
|
2467
|
-
action: z16.object({
|
|
2468
|
-
type: z16.literal("exec"),
|
|
2469
|
-
command: z16.array(z16.string()),
|
|
2470
|
-
timeout_ms: z16.number().optional(),
|
|
2471
|
-
user: z16.string().optional(),
|
|
2472
|
-
working_directory: z16.string().optional(),
|
|
2473
|
-
env: z16.record(z16.string(), z16.string()).optional()
|
|
2474
|
-
})
|
|
2475
|
-
});
|
|
2476
|
-
var imageGenerationCallItem = z16.object({
|
|
2477
|
-
type: z16.literal("image_generation_call"),
|
|
2478
|
-
id: z16.string(),
|
|
2479
|
-
result: z16.string()
|
|
2480
|
-
});
|
|
2481
|
-
var TOP_LOGPROBS_MAX = 20;
|
|
2482
|
-
var LOGPROBS_SCHEMA = z16.array(
|
|
2483
|
-
z16.object({
|
|
2484
|
-
token: z16.string(),
|
|
2485
|
-
logprob: z16.number(),
|
|
2486
|
-
top_logprobs: z16.array(
|
|
2487
|
-
z16.object({
|
|
2488
|
-
token: z16.string(),
|
|
2489
|
-
logprob: z16.number()
|
|
2490
|
-
})
|
|
2491
|
-
)
|
|
2492
|
-
})
|
|
2493
|
-
);
|
|
2494
3132
|
var OpenAIResponsesLanguageModel = class {
|
|
2495
3133
|
constructor(modelId, config) {
|
|
2496
3134
|
this.specificationVersion = "v3";
|
|
@@ -2682,7 +3320,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2682
3320
|
tools: openaiTools2,
|
|
2683
3321
|
toolChoice: openaiToolChoice,
|
|
2684
3322
|
toolWarnings
|
|
2685
|
-
} = prepareResponsesTools({
|
|
3323
|
+
} = await prepareResponsesTools({
|
|
2686
3324
|
tools,
|
|
2687
3325
|
toolChoice,
|
|
2688
3326
|
strictJsonSchema
|
|
@@ -2718,85 +3356,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2718
3356
|
body,
|
|
2719
3357
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2720
3358
|
successfulResponseHandler: createJsonResponseHandler5(
|
|
2721
|
-
|
|
2722
|
-
id: z16.string(),
|
|
2723
|
-
created_at: z16.number(),
|
|
2724
|
-
error: z16.object({
|
|
2725
|
-
code: z16.string(),
|
|
2726
|
-
message: z16.string()
|
|
2727
|
-
}).nullish(),
|
|
2728
|
-
model: z16.string(),
|
|
2729
|
-
output: z16.array(
|
|
2730
|
-
z16.discriminatedUnion("type", [
|
|
2731
|
-
z16.object({
|
|
2732
|
-
type: z16.literal("message"),
|
|
2733
|
-
role: z16.literal("assistant"),
|
|
2734
|
-
id: z16.string(),
|
|
2735
|
-
content: z16.array(
|
|
2736
|
-
z16.object({
|
|
2737
|
-
type: z16.literal("output_text"),
|
|
2738
|
-
text: z16.string(),
|
|
2739
|
-
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2740
|
-
annotations: z16.array(
|
|
2741
|
-
z16.discriminatedUnion("type", [
|
|
2742
|
-
z16.object({
|
|
2743
|
-
type: z16.literal("url_citation"),
|
|
2744
|
-
start_index: z16.number(),
|
|
2745
|
-
end_index: z16.number(),
|
|
2746
|
-
url: z16.string(),
|
|
2747
|
-
title: z16.string()
|
|
2748
|
-
}),
|
|
2749
|
-
z16.object({
|
|
2750
|
-
type: z16.literal("file_citation"),
|
|
2751
|
-
file_id: z16.string(),
|
|
2752
|
-
filename: z16.string().nullish(),
|
|
2753
|
-
index: z16.number().nullish(),
|
|
2754
|
-
start_index: z16.number().nullish(),
|
|
2755
|
-
end_index: z16.number().nullish(),
|
|
2756
|
-
quote: z16.string().nullish()
|
|
2757
|
-
}),
|
|
2758
|
-
z16.object({
|
|
2759
|
-
type: z16.literal("container_file_citation")
|
|
2760
|
-
})
|
|
2761
|
-
])
|
|
2762
|
-
)
|
|
2763
|
-
})
|
|
2764
|
-
)
|
|
2765
|
-
}),
|
|
2766
|
-
webSearchCallItem,
|
|
2767
|
-
fileSearchCallItem,
|
|
2768
|
-
codeInterpreterCallItem,
|
|
2769
|
-
imageGenerationCallItem,
|
|
2770
|
-
localShellCallItem,
|
|
2771
|
-
z16.object({
|
|
2772
|
-
type: z16.literal("function_call"),
|
|
2773
|
-
call_id: z16.string(),
|
|
2774
|
-
name: z16.string(),
|
|
2775
|
-
arguments: z16.string(),
|
|
2776
|
-
id: z16.string()
|
|
2777
|
-
}),
|
|
2778
|
-
z16.object({
|
|
2779
|
-
type: z16.literal("computer_call"),
|
|
2780
|
-
id: z16.string(),
|
|
2781
|
-
status: z16.string().optional()
|
|
2782
|
-
}),
|
|
2783
|
-
z16.object({
|
|
2784
|
-
type: z16.literal("reasoning"),
|
|
2785
|
-
id: z16.string(),
|
|
2786
|
-
encrypted_content: z16.string().nullish(),
|
|
2787
|
-
summary: z16.array(
|
|
2788
|
-
z16.object({
|
|
2789
|
-
type: z16.literal("summary_text"),
|
|
2790
|
-
text: z16.string()
|
|
2791
|
-
})
|
|
2792
|
-
)
|
|
2793
|
-
})
|
|
2794
|
-
])
|
|
2795
|
-
),
|
|
2796
|
-
service_tier: z16.string().nullish(),
|
|
2797
|
-
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2798
|
-
usage: usageSchema2
|
|
2799
|
-
})
|
|
3359
|
+
openaiResponsesResponseSchema
|
|
2800
3360
|
),
|
|
2801
3361
|
abortSignal: options.abortSignal,
|
|
2802
3362
|
fetch: this.config.fetch
|
|
@@ -2859,7 +3419,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2859
3419
|
type: "tool-call",
|
|
2860
3420
|
toolCallId: part.call_id,
|
|
2861
3421
|
toolName: "local_shell",
|
|
2862
|
-
input: JSON.stringify({
|
|
3422
|
+
input: JSON.stringify({
|
|
3423
|
+
action: part.action
|
|
3424
|
+
}),
|
|
2863
3425
|
providerMetadata: {
|
|
2864
3426
|
openai: {
|
|
2865
3427
|
itemId: part.id
|
|
@@ -3490,203 +4052,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3490
4052
|
};
|
|
3491
4053
|
}
|
|
3492
4054
|
};
|
|
3493
|
-
var usageSchema2 = z16.object({
|
|
3494
|
-
input_tokens: z16.number(),
|
|
3495
|
-
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
3496
|
-
output_tokens: z16.number(),
|
|
3497
|
-
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
3498
|
-
});
|
|
3499
|
-
var textDeltaChunkSchema = z16.object({
|
|
3500
|
-
type: z16.literal("response.output_text.delta"),
|
|
3501
|
-
item_id: z16.string(),
|
|
3502
|
-
delta: z16.string(),
|
|
3503
|
-
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3504
|
-
});
|
|
3505
|
-
var errorChunkSchema = z16.object({
|
|
3506
|
-
type: z16.literal("error"),
|
|
3507
|
-
code: z16.string(),
|
|
3508
|
-
message: z16.string(),
|
|
3509
|
-
param: z16.string().nullish(),
|
|
3510
|
-
sequence_number: z16.number()
|
|
3511
|
-
});
|
|
3512
|
-
var responseFinishedChunkSchema = z16.object({
|
|
3513
|
-
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
3514
|
-
response: z16.object({
|
|
3515
|
-
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
3516
|
-
usage: usageSchema2,
|
|
3517
|
-
service_tier: z16.string().nullish()
|
|
3518
|
-
})
|
|
3519
|
-
});
|
|
3520
|
-
var responseCreatedChunkSchema = z16.object({
|
|
3521
|
-
type: z16.literal("response.created"),
|
|
3522
|
-
response: z16.object({
|
|
3523
|
-
id: z16.string(),
|
|
3524
|
-
created_at: z16.number(),
|
|
3525
|
-
model: z16.string(),
|
|
3526
|
-
service_tier: z16.string().nullish()
|
|
3527
|
-
})
|
|
3528
|
-
});
|
|
3529
|
-
var responseOutputItemAddedSchema = z16.object({
|
|
3530
|
-
type: z16.literal("response.output_item.added"),
|
|
3531
|
-
output_index: z16.number(),
|
|
3532
|
-
item: z16.discriminatedUnion("type", [
|
|
3533
|
-
z16.object({
|
|
3534
|
-
type: z16.literal("message"),
|
|
3535
|
-
id: z16.string()
|
|
3536
|
-
}),
|
|
3537
|
-
z16.object({
|
|
3538
|
-
type: z16.literal("reasoning"),
|
|
3539
|
-
id: z16.string(),
|
|
3540
|
-
encrypted_content: z16.string().nullish()
|
|
3541
|
-
}),
|
|
3542
|
-
z16.object({
|
|
3543
|
-
type: z16.literal("function_call"),
|
|
3544
|
-
id: z16.string(),
|
|
3545
|
-
call_id: z16.string(),
|
|
3546
|
-
name: z16.string(),
|
|
3547
|
-
arguments: z16.string()
|
|
3548
|
-
}),
|
|
3549
|
-
z16.object({
|
|
3550
|
-
type: z16.literal("web_search_call"),
|
|
3551
|
-
id: z16.string(),
|
|
3552
|
-
status: z16.string(),
|
|
3553
|
-
action: z16.object({
|
|
3554
|
-
type: z16.literal("search"),
|
|
3555
|
-
query: z16.string().optional()
|
|
3556
|
-
}).nullish()
|
|
3557
|
-
}),
|
|
3558
|
-
z16.object({
|
|
3559
|
-
type: z16.literal("computer_call"),
|
|
3560
|
-
id: z16.string(),
|
|
3561
|
-
status: z16.string()
|
|
3562
|
-
}),
|
|
3563
|
-
z16.object({
|
|
3564
|
-
type: z16.literal("file_search_call"),
|
|
3565
|
-
id: z16.string()
|
|
3566
|
-
}),
|
|
3567
|
-
z16.object({
|
|
3568
|
-
type: z16.literal("image_generation_call"),
|
|
3569
|
-
id: z16.string()
|
|
3570
|
-
}),
|
|
3571
|
-
z16.object({
|
|
3572
|
-
type: z16.literal("code_interpreter_call"),
|
|
3573
|
-
id: z16.string(),
|
|
3574
|
-
container_id: z16.string(),
|
|
3575
|
-
code: z16.string().nullable(),
|
|
3576
|
-
outputs: z16.array(
|
|
3577
|
-
z16.discriminatedUnion("type", [
|
|
3578
|
-
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3579
|
-
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
3580
|
-
])
|
|
3581
|
-
).nullable(),
|
|
3582
|
-
status: z16.string()
|
|
3583
|
-
})
|
|
3584
|
-
])
|
|
3585
|
-
});
|
|
3586
|
-
var responseOutputItemDoneSchema = z16.object({
|
|
3587
|
-
type: z16.literal("response.output_item.done"),
|
|
3588
|
-
output_index: z16.number(),
|
|
3589
|
-
item: z16.discriminatedUnion("type", [
|
|
3590
|
-
z16.object({
|
|
3591
|
-
type: z16.literal("message"),
|
|
3592
|
-
id: z16.string()
|
|
3593
|
-
}),
|
|
3594
|
-
z16.object({
|
|
3595
|
-
type: z16.literal("reasoning"),
|
|
3596
|
-
id: z16.string(),
|
|
3597
|
-
encrypted_content: z16.string().nullish()
|
|
3598
|
-
}),
|
|
3599
|
-
z16.object({
|
|
3600
|
-
type: z16.literal("function_call"),
|
|
3601
|
-
id: z16.string(),
|
|
3602
|
-
call_id: z16.string(),
|
|
3603
|
-
name: z16.string(),
|
|
3604
|
-
arguments: z16.string(),
|
|
3605
|
-
status: z16.literal("completed")
|
|
3606
|
-
}),
|
|
3607
|
-
codeInterpreterCallItem,
|
|
3608
|
-
imageGenerationCallItem,
|
|
3609
|
-
webSearchCallItem,
|
|
3610
|
-
fileSearchCallItem,
|
|
3611
|
-
localShellCallItem,
|
|
3612
|
-
z16.object({
|
|
3613
|
-
type: z16.literal("computer_call"),
|
|
3614
|
-
id: z16.string(),
|
|
3615
|
-
status: z16.literal("completed")
|
|
3616
|
-
})
|
|
3617
|
-
])
|
|
3618
|
-
});
|
|
3619
|
-
var responseFunctionCallArgumentsDeltaSchema = z16.object({
|
|
3620
|
-
type: z16.literal("response.function_call_arguments.delta"),
|
|
3621
|
-
item_id: z16.string(),
|
|
3622
|
-
output_index: z16.number(),
|
|
3623
|
-
delta: z16.string()
|
|
3624
|
-
});
|
|
3625
|
-
var responseImageGenerationCallPartialImageSchema = z16.object({
|
|
3626
|
-
type: z16.literal("response.image_generation_call.partial_image"),
|
|
3627
|
-
item_id: z16.string(),
|
|
3628
|
-
output_index: z16.number(),
|
|
3629
|
-
partial_image_b64: z16.string()
|
|
3630
|
-
});
|
|
3631
|
-
var responseCodeInterpreterCallCodeDeltaSchema = z16.object({
|
|
3632
|
-
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
3633
|
-
item_id: z16.string(),
|
|
3634
|
-
output_index: z16.number(),
|
|
3635
|
-
delta: z16.string()
|
|
3636
|
-
});
|
|
3637
|
-
var responseCodeInterpreterCallCodeDoneSchema = z16.object({
|
|
3638
|
-
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
3639
|
-
item_id: z16.string(),
|
|
3640
|
-
output_index: z16.number(),
|
|
3641
|
-
code: z16.string()
|
|
3642
|
-
});
|
|
3643
|
-
var responseAnnotationAddedSchema = z16.object({
|
|
3644
|
-
type: z16.literal("response.output_text.annotation.added"),
|
|
3645
|
-
annotation: z16.discriminatedUnion("type", [
|
|
3646
|
-
z16.object({
|
|
3647
|
-
type: z16.literal("url_citation"),
|
|
3648
|
-
url: z16.string(),
|
|
3649
|
-
title: z16.string()
|
|
3650
|
-
}),
|
|
3651
|
-
z16.object({
|
|
3652
|
-
type: z16.literal("file_citation"),
|
|
3653
|
-
file_id: z16.string(),
|
|
3654
|
-
filename: z16.string().nullish(),
|
|
3655
|
-
index: z16.number().nullish(),
|
|
3656
|
-
start_index: z16.number().nullish(),
|
|
3657
|
-
end_index: z16.number().nullish(),
|
|
3658
|
-
quote: z16.string().nullish()
|
|
3659
|
-
})
|
|
3660
|
-
])
|
|
3661
|
-
});
|
|
3662
|
-
var responseReasoningSummaryPartAddedSchema = z16.object({
|
|
3663
|
-
type: z16.literal("response.reasoning_summary_part.added"),
|
|
3664
|
-
item_id: z16.string(),
|
|
3665
|
-
summary_index: z16.number()
|
|
3666
|
-
});
|
|
3667
|
-
var responseReasoningSummaryTextDeltaSchema = z16.object({
|
|
3668
|
-
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
3669
|
-
item_id: z16.string(),
|
|
3670
|
-
summary_index: z16.number(),
|
|
3671
|
-
delta: z16.string()
|
|
3672
|
-
});
|
|
3673
|
-
var openaiResponsesChunkSchema = z16.union([
|
|
3674
|
-
textDeltaChunkSchema,
|
|
3675
|
-
responseFinishedChunkSchema,
|
|
3676
|
-
responseCreatedChunkSchema,
|
|
3677
|
-
responseOutputItemAddedSchema,
|
|
3678
|
-
responseOutputItemDoneSchema,
|
|
3679
|
-
responseFunctionCallArgumentsDeltaSchema,
|
|
3680
|
-
responseImageGenerationCallPartialImageSchema,
|
|
3681
|
-
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3682
|
-
responseCodeInterpreterCallCodeDoneSchema,
|
|
3683
|
-
responseAnnotationAddedSchema,
|
|
3684
|
-
responseReasoningSummaryPartAddedSchema,
|
|
3685
|
-
responseReasoningSummaryTextDeltaSchema,
|
|
3686
|
-
errorChunkSchema,
|
|
3687
|
-
z16.object({ type: z16.string() }).loose()
|
|
3688
|
-
// fallback for unknown chunks
|
|
3689
|
-
]);
|
|
3690
4055
|
function isTextDeltaChunk(chunk) {
|
|
3691
4056
|
return chunk.type === "response.output_text.delta";
|
|
3692
4057
|
}
|
|
@@ -3766,47 +4131,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
3766
4131
|
isReasoningModel: false
|
|
3767
4132
|
};
|
|
3768
4133
|
}
|
|
3769
|
-
var openaiResponsesProviderOptionsSchema = z16.object({
|
|
3770
|
-
include: z16.array(
|
|
3771
|
-
z16.enum([
|
|
3772
|
-
"reasoning.encrypted_content",
|
|
3773
|
-
"file_search_call.results",
|
|
3774
|
-
"message.output_text.logprobs"
|
|
3775
|
-
])
|
|
3776
|
-
).nullish(),
|
|
3777
|
-
instructions: z16.string().nullish(),
|
|
3778
|
-
/**
|
|
3779
|
-
* Return the log probabilities of the tokens.
|
|
3780
|
-
*
|
|
3781
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
3782
|
-
* were generated.
|
|
3783
|
-
*
|
|
3784
|
-
* Setting to a number will return the log probabilities of the top n
|
|
3785
|
-
* tokens that were generated.
|
|
3786
|
-
*
|
|
3787
|
-
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3788
|
-
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3789
|
-
*/
|
|
3790
|
-
logprobs: z16.union([z16.boolean(), z16.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3791
|
-
/**
|
|
3792
|
-
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3793
|
-
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3794
|
-
* Any further attempts to call a tool by the model will be ignored.
|
|
3795
|
-
*/
|
|
3796
|
-
maxToolCalls: z16.number().nullish(),
|
|
3797
|
-
metadata: z16.any().nullish(),
|
|
3798
|
-
parallelToolCalls: z16.boolean().nullish(),
|
|
3799
|
-
previousResponseId: z16.string().nullish(),
|
|
3800
|
-
promptCacheKey: z16.string().nullish(),
|
|
3801
|
-
reasoningEffort: z16.string().nullish(),
|
|
3802
|
-
reasoningSummary: z16.string().nullish(),
|
|
3803
|
-
safetyIdentifier: z16.string().nullish(),
|
|
3804
|
-
serviceTier: z16.enum(["auto", "flex", "priority"]).nullish(),
|
|
3805
|
-
store: z16.boolean().nullish(),
|
|
3806
|
-
strictJsonSchema: z16.boolean().nullish(),
|
|
3807
|
-
textVerbosity: z16.enum(["low", "medium", "high"]).nullish(),
|
|
3808
|
-
user: z16.string().nullish()
|
|
3809
|
-
});
|
|
3810
4134
|
|
|
3811
4135
|
// src/speech/openai-speech-model.ts
|
|
3812
4136
|
import {
|
|
@@ -3815,11 +4139,23 @@ import {
|
|
|
3815
4139
|
parseProviderOptions as parseProviderOptions6,
|
|
3816
4140
|
postJsonToApi as postJsonToApi6
|
|
3817
4141
|
} from "@ai-sdk/provider-utils";
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
4142
|
+
|
|
4143
|
+
// src/speech/openai-speech-options.ts
|
|
4144
|
+
import {
|
|
4145
|
+
lazyValidator as lazyValidator10,
|
|
4146
|
+
zodSchema as zodSchema16
|
|
4147
|
+
} from "@ai-sdk/provider-utils";
|
|
4148
|
+
import * as z18 from "zod/v4";
|
|
4149
|
+
var openaiSpeechProviderOptionsSchema = lazyValidator10(
|
|
4150
|
+
() => zodSchema16(
|
|
4151
|
+
z18.object({
|
|
4152
|
+
instructions: z18.string().nullish(),
|
|
4153
|
+
speed: z18.number().min(0.25).max(4).default(1).nullish()
|
|
4154
|
+
})
|
|
4155
|
+
)
|
|
4156
|
+
);
|
|
4157
|
+
|
|
4158
|
+
// src/speech/openai-speech-model.ts
|
|
3823
4159
|
var OpenAISpeechModel = class {
|
|
3824
4160
|
constructor(modelId, config) {
|
|
3825
4161
|
this.modelId = modelId;
|
|
@@ -3842,7 +4178,7 @@ var OpenAISpeechModel = class {
|
|
|
3842
4178
|
const openAIOptions = await parseProviderOptions6({
|
|
3843
4179
|
provider: "openai",
|
|
3844
4180
|
providerOptions,
|
|
3845
|
-
schema:
|
|
4181
|
+
schema: openaiSpeechProviderOptionsSchema
|
|
3846
4182
|
});
|
|
3847
4183
|
const requestBody = {
|
|
3848
4184
|
model: this.modelId,
|
|
@@ -3929,34 +4265,75 @@ import {
|
|
|
3929
4265
|
parseProviderOptions as parseProviderOptions7,
|
|
3930
4266
|
postFormDataToApi
|
|
3931
4267
|
} from "@ai-sdk/provider-utils";
|
|
3932
|
-
|
|
4268
|
+
|
|
4269
|
+
// src/transcription/openai-transcription-api.ts
|
|
4270
|
+
import { lazyValidator as lazyValidator11, zodSchema as zodSchema17 } from "@ai-sdk/provider-utils";
|
|
4271
|
+
import * as z19 from "zod/v4";
|
|
4272
|
+
var openaiTranscriptionResponseSchema = lazyValidator11(
|
|
4273
|
+
() => zodSchema17(
|
|
4274
|
+
z19.object({
|
|
4275
|
+
text: z19.string(),
|
|
4276
|
+
language: z19.string().nullish(),
|
|
4277
|
+
duration: z19.number().nullish(),
|
|
4278
|
+
words: z19.array(
|
|
4279
|
+
z19.object({
|
|
4280
|
+
word: z19.string(),
|
|
4281
|
+
start: z19.number(),
|
|
4282
|
+
end: z19.number()
|
|
4283
|
+
})
|
|
4284
|
+
).nullish(),
|
|
4285
|
+
segments: z19.array(
|
|
4286
|
+
z19.object({
|
|
4287
|
+
id: z19.number(),
|
|
4288
|
+
seek: z19.number(),
|
|
4289
|
+
start: z19.number(),
|
|
4290
|
+
end: z19.number(),
|
|
4291
|
+
text: z19.string(),
|
|
4292
|
+
tokens: z19.array(z19.number()),
|
|
4293
|
+
temperature: z19.number(),
|
|
4294
|
+
avg_logprob: z19.number(),
|
|
4295
|
+
compression_ratio: z19.number(),
|
|
4296
|
+
no_speech_prob: z19.number()
|
|
4297
|
+
})
|
|
4298
|
+
).nullish()
|
|
4299
|
+
})
|
|
4300
|
+
)
|
|
4301
|
+
);
|
|
3933
4302
|
|
|
3934
4303
|
// src/transcription/openai-transcription-options.ts
|
|
3935
|
-
import {
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4304
|
+
import {
|
|
4305
|
+
lazyValidator as lazyValidator12,
|
|
4306
|
+
zodSchema as zodSchema18
|
|
4307
|
+
} from "@ai-sdk/provider-utils";
|
|
4308
|
+
import * as z20 from "zod/v4";
|
|
4309
|
+
var openAITranscriptionProviderOptions = lazyValidator12(
|
|
4310
|
+
() => zodSchema18(
|
|
4311
|
+
z20.object({
|
|
4312
|
+
/**
|
|
4313
|
+
* Additional information to include in the transcription response.
|
|
4314
|
+
*/
|
|
4315
|
+
include: z20.array(z20.string()).optional(),
|
|
4316
|
+
/**
|
|
4317
|
+
* The language of the input audio in ISO-639-1 format.
|
|
4318
|
+
*/
|
|
4319
|
+
language: z20.string().optional(),
|
|
4320
|
+
/**
|
|
4321
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
4322
|
+
*/
|
|
4323
|
+
prompt: z20.string().optional(),
|
|
4324
|
+
/**
|
|
4325
|
+
* The sampling temperature, between 0 and 1.
|
|
4326
|
+
* @default 0
|
|
4327
|
+
*/
|
|
4328
|
+
temperature: z20.number().min(0).max(1).default(0).optional(),
|
|
4329
|
+
/**
|
|
4330
|
+
* The timestamp granularities to populate for this transcription.
|
|
4331
|
+
* @default ['segment']
|
|
4332
|
+
*/
|
|
4333
|
+
timestampGranularities: z20.array(z20.enum(["word", "segment"])).default(["segment"]).optional()
|
|
4334
|
+
})
|
|
4335
|
+
)
|
|
4336
|
+
);
|
|
3960
4337
|
|
|
3961
4338
|
// src/transcription/openai-transcription-model.ts
|
|
3962
4339
|
var languageMap = {
|
|
@@ -4124,35 +4501,9 @@ var OpenAITranscriptionModel = class {
|
|
|
4124
4501
|
};
|
|
4125
4502
|
}
|
|
4126
4503
|
};
|
|
4127
|
-
var openaiTranscriptionResponseSchema = z19.object({
|
|
4128
|
-
text: z19.string(),
|
|
4129
|
-
language: z19.string().nullish(),
|
|
4130
|
-
duration: z19.number().nullish(),
|
|
4131
|
-
words: z19.array(
|
|
4132
|
-
z19.object({
|
|
4133
|
-
word: z19.string(),
|
|
4134
|
-
start: z19.number(),
|
|
4135
|
-
end: z19.number()
|
|
4136
|
-
})
|
|
4137
|
-
).nullish(),
|
|
4138
|
-
segments: z19.array(
|
|
4139
|
-
z19.object({
|
|
4140
|
-
id: z19.number(),
|
|
4141
|
-
seek: z19.number(),
|
|
4142
|
-
start: z19.number(),
|
|
4143
|
-
end: z19.number(),
|
|
4144
|
-
text: z19.string(),
|
|
4145
|
-
tokens: z19.array(z19.number()),
|
|
4146
|
-
temperature: z19.number(),
|
|
4147
|
-
avg_logprob: z19.number(),
|
|
4148
|
-
compression_ratio: z19.number(),
|
|
4149
|
-
no_speech_prob: z19.number()
|
|
4150
|
-
})
|
|
4151
|
-
).nullish()
|
|
4152
|
-
});
|
|
4153
4504
|
|
|
4154
4505
|
// src/version.ts
|
|
4155
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4506
|
+
var VERSION = true ? "3.0.0-beta.18" : "0.0.0-test";
|
|
4156
4507
|
|
|
4157
4508
|
// src/openai-provider.ts
|
|
4158
4509
|
function createOpenAI(options = {}) {
|