@ai-sdk/openai 3.0.0-beta.17 → 3.0.0-beta.19
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 -1033
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1295 -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 +1338 -1028
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1307 -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,246 @@ 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. The request will be processed with the service tier configured in the
|
|
461
|
+
* Project settings. Unless otherwise configured, the Project will use 'default'.
|
|
462
|
+
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
463
|
+
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
464
|
+
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
465
|
+
*
|
|
466
|
+
* @default 'auto'
|
|
467
|
+
*/
|
|
468
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
469
|
+
/**
|
|
470
|
+
* Whether to use strict JSON schema validation.
|
|
471
|
+
*
|
|
472
|
+
* @default false
|
|
473
|
+
*/
|
|
474
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
475
|
+
/**
|
|
476
|
+
* Controls the verbosity of the model's responses.
|
|
477
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
478
|
+
*/
|
|
479
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
480
|
+
/**
|
|
481
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
482
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
483
|
+
*/
|
|
484
|
+
promptCacheKey: z3.string().optional(),
|
|
485
|
+
/**
|
|
486
|
+
* A stable identifier used to help detect users of your application
|
|
487
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
488
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
489
|
+
* username or email address, in order to avoid sending us any identifying
|
|
490
|
+
* information.
|
|
491
|
+
*/
|
|
492
|
+
safetyIdentifier: z3.string().optional()
|
|
493
|
+
})
|
|
494
|
+
)
|
|
495
|
+
);
|
|
346
496
|
|
|
347
497
|
// src/chat/openai-chat-prepare-tools.ts
|
|
348
498
|
import {
|
|
@@ -900,121 +1050,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
900
1050
|
};
|
|
901
1051
|
}
|
|
902
1052
|
};
|
|
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
1053
|
function isReasoningModel(modelId) {
|
|
1019
1054
|
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
1020
1055
|
}
|
|
@@ -1072,7 +1107,6 @@ import {
|
|
|
1072
1107
|
parseProviderOptions as parseProviderOptions2,
|
|
1073
1108
|
postJsonToApi as postJsonToApi2
|
|
1074
1109
|
} from "@ai-sdk/provider-utils";
|
|
1075
|
-
import { z as z5 } from "zod/v4";
|
|
1076
1110
|
|
|
1077
1111
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1078
1112
|
import {
|
|
@@ -1182,48 +1216,117 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1182
1216
|
}
|
|
1183
1217
|
}
|
|
1184
1218
|
|
|
1219
|
+
// src/completion/openai-completion-api.ts
|
|
1220
|
+
import * as z4 from "zod/v4";
|
|
1221
|
+
import {
|
|
1222
|
+
lazyValidator as lazyValidator3,
|
|
1223
|
+
zodSchema as zodSchema3
|
|
1224
|
+
} from "@ai-sdk/provider-utils";
|
|
1225
|
+
var openaiCompletionResponseSchema = lazyValidator3(
|
|
1226
|
+
() => zodSchema3(
|
|
1227
|
+
z4.object({
|
|
1228
|
+
id: z4.string().nullish(),
|
|
1229
|
+
created: z4.number().nullish(),
|
|
1230
|
+
model: z4.string().nullish(),
|
|
1231
|
+
choices: z4.array(
|
|
1232
|
+
z4.object({
|
|
1233
|
+
text: z4.string(),
|
|
1234
|
+
finish_reason: z4.string(),
|
|
1235
|
+
logprobs: z4.object({
|
|
1236
|
+
tokens: z4.array(z4.string()),
|
|
1237
|
+
token_logprobs: z4.array(z4.number()),
|
|
1238
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1239
|
+
}).nullish()
|
|
1240
|
+
})
|
|
1241
|
+
),
|
|
1242
|
+
usage: z4.object({
|
|
1243
|
+
prompt_tokens: z4.number(),
|
|
1244
|
+
completion_tokens: z4.number(),
|
|
1245
|
+
total_tokens: z4.number()
|
|
1246
|
+
}).nullish()
|
|
1247
|
+
})
|
|
1248
|
+
)
|
|
1249
|
+
);
|
|
1250
|
+
var openaiCompletionChunkSchema = lazyValidator3(
|
|
1251
|
+
() => zodSchema3(
|
|
1252
|
+
z4.union([
|
|
1253
|
+
z4.object({
|
|
1254
|
+
id: z4.string().nullish(),
|
|
1255
|
+
created: z4.number().nullish(),
|
|
1256
|
+
model: z4.string().nullish(),
|
|
1257
|
+
choices: z4.array(
|
|
1258
|
+
z4.object({
|
|
1259
|
+
text: z4.string(),
|
|
1260
|
+
finish_reason: z4.string().nullish(),
|
|
1261
|
+
index: z4.number(),
|
|
1262
|
+
logprobs: z4.object({
|
|
1263
|
+
tokens: z4.array(z4.string()),
|
|
1264
|
+
token_logprobs: z4.array(z4.number()),
|
|
1265
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1266
|
+
}).nullish()
|
|
1267
|
+
})
|
|
1268
|
+
),
|
|
1269
|
+
usage: z4.object({
|
|
1270
|
+
prompt_tokens: z4.number(),
|
|
1271
|
+
completion_tokens: z4.number(),
|
|
1272
|
+
total_tokens: z4.number()
|
|
1273
|
+
}).nullish()
|
|
1274
|
+
}),
|
|
1275
|
+
openaiErrorDataSchema
|
|
1276
|
+
])
|
|
1277
|
+
)
|
|
1278
|
+
);
|
|
1279
|
+
|
|
1185
1280
|
// 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
|
-
|
|
1281
|
+
import {
|
|
1282
|
+
lazyValidator as lazyValidator4,
|
|
1283
|
+
zodSchema as zodSchema4
|
|
1284
|
+
} from "@ai-sdk/provider-utils";
|
|
1285
|
+
import * as z5 from "zod/v4";
|
|
1286
|
+
var openaiCompletionProviderOptions = lazyValidator4(
|
|
1287
|
+
() => zodSchema4(
|
|
1288
|
+
z5.object({
|
|
1289
|
+
/**
|
|
1290
|
+
Echo back the prompt in addition to the completion.
|
|
1291
|
+
*/
|
|
1292
|
+
echo: z5.boolean().optional(),
|
|
1293
|
+
/**
|
|
1294
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
1295
|
+
|
|
1296
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1297
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1298
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1299
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
1300
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
1301
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
1302
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
1303
|
+
|
|
1304
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1305
|
+
token from being generated.
|
|
1306
|
+
*/
|
|
1307
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1308
|
+
/**
|
|
1309
|
+
The suffix that comes after a completion of inserted text.
|
|
1310
|
+
*/
|
|
1311
|
+
suffix: z5.string().optional(),
|
|
1312
|
+
/**
|
|
1313
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1314
|
+
monitor and detect abuse. Learn more.
|
|
1315
|
+
*/
|
|
1316
|
+
user: z5.string().optional(),
|
|
1317
|
+
/**
|
|
1318
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1319
|
+
the response size and can slow down response times. However, it can
|
|
1320
|
+
be useful to better understand how the model is behaving.
|
|
1321
|
+
Setting to true will return the log probabilities of the tokens that
|
|
1322
|
+
were generated.
|
|
1323
|
+
Setting to a number will return the log probabilities of the top n
|
|
1324
|
+
tokens that were generated.
|
|
1325
|
+
*/
|
|
1326
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1327
|
+
})
|
|
1328
|
+
)
|
|
1329
|
+
);
|
|
1227
1330
|
|
|
1228
1331
|
// src/completion/openai-completion-language-model.ts
|
|
1229
1332
|
var OpenAICompletionLanguageModel = class {
|
|
@@ -1454,49 +1557,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1454
1557
|
};
|
|
1455
1558
|
}
|
|
1456
1559
|
};
|
|
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
1560
|
|
|
1501
1561
|
// src/embedding/openai-embedding-model.ts
|
|
1502
1562
|
import {
|
|
@@ -1508,22 +1568,41 @@ import {
|
|
|
1508
1568
|
parseProviderOptions as parseProviderOptions3,
|
|
1509
1569
|
postJsonToApi as postJsonToApi3
|
|
1510
1570
|
} from "@ai-sdk/provider-utils";
|
|
1511
|
-
import { z as z7 } from "zod/v4";
|
|
1512
1571
|
|
|
1513
1572
|
// src/embedding/openai-embedding-options.ts
|
|
1514
|
-
import {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1573
|
+
import {
|
|
1574
|
+
lazyValidator as lazyValidator5,
|
|
1575
|
+
zodSchema as zodSchema5
|
|
1576
|
+
} from "@ai-sdk/provider-utils";
|
|
1577
|
+
import * as z6 from "zod/v4";
|
|
1578
|
+
var openaiEmbeddingProviderOptions = lazyValidator5(
|
|
1579
|
+
() => zodSchema5(
|
|
1580
|
+
z6.object({
|
|
1581
|
+
/**
|
|
1582
|
+
The number of dimensions the resulting output embeddings should have.
|
|
1583
|
+
Only supported in text-embedding-3 and later models.
|
|
1584
|
+
*/
|
|
1585
|
+
dimensions: z6.number().optional(),
|
|
1586
|
+
/**
|
|
1587
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1588
|
+
monitor and detect abuse. Learn more.
|
|
1589
|
+
*/
|
|
1590
|
+
user: z6.string().optional()
|
|
1591
|
+
})
|
|
1592
|
+
)
|
|
1593
|
+
);
|
|
1594
|
+
|
|
1595
|
+
// src/embedding/openai-embedding-api.ts
|
|
1596
|
+
import { lazyValidator as lazyValidator6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1597
|
+
import * as z7 from "zod/v4";
|
|
1598
|
+
var openaiTextEmbeddingResponseSchema = lazyValidator6(
|
|
1599
|
+
() => zodSchema6(
|
|
1600
|
+
z7.object({
|
|
1601
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1602
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1603
|
+
})
|
|
1604
|
+
)
|
|
1605
|
+
);
|
|
1527
1606
|
|
|
1528
1607
|
// src/embedding/openai-embedding-model.ts
|
|
1529
1608
|
var OpenAIEmbeddingModel = class {
|
|
@@ -1588,10 +1667,6 @@ var OpenAIEmbeddingModel = class {
|
|
|
1588
1667
|
};
|
|
1589
1668
|
}
|
|
1590
1669
|
};
|
|
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
1670
|
|
|
1596
1671
|
// src/image/openai-image-model.ts
|
|
1597
1672
|
import {
|
|
@@ -1599,7 +1674,22 @@ import {
|
|
|
1599
1674
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1600
1675
|
postJsonToApi as postJsonToApi4
|
|
1601
1676
|
} from "@ai-sdk/provider-utils";
|
|
1602
|
-
|
|
1677
|
+
|
|
1678
|
+
// src/image/openai-image-api.ts
|
|
1679
|
+
import { lazyValidator as lazyValidator7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1680
|
+
import * as z8 from "zod/v4";
|
|
1681
|
+
var openaiImageResponseSchema = lazyValidator7(
|
|
1682
|
+
() => zodSchema7(
|
|
1683
|
+
z8.object({
|
|
1684
|
+
data: z8.array(
|
|
1685
|
+
z8.object({
|
|
1686
|
+
b64_json: z8.string(),
|
|
1687
|
+
revised_prompt: z8.string().optional()
|
|
1688
|
+
})
|
|
1689
|
+
)
|
|
1690
|
+
})
|
|
1691
|
+
)
|
|
1692
|
+
);
|
|
1603
1693
|
|
|
1604
1694
|
// src/image/openai-image-options.ts
|
|
1605
1695
|
var modelMaxImagesPerCall = {
|
|
@@ -1691,35 +1781,46 @@ var OpenAIImageModel = class {
|
|
|
1691
1781
|
};
|
|
1692
1782
|
}
|
|
1693
1783
|
};
|
|
1694
|
-
var openaiImageResponseSchema = z8.object({
|
|
1695
|
-
data: z8.array(
|
|
1696
|
-
z8.object({ b64_json: z8.string(), revised_prompt: z8.string().optional() })
|
|
1697
|
-
)
|
|
1698
|
-
});
|
|
1699
1784
|
|
|
1700
1785
|
// 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(),
|
|
1786
|
+
import {
|
|
1787
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
1788
|
+
lazySchema,
|
|
1789
|
+
zodSchema as zodSchema8
|
|
1790
|
+
} from "@ai-sdk/provider-utils";
|
|
1791
|
+
import * as z9 from "zod/v4";
|
|
1792
|
+
var codeInterpreterInputSchema = lazySchema(
|
|
1793
|
+
() => zodSchema8(
|
|
1718
1794
|
z9.object({
|
|
1719
|
-
|
|
1795
|
+
code: z9.string().nullish(),
|
|
1796
|
+
containerId: z9.string()
|
|
1720
1797
|
})
|
|
1721
|
-
|
|
1722
|
-
|
|
1798
|
+
)
|
|
1799
|
+
);
|
|
1800
|
+
var codeInterpreterOutputSchema = lazySchema(
|
|
1801
|
+
() => zodSchema8(
|
|
1802
|
+
z9.object({
|
|
1803
|
+
outputs: z9.array(
|
|
1804
|
+
z9.discriminatedUnion("type", [
|
|
1805
|
+
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1806
|
+
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1807
|
+
])
|
|
1808
|
+
).nullish()
|
|
1809
|
+
})
|
|
1810
|
+
)
|
|
1811
|
+
);
|
|
1812
|
+
var codeInterpreterArgsSchema = lazySchema(
|
|
1813
|
+
() => zodSchema8(
|
|
1814
|
+
z9.object({
|
|
1815
|
+
container: z9.union([
|
|
1816
|
+
z9.string(),
|
|
1817
|
+
z9.object({
|
|
1818
|
+
fileIds: z9.array(z9.string()).optional()
|
|
1819
|
+
})
|
|
1820
|
+
]).optional()
|
|
1821
|
+
})
|
|
1822
|
+
)
|
|
1823
|
+
);
|
|
1723
1824
|
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
1724
1825
|
id: "openai.code_interpreter",
|
|
1725
1826
|
name: "code_interpreter",
|
|
@@ -1731,8 +1832,12 @@ var codeInterpreter = (args = {}) => {
|
|
|
1731
1832
|
};
|
|
1732
1833
|
|
|
1733
1834
|
// src/tool/file-search.ts
|
|
1734
|
-
import {
|
|
1735
|
-
|
|
1835
|
+
import {
|
|
1836
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
1837
|
+
lazySchema as lazySchema2,
|
|
1838
|
+
zodSchema as zodSchema9
|
|
1839
|
+
} from "@ai-sdk/provider-utils";
|
|
1840
|
+
import * as z10 from "zod/v4";
|
|
1736
1841
|
var comparisonFilterSchema = z10.object({
|
|
1737
1842
|
key: z10.string(),
|
|
1738
1843
|
type: z10.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
@@ -1744,27 +1849,35 @@ var compoundFilterSchema = z10.object({
|
|
|
1744
1849
|
z10.union([comparisonFilterSchema, z10.lazy(() => compoundFilterSchema)])
|
|
1745
1850
|
)
|
|
1746
1851
|
});
|
|
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(
|
|
1852
|
+
var fileSearchArgsSchema = lazySchema2(
|
|
1853
|
+
() => zodSchema9(
|
|
1759
1854
|
z10.object({
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1855
|
+
vectorStoreIds: z10.array(z10.string()),
|
|
1856
|
+
maxNumResults: z10.number().optional(),
|
|
1857
|
+
ranking: z10.object({
|
|
1858
|
+
ranker: z10.string().optional(),
|
|
1859
|
+
scoreThreshold: z10.number().optional()
|
|
1860
|
+
}).optional(),
|
|
1861
|
+
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1765
1862
|
})
|
|
1766
|
-
)
|
|
1767
|
-
|
|
1863
|
+
)
|
|
1864
|
+
);
|
|
1865
|
+
var fileSearchOutputSchema = lazySchema2(
|
|
1866
|
+
() => zodSchema9(
|
|
1867
|
+
z10.object({
|
|
1868
|
+
queries: z10.array(z10.string()),
|
|
1869
|
+
results: z10.array(
|
|
1870
|
+
z10.object({
|
|
1871
|
+
attributes: z10.record(z10.string(), z10.unknown()),
|
|
1872
|
+
fileId: z10.string(),
|
|
1873
|
+
filename: z10.string(),
|
|
1874
|
+
score: z10.number(),
|
|
1875
|
+
text: z10.string()
|
|
1876
|
+
})
|
|
1877
|
+
).nullable()
|
|
1878
|
+
})
|
|
1879
|
+
)
|
|
1880
|
+
);
|
|
1768
1881
|
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
1769
1882
|
id: "openai.file_search",
|
|
1770
1883
|
name: "file_search",
|
|
@@ -1773,30 +1886,39 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
|
1773
1886
|
});
|
|
1774
1887
|
|
|
1775
1888
|
// 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
|
-
|
|
1889
|
+
import {
|
|
1890
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
|
|
1891
|
+
lazySchema as lazySchema3,
|
|
1892
|
+
zodSchema as zodSchema10
|
|
1893
|
+
} from "@ai-sdk/provider-utils";
|
|
1894
|
+
import * as z11 from "zod/v4";
|
|
1895
|
+
var imageGenerationArgsSchema = lazySchema3(
|
|
1896
|
+
() => zodSchema10(
|
|
1897
|
+
z11.object({
|
|
1898
|
+
background: z11.enum(["auto", "opaque", "transparent"]).optional(),
|
|
1899
|
+
inputFidelity: z11.enum(["low", "high"]).optional(),
|
|
1900
|
+
inputImageMask: z11.object({
|
|
1901
|
+
fileId: z11.string().optional(),
|
|
1902
|
+
imageUrl: z11.string().optional()
|
|
1903
|
+
}).optional(),
|
|
1904
|
+
model: z11.string().optional(),
|
|
1905
|
+
moderation: z11.enum(["auto"]).optional(),
|
|
1906
|
+
outputCompression: z11.number().int().min(0).max(100).optional(),
|
|
1907
|
+
outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
|
|
1908
|
+
partialImages: z11.number().int().min(0).max(3).optional(),
|
|
1909
|
+
quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1910
|
+
size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1911
|
+
}).strict()
|
|
1912
|
+
)
|
|
1913
|
+
);
|
|
1914
|
+
var imageGenerationInputSchema = lazySchema3(() => zodSchema10(z11.object({})));
|
|
1915
|
+
var imageGenerationOutputSchema = lazySchema3(
|
|
1916
|
+
() => zodSchema10(z11.object({ result: z11.string() }))
|
|
1917
|
+
);
|
|
1796
1918
|
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
1797
1919
|
id: "openai.image_generation",
|
|
1798
1920
|
name: "image_generation",
|
|
1799
|
-
inputSchema:
|
|
1921
|
+
inputSchema: imageGenerationInputSchema,
|
|
1800
1922
|
outputSchema: imageGenerationOutputSchema
|
|
1801
1923
|
});
|
|
1802
1924
|
var imageGeneration = (args = {}) => {
|
|
@@ -1804,21 +1926,29 @@ var imageGeneration = (args = {}) => {
|
|
|
1804
1926
|
};
|
|
1805
1927
|
|
|
1806
1928
|
// src/tool/local-shell.ts
|
|
1807
|
-
import {
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1929
|
+
import {
|
|
1930
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
1931
|
+
lazySchema as lazySchema4,
|
|
1932
|
+
zodSchema as zodSchema11
|
|
1933
|
+
} from "@ai-sdk/provider-utils";
|
|
1934
|
+
import * as z12 from "zod/v4";
|
|
1935
|
+
var localShellInputSchema = lazySchema4(
|
|
1936
|
+
() => zodSchema11(
|
|
1937
|
+
z12.object({
|
|
1938
|
+
action: z12.object({
|
|
1939
|
+
type: z12.literal("exec"),
|
|
1940
|
+
command: z12.array(z12.string()),
|
|
1941
|
+
timeoutMs: z12.number().optional(),
|
|
1942
|
+
user: z12.string().optional(),
|
|
1943
|
+
workingDirectory: z12.string().optional(),
|
|
1944
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
1945
|
+
})
|
|
1946
|
+
})
|
|
1947
|
+
)
|
|
1948
|
+
);
|
|
1949
|
+
var localShellOutputSchema = lazySchema4(
|
|
1950
|
+
() => zodSchema11(z12.object({ output: z12.string() }))
|
|
1951
|
+
);
|
|
1822
1952
|
var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1823
1953
|
id: "openai.local_shell",
|
|
1824
1954
|
name: "local_shell",
|
|
@@ -1827,103 +1957,129 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
1827
1957
|
});
|
|
1828
1958
|
|
|
1829
1959
|
// src/tool/web-search.ts
|
|
1830
|
-
import {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1960
|
+
import {
|
|
1961
|
+
createProviderDefinedToolFactory,
|
|
1962
|
+
lazySchema as lazySchema5,
|
|
1963
|
+
zodSchema as zodSchema12
|
|
1964
|
+
} from "@ai-sdk/provider-utils";
|
|
1965
|
+
import * as z13 from "zod/v4";
|
|
1966
|
+
var webSearchArgsSchema = lazySchema5(
|
|
1967
|
+
() => zodSchema12(
|
|
1968
|
+
z13.object({
|
|
1969
|
+
filters: z13.object({
|
|
1970
|
+
allowedDomains: z13.array(z13.string()).optional()
|
|
1971
|
+
}).optional(),
|
|
1972
|
+
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1973
|
+
userLocation: z13.object({
|
|
1974
|
+
type: z13.literal("approximate"),
|
|
1975
|
+
country: z13.string().optional(),
|
|
1976
|
+
city: z13.string().optional(),
|
|
1977
|
+
region: z13.string().optional(),
|
|
1978
|
+
timezone: z13.string().optional()
|
|
1979
|
+
}).optional()
|
|
1980
|
+
})
|
|
1981
|
+
)
|
|
1982
|
+
);
|
|
1983
|
+
var webSearchInputSchema = lazySchema5(
|
|
1984
|
+
() => zodSchema12(
|
|
1985
|
+
z13.object({
|
|
1986
|
+
action: z13.discriminatedUnion("type", [
|
|
1987
|
+
z13.object({
|
|
1988
|
+
type: z13.literal("search"),
|
|
1989
|
+
query: z13.string().nullish()
|
|
1990
|
+
}),
|
|
1991
|
+
z13.object({
|
|
1992
|
+
type: z13.literal("open_page"),
|
|
1993
|
+
url: z13.string()
|
|
1994
|
+
}),
|
|
1995
|
+
z13.object({
|
|
1996
|
+
type: z13.literal("find"),
|
|
1997
|
+
url: z13.string(),
|
|
1998
|
+
pattern: z13.string()
|
|
1999
|
+
})
|
|
2000
|
+
]).nullish()
|
|
2001
|
+
})
|
|
2002
|
+
)
|
|
2003
|
+
);
|
|
1845
2004
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
1846
2005
|
id: "openai.web_search",
|
|
1847
2006
|
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
|
-
})
|
|
2007
|
+
inputSchema: webSearchInputSchema
|
|
1865
2008
|
});
|
|
1866
2009
|
var webSearch = (args = {}) => {
|
|
1867
2010
|
return webSearchToolFactory(args);
|
|
1868
2011
|
};
|
|
1869
2012
|
|
|
1870
2013
|
// 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
|
-
|
|
2014
|
+
import {
|
|
2015
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2016
|
+
lazySchema as lazySchema6,
|
|
2017
|
+
zodSchema as zodSchema13
|
|
2018
|
+
} from "@ai-sdk/provider-utils";
|
|
2019
|
+
import * as z14 from "zod/v4";
|
|
2020
|
+
var webSearchPreviewArgsSchema = lazySchema6(
|
|
2021
|
+
() => zodSchema13(
|
|
2022
|
+
z14.object({
|
|
2023
|
+
/**
|
|
2024
|
+
* Search context size to use for the web search.
|
|
2025
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
2026
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
2027
|
+
* - low: Least context, lowest cost, fastest response
|
|
2028
|
+
*/
|
|
2029
|
+
searchContextSize: z14.enum(["low", "medium", "high"]).optional(),
|
|
2030
|
+
/**
|
|
2031
|
+
* User location information to provide geographically relevant search results.
|
|
2032
|
+
*/
|
|
2033
|
+
userLocation: z14.object({
|
|
2034
|
+
/**
|
|
2035
|
+
* Type of location (always 'approximate')
|
|
2036
|
+
*/
|
|
2037
|
+
type: z14.literal("approximate"),
|
|
2038
|
+
/**
|
|
2039
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2040
|
+
*/
|
|
2041
|
+
country: z14.string().optional(),
|
|
2042
|
+
/**
|
|
2043
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
2044
|
+
*/
|
|
2045
|
+
city: z14.string().optional(),
|
|
2046
|
+
/**
|
|
2047
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
2048
|
+
*/
|
|
2049
|
+
region: z14.string().optional(),
|
|
2050
|
+
/**
|
|
2051
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
2052
|
+
*/
|
|
2053
|
+
timezone: z14.string().optional()
|
|
2054
|
+
}).optional()
|
|
2055
|
+
})
|
|
2056
|
+
)
|
|
2057
|
+
);
|
|
2058
|
+
var webSearchPreviewInputSchema = lazySchema6(
|
|
2059
|
+
() => zodSchema13(
|
|
2060
|
+
z14.object({
|
|
2061
|
+
action: z14.discriminatedUnion("type", [
|
|
2062
|
+
z14.object({
|
|
2063
|
+
type: z14.literal("search"),
|
|
2064
|
+
query: z14.string().nullish()
|
|
2065
|
+
}),
|
|
2066
|
+
z14.object({
|
|
2067
|
+
type: z14.literal("open_page"),
|
|
2068
|
+
url: z14.string()
|
|
2069
|
+
}),
|
|
2070
|
+
z14.object({
|
|
2071
|
+
type: z14.literal("find"),
|
|
2072
|
+
url: z14.string(),
|
|
2073
|
+
pattern: z14.string()
|
|
2074
|
+
})
|
|
2075
|
+
]).nullish()
|
|
2076
|
+
})
|
|
2077
|
+
)
|
|
2078
|
+
);
|
|
1907
2079
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
1908
2080
|
id: "openai.web_search_preview",
|
|
1909
2081
|
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
|
-
})
|
|
2082
|
+
inputSchema: webSearchPreviewInputSchema
|
|
1927
2083
|
});
|
|
1928
2084
|
|
|
1929
2085
|
// src/openai-tools.ts
|
|
@@ -2016,14 +2172,17 @@ import {
|
|
|
2016
2172
|
parseProviderOptions as parseProviderOptions5,
|
|
2017
2173
|
postJsonToApi as postJsonToApi5
|
|
2018
2174
|
} from "@ai-sdk/provider-utils";
|
|
2019
|
-
import { z as z16 } from "zod/v4";
|
|
2020
2175
|
|
|
2021
2176
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2022
2177
|
import {
|
|
2023
2178
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2024
2179
|
} from "@ai-sdk/provider";
|
|
2025
|
-
import {
|
|
2026
|
-
|
|
2180
|
+
import {
|
|
2181
|
+
convertToBase64 as convertToBase642,
|
|
2182
|
+
parseProviderOptions as parseProviderOptions4,
|
|
2183
|
+
validateTypes
|
|
2184
|
+
} from "@ai-sdk/provider-utils";
|
|
2185
|
+
import * as z15 from "zod/v4";
|
|
2027
2186
|
function isFileId(data, prefixes) {
|
|
2028
2187
|
if (!prefixes) return false;
|
|
2029
2188
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2129,7 +2288,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2129
2288
|
break;
|
|
2130
2289
|
}
|
|
2131
2290
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2132
|
-
const parsedInput =
|
|
2291
|
+
const parsedInput = await validateTypes({
|
|
2292
|
+
value: part.input,
|
|
2293
|
+
schema: localShellInputSchema
|
|
2294
|
+
});
|
|
2133
2295
|
input.push({
|
|
2134
2296
|
type: "local_shell_call",
|
|
2135
2297
|
call_id: part.toolCallId,
|
|
@@ -2225,10 +2387,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2225
2387
|
for (const part of content) {
|
|
2226
2388
|
const output = part.output;
|
|
2227
2389
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2390
|
+
const parsedOutput = await validateTypes({
|
|
2391
|
+
value: output.value,
|
|
2392
|
+
schema: localShellOutputSchema
|
|
2393
|
+
});
|
|
2228
2394
|
input.push({
|
|
2229
2395
|
type: "local_shell_call_output",
|
|
2230
2396
|
call_id: part.toolCallId,
|
|
2231
|
-
output:
|
|
2397
|
+
output: parsedOutput.output
|
|
2232
2398
|
});
|
|
2233
2399
|
break;
|
|
2234
2400
|
}
|
|
@@ -2286,11 +2452,547 @@ function mapOpenAIResponseFinishReason({
|
|
|
2286
2452
|
}
|
|
2287
2453
|
}
|
|
2288
2454
|
|
|
2455
|
+
// src/responses/openai-responses-api.ts
|
|
2456
|
+
import {
|
|
2457
|
+
lazyValidator as lazyValidator8,
|
|
2458
|
+
zodSchema as zodSchema14
|
|
2459
|
+
} from "@ai-sdk/provider-utils";
|
|
2460
|
+
import * as z16 from "zod/v4";
|
|
2461
|
+
var openaiResponsesChunkSchema = lazyValidator8(
|
|
2462
|
+
() => zodSchema14(
|
|
2463
|
+
z16.union([
|
|
2464
|
+
z16.object({
|
|
2465
|
+
type: z16.literal("response.output_text.delta"),
|
|
2466
|
+
item_id: z16.string(),
|
|
2467
|
+
delta: z16.string(),
|
|
2468
|
+
logprobs: z16.array(
|
|
2469
|
+
z16.object({
|
|
2470
|
+
token: z16.string(),
|
|
2471
|
+
logprob: z16.number(),
|
|
2472
|
+
top_logprobs: z16.array(
|
|
2473
|
+
z16.object({
|
|
2474
|
+
token: z16.string(),
|
|
2475
|
+
logprob: z16.number()
|
|
2476
|
+
})
|
|
2477
|
+
)
|
|
2478
|
+
})
|
|
2479
|
+
).nullish()
|
|
2480
|
+
}),
|
|
2481
|
+
z16.object({
|
|
2482
|
+
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
2483
|
+
response: z16.object({
|
|
2484
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2485
|
+
usage: z16.object({
|
|
2486
|
+
input_tokens: z16.number(),
|
|
2487
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2488
|
+
output_tokens: z16.number(),
|
|
2489
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2490
|
+
}),
|
|
2491
|
+
service_tier: z16.string().nullish()
|
|
2492
|
+
})
|
|
2493
|
+
}),
|
|
2494
|
+
z16.object({
|
|
2495
|
+
type: z16.literal("response.created"),
|
|
2496
|
+
response: z16.object({
|
|
2497
|
+
id: z16.string(),
|
|
2498
|
+
created_at: z16.number(),
|
|
2499
|
+
model: z16.string(),
|
|
2500
|
+
service_tier: z16.string().nullish()
|
|
2501
|
+
})
|
|
2502
|
+
}),
|
|
2503
|
+
z16.object({
|
|
2504
|
+
type: z16.literal("response.output_item.added"),
|
|
2505
|
+
output_index: z16.number(),
|
|
2506
|
+
item: z16.discriminatedUnion("type", [
|
|
2507
|
+
z16.object({
|
|
2508
|
+
type: z16.literal("message"),
|
|
2509
|
+
id: z16.string()
|
|
2510
|
+
}),
|
|
2511
|
+
z16.object({
|
|
2512
|
+
type: z16.literal("reasoning"),
|
|
2513
|
+
id: z16.string(),
|
|
2514
|
+
encrypted_content: z16.string().nullish()
|
|
2515
|
+
}),
|
|
2516
|
+
z16.object({
|
|
2517
|
+
type: z16.literal("function_call"),
|
|
2518
|
+
id: z16.string(),
|
|
2519
|
+
call_id: z16.string(),
|
|
2520
|
+
name: z16.string(),
|
|
2521
|
+
arguments: z16.string()
|
|
2522
|
+
}),
|
|
2523
|
+
z16.object({
|
|
2524
|
+
type: z16.literal("web_search_call"),
|
|
2525
|
+
id: z16.string(),
|
|
2526
|
+
status: z16.string(),
|
|
2527
|
+
action: z16.object({
|
|
2528
|
+
type: z16.literal("search"),
|
|
2529
|
+
query: z16.string().optional()
|
|
2530
|
+
}).nullish()
|
|
2531
|
+
}),
|
|
2532
|
+
z16.object({
|
|
2533
|
+
type: z16.literal("computer_call"),
|
|
2534
|
+
id: z16.string(),
|
|
2535
|
+
status: z16.string()
|
|
2536
|
+
}),
|
|
2537
|
+
z16.object({
|
|
2538
|
+
type: z16.literal("file_search_call"),
|
|
2539
|
+
id: z16.string()
|
|
2540
|
+
}),
|
|
2541
|
+
z16.object({
|
|
2542
|
+
type: z16.literal("image_generation_call"),
|
|
2543
|
+
id: z16.string()
|
|
2544
|
+
}),
|
|
2545
|
+
z16.object({
|
|
2546
|
+
type: z16.literal("code_interpreter_call"),
|
|
2547
|
+
id: z16.string(),
|
|
2548
|
+
container_id: z16.string(),
|
|
2549
|
+
code: z16.string().nullable(),
|
|
2550
|
+
outputs: z16.array(
|
|
2551
|
+
z16.discriminatedUnion("type", [
|
|
2552
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2553
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2554
|
+
])
|
|
2555
|
+
).nullable(),
|
|
2556
|
+
status: z16.string()
|
|
2557
|
+
})
|
|
2558
|
+
])
|
|
2559
|
+
}),
|
|
2560
|
+
z16.object({
|
|
2561
|
+
type: z16.literal("response.output_item.done"),
|
|
2562
|
+
output_index: z16.number(),
|
|
2563
|
+
item: z16.discriminatedUnion("type", [
|
|
2564
|
+
z16.object({
|
|
2565
|
+
type: z16.literal("message"),
|
|
2566
|
+
id: z16.string()
|
|
2567
|
+
}),
|
|
2568
|
+
z16.object({
|
|
2569
|
+
type: z16.literal("reasoning"),
|
|
2570
|
+
id: z16.string(),
|
|
2571
|
+
encrypted_content: z16.string().nullish()
|
|
2572
|
+
}),
|
|
2573
|
+
z16.object({
|
|
2574
|
+
type: z16.literal("function_call"),
|
|
2575
|
+
id: z16.string(),
|
|
2576
|
+
call_id: z16.string(),
|
|
2577
|
+
name: z16.string(),
|
|
2578
|
+
arguments: z16.string(),
|
|
2579
|
+
status: z16.literal("completed")
|
|
2580
|
+
}),
|
|
2581
|
+
z16.object({
|
|
2582
|
+
type: z16.literal("code_interpreter_call"),
|
|
2583
|
+
id: z16.string(),
|
|
2584
|
+
code: z16.string().nullable(),
|
|
2585
|
+
container_id: z16.string(),
|
|
2586
|
+
outputs: z16.array(
|
|
2587
|
+
z16.discriminatedUnion("type", [
|
|
2588
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2589
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2590
|
+
])
|
|
2591
|
+
).nullable()
|
|
2592
|
+
}),
|
|
2593
|
+
z16.object({
|
|
2594
|
+
type: z16.literal("image_generation_call"),
|
|
2595
|
+
id: z16.string(),
|
|
2596
|
+
result: z16.string()
|
|
2597
|
+
}),
|
|
2598
|
+
z16.object({
|
|
2599
|
+
type: z16.literal("web_search_call"),
|
|
2600
|
+
id: z16.string(),
|
|
2601
|
+
status: z16.string(),
|
|
2602
|
+
action: z16.discriminatedUnion("type", [
|
|
2603
|
+
z16.object({
|
|
2604
|
+
type: z16.literal("search"),
|
|
2605
|
+
query: z16.string().nullish()
|
|
2606
|
+
}),
|
|
2607
|
+
z16.object({
|
|
2608
|
+
type: z16.literal("open_page"),
|
|
2609
|
+
url: z16.string()
|
|
2610
|
+
}),
|
|
2611
|
+
z16.object({
|
|
2612
|
+
type: z16.literal("find"),
|
|
2613
|
+
url: z16.string(),
|
|
2614
|
+
pattern: z16.string()
|
|
2615
|
+
})
|
|
2616
|
+
]).nullish()
|
|
2617
|
+
}),
|
|
2618
|
+
z16.object({
|
|
2619
|
+
type: z16.literal("file_search_call"),
|
|
2620
|
+
id: z16.string(),
|
|
2621
|
+
queries: z16.array(z16.string()),
|
|
2622
|
+
results: z16.array(
|
|
2623
|
+
z16.object({
|
|
2624
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2625
|
+
file_id: z16.string(),
|
|
2626
|
+
filename: z16.string(),
|
|
2627
|
+
score: z16.number(),
|
|
2628
|
+
text: z16.string()
|
|
2629
|
+
})
|
|
2630
|
+
).nullish()
|
|
2631
|
+
}),
|
|
2632
|
+
z16.object({
|
|
2633
|
+
type: z16.literal("local_shell_call"),
|
|
2634
|
+
id: z16.string(),
|
|
2635
|
+
call_id: z16.string(),
|
|
2636
|
+
action: z16.object({
|
|
2637
|
+
type: z16.literal("exec"),
|
|
2638
|
+
command: z16.array(z16.string()),
|
|
2639
|
+
timeout_ms: z16.number().optional(),
|
|
2640
|
+
user: z16.string().optional(),
|
|
2641
|
+
working_directory: z16.string().optional(),
|
|
2642
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2643
|
+
})
|
|
2644
|
+
}),
|
|
2645
|
+
z16.object({
|
|
2646
|
+
type: z16.literal("computer_call"),
|
|
2647
|
+
id: z16.string(),
|
|
2648
|
+
status: z16.literal("completed")
|
|
2649
|
+
})
|
|
2650
|
+
])
|
|
2651
|
+
}),
|
|
2652
|
+
z16.object({
|
|
2653
|
+
type: z16.literal("response.function_call_arguments.delta"),
|
|
2654
|
+
item_id: z16.string(),
|
|
2655
|
+
output_index: z16.number(),
|
|
2656
|
+
delta: z16.string()
|
|
2657
|
+
}),
|
|
2658
|
+
z16.object({
|
|
2659
|
+
type: z16.literal("response.image_generation_call.partial_image"),
|
|
2660
|
+
item_id: z16.string(),
|
|
2661
|
+
output_index: z16.number(),
|
|
2662
|
+
partial_image_b64: z16.string()
|
|
2663
|
+
}),
|
|
2664
|
+
z16.object({
|
|
2665
|
+
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
2666
|
+
item_id: z16.string(),
|
|
2667
|
+
output_index: z16.number(),
|
|
2668
|
+
delta: z16.string()
|
|
2669
|
+
}),
|
|
2670
|
+
z16.object({
|
|
2671
|
+
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
2672
|
+
item_id: z16.string(),
|
|
2673
|
+
output_index: z16.number(),
|
|
2674
|
+
code: z16.string()
|
|
2675
|
+
}),
|
|
2676
|
+
z16.object({
|
|
2677
|
+
type: z16.literal("response.output_text.annotation.added"),
|
|
2678
|
+
annotation: z16.discriminatedUnion("type", [
|
|
2679
|
+
z16.object({
|
|
2680
|
+
type: z16.literal("url_citation"),
|
|
2681
|
+
url: z16.string(),
|
|
2682
|
+
title: z16.string()
|
|
2683
|
+
}),
|
|
2684
|
+
z16.object({
|
|
2685
|
+
type: z16.literal("file_citation"),
|
|
2686
|
+
file_id: z16.string(),
|
|
2687
|
+
filename: z16.string().nullish(),
|
|
2688
|
+
index: z16.number().nullish(),
|
|
2689
|
+
start_index: z16.number().nullish(),
|
|
2690
|
+
end_index: z16.number().nullish(),
|
|
2691
|
+
quote: z16.string().nullish()
|
|
2692
|
+
})
|
|
2693
|
+
])
|
|
2694
|
+
}),
|
|
2695
|
+
z16.object({
|
|
2696
|
+
type: z16.literal("response.reasoning_summary_part.added"),
|
|
2697
|
+
item_id: z16.string(),
|
|
2698
|
+
summary_index: z16.number()
|
|
2699
|
+
}),
|
|
2700
|
+
z16.object({
|
|
2701
|
+
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
2702
|
+
item_id: z16.string(),
|
|
2703
|
+
summary_index: z16.number(),
|
|
2704
|
+
delta: z16.string()
|
|
2705
|
+
}),
|
|
2706
|
+
z16.object({
|
|
2707
|
+
type: z16.literal("error"),
|
|
2708
|
+
code: z16.string(),
|
|
2709
|
+
message: z16.string(),
|
|
2710
|
+
param: z16.string().nullish(),
|
|
2711
|
+
sequence_number: z16.number()
|
|
2712
|
+
}),
|
|
2713
|
+
z16.object({ type: z16.string() }).loose().transform((value) => ({
|
|
2714
|
+
type: "unknown_chunk",
|
|
2715
|
+
message: value.type
|
|
2716
|
+
}))
|
|
2717
|
+
// fallback for unknown chunks
|
|
2718
|
+
])
|
|
2719
|
+
)
|
|
2720
|
+
);
|
|
2721
|
+
var openaiResponsesResponseSchema = lazyValidator8(
|
|
2722
|
+
() => zodSchema14(
|
|
2723
|
+
z16.object({
|
|
2724
|
+
id: z16.string(),
|
|
2725
|
+
created_at: z16.number(),
|
|
2726
|
+
error: z16.object({
|
|
2727
|
+
code: z16.string(),
|
|
2728
|
+
message: z16.string()
|
|
2729
|
+
}).nullish(),
|
|
2730
|
+
model: z16.string(),
|
|
2731
|
+
output: z16.array(
|
|
2732
|
+
z16.discriminatedUnion("type", [
|
|
2733
|
+
z16.object({
|
|
2734
|
+
type: z16.literal("message"),
|
|
2735
|
+
role: z16.literal("assistant"),
|
|
2736
|
+
id: z16.string(),
|
|
2737
|
+
content: z16.array(
|
|
2738
|
+
z16.object({
|
|
2739
|
+
type: z16.literal("output_text"),
|
|
2740
|
+
text: z16.string(),
|
|
2741
|
+
logprobs: z16.array(
|
|
2742
|
+
z16.object({
|
|
2743
|
+
token: z16.string(),
|
|
2744
|
+
logprob: z16.number(),
|
|
2745
|
+
top_logprobs: z16.array(
|
|
2746
|
+
z16.object({
|
|
2747
|
+
token: z16.string(),
|
|
2748
|
+
logprob: z16.number()
|
|
2749
|
+
})
|
|
2750
|
+
)
|
|
2751
|
+
})
|
|
2752
|
+
).nullish(),
|
|
2753
|
+
annotations: z16.array(
|
|
2754
|
+
z16.discriminatedUnion("type", [
|
|
2755
|
+
z16.object({
|
|
2756
|
+
type: z16.literal("url_citation"),
|
|
2757
|
+
start_index: z16.number(),
|
|
2758
|
+
end_index: z16.number(),
|
|
2759
|
+
url: z16.string(),
|
|
2760
|
+
title: z16.string()
|
|
2761
|
+
}),
|
|
2762
|
+
z16.object({
|
|
2763
|
+
type: z16.literal("file_citation"),
|
|
2764
|
+
file_id: z16.string(),
|
|
2765
|
+
filename: z16.string().nullish(),
|
|
2766
|
+
index: z16.number().nullish(),
|
|
2767
|
+
start_index: z16.number().nullish(),
|
|
2768
|
+
end_index: z16.number().nullish(),
|
|
2769
|
+
quote: z16.string().nullish()
|
|
2770
|
+
}),
|
|
2771
|
+
z16.object({
|
|
2772
|
+
type: z16.literal("container_file_citation")
|
|
2773
|
+
})
|
|
2774
|
+
])
|
|
2775
|
+
)
|
|
2776
|
+
})
|
|
2777
|
+
)
|
|
2778
|
+
}),
|
|
2779
|
+
z16.object({
|
|
2780
|
+
type: z16.literal("web_search_call"),
|
|
2781
|
+
id: z16.string(),
|
|
2782
|
+
status: z16.string(),
|
|
2783
|
+
action: z16.discriminatedUnion("type", [
|
|
2784
|
+
z16.object({
|
|
2785
|
+
type: z16.literal("search"),
|
|
2786
|
+
query: z16.string().nullish()
|
|
2787
|
+
}),
|
|
2788
|
+
z16.object({
|
|
2789
|
+
type: z16.literal("open_page"),
|
|
2790
|
+
url: z16.string()
|
|
2791
|
+
}),
|
|
2792
|
+
z16.object({
|
|
2793
|
+
type: z16.literal("find"),
|
|
2794
|
+
url: z16.string(),
|
|
2795
|
+
pattern: z16.string()
|
|
2796
|
+
})
|
|
2797
|
+
]).nullish()
|
|
2798
|
+
}),
|
|
2799
|
+
z16.object({
|
|
2800
|
+
type: z16.literal("file_search_call"),
|
|
2801
|
+
id: z16.string(),
|
|
2802
|
+
queries: z16.array(z16.string()),
|
|
2803
|
+
results: z16.array(
|
|
2804
|
+
z16.object({
|
|
2805
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2806
|
+
file_id: z16.string(),
|
|
2807
|
+
filename: z16.string(),
|
|
2808
|
+
score: z16.number(),
|
|
2809
|
+
text: z16.string()
|
|
2810
|
+
})
|
|
2811
|
+
).nullish()
|
|
2812
|
+
}),
|
|
2813
|
+
z16.object({
|
|
2814
|
+
type: z16.literal("code_interpreter_call"),
|
|
2815
|
+
id: z16.string(),
|
|
2816
|
+
code: z16.string().nullable(),
|
|
2817
|
+
container_id: z16.string(),
|
|
2818
|
+
outputs: z16.array(
|
|
2819
|
+
z16.discriminatedUnion("type", [
|
|
2820
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2821
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2822
|
+
])
|
|
2823
|
+
).nullable()
|
|
2824
|
+
}),
|
|
2825
|
+
z16.object({
|
|
2826
|
+
type: z16.literal("image_generation_call"),
|
|
2827
|
+
id: z16.string(),
|
|
2828
|
+
result: z16.string()
|
|
2829
|
+
}),
|
|
2830
|
+
z16.object({
|
|
2831
|
+
type: z16.literal("local_shell_call"),
|
|
2832
|
+
id: z16.string(),
|
|
2833
|
+
call_id: z16.string(),
|
|
2834
|
+
action: z16.object({
|
|
2835
|
+
type: z16.literal("exec"),
|
|
2836
|
+
command: z16.array(z16.string()),
|
|
2837
|
+
timeout_ms: z16.number().optional(),
|
|
2838
|
+
user: z16.string().optional(),
|
|
2839
|
+
working_directory: z16.string().optional(),
|
|
2840
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2841
|
+
})
|
|
2842
|
+
}),
|
|
2843
|
+
z16.object({
|
|
2844
|
+
type: z16.literal("function_call"),
|
|
2845
|
+
call_id: z16.string(),
|
|
2846
|
+
name: z16.string(),
|
|
2847
|
+
arguments: z16.string(),
|
|
2848
|
+
id: z16.string()
|
|
2849
|
+
}),
|
|
2850
|
+
z16.object({
|
|
2851
|
+
type: z16.literal("computer_call"),
|
|
2852
|
+
id: z16.string(),
|
|
2853
|
+
status: z16.string().optional()
|
|
2854
|
+
}),
|
|
2855
|
+
z16.object({
|
|
2856
|
+
type: z16.literal("reasoning"),
|
|
2857
|
+
id: z16.string(),
|
|
2858
|
+
encrypted_content: z16.string().nullish(),
|
|
2859
|
+
summary: z16.array(
|
|
2860
|
+
z16.object({
|
|
2861
|
+
type: z16.literal("summary_text"),
|
|
2862
|
+
text: z16.string()
|
|
2863
|
+
})
|
|
2864
|
+
)
|
|
2865
|
+
})
|
|
2866
|
+
])
|
|
2867
|
+
),
|
|
2868
|
+
service_tier: z16.string().nullish(),
|
|
2869
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2870
|
+
usage: z16.object({
|
|
2871
|
+
input_tokens: z16.number(),
|
|
2872
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2873
|
+
output_tokens: z16.number(),
|
|
2874
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2875
|
+
})
|
|
2876
|
+
})
|
|
2877
|
+
)
|
|
2878
|
+
);
|
|
2879
|
+
|
|
2880
|
+
// src/responses/openai-responses-options.ts
|
|
2881
|
+
import {
|
|
2882
|
+
lazyValidator as lazyValidator9,
|
|
2883
|
+
zodSchema as zodSchema15
|
|
2884
|
+
} from "@ai-sdk/provider-utils";
|
|
2885
|
+
import * as z17 from "zod/v4";
|
|
2886
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2887
|
+
var openaiResponsesReasoningModelIds = [
|
|
2888
|
+
"o1",
|
|
2889
|
+
"o1-2024-12-17",
|
|
2890
|
+
"o3-mini",
|
|
2891
|
+
"o3-mini-2025-01-31",
|
|
2892
|
+
"o3",
|
|
2893
|
+
"o3-2025-04-16",
|
|
2894
|
+
"o4-mini",
|
|
2895
|
+
"o4-mini-2025-04-16",
|
|
2896
|
+
"codex-mini-latest",
|
|
2897
|
+
"computer-use-preview",
|
|
2898
|
+
"gpt-5",
|
|
2899
|
+
"gpt-5-2025-08-07",
|
|
2900
|
+
"gpt-5-codex",
|
|
2901
|
+
"gpt-5-mini",
|
|
2902
|
+
"gpt-5-mini-2025-08-07",
|
|
2903
|
+
"gpt-5-nano",
|
|
2904
|
+
"gpt-5-nano-2025-08-07",
|
|
2905
|
+
"gpt-5-pro",
|
|
2906
|
+
"gpt-5-pro-2025-10-06"
|
|
2907
|
+
];
|
|
2908
|
+
var openaiResponsesModelIds = [
|
|
2909
|
+
"gpt-4.1",
|
|
2910
|
+
"gpt-4.1-2025-04-14",
|
|
2911
|
+
"gpt-4.1-mini",
|
|
2912
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2913
|
+
"gpt-4.1-nano",
|
|
2914
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2915
|
+
"gpt-4o",
|
|
2916
|
+
"gpt-4o-2024-05-13",
|
|
2917
|
+
"gpt-4o-2024-08-06",
|
|
2918
|
+
"gpt-4o-2024-11-20",
|
|
2919
|
+
"gpt-4o-audio-preview",
|
|
2920
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2921
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2922
|
+
"gpt-4o-search-preview",
|
|
2923
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2924
|
+
"gpt-4o-mini-search-preview",
|
|
2925
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2926
|
+
"gpt-4o-mini",
|
|
2927
|
+
"gpt-4o-mini-2024-07-18",
|
|
2928
|
+
"gpt-4-turbo",
|
|
2929
|
+
"gpt-4-turbo-2024-04-09",
|
|
2930
|
+
"gpt-4-turbo-preview",
|
|
2931
|
+
"gpt-4-0125-preview",
|
|
2932
|
+
"gpt-4-1106-preview",
|
|
2933
|
+
"gpt-4",
|
|
2934
|
+
"gpt-4-0613",
|
|
2935
|
+
"gpt-4.5-preview",
|
|
2936
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2937
|
+
"gpt-3.5-turbo-0125",
|
|
2938
|
+
"gpt-3.5-turbo",
|
|
2939
|
+
"gpt-3.5-turbo-1106",
|
|
2940
|
+
"chatgpt-4o-latest",
|
|
2941
|
+
"gpt-5-chat-latest",
|
|
2942
|
+
...openaiResponsesReasoningModelIds
|
|
2943
|
+
];
|
|
2944
|
+
var openaiResponsesProviderOptionsSchema = lazyValidator9(
|
|
2945
|
+
() => zodSchema15(
|
|
2946
|
+
z17.object({
|
|
2947
|
+
include: z17.array(
|
|
2948
|
+
z17.enum([
|
|
2949
|
+
"reasoning.encrypted_content",
|
|
2950
|
+
"file_search_call.results",
|
|
2951
|
+
"message.output_text.logprobs"
|
|
2952
|
+
])
|
|
2953
|
+
).nullish(),
|
|
2954
|
+
instructions: z17.string().nullish(),
|
|
2955
|
+
/**
|
|
2956
|
+
* Return the log probabilities of the tokens.
|
|
2957
|
+
*
|
|
2958
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2959
|
+
* were generated.
|
|
2960
|
+
*
|
|
2961
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2962
|
+
* tokens that were generated.
|
|
2963
|
+
*
|
|
2964
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2965
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2966
|
+
*/
|
|
2967
|
+
logprobs: z17.union([z17.boolean(), z17.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2968
|
+
/**
|
|
2969
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2970
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2971
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2972
|
+
*/
|
|
2973
|
+
maxToolCalls: z17.number().nullish(),
|
|
2974
|
+
metadata: z17.any().nullish(),
|
|
2975
|
+
parallelToolCalls: z17.boolean().nullish(),
|
|
2976
|
+
previousResponseId: z17.string().nullish(),
|
|
2977
|
+
promptCacheKey: z17.string().nullish(),
|
|
2978
|
+
reasoningEffort: z17.string().nullish(),
|
|
2979
|
+
reasoningSummary: z17.string().nullish(),
|
|
2980
|
+
safetyIdentifier: z17.string().nullish(),
|
|
2981
|
+
serviceTier: z17.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
2982
|
+
store: z17.boolean().nullish(),
|
|
2983
|
+
strictJsonSchema: z17.boolean().nullish(),
|
|
2984
|
+
textVerbosity: z17.enum(["low", "medium", "high"]).nullish(),
|
|
2985
|
+
user: z17.string().nullish()
|
|
2986
|
+
})
|
|
2987
|
+
)
|
|
2988
|
+
);
|
|
2989
|
+
|
|
2289
2990
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2290
2991
|
import {
|
|
2291
2992
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
2292
2993
|
} from "@ai-sdk/provider";
|
|
2293
|
-
|
|
2994
|
+
import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
|
|
2995
|
+
async function prepareResponsesTools({
|
|
2294
2996
|
tools,
|
|
2295
2997
|
toolChoice,
|
|
2296
2998
|
strictJsonSchema
|
|
@@ -2315,7 +3017,10 @@ function prepareResponsesTools({
|
|
|
2315
3017
|
case "provider-defined": {
|
|
2316
3018
|
switch (tool.id) {
|
|
2317
3019
|
case "openai.file_search": {
|
|
2318
|
-
const args =
|
|
3020
|
+
const args = await validateTypes2({
|
|
3021
|
+
value: tool.args,
|
|
3022
|
+
schema: fileSearchArgsSchema
|
|
3023
|
+
});
|
|
2319
3024
|
openaiTools2.push({
|
|
2320
3025
|
type: "file_search",
|
|
2321
3026
|
vector_store_ids: args.vectorStoreIds,
|
|
@@ -2335,7 +3040,10 @@ function prepareResponsesTools({
|
|
|
2335
3040
|
break;
|
|
2336
3041
|
}
|
|
2337
3042
|
case "openai.web_search_preview": {
|
|
2338
|
-
const args =
|
|
3043
|
+
const args = await validateTypes2({
|
|
3044
|
+
value: tool.args,
|
|
3045
|
+
schema: webSearchPreviewArgsSchema
|
|
3046
|
+
});
|
|
2339
3047
|
openaiTools2.push({
|
|
2340
3048
|
type: "web_search_preview",
|
|
2341
3049
|
search_context_size: args.searchContextSize,
|
|
@@ -2344,7 +3052,10 @@ function prepareResponsesTools({
|
|
|
2344
3052
|
break;
|
|
2345
3053
|
}
|
|
2346
3054
|
case "openai.web_search": {
|
|
2347
|
-
const args =
|
|
3055
|
+
const args = await validateTypes2({
|
|
3056
|
+
value: tool.args,
|
|
3057
|
+
schema: webSearchArgsSchema
|
|
3058
|
+
});
|
|
2348
3059
|
openaiTools2.push({
|
|
2349
3060
|
type: "web_search",
|
|
2350
3061
|
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
@@ -2354,7 +3065,10 @@ function prepareResponsesTools({
|
|
|
2354
3065
|
break;
|
|
2355
3066
|
}
|
|
2356
3067
|
case "openai.code_interpreter": {
|
|
2357
|
-
const args =
|
|
3068
|
+
const args = await validateTypes2({
|
|
3069
|
+
value: tool.args,
|
|
3070
|
+
schema: codeInterpreterArgsSchema
|
|
3071
|
+
});
|
|
2358
3072
|
openaiTools2.push({
|
|
2359
3073
|
type: "code_interpreter",
|
|
2360
3074
|
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 +3076,10 @@ function prepareResponsesTools({
|
|
|
2362
3076
|
break;
|
|
2363
3077
|
}
|
|
2364
3078
|
case "openai.image_generation": {
|
|
2365
|
-
const args =
|
|
3079
|
+
const args = await validateTypes2({
|
|
3080
|
+
value: tool.args,
|
|
3081
|
+
schema: imageGenerationArgsSchema
|
|
3082
|
+
});
|
|
2366
3083
|
openaiTools2.push({
|
|
2367
3084
|
type: "image_generation",
|
|
2368
3085
|
background: args.background,
|
|
@@ -2414,83 +3131,6 @@ function prepareResponsesTools({
|
|
|
2414
3131
|
}
|
|
2415
3132
|
|
|
2416
3133
|
// 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
3134
|
var OpenAIResponsesLanguageModel = class {
|
|
2495
3135
|
constructor(modelId, config) {
|
|
2496
3136
|
this.specificationVersion = "v3";
|
|
@@ -2682,7 +3322,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2682
3322
|
tools: openaiTools2,
|
|
2683
3323
|
toolChoice: openaiToolChoice,
|
|
2684
3324
|
toolWarnings
|
|
2685
|
-
} = prepareResponsesTools({
|
|
3325
|
+
} = await prepareResponsesTools({
|
|
2686
3326
|
tools,
|
|
2687
3327
|
toolChoice,
|
|
2688
3328
|
strictJsonSchema
|
|
@@ -2718,85 +3358,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2718
3358
|
body,
|
|
2719
3359
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2720
3360
|
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
|
-
})
|
|
3361
|
+
openaiResponsesResponseSchema
|
|
2800
3362
|
),
|
|
2801
3363
|
abortSignal: options.abortSignal,
|
|
2802
3364
|
fetch: this.config.fetch
|
|
@@ -2859,7 +3421,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2859
3421
|
type: "tool-call",
|
|
2860
3422
|
toolCallId: part.call_id,
|
|
2861
3423
|
toolName: "local_shell",
|
|
2862
|
-
input: JSON.stringify({
|
|
3424
|
+
input: JSON.stringify({
|
|
3425
|
+
action: part.action
|
|
3426
|
+
}),
|
|
2863
3427
|
providerMetadata: {
|
|
2864
3428
|
openai: {
|
|
2865
3429
|
itemId: part.id
|
|
@@ -3490,203 +4054,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3490
4054
|
};
|
|
3491
4055
|
}
|
|
3492
4056
|
};
|
|
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
4057
|
function isTextDeltaChunk(chunk) {
|
|
3691
4058
|
return chunk.type === "response.output_text.delta";
|
|
3692
4059
|
}
|
|
@@ -3766,47 +4133,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
3766
4133
|
isReasoningModel: false
|
|
3767
4134
|
};
|
|
3768
4135
|
}
|
|
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
4136
|
|
|
3811
4137
|
// src/speech/openai-speech-model.ts
|
|
3812
4138
|
import {
|
|
@@ -3815,11 +4141,23 @@ import {
|
|
|
3815
4141
|
parseProviderOptions as parseProviderOptions6,
|
|
3816
4142
|
postJsonToApi as postJsonToApi6
|
|
3817
4143
|
} from "@ai-sdk/provider-utils";
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
4144
|
+
|
|
4145
|
+
// src/speech/openai-speech-options.ts
|
|
4146
|
+
import {
|
|
4147
|
+
lazyValidator as lazyValidator10,
|
|
4148
|
+
zodSchema as zodSchema16
|
|
4149
|
+
} from "@ai-sdk/provider-utils";
|
|
4150
|
+
import * as z18 from "zod/v4";
|
|
4151
|
+
var openaiSpeechProviderOptionsSchema = lazyValidator10(
|
|
4152
|
+
() => zodSchema16(
|
|
4153
|
+
z18.object({
|
|
4154
|
+
instructions: z18.string().nullish(),
|
|
4155
|
+
speed: z18.number().min(0.25).max(4).default(1).nullish()
|
|
4156
|
+
})
|
|
4157
|
+
)
|
|
4158
|
+
);
|
|
4159
|
+
|
|
4160
|
+
// src/speech/openai-speech-model.ts
|
|
3823
4161
|
var OpenAISpeechModel = class {
|
|
3824
4162
|
constructor(modelId, config) {
|
|
3825
4163
|
this.modelId = modelId;
|
|
@@ -3842,7 +4180,7 @@ var OpenAISpeechModel = class {
|
|
|
3842
4180
|
const openAIOptions = await parseProviderOptions6({
|
|
3843
4181
|
provider: "openai",
|
|
3844
4182
|
providerOptions,
|
|
3845
|
-
schema:
|
|
4183
|
+
schema: openaiSpeechProviderOptionsSchema
|
|
3846
4184
|
});
|
|
3847
4185
|
const requestBody = {
|
|
3848
4186
|
model: this.modelId,
|
|
@@ -3929,34 +4267,75 @@ import {
|
|
|
3929
4267
|
parseProviderOptions as parseProviderOptions7,
|
|
3930
4268
|
postFormDataToApi
|
|
3931
4269
|
} from "@ai-sdk/provider-utils";
|
|
3932
|
-
|
|
4270
|
+
|
|
4271
|
+
// src/transcription/openai-transcription-api.ts
|
|
4272
|
+
import { lazyValidator as lazyValidator11, zodSchema as zodSchema17 } from "@ai-sdk/provider-utils";
|
|
4273
|
+
import * as z19 from "zod/v4";
|
|
4274
|
+
var openaiTranscriptionResponseSchema = lazyValidator11(
|
|
4275
|
+
() => zodSchema17(
|
|
4276
|
+
z19.object({
|
|
4277
|
+
text: z19.string(),
|
|
4278
|
+
language: z19.string().nullish(),
|
|
4279
|
+
duration: z19.number().nullish(),
|
|
4280
|
+
words: z19.array(
|
|
4281
|
+
z19.object({
|
|
4282
|
+
word: z19.string(),
|
|
4283
|
+
start: z19.number(),
|
|
4284
|
+
end: z19.number()
|
|
4285
|
+
})
|
|
4286
|
+
).nullish(),
|
|
4287
|
+
segments: z19.array(
|
|
4288
|
+
z19.object({
|
|
4289
|
+
id: z19.number(),
|
|
4290
|
+
seek: z19.number(),
|
|
4291
|
+
start: z19.number(),
|
|
4292
|
+
end: z19.number(),
|
|
4293
|
+
text: z19.string(),
|
|
4294
|
+
tokens: z19.array(z19.number()),
|
|
4295
|
+
temperature: z19.number(),
|
|
4296
|
+
avg_logprob: z19.number(),
|
|
4297
|
+
compression_ratio: z19.number(),
|
|
4298
|
+
no_speech_prob: z19.number()
|
|
4299
|
+
})
|
|
4300
|
+
).nullish()
|
|
4301
|
+
})
|
|
4302
|
+
)
|
|
4303
|
+
);
|
|
3933
4304
|
|
|
3934
4305
|
// 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
|
-
|
|
4306
|
+
import {
|
|
4307
|
+
lazyValidator as lazyValidator12,
|
|
4308
|
+
zodSchema as zodSchema18
|
|
4309
|
+
} from "@ai-sdk/provider-utils";
|
|
4310
|
+
import * as z20 from "zod/v4";
|
|
4311
|
+
var openAITranscriptionProviderOptions = lazyValidator12(
|
|
4312
|
+
() => zodSchema18(
|
|
4313
|
+
z20.object({
|
|
4314
|
+
/**
|
|
4315
|
+
* Additional information to include in the transcription response.
|
|
4316
|
+
*/
|
|
4317
|
+
include: z20.array(z20.string()).optional(),
|
|
4318
|
+
/**
|
|
4319
|
+
* The language of the input audio in ISO-639-1 format.
|
|
4320
|
+
*/
|
|
4321
|
+
language: z20.string().optional(),
|
|
4322
|
+
/**
|
|
4323
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
4324
|
+
*/
|
|
4325
|
+
prompt: z20.string().optional(),
|
|
4326
|
+
/**
|
|
4327
|
+
* The sampling temperature, between 0 and 1.
|
|
4328
|
+
* @default 0
|
|
4329
|
+
*/
|
|
4330
|
+
temperature: z20.number().min(0).max(1).default(0).optional(),
|
|
4331
|
+
/**
|
|
4332
|
+
* The timestamp granularities to populate for this transcription.
|
|
4333
|
+
* @default ['segment']
|
|
4334
|
+
*/
|
|
4335
|
+
timestampGranularities: z20.array(z20.enum(["word", "segment"])).default(["segment"]).optional()
|
|
4336
|
+
})
|
|
4337
|
+
)
|
|
4338
|
+
);
|
|
3960
4339
|
|
|
3961
4340
|
// src/transcription/openai-transcription-model.ts
|
|
3962
4341
|
var languageMap = {
|
|
@@ -4124,35 +4503,9 @@ var OpenAITranscriptionModel = class {
|
|
|
4124
4503
|
};
|
|
4125
4504
|
}
|
|
4126
4505
|
};
|
|
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
4506
|
|
|
4154
4507
|
// src/version.ts
|
|
4155
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4508
|
+
var VERSION = true ? "3.0.0-beta.19" : "0.0.0-test";
|
|
4156
4509
|
|
|
4157
4510
|
// src/openai-provider.ts
|
|
4158
4511
|
function createOpenAI(options = {}) {
|