@ai-sdk/openai 2.0.44 → 2.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +38 -65
- package/dist/index.d.ts +38 -65
- package/dist/index.js +1341 -1025
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1295 -934
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +101 -182
- package/dist/internal/index.d.ts +101 -182
- package/dist/internal/index.js +1338 -1020
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1307 -945
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/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({
|
|
@@ -250,95 +249,246 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
|
|
252
|
+
// src/chat/openai-chat-api.ts
|
|
253
|
+
import {
|
|
254
|
+
lazyValidator,
|
|
255
|
+
zodSchema
|
|
256
|
+
} from "@ai-sdk/provider-utils";
|
|
257
|
+
import * as z2 from "zod/v4";
|
|
258
|
+
var openaiChatResponseSchema = lazyValidator(
|
|
259
|
+
() => zodSchema(
|
|
260
|
+
z2.object({
|
|
261
|
+
id: z2.string().nullish(),
|
|
262
|
+
created: z2.number().nullish(),
|
|
263
|
+
model: z2.string().nullish(),
|
|
264
|
+
choices: z2.array(
|
|
265
|
+
z2.object({
|
|
266
|
+
message: z2.object({
|
|
267
|
+
role: z2.literal("assistant").nullish(),
|
|
268
|
+
content: z2.string().nullish(),
|
|
269
|
+
tool_calls: z2.array(
|
|
270
|
+
z2.object({
|
|
271
|
+
id: z2.string().nullish(),
|
|
272
|
+
type: z2.literal("function"),
|
|
273
|
+
function: z2.object({
|
|
274
|
+
name: z2.string(),
|
|
275
|
+
arguments: z2.string()
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
).nullish(),
|
|
279
|
+
annotations: z2.array(
|
|
280
|
+
z2.object({
|
|
281
|
+
type: z2.literal("url_citation"),
|
|
282
|
+
start_index: z2.number(),
|
|
283
|
+
end_index: z2.number(),
|
|
284
|
+
url: z2.string(),
|
|
285
|
+
title: z2.string()
|
|
286
|
+
})
|
|
287
|
+
).nullish()
|
|
288
|
+
}),
|
|
289
|
+
index: z2.number(),
|
|
290
|
+
logprobs: z2.object({
|
|
291
|
+
content: z2.array(
|
|
292
|
+
z2.object({
|
|
293
|
+
token: z2.string(),
|
|
294
|
+
logprob: z2.number(),
|
|
295
|
+
top_logprobs: z2.array(
|
|
296
|
+
z2.object({
|
|
297
|
+
token: z2.string(),
|
|
298
|
+
logprob: z2.number()
|
|
299
|
+
})
|
|
300
|
+
)
|
|
301
|
+
})
|
|
302
|
+
).nullish()
|
|
303
|
+
}).nullish(),
|
|
304
|
+
finish_reason: z2.string().nullish()
|
|
305
|
+
})
|
|
306
|
+
),
|
|
307
|
+
usage: z2.object({
|
|
308
|
+
prompt_tokens: z2.number().nullish(),
|
|
309
|
+
completion_tokens: z2.number().nullish(),
|
|
310
|
+
total_tokens: z2.number().nullish(),
|
|
311
|
+
prompt_tokens_details: z2.object({
|
|
312
|
+
cached_tokens: z2.number().nullish()
|
|
313
|
+
}).nullish(),
|
|
314
|
+
completion_tokens_details: z2.object({
|
|
315
|
+
reasoning_tokens: z2.number().nullish(),
|
|
316
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
317
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
318
|
+
}).nullish()
|
|
319
|
+
}).nullish()
|
|
320
|
+
})
|
|
321
|
+
)
|
|
322
|
+
);
|
|
323
|
+
var openaiChatChunkSchema = lazyValidator(
|
|
324
|
+
() => zodSchema(
|
|
325
|
+
z2.union([
|
|
326
|
+
z2.object({
|
|
327
|
+
id: z2.string().nullish(),
|
|
328
|
+
created: z2.number().nullish(),
|
|
329
|
+
model: z2.string().nullish(),
|
|
330
|
+
choices: z2.array(
|
|
331
|
+
z2.object({
|
|
332
|
+
delta: z2.object({
|
|
333
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
334
|
+
content: z2.string().nullish(),
|
|
335
|
+
tool_calls: z2.array(
|
|
336
|
+
z2.object({
|
|
337
|
+
index: z2.number(),
|
|
338
|
+
id: z2.string().nullish(),
|
|
339
|
+
type: z2.literal("function").nullish(),
|
|
340
|
+
function: z2.object({
|
|
341
|
+
name: z2.string().nullish(),
|
|
342
|
+
arguments: z2.string().nullish()
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
).nullish(),
|
|
346
|
+
annotations: z2.array(
|
|
347
|
+
z2.object({
|
|
348
|
+
type: z2.literal("url_citation"),
|
|
349
|
+
start_index: z2.number(),
|
|
350
|
+
end_index: z2.number(),
|
|
351
|
+
url: z2.string(),
|
|
352
|
+
title: z2.string()
|
|
353
|
+
})
|
|
354
|
+
).nullish()
|
|
355
|
+
}).nullish(),
|
|
356
|
+
logprobs: z2.object({
|
|
357
|
+
content: z2.array(
|
|
358
|
+
z2.object({
|
|
359
|
+
token: z2.string(),
|
|
360
|
+
logprob: z2.number(),
|
|
361
|
+
top_logprobs: z2.array(
|
|
362
|
+
z2.object({
|
|
363
|
+
token: z2.string(),
|
|
364
|
+
logprob: z2.number()
|
|
365
|
+
})
|
|
366
|
+
)
|
|
367
|
+
})
|
|
368
|
+
).nullish()
|
|
369
|
+
}).nullish(),
|
|
370
|
+
finish_reason: z2.string().nullish(),
|
|
371
|
+
index: z2.number()
|
|
372
|
+
})
|
|
373
|
+
),
|
|
374
|
+
usage: z2.object({
|
|
375
|
+
prompt_tokens: z2.number().nullish(),
|
|
376
|
+
completion_tokens: z2.number().nullish(),
|
|
377
|
+
total_tokens: z2.number().nullish(),
|
|
378
|
+
prompt_tokens_details: z2.object({
|
|
379
|
+
cached_tokens: z2.number().nullish()
|
|
380
|
+
}).nullish(),
|
|
381
|
+
completion_tokens_details: z2.object({
|
|
382
|
+
reasoning_tokens: z2.number().nullish(),
|
|
383
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
384
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
385
|
+
}).nullish()
|
|
386
|
+
}).nullish()
|
|
387
|
+
}),
|
|
388
|
+
openaiErrorDataSchema
|
|
389
|
+
])
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
|
|
253
393
|
// src/chat/openai-chat-options.ts
|
|
254
|
-
import {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
394
|
+
import {
|
|
395
|
+
lazyValidator as lazyValidator2,
|
|
396
|
+
zodSchema as zodSchema2
|
|
397
|
+
} from "@ai-sdk/provider-utils";
|
|
398
|
+
import * as z3 from "zod/v4";
|
|
399
|
+
var openaiChatLanguageModelOptions = lazyValidator2(
|
|
400
|
+
() => zodSchema2(
|
|
401
|
+
z3.object({
|
|
402
|
+
/**
|
|
403
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
404
|
+
*
|
|
405
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
406
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
407
|
+
*/
|
|
408
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
409
|
+
/**
|
|
410
|
+
* Return the log probabilities of the tokens.
|
|
411
|
+
*
|
|
412
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
413
|
+
* were generated.
|
|
414
|
+
*
|
|
415
|
+
* Setting to a number will return the log probabilities of the top n
|
|
416
|
+
* tokens that were generated.
|
|
417
|
+
*/
|
|
418
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
419
|
+
/**
|
|
420
|
+
* Whether to enable parallel function calling during tool use. Default to true.
|
|
421
|
+
*/
|
|
422
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
423
|
+
/**
|
|
424
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
425
|
+
* monitor and detect abuse.
|
|
426
|
+
*/
|
|
427
|
+
user: z3.string().optional(),
|
|
428
|
+
/**
|
|
429
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
430
|
+
*/
|
|
431
|
+
reasoningEffort: z3.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
432
|
+
/**
|
|
433
|
+
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
434
|
+
*/
|
|
435
|
+
maxCompletionTokens: z3.number().optional(),
|
|
436
|
+
/**
|
|
437
|
+
* Whether to enable persistence in responses API.
|
|
438
|
+
*/
|
|
439
|
+
store: z3.boolean().optional(),
|
|
440
|
+
/**
|
|
441
|
+
* Metadata to associate with the request.
|
|
442
|
+
*/
|
|
443
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
444
|
+
/**
|
|
445
|
+
* Parameters for prediction mode.
|
|
446
|
+
*/
|
|
447
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
448
|
+
/**
|
|
449
|
+
* Whether to use structured outputs.
|
|
450
|
+
*
|
|
451
|
+
* @default true
|
|
452
|
+
*/
|
|
453
|
+
structuredOutputs: z3.boolean().optional(),
|
|
454
|
+
/**
|
|
455
|
+
* Service tier for the request.
|
|
456
|
+
* - 'auto': Default service tier. The request will be processed with the service tier configured in the
|
|
457
|
+
* Project settings. Unless otherwise configured, the Project will use 'default'.
|
|
458
|
+
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
459
|
+
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
460
|
+
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
461
|
+
*
|
|
462
|
+
* @default 'auto'
|
|
463
|
+
*/
|
|
464
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
465
|
+
/**
|
|
466
|
+
* Whether to use strict JSON schema validation.
|
|
467
|
+
*
|
|
468
|
+
* @default false
|
|
469
|
+
*/
|
|
470
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
471
|
+
/**
|
|
472
|
+
* Controls the verbosity of the model's responses.
|
|
473
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
474
|
+
*/
|
|
475
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
476
|
+
/**
|
|
477
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
478
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
479
|
+
*/
|
|
480
|
+
promptCacheKey: z3.string().optional(),
|
|
481
|
+
/**
|
|
482
|
+
* A stable identifier used to help detect users of your application
|
|
483
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
484
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
485
|
+
* username or email address, in order to avoid sending us any identifying
|
|
486
|
+
* information.
|
|
487
|
+
*/
|
|
488
|
+
safetyIdentifier: z3.string().optional()
|
|
489
|
+
})
|
|
490
|
+
)
|
|
491
|
+
);
|
|
342
492
|
|
|
343
493
|
// src/chat/openai-chat-prepare-tools.ts
|
|
344
494
|
import {
|
|
@@ -896,121 +1046,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
896
1046
|
};
|
|
897
1047
|
}
|
|
898
1048
|
};
|
|
899
|
-
var openaiTokenUsageSchema = z3.object({
|
|
900
|
-
prompt_tokens: z3.number().nullish(),
|
|
901
|
-
completion_tokens: z3.number().nullish(),
|
|
902
|
-
total_tokens: z3.number().nullish(),
|
|
903
|
-
prompt_tokens_details: z3.object({
|
|
904
|
-
cached_tokens: z3.number().nullish()
|
|
905
|
-
}).nullish(),
|
|
906
|
-
completion_tokens_details: z3.object({
|
|
907
|
-
reasoning_tokens: z3.number().nullish(),
|
|
908
|
-
accepted_prediction_tokens: z3.number().nullish(),
|
|
909
|
-
rejected_prediction_tokens: z3.number().nullish()
|
|
910
|
-
}).nullish()
|
|
911
|
-
}).nullish();
|
|
912
|
-
var openaiChatResponseSchema = z3.object({
|
|
913
|
-
id: z3.string().nullish(),
|
|
914
|
-
created: z3.number().nullish(),
|
|
915
|
-
model: z3.string().nullish(),
|
|
916
|
-
choices: z3.array(
|
|
917
|
-
z3.object({
|
|
918
|
-
message: z3.object({
|
|
919
|
-
role: z3.literal("assistant").nullish(),
|
|
920
|
-
content: z3.string().nullish(),
|
|
921
|
-
tool_calls: z3.array(
|
|
922
|
-
z3.object({
|
|
923
|
-
id: z3.string().nullish(),
|
|
924
|
-
type: z3.literal("function"),
|
|
925
|
-
function: z3.object({
|
|
926
|
-
name: z3.string(),
|
|
927
|
-
arguments: z3.string()
|
|
928
|
-
})
|
|
929
|
-
})
|
|
930
|
-
).nullish(),
|
|
931
|
-
annotations: z3.array(
|
|
932
|
-
z3.object({
|
|
933
|
-
type: z3.literal("url_citation"),
|
|
934
|
-
start_index: z3.number(),
|
|
935
|
-
end_index: z3.number(),
|
|
936
|
-
url: z3.string(),
|
|
937
|
-
title: z3.string()
|
|
938
|
-
})
|
|
939
|
-
).nullish()
|
|
940
|
-
}),
|
|
941
|
-
index: z3.number(),
|
|
942
|
-
logprobs: z3.object({
|
|
943
|
-
content: z3.array(
|
|
944
|
-
z3.object({
|
|
945
|
-
token: z3.string(),
|
|
946
|
-
logprob: z3.number(),
|
|
947
|
-
top_logprobs: z3.array(
|
|
948
|
-
z3.object({
|
|
949
|
-
token: z3.string(),
|
|
950
|
-
logprob: z3.number()
|
|
951
|
-
})
|
|
952
|
-
)
|
|
953
|
-
})
|
|
954
|
-
).nullish()
|
|
955
|
-
}).nullish(),
|
|
956
|
-
finish_reason: z3.string().nullish()
|
|
957
|
-
})
|
|
958
|
-
),
|
|
959
|
-
usage: openaiTokenUsageSchema
|
|
960
|
-
});
|
|
961
|
-
var openaiChatChunkSchema = z3.union([
|
|
962
|
-
z3.object({
|
|
963
|
-
id: z3.string().nullish(),
|
|
964
|
-
created: z3.number().nullish(),
|
|
965
|
-
model: z3.string().nullish(),
|
|
966
|
-
choices: z3.array(
|
|
967
|
-
z3.object({
|
|
968
|
-
delta: z3.object({
|
|
969
|
-
role: z3.enum(["assistant"]).nullish(),
|
|
970
|
-
content: z3.string().nullish(),
|
|
971
|
-
tool_calls: z3.array(
|
|
972
|
-
z3.object({
|
|
973
|
-
index: z3.number(),
|
|
974
|
-
id: z3.string().nullish(),
|
|
975
|
-
type: z3.literal("function").nullish(),
|
|
976
|
-
function: z3.object({
|
|
977
|
-
name: z3.string().nullish(),
|
|
978
|
-
arguments: z3.string().nullish()
|
|
979
|
-
})
|
|
980
|
-
})
|
|
981
|
-
).nullish(),
|
|
982
|
-
annotations: z3.array(
|
|
983
|
-
z3.object({
|
|
984
|
-
type: z3.literal("url_citation"),
|
|
985
|
-
start_index: z3.number(),
|
|
986
|
-
end_index: z3.number(),
|
|
987
|
-
url: z3.string(),
|
|
988
|
-
title: z3.string()
|
|
989
|
-
})
|
|
990
|
-
).nullish()
|
|
991
|
-
}).nullish(),
|
|
992
|
-
logprobs: z3.object({
|
|
993
|
-
content: z3.array(
|
|
994
|
-
z3.object({
|
|
995
|
-
token: z3.string(),
|
|
996
|
-
logprob: z3.number(),
|
|
997
|
-
top_logprobs: z3.array(
|
|
998
|
-
z3.object({
|
|
999
|
-
token: z3.string(),
|
|
1000
|
-
logprob: z3.number()
|
|
1001
|
-
})
|
|
1002
|
-
)
|
|
1003
|
-
})
|
|
1004
|
-
).nullish()
|
|
1005
|
-
}).nullish(),
|
|
1006
|
-
finish_reason: z3.string().nullish(),
|
|
1007
|
-
index: z3.number()
|
|
1008
|
-
})
|
|
1009
|
-
),
|
|
1010
|
-
usage: openaiTokenUsageSchema
|
|
1011
|
-
}),
|
|
1012
|
-
openaiErrorDataSchema
|
|
1013
|
-
]);
|
|
1014
1049
|
function isReasoningModel(modelId) {
|
|
1015
1050
|
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
1016
1051
|
}
|
|
@@ -1068,7 +1103,6 @@ import {
|
|
|
1068
1103
|
parseProviderOptions as parseProviderOptions2,
|
|
1069
1104
|
postJsonToApi as postJsonToApi2
|
|
1070
1105
|
} from "@ai-sdk/provider-utils";
|
|
1071
|
-
import { z as z5 } from "zod/v4";
|
|
1072
1106
|
|
|
1073
1107
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1074
1108
|
import {
|
|
@@ -1178,48 +1212,117 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1178
1212
|
}
|
|
1179
1213
|
}
|
|
1180
1214
|
|
|
1215
|
+
// src/completion/openai-completion-api.ts
|
|
1216
|
+
import * as z4 from "zod/v4";
|
|
1217
|
+
import {
|
|
1218
|
+
lazyValidator as lazyValidator3,
|
|
1219
|
+
zodSchema as zodSchema3
|
|
1220
|
+
} from "@ai-sdk/provider-utils";
|
|
1221
|
+
var openaiCompletionResponseSchema = lazyValidator3(
|
|
1222
|
+
() => zodSchema3(
|
|
1223
|
+
z4.object({
|
|
1224
|
+
id: z4.string().nullish(),
|
|
1225
|
+
created: z4.number().nullish(),
|
|
1226
|
+
model: z4.string().nullish(),
|
|
1227
|
+
choices: z4.array(
|
|
1228
|
+
z4.object({
|
|
1229
|
+
text: z4.string(),
|
|
1230
|
+
finish_reason: z4.string(),
|
|
1231
|
+
logprobs: z4.object({
|
|
1232
|
+
tokens: z4.array(z4.string()),
|
|
1233
|
+
token_logprobs: z4.array(z4.number()),
|
|
1234
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1235
|
+
}).nullish()
|
|
1236
|
+
})
|
|
1237
|
+
),
|
|
1238
|
+
usage: z4.object({
|
|
1239
|
+
prompt_tokens: z4.number(),
|
|
1240
|
+
completion_tokens: z4.number(),
|
|
1241
|
+
total_tokens: z4.number()
|
|
1242
|
+
}).nullish()
|
|
1243
|
+
})
|
|
1244
|
+
)
|
|
1245
|
+
);
|
|
1246
|
+
var openaiCompletionChunkSchema = lazyValidator3(
|
|
1247
|
+
() => zodSchema3(
|
|
1248
|
+
z4.union([
|
|
1249
|
+
z4.object({
|
|
1250
|
+
id: z4.string().nullish(),
|
|
1251
|
+
created: z4.number().nullish(),
|
|
1252
|
+
model: z4.string().nullish(),
|
|
1253
|
+
choices: z4.array(
|
|
1254
|
+
z4.object({
|
|
1255
|
+
text: z4.string(),
|
|
1256
|
+
finish_reason: z4.string().nullish(),
|
|
1257
|
+
index: z4.number(),
|
|
1258
|
+
logprobs: z4.object({
|
|
1259
|
+
tokens: z4.array(z4.string()),
|
|
1260
|
+
token_logprobs: z4.array(z4.number()),
|
|
1261
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1262
|
+
}).nullish()
|
|
1263
|
+
})
|
|
1264
|
+
),
|
|
1265
|
+
usage: z4.object({
|
|
1266
|
+
prompt_tokens: z4.number(),
|
|
1267
|
+
completion_tokens: z4.number(),
|
|
1268
|
+
total_tokens: z4.number()
|
|
1269
|
+
}).nullish()
|
|
1270
|
+
}),
|
|
1271
|
+
openaiErrorDataSchema
|
|
1272
|
+
])
|
|
1273
|
+
)
|
|
1274
|
+
);
|
|
1275
|
+
|
|
1181
1276
|
// src/completion/openai-completion-options.ts
|
|
1182
|
-
import {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
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
|
-
|
|
1277
|
+
import {
|
|
1278
|
+
lazyValidator as lazyValidator4,
|
|
1279
|
+
zodSchema as zodSchema4
|
|
1280
|
+
} from "@ai-sdk/provider-utils";
|
|
1281
|
+
import * as z5 from "zod/v4";
|
|
1282
|
+
var openaiCompletionProviderOptions = lazyValidator4(
|
|
1283
|
+
() => zodSchema4(
|
|
1284
|
+
z5.object({
|
|
1285
|
+
/**
|
|
1286
|
+
Echo back the prompt in addition to the completion.
|
|
1287
|
+
*/
|
|
1288
|
+
echo: z5.boolean().optional(),
|
|
1289
|
+
/**
|
|
1290
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
1291
|
+
|
|
1292
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1293
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1294
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1295
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
1296
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
1297
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
1298
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
1299
|
+
|
|
1300
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1301
|
+
token from being generated.
|
|
1302
|
+
*/
|
|
1303
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1304
|
+
/**
|
|
1305
|
+
The suffix that comes after a completion of inserted text.
|
|
1306
|
+
*/
|
|
1307
|
+
suffix: z5.string().optional(),
|
|
1308
|
+
/**
|
|
1309
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1310
|
+
monitor and detect abuse. Learn more.
|
|
1311
|
+
*/
|
|
1312
|
+
user: z5.string().optional(),
|
|
1313
|
+
/**
|
|
1314
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1315
|
+
the response size and can slow down response times. However, it can
|
|
1316
|
+
be useful to better understand how the model is behaving.
|
|
1317
|
+
Setting to true will return the log probabilities of the tokens that
|
|
1318
|
+
were generated.
|
|
1319
|
+
Setting to a number will return the log probabilities of the top n
|
|
1320
|
+
tokens that were generated.
|
|
1321
|
+
*/
|
|
1322
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1323
|
+
})
|
|
1324
|
+
)
|
|
1325
|
+
);
|
|
1223
1326
|
|
|
1224
1327
|
// src/completion/openai-completion-language-model.ts
|
|
1225
1328
|
var OpenAICompletionLanguageModel = class {
|
|
@@ -1450,49 +1553,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1450
1553
|
};
|
|
1451
1554
|
}
|
|
1452
1555
|
};
|
|
1453
|
-
var usageSchema = z5.object({
|
|
1454
|
-
prompt_tokens: z5.number(),
|
|
1455
|
-
completion_tokens: z5.number(),
|
|
1456
|
-
total_tokens: z5.number()
|
|
1457
|
-
});
|
|
1458
|
-
var openaiCompletionResponseSchema = z5.object({
|
|
1459
|
-
id: z5.string().nullish(),
|
|
1460
|
-
created: z5.number().nullish(),
|
|
1461
|
-
model: z5.string().nullish(),
|
|
1462
|
-
choices: z5.array(
|
|
1463
|
-
z5.object({
|
|
1464
|
-
text: z5.string(),
|
|
1465
|
-
finish_reason: z5.string(),
|
|
1466
|
-
logprobs: z5.object({
|
|
1467
|
-
tokens: z5.array(z5.string()),
|
|
1468
|
-
token_logprobs: z5.array(z5.number()),
|
|
1469
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1470
|
-
}).nullish()
|
|
1471
|
-
})
|
|
1472
|
-
),
|
|
1473
|
-
usage: usageSchema.nullish()
|
|
1474
|
-
});
|
|
1475
|
-
var openaiCompletionChunkSchema = z5.union([
|
|
1476
|
-
z5.object({
|
|
1477
|
-
id: z5.string().nullish(),
|
|
1478
|
-
created: z5.number().nullish(),
|
|
1479
|
-
model: z5.string().nullish(),
|
|
1480
|
-
choices: z5.array(
|
|
1481
|
-
z5.object({
|
|
1482
|
-
text: z5.string(),
|
|
1483
|
-
finish_reason: z5.string().nullish(),
|
|
1484
|
-
index: z5.number(),
|
|
1485
|
-
logprobs: z5.object({
|
|
1486
|
-
tokens: z5.array(z5.string()),
|
|
1487
|
-
token_logprobs: z5.array(z5.number()),
|
|
1488
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1489
|
-
}).nullish()
|
|
1490
|
-
})
|
|
1491
|
-
),
|
|
1492
|
-
usage: usageSchema.nullish()
|
|
1493
|
-
}),
|
|
1494
|
-
openaiErrorDataSchema
|
|
1495
|
-
]);
|
|
1496
1556
|
|
|
1497
1557
|
// src/embedding/openai-embedding-model.ts
|
|
1498
1558
|
import {
|
|
@@ -1504,22 +1564,41 @@ import {
|
|
|
1504
1564
|
parseProviderOptions as parseProviderOptions3,
|
|
1505
1565
|
postJsonToApi as postJsonToApi3
|
|
1506
1566
|
} from "@ai-sdk/provider-utils";
|
|
1507
|
-
import { z as z7 } from "zod/v4";
|
|
1508
1567
|
|
|
1509
1568
|
// src/embedding/openai-embedding-options.ts
|
|
1510
|
-
import {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1569
|
+
import {
|
|
1570
|
+
lazyValidator as lazyValidator5,
|
|
1571
|
+
zodSchema as zodSchema5
|
|
1572
|
+
} from "@ai-sdk/provider-utils";
|
|
1573
|
+
import * as z6 from "zod/v4";
|
|
1574
|
+
var openaiEmbeddingProviderOptions = lazyValidator5(
|
|
1575
|
+
() => zodSchema5(
|
|
1576
|
+
z6.object({
|
|
1577
|
+
/**
|
|
1578
|
+
The number of dimensions the resulting output embeddings should have.
|
|
1579
|
+
Only supported in text-embedding-3 and later models.
|
|
1580
|
+
*/
|
|
1581
|
+
dimensions: z6.number().optional(),
|
|
1582
|
+
/**
|
|
1583
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1584
|
+
monitor and detect abuse. Learn more.
|
|
1585
|
+
*/
|
|
1586
|
+
user: z6.string().optional()
|
|
1587
|
+
})
|
|
1588
|
+
)
|
|
1589
|
+
);
|
|
1590
|
+
|
|
1591
|
+
// src/embedding/openai-embedding-api.ts
|
|
1592
|
+
import { lazyValidator as lazyValidator6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1593
|
+
import * as z7 from "zod/v4";
|
|
1594
|
+
var openaiTextEmbeddingResponseSchema = lazyValidator6(
|
|
1595
|
+
() => zodSchema6(
|
|
1596
|
+
z7.object({
|
|
1597
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1598
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1599
|
+
})
|
|
1600
|
+
)
|
|
1601
|
+
);
|
|
1523
1602
|
|
|
1524
1603
|
// src/embedding/openai-embedding-model.ts
|
|
1525
1604
|
var OpenAIEmbeddingModel = class {
|
|
@@ -1584,10 +1663,6 @@ var OpenAIEmbeddingModel = class {
|
|
|
1584
1663
|
};
|
|
1585
1664
|
}
|
|
1586
1665
|
};
|
|
1587
|
-
var openaiTextEmbeddingResponseSchema = z7.object({
|
|
1588
|
-
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1589
|
-
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1590
|
-
});
|
|
1591
1666
|
|
|
1592
1667
|
// src/image/openai-image-model.ts
|
|
1593
1668
|
import {
|
|
@@ -1595,7 +1670,22 @@ import {
|
|
|
1595
1670
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1596
1671
|
postJsonToApi as postJsonToApi4
|
|
1597
1672
|
} from "@ai-sdk/provider-utils";
|
|
1598
|
-
|
|
1673
|
+
|
|
1674
|
+
// src/image/openai-image-api.ts
|
|
1675
|
+
import { lazyValidator as lazyValidator7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1676
|
+
import * as z8 from "zod/v4";
|
|
1677
|
+
var openaiImageResponseSchema = lazyValidator7(
|
|
1678
|
+
() => zodSchema7(
|
|
1679
|
+
z8.object({
|
|
1680
|
+
data: z8.array(
|
|
1681
|
+
z8.object({
|
|
1682
|
+
b64_json: z8.string(),
|
|
1683
|
+
revised_prompt: z8.string().optional()
|
|
1684
|
+
})
|
|
1685
|
+
)
|
|
1686
|
+
})
|
|
1687
|
+
)
|
|
1688
|
+
);
|
|
1599
1689
|
|
|
1600
1690
|
// src/image/openai-image-options.ts
|
|
1601
1691
|
var modelMaxImagesPerCall = {
|
|
@@ -1687,35 +1777,46 @@ var OpenAIImageModel = class {
|
|
|
1687
1777
|
};
|
|
1688
1778
|
}
|
|
1689
1779
|
};
|
|
1690
|
-
var openaiImageResponseSchema = z8.object({
|
|
1691
|
-
data: z8.array(
|
|
1692
|
-
z8.object({ b64_json: z8.string(), revised_prompt: z8.string().optional() })
|
|
1693
|
-
)
|
|
1694
|
-
});
|
|
1695
1780
|
|
|
1696
1781
|
// src/tool/code-interpreter.ts
|
|
1697
|
-
import {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
var
|
|
1704
|
-
|
|
1705
|
-
z9.discriminatedUnion("type", [
|
|
1706
|
-
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1707
|
-
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1708
|
-
])
|
|
1709
|
-
).nullish()
|
|
1710
|
-
});
|
|
1711
|
-
var codeInterpreterArgsSchema = z9.object({
|
|
1712
|
-
container: z9.union([
|
|
1713
|
-
z9.string(),
|
|
1782
|
+
import {
|
|
1783
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
1784
|
+
lazySchema,
|
|
1785
|
+
zodSchema as zodSchema8
|
|
1786
|
+
} from "@ai-sdk/provider-utils";
|
|
1787
|
+
import * as z9 from "zod/v4";
|
|
1788
|
+
var codeInterpreterInputSchema = lazySchema(
|
|
1789
|
+
() => zodSchema8(
|
|
1714
1790
|
z9.object({
|
|
1715
|
-
|
|
1791
|
+
code: z9.string().nullish(),
|
|
1792
|
+
containerId: z9.string()
|
|
1716
1793
|
})
|
|
1717
|
-
|
|
1718
|
-
|
|
1794
|
+
)
|
|
1795
|
+
);
|
|
1796
|
+
var codeInterpreterOutputSchema = lazySchema(
|
|
1797
|
+
() => zodSchema8(
|
|
1798
|
+
z9.object({
|
|
1799
|
+
outputs: z9.array(
|
|
1800
|
+
z9.discriminatedUnion("type", [
|
|
1801
|
+
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1802
|
+
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1803
|
+
])
|
|
1804
|
+
).nullish()
|
|
1805
|
+
})
|
|
1806
|
+
)
|
|
1807
|
+
);
|
|
1808
|
+
var codeInterpreterArgsSchema = lazySchema(
|
|
1809
|
+
() => zodSchema8(
|
|
1810
|
+
z9.object({
|
|
1811
|
+
container: z9.union([
|
|
1812
|
+
z9.string(),
|
|
1813
|
+
z9.object({
|
|
1814
|
+
fileIds: z9.array(z9.string()).optional()
|
|
1815
|
+
})
|
|
1816
|
+
]).optional()
|
|
1817
|
+
})
|
|
1818
|
+
)
|
|
1819
|
+
);
|
|
1719
1820
|
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
1720
1821
|
id: "openai.code_interpreter",
|
|
1721
1822
|
name: "code_interpreter",
|
|
@@ -1727,8 +1828,12 @@ var codeInterpreter = (args = {}) => {
|
|
|
1727
1828
|
};
|
|
1728
1829
|
|
|
1729
1830
|
// src/tool/file-search.ts
|
|
1730
|
-
import {
|
|
1731
|
-
|
|
1831
|
+
import {
|
|
1832
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
1833
|
+
lazySchema as lazySchema2,
|
|
1834
|
+
zodSchema as zodSchema9
|
|
1835
|
+
} from "@ai-sdk/provider-utils";
|
|
1836
|
+
import * as z10 from "zod/v4";
|
|
1732
1837
|
var comparisonFilterSchema = z10.object({
|
|
1733
1838
|
key: z10.string(),
|
|
1734
1839
|
type: z10.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
@@ -1740,27 +1845,35 @@ var compoundFilterSchema = z10.object({
|
|
|
1740
1845
|
z10.union([comparisonFilterSchema, z10.lazy(() => compoundFilterSchema)])
|
|
1741
1846
|
)
|
|
1742
1847
|
});
|
|
1743
|
-
var fileSearchArgsSchema =
|
|
1744
|
-
|
|
1745
|
-
maxNumResults: z10.number().optional(),
|
|
1746
|
-
ranking: z10.object({
|
|
1747
|
-
ranker: z10.string().optional(),
|
|
1748
|
-
scoreThreshold: z10.number().optional()
|
|
1749
|
-
}).optional(),
|
|
1750
|
-
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1751
|
-
});
|
|
1752
|
-
var fileSearchOutputSchema = z10.object({
|
|
1753
|
-
queries: z10.array(z10.string()),
|
|
1754
|
-
results: z10.array(
|
|
1848
|
+
var fileSearchArgsSchema = lazySchema2(
|
|
1849
|
+
() => zodSchema9(
|
|
1755
1850
|
z10.object({
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1851
|
+
vectorStoreIds: z10.array(z10.string()),
|
|
1852
|
+
maxNumResults: z10.number().optional(),
|
|
1853
|
+
ranking: z10.object({
|
|
1854
|
+
ranker: z10.string().optional(),
|
|
1855
|
+
scoreThreshold: z10.number().optional()
|
|
1856
|
+
}).optional(),
|
|
1857
|
+
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1761
1858
|
})
|
|
1762
|
-
)
|
|
1763
|
-
|
|
1859
|
+
)
|
|
1860
|
+
);
|
|
1861
|
+
var fileSearchOutputSchema = lazySchema2(
|
|
1862
|
+
() => zodSchema9(
|
|
1863
|
+
z10.object({
|
|
1864
|
+
queries: z10.array(z10.string()),
|
|
1865
|
+
results: z10.array(
|
|
1866
|
+
z10.object({
|
|
1867
|
+
attributes: z10.record(z10.string(), z10.unknown()),
|
|
1868
|
+
fileId: z10.string(),
|
|
1869
|
+
filename: z10.string(),
|
|
1870
|
+
score: z10.number(),
|
|
1871
|
+
text: z10.string()
|
|
1872
|
+
})
|
|
1873
|
+
).nullable()
|
|
1874
|
+
})
|
|
1875
|
+
)
|
|
1876
|
+
);
|
|
1764
1877
|
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
1765
1878
|
id: "openai.file_search",
|
|
1766
1879
|
name: "file_search",
|
|
@@ -1769,29 +1882,39 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
|
1769
1882
|
});
|
|
1770
1883
|
|
|
1771
1884
|
// src/tool/image-generation.ts
|
|
1772
|
-
import {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1885
|
+
import {
|
|
1886
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
|
|
1887
|
+
lazySchema as lazySchema3,
|
|
1888
|
+
zodSchema as zodSchema10
|
|
1889
|
+
} from "@ai-sdk/provider-utils";
|
|
1890
|
+
import * as z11 from "zod/v4";
|
|
1891
|
+
var imageGenerationArgsSchema = lazySchema3(
|
|
1892
|
+
() => zodSchema10(
|
|
1893
|
+
z11.object({
|
|
1894
|
+
background: z11.enum(["auto", "opaque", "transparent"]).optional(),
|
|
1895
|
+
inputFidelity: z11.enum(["low", "high"]).optional(),
|
|
1896
|
+
inputImageMask: z11.object({
|
|
1897
|
+
fileId: z11.string().optional(),
|
|
1898
|
+
imageUrl: z11.string().optional()
|
|
1899
|
+
}).optional(),
|
|
1900
|
+
model: z11.string().optional(),
|
|
1901
|
+
moderation: z11.enum(["auto"]).optional(),
|
|
1902
|
+
outputCompression: z11.number().int().min(0).max(100).optional(),
|
|
1903
|
+
outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
|
|
1904
|
+
partialImages: z11.number().int().min(0).max(3).optional(),
|
|
1905
|
+
quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1906
|
+
size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1907
|
+
}).strict()
|
|
1908
|
+
)
|
|
1909
|
+
);
|
|
1910
|
+
var imageGenerationInputSchema = lazySchema3(() => zodSchema10(z11.object({})));
|
|
1911
|
+
var imageGenerationOutputSchema = lazySchema3(
|
|
1912
|
+
() => zodSchema10(z11.object({ result: z11.string() }))
|
|
1913
|
+
);
|
|
1791
1914
|
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
1792
1915
|
id: "openai.image_generation",
|
|
1793
1916
|
name: "image_generation",
|
|
1794
|
-
inputSchema:
|
|
1917
|
+
inputSchema: imageGenerationInputSchema,
|
|
1795
1918
|
outputSchema: imageGenerationOutputSchema
|
|
1796
1919
|
});
|
|
1797
1920
|
var imageGeneration = (args = {}) => {
|
|
@@ -1799,21 +1922,29 @@ var imageGeneration = (args = {}) => {
|
|
|
1799
1922
|
};
|
|
1800
1923
|
|
|
1801
1924
|
// src/tool/local-shell.ts
|
|
1802
|
-
import {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1925
|
+
import {
|
|
1926
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
1927
|
+
lazySchema as lazySchema4,
|
|
1928
|
+
zodSchema as zodSchema11
|
|
1929
|
+
} from "@ai-sdk/provider-utils";
|
|
1930
|
+
import * as z12 from "zod/v4";
|
|
1931
|
+
var localShellInputSchema = lazySchema4(
|
|
1932
|
+
() => zodSchema11(
|
|
1933
|
+
z12.object({
|
|
1934
|
+
action: z12.object({
|
|
1935
|
+
type: z12.literal("exec"),
|
|
1936
|
+
command: z12.array(z12.string()),
|
|
1937
|
+
timeoutMs: z12.number().optional(),
|
|
1938
|
+
user: z12.string().optional(),
|
|
1939
|
+
workingDirectory: z12.string().optional(),
|
|
1940
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
1941
|
+
})
|
|
1942
|
+
})
|
|
1943
|
+
)
|
|
1944
|
+
);
|
|
1945
|
+
var localShellOutputSchema = lazySchema4(
|
|
1946
|
+
() => zodSchema11(z12.object({ output: z12.string() }))
|
|
1947
|
+
);
|
|
1817
1948
|
var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1818
1949
|
id: "openai.local_shell",
|
|
1819
1950
|
name: "local_shell",
|
|
@@ -1822,103 +1953,129 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
1822
1953
|
});
|
|
1823
1954
|
|
|
1824
1955
|
// src/tool/web-search.ts
|
|
1825
|
-
import {
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1956
|
+
import {
|
|
1957
|
+
createProviderDefinedToolFactory,
|
|
1958
|
+
lazySchema as lazySchema5,
|
|
1959
|
+
zodSchema as zodSchema12
|
|
1960
|
+
} from "@ai-sdk/provider-utils";
|
|
1961
|
+
import * as z13 from "zod/v4";
|
|
1962
|
+
var webSearchArgsSchema = lazySchema5(
|
|
1963
|
+
() => zodSchema12(
|
|
1964
|
+
z13.object({
|
|
1965
|
+
filters: z13.object({
|
|
1966
|
+
allowedDomains: z13.array(z13.string()).optional()
|
|
1967
|
+
}).optional(),
|
|
1968
|
+
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1969
|
+
userLocation: z13.object({
|
|
1970
|
+
type: z13.literal("approximate"),
|
|
1971
|
+
country: z13.string().optional(),
|
|
1972
|
+
city: z13.string().optional(),
|
|
1973
|
+
region: z13.string().optional(),
|
|
1974
|
+
timezone: z13.string().optional()
|
|
1975
|
+
}).optional()
|
|
1976
|
+
})
|
|
1977
|
+
)
|
|
1978
|
+
);
|
|
1979
|
+
var webSearchInputSchema = lazySchema5(
|
|
1980
|
+
() => zodSchema12(
|
|
1981
|
+
z13.object({
|
|
1982
|
+
action: z13.discriminatedUnion("type", [
|
|
1983
|
+
z13.object({
|
|
1984
|
+
type: z13.literal("search"),
|
|
1985
|
+
query: z13.string().nullish()
|
|
1986
|
+
}),
|
|
1987
|
+
z13.object({
|
|
1988
|
+
type: z13.literal("open_page"),
|
|
1989
|
+
url: z13.string()
|
|
1990
|
+
}),
|
|
1991
|
+
z13.object({
|
|
1992
|
+
type: z13.literal("find"),
|
|
1993
|
+
url: z13.string(),
|
|
1994
|
+
pattern: z13.string()
|
|
1995
|
+
})
|
|
1996
|
+
]).nullish()
|
|
1997
|
+
})
|
|
1998
|
+
)
|
|
1999
|
+
);
|
|
1840
2000
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
1841
2001
|
id: "openai.web_search",
|
|
1842
2002
|
name: "web_search",
|
|
1843
|
-
inputSchema:
|
|
1844
|
-
action: z13.discriminatedUnion("type", [
|
|
1845
|
-
z13.object({
|
|
1846
|
-
type: z13.literal("search"),
|
|
1847
|
-
query: z13.string().nullish()
|
|
1848
|
-
}),
|
|
1849
|
-
z13.object({
|
|
1850
|
-
type: z13.literal("open_page"),
|
|
1851
|
-
url: z13.string()
|
|
1852
|
-
}),
|
|
1853
|
-
z13.object({
|
|
1854
|
-
type: z13.literal("find"),
|
|
1855
|
-
url: z13.string(),
|
|
1856
|
-
pattern: z13.string()
|
|
1857
|
-
})
|
|
1858
|
-
]).nullish()
|
|
1859
|
-
})
|
|
2003
|
+
inputSchema: webSearchInputSchema
|
|
1860
2004
|
});
|
|
1861
2005
|
var webSearch = (args = {}) => {
|
|
1862
2006
|
return webSearchToolFactory(args);
|
|
1863
2007
|
};
|
|
1864
2008
|
|
|
1865
2009
|
// src/tool/web-search-preview.ts
|
|
1866
|
-
import {
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
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
|
-
|
|
2010
|
+
import {
|
|
2011
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2012
|
+
lazySchema as lazySchema6,
|
|
2013
|
+
zodSchema as zodSchema13
|
|
2014
|
+
} from "@ai-sdk/provider-utils";
|
|
2015
|
+
import * as z14 from "zod/v4";
|
|
2016
|
+
var webSearchPreviewArgsSchema = lazySchema6(
|
|
2017
|
+
() => zodSchema13(
|
|
2018
|
+
z14.object({
|
|
2019
|
+
/**
|
|
2020
|
+
* Search context size to use for the web search.
|
|
2021
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
2022
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
2023
|
+
* - low: Least context, lowest cost, fastest response
|
|
2024
|
+
*/
|
|
2025
|
+
searchContextSize: z14.enum(["low", "medium", "high"]).optional(),
|
|
2026
|
+
/**
|
|
2027
|
+
* User location information to provide geographically relevant search results.
|
|
2028
|
+
*/
|
|
2029
|
+
userLocation: z14.object({
|
|
2030
|
+
/**
|
|
2031
|
+
* Type of location (always 'approximate')
|
|
2032
|
+
*/
|
|
2033
|
+
type: z14.literal("approximate"),
|
|
2034
|
+
/**
|
|
2035
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2036
|
+
*/
|
|
2037
|
+
country: z14.string().optional(),
|
|
2038
|
+
/**
|
|
2039
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
2040
|
+
*/
|
|
2041
|
+
city: z14.string().optional(),
|
|
2042
|
+
/**
|
|
2043
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
2044
|
+
*/
|
|
2045
|
+
region: z14.string().optional(),
|
|
2046
|
+
/**
|
|
2047
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
2048
|
+
*/
|
|
2049
|
+
timezone: z14.string().optional()
|
|
2050
|
+
}).optional()
|
|
2051
|
+
})
|
|
2052
|
+
)
|
|
2053
|
+
);
|
|
2054
|
+
var webSearchPreviewInputSchema = lazySchema6(
|
|
2055
|
+
() => zodSchema13(
|
|
2056
|
+
z14.object({
|
|
2057
|
+
action: z14.discriminatedUnion("type", [
|
|
2058
|
+
z14.object({
|
|
2059
|
+
type: z14.literal("search"),
|
|
2060
|
+
query: z14.string().nullish()
|
|
2061
|
+
}),
|
|
2062
|
+
z14.object({
|
|
2063
|
+
type: z14.literal("open_page"),
|
|
2064
|
+
url: z14.string()
|
|
2065
|
+
}),
|
|
2066
|
+
z14.object({
|
|
2067
|
+
type: z14.literal("find"),
|
|
2068
|
+
url: z14.string(),
|
|
2069
|
+
pattern: z14.string()
|
|
2070
|
+
})
|
|
2071
|
+
]).nullish()
|
|
2072
|
+
})
|
|
2073
|
+
)
|
|
2074
|
+
);
|
|
1902
2075
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
1903
2076
|
id: "openai.web_search_preview",
|
|
1904
2077
|
name: "web_search_preview",
|
|
1905
|
-
inputSchema:
|
|
1906
|
-
action: z14.discriminatedUnion("type", [
|
|
1907
|
-
z14.object({
|
|
1908
|
-
type: z14.literal("search"),
|
|
1909
|
-
query: z14.string().nullish()
|
|
1910
|
-
}),
|
|
1911
|
-
z14.object({
|
|
1912
|
-
type: z14.literal("open_page"),
|
|
1913
|
-
url: z14.string()
|
|
1914
|
-
}),
|
|
1915
|
-
z14.object({
|
|
1916
|
-
type: z14.literal("find"),
|
|
1917
|
-
url: z14.string(),
|
|
1918
|
-
pattern: z14.string()
|
|
1919
|
-
})
|
|
1920
|
-
]).nullish()
|
|
1921
|
-
})
|
|
2078
|
+
inputSchema: webSearchPreviewInputSchema
|
|
1922
2079
|
});
|
|
1923
2080
|
|
|
1924
2081
|
// src/openai-tools.ts
|
|
@@ -2006,14 +2163,17 @@ import {
|
|
|
2006
2163
|
parseProviderOptions as parseProviderOptions5,
|
|
2007
2164
|
postJsonToApi as postJsonToApi5
|
|
2008
2165
|
} from "@ai-sdk/provider-utils";
|
|
2009
|
-
import { z as z16 } from "zod/v4";
|
|
2010
2166
|
|
|
2011
2167
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2012
2168
|
import {
|
|
2013
2169
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2014
2170
|
} from "@ai-sdk/provider";
|
|
2015
|
-
import {
|
|
2016
|
-
|
|
2171
|
+
import {
|
|
2172
|
+
convertToBase64 as convertToBase642,
|
|
2173
|
+
parseProviderOptions as parseProviderOptions4,
|
|
2174
|
+
validateTypes
|
|
2175
|
+
} from "@ai-sdk/provider-utils";
|
|
2176
|
+
import * as z15 from "zod/v4";
|
|
2017
2177
|
function isFileId(data, prefixes) {
|
|
2018
2178
|
if (!prefixes) return false;
|
|
2019
2179
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2119,7 +2279,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2119
2279
|
break;
|
|
2120
2280
|
}
|
|
2121
2281
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2122
|
-
const parsedInput =
|
|
2282
|
+
const parsedInput = await validateTypes({
|
|
2283
|
+
value: part.input,
|
|
2284
|
+
schema: localShellInputSchema
|
|
2285
|
+
});
|
|
2123
2286
|
input.push({
|
|
2124
2287
|
type: "local_shell_call",
|
|
2125
2288
|
call_id: part.toolCallId,
|
|
@@ -2215,10 +2378,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2215
2378
|
for (const part of content) {
|
|
2216
2379
|
const output = part.output;
|
|
2217
2380
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2381
|
+
const parsedOutput = await validateTypes({
|
|
2382
|
+
value: output.value,
|
|
2383
|
+
schema: localShellOutputSchema
|
|
2384
|
+
});
|
|
2218
2385
|
input.push({
|
|
2219
2386
|
type: "local_shell_call_output",
|
|
2220
2387
|
call_id: part.toolCallId,
|
|
2221
|
-
output:
|
|
2388
|
+
output: parsedOutput.output
|
|
2222
2389
|
});
|
|
2223
2390
|
break;
|
|
2224
2391
|
}
|
|
@@ -2273,11 +2440,547 @@ function mapOpenAIResponseFinishReason({
|
|
|
2273
2440
|
}
|
|
2274
2441
|
}
|
|
2275
2442
|
|
|
2443
|
+
// src/responses/openai-responses-api.ts
|
|
2444
|
+
import {
|
|
2445
|
+
lazyValidator as lazyValidator8,
|
|
2446
|
+
zodSchema as zodSchema14
|
|
2447
|
+
} from "@ai-sdk/provider-utils";
|
|
2448
|
+
import * as z16 from "zod/v4";
|
|
2449
|
+
var openaiResponsesChunkSchema = lazyValidator8(
|
|
2450
|
+
() => zodSchema14(
|
|
2451
|
+
z16.union([
|
|
2452
|
+
z16.object({
|
|
2453
|
+
type: z16.literal("response.output_text.delta"),
|
|
2454
|
+
item_id: z16.string(),
|
|
2455
|
+
delta: z16.string(),
|
|
2456
|
+
logprobs: z16.array(
|
|
2457
|
+
z16.object({
|
|
2458
|
+
token: z16.string(),
|
|
2459
|
+
logprob: z16.number(),
|
|
2460
|
+
top_logprobs: z16.array(
|
|
2461
|
+
z16.object({
|
|
2462
|
+
token: z16.string(),
|
|
2463
|
+
logprob: z16.number()
|
|
2464
|
+
})
|
|
2465
|
+
)
|
|
2466
|
+
})
|
|
2467
|
+
).nullish()
|
|
2468
|
+
}),
|
|
2469
|
+
z16.object({
|
|
2470
|
+
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
2471
|
+
response: z16.object({
|
|
2472
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2473
|
+
usage: z16.object({
|
|
2474
|
+
input_tokens: z16.number(),
|
|
2475
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2476
|
+
output_tokens: z16.number(),
|
|
2477
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2478
|
+
}),
|
|
2479
|
+
service_tier: z16.string().nullish()
|
|
2480
|
+
})
|
|
2481
|
+
}),
|
|
2482
|
+
z16.object({
|
|
2483
|
+
type: z16.literal("response.created"),
|
|
2484
|
+
response: z16.object({
|
|
2485
|
+
id: z16.string(),
|
|
2486
|
+
created_at: z16.number(),
|
|
2487
|
+
model: z16.string(),
|
|
2488
|
+
service_tier: z16.string().nullish()
|
|
2489
|
+
})
|
|
2490
|
+
}),
|
|
2491
|
+
z16.object({
|
|
2492
|
+
type: z16.literal("response.output_item.added"),
|
|
2493
|
+
output_index: z16.number(),
|
|
2494
|
+
item: z16.discriminatedUnion("type", [
|
|
2495
|
+
z16.object({
|
|
2496
|
+
type: z16.literal("message"),
|
|
2497
|
+
id: z16.string()
|
|
2498
|
+
}),
|
|
2499
|
+
z16.object({
|
|
2500
|
+
type: z16.literal("reasoning"),
|
|
2501
|
+
id: z16.string(),
|
|
2502
|
+
encrypted_content: z16.string().nullish()
|
|
2503
|
+
}),
|
|
2504
|
+
z16.object({
|
|
2505
|
+
type: z16.literal("function_call"),
|
|
2506
|
+
id: z16.string(),
|
|
2507
|
+
call_id: z16.string(),
|
|
2508
|
+
name: z16.string(),
|
|
2509
|
+
arguments: z16.string()
|
|
2510
|
+
}),
|
|
2511
|
+
z16.object({
|
|
2512
|
+
type: z16.literal("web_search_call"),
|
|
2513
|
+
id: z16.string(),
|
|
2514
|
+
status: z16.string(),
|
|
2515
|
+
action: z16.object({
|
|
2516
|
+
type: z16.literal("search"),
|
|
2517
|
+
query: z16.string().optional()
|
|
2518
|
+
}).nullish()
|
|
2519
|
+
}),
|
|
2520
|
+
z16.object({
|
|
2521
|
+
type: z16.literal("computer_call"),
|
|
2522
|
+
id: z16.string(),
|
|
2523
|
+
status: z16.string()
|
|
2524
|
+
}),
|
|
2525
|
+
z16.object({
|
|
2526
|
+
type: z16.literal("file_search_call"),
|
|
2527
|
+
id: z16.string()
|
|
2528
|
+
}),
|
|
2529
|
+
z16.object({
|
|
2530
|
+
type: z16.literal("image_generation_call"),
|
|
2531
|
+
id: z16.string()
|
|
2532
|
+
}),
|
|
2533
|
+
z16.object({
|
|
2534
|
+
type: z16.literal("code_interpreter_call"),
|
|
2535
|
+
id: z16.string(),
|
|
2536
|
+
container_id: z16.string(),
|
|
2537
|
+
code: z16.string().nullable(),
|
|
2538
|
+
outputs: z16.array(
|
|
2539
|
+
z16.discriminatedUnion("type", [
|
|
2540
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2541
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2542
|
+
])
|
|
2543
|
+
).nullable(),
|
|
2544
|
+
status: z16.string()
|
|
2545
|
+
})
|
|
2546
|
+
])
|
|
2547
|
+
}),
|
|
2548
|
+
z16.object({
|
|
2549
|
+
type: z16.literal("response.output_item.done"),
|
|
2550
|
+
output_index: z16.number(),
|
|
2551
|
+
item: z16.discriminatedUnion("type", [
|
|
2552
|
+
z16.object({
|
|
2553
|
+
type: z16.literal("message"),
|
|
2554
|
+
id: z16.string()
|
|
2555
|
+
}),
|
|
2556
|
+
z16.object({
|
|
2557
|
+
type: z16.literal("reasoning"),
|
|
2558
|
+
id: z16.string(),
|
|
2559
|
+
encrypted_content: z16.string().nullish()
|
|
2560
|
+
}),
|
|
2561
|
+
z16.object({
|
|
2562
|
+
type: z16.literal("function_call"),
|
|
2563
|
+
id: z16.string(),
|
|
2564
|
+
call_id: z16.string(),
|
|
2565
|
+
name: z16.string(),
|
|
2566
|
+
arguments: z16.string(),
|
|
2567
|
+
status: z16.literal("completed")
|
|
2568
|
+
}),
|
|
2569
|
+
z16.object({
|
|
2570
|
+
type: z16.literal("code_interpreter_call"),
|
|
2571
|
+
id: z16.string(),
|
|
2572
|
+
code: z16.string().nullable(),
|
|
2573
|
+
container_id: z16.string(),
|
|
2574
|
+
outputs: z16.array(
|
|
2575
|
+
z16.discriminatedUnion("type", [
|
|
2576
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2577
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2578
|
+
])
|
|
2579
|
+
).nullable()
|
|
2580
|
+
}),
|
|
2581
|
+
z16.object({
|
|
2582
|
+
type: z16.literal("image_generation_call"),
|
|
2583
|
+
id: z16.string(),
|
|
2584
|
+
result: z16.string()
|
|
2585
|
+
}),
|
|
2586
|
+
z16.object({
|
|
2587
|
+
type: z16.literal("web_search_call"),
|
|
2588
|
+
id: z16.string(),
|
|
2589
|
+
status: z16.string(),
|
|
2590
|
+
action: z16.discriminatedUnion("type", [
|
|
2591
|
+
z16.object({
|
|
2592
|
+
type: z16.literal("search"),
|
|
2593
|
+
query: z16.string().nullish()
|
|
2594
|
+
}),
|
|
2595
|
+
z16.object({
|
|
2596
|
+
type: z16.literal("open_page"),
|
|
2597
|
+
url: z16.string()
|
|
2598
|
+
}),
|
|
2599
|
+
z16.object({
|
|
2600
|
+
type: z16.literal("find"),
|
|
2601
|
+
url: z16.string(),
|
|
2602
|
+
pattern: z16.string()
|
|
2603
|
+
})
|
|
2604
|
+
]).nullish()
|
|
2605
|
+
}),
|
|
2606
|
+
z16.object({
|
|
2607
|
+
type: z16.literal("file_search_call"),
|
|
2608
|
+
id: z16.string(),
|
|
2609
|
+
queries: z16.array(z16.string()),
|
|
2610
|
+
results: z16.array(
|
|
2611
|
+
z16.object({
|
|
2612
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2613
|
+
file_id: z16.string(),
|
|
2614
|
+
filename: z16.string(),
|
|
2615
|
+
score: z16.number(),
|
|
2616
|
+
text: z16.string()
|
|
2617
|
+
})
|
|
2618
|
+
).nullish()
|
|
2619
|
+
}),
|
|
2620
|
+
z16.object({
|
|
2621
|
+
type: z16.literal("local_shell_call"),
|
|
2622
|
+
id: z16.string(),
|
|
2623
|
+
call_id: z16.string(),
|
|
2624
|
+
action: z16.object({
|
|
2625
|
+
type: z16.literal("exec"),
|
|
2626
|
+
command: z16.array(z16.string()),
|
|
2627
|
+
timeout_ms: z16.number().optional(),
|
|
2628
|
+
user: z16.string().optional(),
|
|
2629
|
+
working_directory: z16.string().optional(),
|
|
2630
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2631
|
+
})
|
|
2632
|
+
}),
|
|
2633
|
+
z16.object({
|
|
2634
|
+
type: z16.literal("computer_call"),
|
|
2635
|
+
id: z16.string(),
|
|
2636
|
+
status: z16.literal("completed")
|
|
2637
|
+
})
|
|
2638
|
+
])
|
|
2639
|
+
}),
|
|
2640
|
+
z16.object({
|
|
2641
|
+
type: z16.literal("response.function_call_arguments.delta"),
|
|
2642
|
+
item_id: z16.string(),
|
|
2643
|
+
output_index: z16.number(),
|
|
2644
|
+
delta: z16.string()
|
|
2645
|
+
}),
|
|
2646
|
+
z16.object({
|
|
2647
|
+
type: z16.literal("response.image_generation_call.partial_image"),
|
|
2648
|
+
item_id: z16.string(),
|
|
2649
|
+
output_index: z16.number(),
|
|
2650
|
+
partial_image_b64: z16.string()
|
|
2651
|
+
}),
|
|
2652
|
+
z16.object({
|
|
2653
|
+
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
2654
|
+
item_id: z16.string(),
|
|
2655
|
+
output_index: z16.number(),
|
|
2656
|
+
delta: z16.string()
|
|
2657
|
+
}),
|
|
2658
|
+
z16.object({
|
|
2659
|
+
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
2660
|
+
item_id: z16.string(),
|
|
2661
|
+
output_index: z16.number(),
|
|
2662
|
+
code: z16.string()
|
|
2663
|
+
}),
|
|
2664
|
+
z16.object({
|
|
2665
|
+
type: z16.literal("response.output_text.annotation.added"),
|
|
2666
|
+
annotation: z16.discriminatedUnion("type", [
|
|
2667
|
+
z16.object({
|
|
2668
|
+
type: z16.literal("url_citation"),
|
|
2669
|
+
url: z16.string(),
|
|
2670
|
+
title: z16.string()
|
|
2671
|
+
}),
|
|
2672
|
+
z16.object({
|
|
2673
|
+
type: z16.literal("file_citation"),
|
|
2674
|
+
file_id: z16.string(),
|
|
2675
|
+
filename: z16.string().nullish(),
|
|
2676
|
+
index: z16.number().nullish(),
|
|
2677
|
+
start_index: z16.number().nullish(),
|
|
2678
|
+
end_index: z16.number().nullish(),
|
|
2679
|
+
quote: z16.string().nullish()
|
|
2680
|
+
})
|
|
2681
|
+
])
|
|
2682
|
+
}),
|
|
2683
|
+
z16.object({
|
|
2684
|
+
type: z16.literal("response.reasoning_summary_part.added"),
|
|
2685
|
+
item_id: z16.string(),
|
|
2686
|
+
summary_index: z16.number()
|
|
2687
|
+
}),
|
|
2688
|
+
z16.object({
|
|
2689
|
+
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
2690
|
+
item_id: z16.string(),
|
|
2691
|
+
summary_index: z16.number(),
|
|
2692
|
+
delta: z16.string()
|
|
2693
|
+
}),
|
|
2694
|
+
z16.object({
|
|
2695
|
+
type: z16.literal("error"),
|
|
2696
|
+
code: z16.string(),
|
|
2697
|
+
message: z16.string(),
|
|
2698
|
+
param: z16.string().nullish(),
|
|
2699
|
+
sequence_number: z16.number()
|
|
2700
|
+
}),
|
|
2701
|
+
z16.object({ type: z16.string() }).loose().transform((value) => ({
|
|
2702
|
+
type: "unknown_chunk",
|
|
2703
|
+
message: value.type
|
|
2704
|
+
}))
|
|
2705
|
+
// fallback for unknown chunks
|
|
2706
|
+
])
|
|
2707
|
+
)
|
|
2708
|
+
);
|
|
2709
|
+
var openaiResponsesResponseSchema = lazyValidator8(
|
|
2710
|
+
() => zodSchema14(
|
|
2711
|
+
z16.object({
|
|
2712
|
+
id: z16.string(),
|
|
2713
|
+
created_at: z16.number(),
|
|
2714
|
+
error: z16.object({
|
|
2715
|
+
code: z16.string(),
|
|
2716
|
+
message: z16.string()
|
|
2717
|
+
}).nullish(),
|
|
2718
|
+
model: z16.string(),
|
|
2719
|
+
output: z16.array(
|
|
2720
|
+
z16.discriminatedUnion("type", [
|
|
2721
|
+
z16.object({
|
|
2722
|
+
type: z16.literal("message"),
|
|
2723
|
+
role: z16.literal("assistant"),
|
|
2724
|
+
id: z16.string(),
|
|
2725
|
+
content: z16.array(
|
|
2726
|
+
z16.object({
|
|
2727
|
+
type: z16.literal("output_text"),
|
|
2728
|
+
text: z16.string(),
|
|
2729
|
+
logprobs: z16.array(
|
|
2730
|
+
z16.object({
|
|
2731
|
+
token: z16.string(),
|
|
2732
|
+
logprob: z16.number(),
|
|
2733
|
+
top_logprobs: z16.array(
|
|
2734
|
+
z16.object({
|
|
2735
|
+
token: z16.string(),
|
|
2736
|
+
logprob: z16.number()
|
|
2737
|
+
})
|
|
2738
|
+
)
|
|
2739
|
+
})
|
|
2740
|
+
).nullish(),
|
|
2741
|
+
annotations: z16.array(
|
|
2742
|
+
z16.discriminatedUnion("type", [
|
|
2743
|
+
z16.object({
|
|
2744
|
+
type: z16.literal("url_citation"),
|
|
2745
|
+
start_index: z16.number(),
|
|
2746
|
+
end_index: z16.number(),
|
|
2747
|
+
url: z16.string(),
|
|
2748
|
+
title: z16.string()
|
|
2749
|
+
}),
|
|
2750
|
+
z16.object({
|
|
2751
|
+
type: z16.literal("file_citation"),
|
|
2752
|
+
file_id: z16.string(),
|
|
2753
|
+
filename: z16.string().nullish(),
|
|
2754
|
+
index: z16.number().nullish(),
|
|
2755
|
+
start_index: z16.number().nullish(),
|
|
2756
|
+
end_index: z16.number().nullish(),
|
|
2757
|
+
quote: z16.string().nullish()
|
|
2758
|
+
}),
|
|
2759
|
+
z16.object({
|
|
2760
|
+
type: z16.literal("container_file_citation")
|
|
2761
|
+
})
|
|
2762
|
+
])
|
|
2763
|
+
)
|
|
2764
|
+
})
|
|
2765
|
+
)
|
|
2766
|
+
}),
|
|
2767
|
+
z16.object({
|
|
2768
|
+
type: z16.literal("web_search_call"),
|
|
2769
|
+
id: z16.string(),
|
|
2770
|
+
status: z16.string(),
|
|
2771
|
+
action: z16.discriminatedUnion("type", [
|
|
2772
|
+
z16.object({
|
|
2773
|
+
type: z16.literal("search"),
|
|
2774
|
+
query: z16.string().nullish()
|
|
2775
|
+
}),
|
|
2776
|
+
z16.object({
|
|
2777
|
+
type: z16.literal("open_page"),
|
|
2778
|
+
url: z16.string()
|
|
2779
|
+
}),
|
|
2780
|
+
z16.object({
|
|
2781
|
+
type: z16.literal("find"),
|
|
2782
|
+
url: z16.string(),
|
|
2783
|
+
pattern: z16.string()
|
|
2784
|
+
})
|
|
2785
|
+
]).nullish()
|
|
2786
|
+
}),
|
|
2787
|
+
z16.object({
|
|
2788
|
+
type: z16.literal("file_search_call"),
|
|
2789
|
+
id: z16.string(),
|
|
2790
|
+
queries: z16.array(z16.string()),
|
|
2791
|
+
results: z16.array(
|
|
2792
|
+
z16.object({
|
|
2793
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2794
|
+
file_id: z16.string(),
|
|
2795
|
+
filename: z16.string(),
|
|
2796
|
+
score: z16.number(),
|
|
2797
|
+
text: z16.string()
|
|
2798
|
+
})
|
|
2799
|
+
).nullish()
|
|
2800
|
+
}),
|
|
2801
|
+
z16.object({
|
|
2802
|
+
type: z16.literal("code_interpreter_call"),
|
|
2803
|
+
id: z16.string(),
|
|
2804
|
+
code: z16.string().nullable(),
|
|
2805
|
+
container_id: z16.string(),
|
|
2806
|
+
outputs: z16.array(
|
|
2807
|
+
z16.discriminatedUnion("type", [
|
|
2808
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2809
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2810
|
+
])
|
|
2811
|
+
).nullable()
|
|
2812
|
+
}),
|
|
2813
|
+
z16.object({
|
|
2814
|
+
type: z16.literal("image_generation_call"),
|
|
2815
|
+
id: z16.string(),
|
|
2816
|
+
result: z16.string()
|
|
2817
|
+
}),
|
|
2818
|
+
z16.object({
|
|
2819
|
+
type: z16.literal("local_shell_call"),
|
|
2820
|
+
id: z16.string(),
|
|
2821
|
+
call_id: z16.string(),
|
|
2822
|
+
action: z16.object({
|
|
2823
|
+
type: z16.literal("exec"),
|
|
2824
|
+
command: z16.array(z16.string()),
|
|
2825
|
+
timeout_ms: z16.number().optional(),
|
|
2826
|
+
user: z16.string().optional(),
|
|
2827
|
+
working_directory: z16.string().optional(),
|
|
2828
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2829
|
+
})
|
|
2830
|
+
}),
|
|
2831
|
+
z16.object({
|
|
2832
|
+
type: z16.literal("function_call"),
|
|
2833
|
+
call_id: z16.string(),
|
|
2834
|
+
name: z16.string(),
|
|
2835
|
+
arguments: z16.string(),
|
|
2836
|
+
id: z16.string()
|
|
2837
|
+
}),
|
|
2838
|
+
z16.object({
|
|
2839
|
+
type: z16.literal("computer_call"),
|
|
2840
|
+
id: z16.string(),
|
|
2841
|
+
status: z16.string().optional()
|
|
2842
|
+
}),
|
|
2843
|
+
z16.object({
|
|
2844
|
+
type: z16.literal("reasoning"),
|
|
2845
|
+
id: z16.string(),
|
|
2846
|
+
encrypted_content: z16.string().nullish(),
|
|
2847
|
+
summary: z16.array(
|
|
2848
|
+
z16.object({
|
|
2849
|
+
type: z16.literal("summary_text"),
|
|
2850
|
+
text: z16.string()
|
|
2851
|
+
})
|
|
2852
|
+
)
|
|
2853
|
+
})
|
|
2854
|
+
])
|
|
2855
|
+
),
|
|
2856
|
+
service_tier: z16.string().nullish(),
|
|
2857
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2858
|
+
usage: z16.object({
|
|
2859
|
+
input_tokens: z16.number(),
|
|
2860
|
+
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2861
|
+
output_tokens: z16.number(),
|
|
2862
|
+
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2863
|
+
})
|
|
2864
|
+
})
|
|
2865
|
+
)
|
|
2866
|
+
);
|
|
2867
|
+
|
|
2868
|
+
// src/responses/openai-responses-options.ts
|
|
2869
|
+
import {
|
|
2870
|
+
lazyValidator as lazyValidator9,
|
|
2871
|
+
zodSchema as zodSchema15
|
|
2872
|
+
} from "@ai-sdk/provider-utils";
|
|
2873
|
+
import * as z17 from "zod/v4";
|
|
2874
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2875
|
+
var openaiResponsesReasoningModelIds = [
|
|
2876
|
+
"o1",
|
|
2877
|
+
"o1-2024-12-17",
|
|
2878
|
+
"o3-mini",
|
|
2879
|
+
"o3-mini-2025-01-31",
|
|
2880
|
+
"o3",
|
|
2881
|
+
"o3-2025-04-16",
|
|
2882
|
+
"o4-mini",
|
|
2883
|
+
"o4-mini-2025-04-16",
|
|
2884
|
+
"codex-mini-latest",
|
|
2885
|
+
"computer-use-preview",
|
|
2886
|
+
"gpt-5",
|
|
2887
|
+
"gpt-5-2025-08-07",
|
|
2888
|
+
"gpt-5-codex",
|
|
2889
|
+
"gpt-5-mini",
|
|
2890
|
+
"gpt-5-mini-2025-08-07",
|
|
2891
|
+
"gpt-5-nano",
|
|
2892
|
+
"gpt-5-nano-2025-08-07",
|
|
2893
|
+
"gpt-5-pro",
|
|
2894
|
+
"gpt-5-pro-2025-10-06"
|
|
2895
|
+
];
|
|
2896
|
+
var openaiResponsesModelIds = [
|
|
2897
|
+
"gpt-4.1",
|
|
2898
|
+
"gpt-4.1-2025-04-14",
|
|
2899
|
+
"gpt-4.1-mini",
|
|
2900
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2901
|
+
"gpt-4.1-nano",
|
|
2902
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2903
|
+
"gpt-4o",
|
|
2904
|
+
"gpt-4o-2024-05-13",
|
|
2905
|
+
"gpt-4o-2024-08-06",
|
|
2906
|
+
"gpt-4o-2024-11-20",
|
|
2907
|
+
"gpt-4o-audio-preview",
|
|
2908
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2909
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2910
|
+
"gpt-4o-search-preview",
|
|
2911
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2912
|
+
"gpt-4o-mini-search-preview",
|
|
2913
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2914
|
+
"gpt-4o-mini",
|
|
2915
|
+
"gpt-4o-mini-2024-07-18",
|
|
2916
|
+
"gpt-4-turbo",
|
|
2917
|
+
"gpt-4-turbo-2024-04-09",
|
|
2918
|
+
"gpt-4-turbo-preview",
|
|
2919
|
+
"gpt-4-0125-preview",
|
|
2920
|
+
"gpt-4-1106-preview",
|
|
2921
|
+
"gpt-4",
|
|
2922
|
+
"gpt-4-0613",
|
|
2923
|
+
"gpt-4.5-preview",
|
|
2924
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2925
|
+
"gpt-3.5-turbo-0125",
|
|
2926
|
+
"gpt-3.5-turbo",
|
|
2927
|
+
"gpt-3.5-turbo-1106",
|
|
2928
|
+
"chatgpt-4o-latest",
|
|
2929
|
+
"gpt-5-chat-latest",
|
|
2930
|
+
...openaiResponsesReasoningModelIds
|
|
2931
|
+
];
|
|
2932
|
+
var openaiResponsesProviderOptionsSchema = lazyValidator9(
|
|
2933
|
+
() => zodSchema15(
|
|
2934
|
+
z17.object({
|
|
2935
|
+
include: z17.array(
|
|
2936
|
+
z17.enum([
|
|
2937
|
+
"reasoning.encrypted_content",
|
|
2938
|
+
"file_search_call.results",
|
|
2939
|
+
"message.output_text.logprobs"
|
|
2940
|
+
])
|
|
2941
|
+
).nullish(),
|
|
2942
|
+
instructions: z17.string().nullish(),
|
|
2943
|
+
/**
|
|
2944
|
+
* Return the log probabilities of the tokens.
|
|
2945
|
+
*
|
|
2946
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2947
|
+
* were generated.
|
|
2948
|
+
*
|
|
2949
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2950
|
+
* tokens that were generated.
|
|
2951
|
+
*
|
|
2952
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2953
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2954
|
+
*/
|
|
2955
|
+
logprobs: z17.union([z17.boolean(), z17.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2956
|
+
/**
|
|
2957
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2958
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2959
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2960
|
+
*/
|
|
2961
|
+
maxToolCalls: z17.number().nullish(),
|
|
2962
|
+
metadata: z17.any().nullish(),
|
|
2963
|
+
parallelToolCalls: z17.boolean().nullish(),
|
|
2964
|
+
previousResponseId: z17.string().nullish(),
|
|
2965
|
+
promptCacheKey: z17.string().nullish(),
|
|
2966
|
+
reasoningEffort: z17.string().nullish(),
|
|
2967
|
+
reasoningSummary: z17.string().nullish(),
|
|
2968
|
+
safetyIdentifier: z17.string().nullish(),
|
|
2969
|
+
serviceTier: z17.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
2970
|
+
store: z17.boolean().nullish(),
|
|
2971
|
+
strictJsonSchema: z17.boolean().nullish(),
|
|
2972
|
+
textVerbosity: z17.enum(["low", "medium", "high"]).nullish(),
|
|
2973
|
+
user: z17.string().nullish()
|
|
2974
|
+
})
|
|
2975
|
+
)
|
|
2976
|
+
);
|
|
2977
|
+
|
|
2276
2978
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2277
2979
|
import {
|
|
2278
2980
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
2279
2981
|
} from "@ai-sdk/provider";
|
|
2280
|
-
|
|
2982
|
+
import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
|
|
2983
|
+
async function prepareResponsesTools({
|
|
2281
2984
|
tools,
|
|
2282
2985
|
toolChoice,
|
|
2283
2986
|
strictJsonSchema
|
|
@@ -2302,7 +3005,10 @@ function prepareResponsesTools({
|
|
|
2302
3005
|
case "provider-defined": {
|
|
2303
3006
|
switch (tool.id) {
|
|
2304
3007
|
case "openai.file_search": {
|
|
2305
|
-
const args =
|
|
3008
|
+
const args = await validateTypes2({
|
|
3009
|
+
value: tool.args,
|
|
3010
|
+
schema: fileSearchArgsSchema
|
|
3011
|
+
});
|
|
2306
3012
|
openaiTools2.push({
|
|
2307
3013
|
type: "file_search",
|
|
2308
3014
|
vector_store_ids: args.vectorStoreIds,
|
|
@@ -2322,7 +3028,10 @@ function prepareResponsesTools({
|
|
|
2322
3028
|
break;
|
|
2323
3029
|
}
|
|
2324
3030
|
case "openai.web_search_preview": {
|
|
2325
|
-
const args =
|
|
3031
|
+
const args = await validateTypes2({
|
|
3032
|
+
value: tool.args,
|
|
3033
|
+
schema: webSearchPreviewArgsSchema
|
|
3034
|
+
});
|
|
2326
3035
|
openaiTools2.push({
|
|
2327
3036
|
type: "web_search_preview",
|
|
2328
3037
|
search_context_size: args.searchContextSize,
|
|
@@ -2331,7 +3040,10 @@ function prepareResponsesTools({
|
|
|
2331
3040
|
break;
|
|
2332
3041
|
}
|
|
2333
3042
|
case "openai.web_search": {
|
|
2334
|
-
const args =
|
|
3043
|
+
const args = await validateTypes2({
|
|
3044
|
+
value: tool.args,
|
|
3045
|
+
schema: webSearchArgsSchema
|
|
3046
|
+
});
|
|
2335
3047
|
openaiTools2.push({
|
|
2336
3048
|
type: "web_search",
|
|
2337
3049
|
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
@@ -2341,7 +3053,10 @@ function prepareResponsesTools({
|
|
|
2341
3053
|
break;
|
|
2342
3054
|
}
|
|
2343
3055
|
case "openai.code_interpreter": {
|
|
2344
|
-
const args =
|
|
3056
|
+
const args = await validateTypes2({
|
|
3057
|
+
value: tool.args,
|
|
3058
|
+
schema: codeInterpreterArgsSchema
|
|
3059
|
+
});
|
|
2345
3060
|
openaiTools2.push({
|
|
2346
3061
|
type: "code_interpreter",
|
|
2347
3062
|
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
@@ -2349,7 +3064,10 @@ function prepareResponsesTools({
|
|
|
2349
3064
|
break;
|
|
2350
3065
|
}
|
|
2351
3066
|
case "openai.image_generation": {
|
|
2352
|
-
const args =
|
|
3067
|
+
const args = await validateTypes2({
|
|
3068
|
+
value: tool.args,
|
|
3069
|
+
schema: imageGenerationArgsSchema
|
|
3070
|
+
});
|
|
2353
3071
|
openaiTools2.push({
|
|
2354
3072
|
type: "image_generation",
|
|
2355
3073
|
background: args.background,
|
|
@@ -2400,83 +3118,6 @@ function prepareResponsesTools({
|
|
|
2400
3118
|
}
|
|
2401
3119
|
|
|
2402
3120
|
// src/responses/openai-responses-language-model.ts
|
|
2403
|
-
var webSearchCallItem = z16.object({
|
|
2404
|
-
type: z16.literal("web_search_call"),
|
|
2405
|
-
id: z16.string(),
|
|
2406
|
-
status: z16.string(),
|
|
2407
|
-
action: z16.discriminatedUnion("type", [
|
|
2408
|
-
z16.object({
|
|
2409
|
-
type: z16.literal("search"),
|
|
2410
|
-
query: z16.string().nullish()
|
|
2411
|
-
}),
|
|
2412
|
-
z16.object({
|
|
2413
|
-
type: z16.literal("open_page"),
|
|
2414
|
-
url: z16.string()
|
|
2415
|
-
}),
|
|
2416
|
-
z16.object({
|
|
2417
|
-
type: z16.literal("find"),
|
|
2418
|
-
url: z16.string(),
|
|
2419
|
-
pattern: z16.string()
|
|
2420
|
-
})
|
|
2421
|
-
]).nullish()
|
|
2422
|
-
});
|
|
2423
|
-
var fileSearchCallItem = z16.object({
|
|
2424
|
-
type: z16.literal("file_search_call"),
|
|
2425
|
-
id: z16.string(),
|
|
2426
|
-
queries: z16.array(z16.string()),
|
|
2427
|
-
results: z16.array(
|
|
2428
|
-
z16.object({
|
|
2429
|
-
attributes: z16.record(z16.string(), z16.unknown()),
|
|
2430
|
-
file_id: z16.string(),
|
|
2431
|
-
filename: z16.string(),
|
|
2432
|
-
score: z16.number(),
|
|
2433
|
-
text: z16.string()
|
|
2434
|
-
})
|
|
2435
|
-
).nullish()
|
|
2436
|
-
});
|
|
2437
|
-
var codeInterpreterCallItem = z16.object({
|
|
2438
|
-
type: z16.literal("code_interpreter_call"),
|
|
2439
|
-
id: z16.string(),
|
|
2440
|
-
code: z16.string().nullable(),
|
|
2441
|
-
container_id: z16.string(),
|
|
2442
|
-
outputs: z16.array(
|
|
2443
|
-
z16.discriminatedUnion("type", [
|
|
2444
|
-
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
2445
|
-
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2446
|
-
])
|
|
2447
|
-
).nullable()
|
|
2448
|
-
});
|
|
2449
|
-
var localShellCallItem = z16.object({
|
|
2450
|
-
type: z16.literal("local_shell_call"),
|
|
2451
|
-
id: z16.string(),
|
|
2452
|
-
call_id: z16.string(),
|
|
2453
|
-
action: z16.object({
|
|
2454
|
-
type: z16.literal("exec"),
|
|
2455
|
-
command: z16.array(z16.string()),
|
|
2456
|
-
timeout_ms: z16.number().optional(),
|
|
2457
|
-
user: z16.string().optional(),
|
|
2458
|
-
working_directory: z16.string().optional(),
|
|
2459
|
-
env: z16.record(z16.string(), z16.string()).optional()
|
|
2460
|
-
})
|
|
2461
|
-
});
|
|
2462
|
-
var imageGenerationCallItem = z16.object({
|
|
2463
|
-
type: z16.literal("image_generation_call"),
|
|
2464
|
-
id: z16.string(),
|
|
2465
|
-
result: z16.string()
|
|
2466
|
-
});
|
|
2467
|
-
var TOP_LOGPROBS_MAX = 20;
|
|
2468
|
-
var LOGPROBS_SCHEMA = 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
|
-
);
|
|
2480
3121
|
var OpenAIResponsesLanguageModel = class {
|
|
2481
3122
|
constructor(modelId, config) {
|
|
2482
3123
|
this.specificationVersion = "v2";
|
|
@@ -2668,7 +3309,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2668
3309
|
tools: openaiTools2,
|
|
2669
3310
|
toolChoice: openaiToolChoice,
|
|
2670
3311
|
toolWarnings
|
|
2671
|
-
} = prepareResponsesTools({
|
|
3312
|
+
} = await prepareResponsesTools({
|
|
2672
3313
|
tools,
|
|
2673
3314
|
toolChoice,
|
|
2674
3315
|
strictJsonSchema
|
|
@@ -2704,85 +3345,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2704
3345
|
body,
|
|
2705
3346
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2706
3347
|
successfulResponseHandler: createJsonResponseHandler5(
|
|
2707
|
-
|
|
2708
|
-
id: z16.string(),
|
|
2709
|
-
created_at: z16.number(),
|
|
2710
|
-
error: z16.object({
|
|
2711
|
-
code: z16.string(),
|
|
2712
|
-
message: z16.string()
|
|
2713
|
-
}).nullish(),
|
|
2714
|
-
model: z16.string(),
|
|
2715
|
-
output: z16.array(
|
|
2716
|
-
z16.discriminatedUnion("type", [
|
|
2717
|
-
z16.object({
|
|
2718
|
-
type: z16.literal("message"),
|
|
2719
|
-
role: z16.literal("assistant"),
|
|
2720
|
-
id: z16.string(),
|
|
2721
|
-
content: z16.array(
|
|
2722
|
-
z16.object({
|
|
2723
|
-
type: z16.literal("output_text"),
|
|
2724
|
-
text: z16.string(),
|
|
2725
|
-
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2726
|
-
annotations: z16.array(
|
|
2727
|
-
z16.discriminatedUnion("type", [
|
|
2728
|
-
z16.object({
|
|
2729
|
-
type: z16.literal("url_citation"),
|
|
2730
|
-
start_index: z16.number(),
|
|
2731
|
-
end_index: z16.number(),
|
|
2732
|
-
url: z16.string(),
|
|
2733
|
-
title: z16.string()
|
|
2734
|
-
}),
|
|
2735
|
-
z16.object({
|
|
2736
|
-
type: z16.literal("file_citation"),
|
|
2737
|
-
file_id: z16.string(),
|
|
2738
|
-
filename: z16.string().nullish(),
|
|
2739
|
-
index: z16.number().nullish(),
|
|
2740
|
-
start_index: z16.number().nullish(),
|
|
2741
|
-
end_index: z16.number().nullish(),
|
|
2742
|
-
quote: z16.string().nullish()
|
|
2743
|
-
}),
|
|
2744
|
-
z16.object({
|
|
2745
|
-
type: z16.literal("container_file_citation")
|
|
2746
|
-
})
|
|
2747
|
-
])
|
|
2748
|
-
)
|
|
2749
|
-
})
|
|
2750
|
-
)
|
|
2751
|
-
}),
|
|
2752
|
-
webSearchCallItem,
|
|
2753
|
-
fileSearchCallItem,
|
|
2754
|
-
codeInterpreterCallItem,
|
|
2755
|
-
imageGenerationCallItem,
|
|
2756
|
-
localShellCallItem,
|
|
2757
|
-
z16.object({
|
|
2758
|
-
type: z16.literal("function_call"),
|
|
2759
|
-
call_id: z16.string(),
|
|
2760
|
-
name: z16.string(),
|
|
2761
|
-
arguments: z16.string(),
|
|
2762
|
-
id: z16.string()
|
|
2763
|
-
}),
|
|
2764
|
-
z16.object({
|
|
2765
|
-
type: z16.literal("computer_call"),
|
|
2766
|
-
id: z16.string(),
|
|
2767
|
-
status: z16.string().optional()
|
|
2768
|
-
}),
|
|
2769
|
-
z16.object({
|
|
2770
|
-
type: z16.literal("reasoning"),
|
|
2771
|
-
id: z16.string(),
|
|
2772
|
-
encrypted_content: z16.string().nullish(),
|
|
2773
|
-
summary: z16.array(
|
|
2774
|
-
z16.object({
|
|
2775
|
-
type: z16.literal("summary_text"),
|
|
2776
|
-
text: z16.string()
|
|
2777
|
-
})
|
|
2778
|
-
)
|
|
2779
|
-
})
|
|
2780
|
-
])
|
|
2781
|
-
),
|
|
2782
|
-
service_tier: z16.string().nullish(),
|
|
2783
|
-
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2784
|
-
usage: usageSchema2
|
|
2785
|
-
})
|
|
3348
|
+
openaiResponsesResponseSchema
|
|
2786
3349
|
),
|
|
2787
3350
|
abortSignal: options.abortSignal,
|
|
2788
3351
|
fetch: this.config.fetch
|
|
@@ -2845,7 +3408,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2845
3408
|
type: "tool-call",
|
|
2846
3409
|
toolCallId: part.call_id,
|
|
2847
3410
|
toolName: "local_shell",
|
|
2848
|
-
input: JSON.stringify({
|
|
3411
|
+
input: JSON.stringify({
|
|
3412
|
+
action: part.action
|
|
3413
|
+
}),
|
|
2849
3414
|
providerMetadata: {
|
|
2850
3415
|
openai: {
|
|
2851
3416
|
itemId: part.id
|
|
@@ -3465,196 +4030,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3465
4030
|
};
|
|
3466
4031
|
}
|
|
3467
4032
|
};
|
|
3468
|
-
var usageSchema2 = z16.object({
|
|
3469
|
-
input_tokens: z16.number(),
|
|
3470
|
-
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
3471
|
-
output_tokens: z16.number(),
|
|
3472
|
-
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
3473
|
-
});
|
|
3474
|
-
var textDeltaChunkSchema = z16.object({
|
|
3475
|
-
type: z16.literal("response.output_text.delta"),
|
|
3476
|
-
item_id: z16.string(),
|
|
3477
|
-
delta: z16.string(),
|
|
3478
|
-
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3479
|
-
});
|
|
3480
|
-
var errorChunkSchema = z16.object({
|
|
3481
|
-
type: z16.literal("error"),
|
|
3482
|
-
code: z16.string(),
|
|
3483
|
-
message: z16.string(),
|
|
3484
|
-
param: z16.string().nullish(),
|
|
3485
|
-
sequence_number: z16.number()
|
|
3486
|
-
});
|
|
3487
|
-
var responseFinishedChunkSchema = z16.object({
|
|
3488
|
-
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
3489
|
-
response: z16.object({
|
|
3490
|
-
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
3491
|
-
usage: usageSchema2,
|
|
3492
|
-
service_tier: z16.string().nullish()
|
|
3493
|
-
})
|
|
3494
|
-
});
|
|
3495
|
-
var responseCreatedChunkSchema = z16.object({
|
|
3496
|
-
type: z16.literal("response.created"),
|
|
3497
|
-
response: z16.object({
|
|
3498
|
-
id: z16.string(),
|
|
3499
|
-
created_at: z16.number(),
|
|
3500
|
-
model: z16.string(),
|
|
3501
|
-
service_tier: z16.string().nullish()
|
|
3502
|
-
})
|
|
3503
|
-
});
|
|
3504
|
-
var responseOutputItemAddedSchema = z16.object({
|
|
3505
|
-
type: z16.literal("response.output_item.added"),
|
|
3506
|
-
output_index: z16.number(),
|
|
3507
|
-
item: z16.discriminatedUnion("type", [
|
|
3508
|
-
z16.object({
|
|
3509
|
-
type: z16.literal("message"),
|
|
3510
|
-
id: z16.string()
|
|
3511
|
-
}),
|
|
3512
|
-
z16.object({
|
|
3513
|
-
type: z16.literal("reasoning"),
|
|
3514
|
-
id: z16.string(),
|
|
3515
|
-
encrypted_content: z16.string().nullish()
|
|
3516
|
-
}),
|
|
3517
|
-
z16.object({
|
|
3518
|
-
type: z16.literal("function_call"),
|
|
3519
|
-
id: z16.string(),
|
|
3520
|
-
call_id: z16.string(),
|
|
3521
|
-
name: z16.string(),
|
|
3522
|
-
arguments: z16.string()
|
|
3523
|
-
}),
|
|
3524
|
-
z16.object({
|
|
3525
|
-
type: z16.literal("web_search_call"),
|
|
3526
|
-
id: z16.string(),
|
|
3527
|
-
status: z16.string(),
|
|
3528
|
-
action: z16.object({
|
|
3529
|
-
type: z16.literal("search"),
|
|
3530
|
-
query: z16.string().optional()
|
|
3531
|
-
}).nullish()
|
|
3532
|
-
}),
|
|
3533
|
-
z16.object({
|
|
3534
|
-
type: z16.literal("computer_call"),
|
|
3535
|
-
id: z16.string(),
|
|
3536
|
-
status: z16.string()
|
|
3537
|
-
}),
|
|
3538
|
-
z16.object({
|
|
3539
|
-
type: z16.literal("file_search_call"),
|
|
3540
|
-
id: z16.string()
|
|
3541
|
-
}),
|
|
3542
|
-
z16.object({
|
|
3543
|
-
type: z16.literal("image_generation_call"),
|
|
3544
|
-
id: z16.string()
|
|
3545
|
-
}),
|
|
3546
|
-
z16.object({
|
|
3547
|
-
type: z16.literal("code_interpreter_call"),
|
|
3548
|
-
id: z16.string(),
|
|
3549
|
-
container_id: z16.string(),
|
|
3550
|
-
code: z16.string().nullable(),
|
|
3551
|
-
outputs: z16.array(
|
|
3552
|
-
z16.discriminatedUnion("type", [
|
|
3553
|
-
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3554
|
-
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
3555
|
-
])
|
|
3556
|
-
).nullable(),
|
|
3557
|
-
status: z16.string()
|
|
3558
|
-
})
|
|
3559
|
-
])
|
|
3560
|
-
});
|
|
3561
|
-
var responseOutputItemDoneSchema = z16.object({
|
|
3562
|
-
type: z16.literal("response.output_item.done"),
|
|
3563
|
-
output_index: z16.number(),
|
|
3564
|
-
item: z16.discriminatedUnion("type", [
|
|
3565
|
-
z16.object({
|
|
3566
|
-
type: z16.literal("message"),
|
|
3567
|
-
id: z16.string()
|
|
3568
|
-
}),
|
|
3569
|
-
z16.object({
|
|
3570
|
-
type: z16.literal("reasoning"),
|
|
3571
|
-
id: z16.string(),
|
|
3572
|
-
encrypted_content: z16.string().nullish()
|
|
3573
|
-
}),
|
|
3574
|
-
z16.object({
|
|
3575
|
-
type: z16.literal("function_call"),
|
|
3576
|
-
id: z16.string(),
|
|
3577
|
-
call_id: z16.string(),
|
|
3578
|
-
name: z16.string(),
|
|
3579
|
-
arguments: z16.string(),
|
|
3580
|
-
status: z16.literal("completed")
|
|
3581
|
-
}),
|
|
3582
|
-
codeInterpreterCallItem,
|
|
3583
|
-
imageGenerationCallItem,
|
|
3584
|
-
webSearchCallItem,
|
|
3585
|
-
fileSearchCallItem,
|
|
3586
|
-
localShellCallItem,
|
|
3587
|
-
z16.object({
|
|
3588
|
-
type: z16.literal("computer_call"),
|
|
3589
|
-
id: z16.string(),
|
|
3590
|
-
status: z16.literal("completed")
|
|
3591
|
-
})
|
|
3592
|
-
])
|
|
3593
|
-
});
|
|
3594
|
-
var responseFunctionCallArgumentsDeltaSchema = z16.object({
|
|
3595
|
-
type: z16.literal("response.function_call_arguments.delta"),
|
|
3596
|
-
item_id: z16.string(),
|
|
3597
|
-
output_index: z16.number(),
|
|
3598
|
-
delta: z16.string()
|
|
3599
|
-
});
|
|
3600
|
-
var responseCodeInterpreterCallCodeDeltaSchema = z16.object({
|
|
3601
|
-
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
3602
|
-
item_id: z16.string(),
|
|
3603
|
-
output_index: z16.number(),
|
|
3604
|
-
delta: z16.string()
|
|
3605
|
-
});
|
|
3606
|
-
var responseCodeInterpreterCallCodeDoneSchema = z16.object({
|
|
3607
|
-
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
3608
|
-
item_id: z16.string(),
|
|
3609
|
-
output_index: z16.number(),
|
|
3610
|
-
code: z16.string()
|
|
3611
|
-
});
|
|
3612
|
-
var responseAnnotationAddedSchema = z16.object({
|
|
3613
|
-
type: z16.literal("response.output_text.annotation.added"),
|
|
3614
|
-
annotation: z16.discriminatedUnion("type", [
|
|
3615
|
-
z16.object({
|
|
3616
|
-
type: z16.literal("url_citation"),
|
|
3617
|
-
url: z16.string(),
|
|
3618
|
-
title: z16.string()
|
|
3619
|
-
}),
|
|
3620
|
-
z16.object({
|
|
3621
|
-
type: z16.literal("file_citation"),
|
|
3622
|
-
file_id: z16.string(),
|
|
3623
|
-
filename: z16.string().nullish(),
|
|
3624
|
-
index: z16.number().nullish(),
|
|
3625
|
-
start_index: z16.number().nullish(),
|
|
3626
|
-
end_index: z16.number().nullish(),
|
|
3627
|
-
quote: z16.string().nullish()
|
|
3628
|
-
})
|
|
3629
|
-
])
|
|
3630
|
-
});
|
|
3631
|
-
var responseReasoningSummaryPartAddedSchema = z16.object({
|
|
3632
|
-
type: z16.literal("response.reasoning_summary_part.added"),
|
|
3633
|
-
item_id: z16.string(),
|
|
3634
|
-
summary_index: z16.number()
|
|
3635
|
-
});
|
|
3636
|
-
var responseReasoningSummaryTextDeltaSchema = z16.object({
|
|
3637
|
-
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
3638
|
-
item_id: z16.string(),
|
|
3639
|
-
summary_index: z16.number(),
|
|
3640
|
-
delta: z16.string()
|
|
3641
|
-
});
|
|
3642
|
-
var openaiResponsesChunkSchema = z16.union([
|
|
3643
|
-
textDeltaChunkSchema,
|
|
3644
|
-
responseFinishedChunkSchema,
|
|
3645
|
-
responseCreatedChunkSchema,
|
|
3646
|
-
responseOutputItemAddedSchema,
|
|
3647
|
-
responseOutputItemDoneSchema,
|
|
3648
|
-
responseFunctionCallArgumentsDeltaSchema,
|
|
3649
|
-
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3650
|
-
responseCodeInterpreterCallCodeDoneSchema,
|
|
3651
|
-
responseAnnotationAddedSchema,
|
|
3652
|
-
responseReasoningSummaryPartAddedSchema,
|
|
3653
|
-
responseReasoningSummaryTextDeltaSchema,
|
|
3654
|
-
errorChunkSchema,
|
|
3655
|
-
z16.object({ type: z16.string() }).loose()
|
|
3656
|
-
// fallback for unknown chunks
|
|
3657
|
-
]);
|
|
3658
4033
|
function isTextDeltaChunk(chunk) {
|
|
3659
4034
|
return chunk.type === "response.output_text.delta";
|
|
3660
4035
|
}
|
|
@@ -3731,47 +4106,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
3731
4106
|
isReasoningModel: false
|
|
3732
4107
|
};
|
|
3733
4108
|
}
|
|
3734
|
-
var openaiResponsesProviderOptionsSchema = z16.object({
|
|
3735
|
-
include: z16.array(
|
|
3736
|
-
z16.enum([
|
|
3737
|
-
"reasoning.encrypted_content",
|
|
3738
|
-
"file_search_call.results",
|
|
3739
|
-
"message.output_text.logprobs"
|
|
3740
|
-
])
|
|
3741
|
-
).nullish(),
|
|
3742
|
-
instructions: z16.string().nullish(),
|
|
3743
|
-
/**
|
|
3744
|
-
* Return the log probabilities of the tokens.
|
|
3745
|
-
*
|
|
3746
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
3747
|
-
* were generated.
|
|
3748
|
-
*
|
|
3749
|
-
* Setting to a number will return the log probabilities of the top n
|
|
3750
|
-
* tokens that were generated.
|
|
3751
|
-
*
|
|
3752
|
-
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3753
|
-
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3754
|
-
*/
|
|
3755
|
-
logprobs: z16.union([z16.boolean(), z16.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3756
|
-
/**
|
|
3757
|
-
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3758
|
-
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3759
|
-
* Any further attempts to call a tool by the model will be ignored.
|
|
3760
|
-
*/
|
|
3761
|
-
maxToolCalls: z16.number().nullish(),
|
|
3762
|
-
metadata: z16.any().nullish(),
|
|
3763
|
-
parallelToolCalls: z16.boolean().nullish(),
|
|
3764
|
-
previousResponseId: z16.string().nullish(),
|
|
3765
|
-
promptCacheKey: z16.string().nullish(),
|
|
3766
|
-
reasoningEffort: z16.string().nullish(),
|
|
3767
|
-
reasoningSummary: z16.string().nullish(),
|
|
3768
|
-
safetyIdentifier: z16.string().nullish(),
|
|
3769
|
-
serviceTier: z16.enum(["auto", "flex", "priority"]).nullish(),
|
|
3770
|
-
store: z16.boolean().nullish(),
|
|
3771
|
-
strictJsonSchema: z16.boolean().nullish(),
|
|
3772
|
-
textVerbosity: z16.enum(["low", "medium", "high"]).nullish(),
|
|
3773
|
-
user: z16.string().nullish()
|
|
3774
|
-
});
|
|
3775
4109
|
|
|
3776
4110
|
// src/speech/openai-speech-model.ts
|
|
3777
4111
|
import {
|
|
@@ -3780,11 +4114,23 @@ import {
|
|
|
3780
4114
|
parseProviderOptions as parseProviderOptions6,
|
|
3781
4115
|
postJsonToApi as postJsonToApi6
|
|
3782
4116
|
} from "@ai-sdk/provider-utils";
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
4117
|
+
|
|
4118
|
+
// src/speech/openai-speech-options.ts
|
|
4119
|
+
import {
|
|
4120
|
+
lazyValidator as lazyValidator10,
|
|
4121
|
+
zodSchema as zodSchema16
|
|
4122
|
+
} from "@ai-sdk/provider-utils";
|
|
4123
|
+
import * as z18 from "zod/v4";
|
|
4124
|
+
var openaiSpeechProviderOptionsSchema = lazyValidator10(
|
|
4125
|
+
() => zodSchema16(
|
|
4126
|
+
z18.object({
|
|
4127
|
+
instructions: z18.string().nullish(),
|
|
4128
|
+
speed: z18.number().min(0.25).max(4).default(1).nullish()
|
|
4129
|
+
})
|
|
4130
|
+
)
|
|
4131
|
+
);
|
|
4132
|
+
|
|
4133
|
+
// src/speech/openai-speech-model.ts
|
|
3788
4134
|
var OpenAISpeechModel = class {
|
|
3789
4135
|
constructor(modelId, config) {
|
|
3790
4136
|
this.modelId = modelId;
|
|
@@ -3807,7 +4153,7 @@ var OpenAISpeechModel = class {
|
|
|
3807
4153
|
const openAIOptions = await parseProviderOptions6({
|
|
3808
4154
|
provider: "openai",
|
|
3809
4155
|
providerOptions,
|
|
3810
|
-
schema:
|
|
4156
|
+
schema: openaiSpeechProviderOptionsSchema
|
|
3811
4157
|
});
|
|
3812
4158
|
const requestBody = {
|
|
3813
4159
|
model: this.modelId,
|
|
@@ -3894,34 +4240,75 @@ import {
|
|
|
3894
4240
|
parseProviderOptions as parseProviderOptions7,
|
|
3895
4241
|
postFormDataToApi
|
|
3896
4242
|
} from "@ai-sdk/provider-utils";
|
|
3897
|
-
|
|
4243
|
+
|
|
4244
|
+
// src/transcription/openai-transcription-api.ts
|
|
4245
|
+
import { lazyValidator as lazyValidator11, zodSchema as zodSchema17 } from "@ai-sdk/provider-utils";
|
|
4246
|
+
import * as z19 from "zod/v4";
|
|
4247
|
+
var openaiTranscriptionResponseSchema = lazyValidator11(
|
|
4248
|
+
() => zodSchema17(
|
|
4249
|
+
z19.object({
|
|
4250
|
+
text: z19.string(),
|
|
4251
|
+
language: z19.string().nullish(),
|
|
4252
|
+
duration: z19.number().nullish(),
|
|
4253
|
+
words: z19.array(
|
|
4254
|
+
z19.object({
|
|
4255
|
+
word: z19.string(),
|
|
4256
|
+
start: z19.number(),
|
|
4257
|
+
end: z19.number()
|
|
4258
|
+
})
|
|
4259
|
+
).nullish(),
|
|
4260
|
+
segments: z19.array(
|
|
4261
|
+
z19.object({
|
|
4262
|
+
id: z19.number(),
|
|
4263
|
+
seek: z19.number(),
|
|
4264
|
+
start: z19.number(),
|
|
4265
|
+
end: z19.number(),
|
|
4266
|
+
text: z19.string(),
|
|
4267
|
+
tokens: z19.array(z19.number()),
|
|
4268
|
+
temperature: z19.number(),
|
|
4269
|
+
avg_logprob: z19.number(),
|
|
4270
|
+
compression_ratio: z19.number(),
|
|
4271
|
+
no_speech_prob: z19.number()
|
|
4272
|
+
})
|
|
4273
|
+
).nullish()
|
|
4274
|
+
})
|
|
4275
|
+
)
|
|
4276
|
+
);
|
|
3898
4277
|
|
|
3899
4278
|
// src/transcription/openai-transcription-options.ts
|
|
3900
|
-
import {
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
4279
|
+
import {
|
|
4280
|
+
lazyValidator as lazyValidator12,
|
|
4281
|
+
zodSchema as zodSchema18
|
|
4282
|
+
} from "@ai-sdk/provider-utils";
|
|
4283
|
+
import * as z20 from "zod/v4";
|
|
4284
|
+
var openAITranscriptionProviderOptions = lazyValidator12(
|
|
4285
|
+
() => zodSchema18(
|
|
4286
|
+
z20.object({
|
|
4287
|
+
/**
|
|
4288
|
+
* Additional information to include in the transcription response.
|
|
4289
|
+
*/
|
|
4290
|
+
include: z20.array(z20.string()).optional(),
|
|
4291
|
+
/**
|
|
4292
|
+
* The language of the input audio in ISO-639-1 format.
|
|
4293
|
+
*/
|
|
4294
|
+
language: z20.string().optional(),
|
|
4295
|
+
/**
|
|
4296
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
4297
|
+
*/
|
|
4298
|
+
prompt: z20.string().optional(),
|
|
4299
|
+
/**
|
|
4300
|
+
* The sampling temperature, between 0 and 1.
|
|
4301
|
+
* @default 0
|
|
4302
|
+
*/
|
|
4303
|
+
temperature: z20.number().min(0).max(1).default(0).optional(),
|
|
4304
|
+
/**
|
|
4305
|
+
* The timestamp granularities to populate for this transcription.
|
|
4306
|
+
* @default ['segment']
|
|
4307
|
+
*/
|
|
4308
|
+
timestampGranularities: z20.array(z20.enum(["word", "segment"])).default(["segment"]).optional()
|
|
4309
|
+
})
|
|
4310
|
+
)
|
|
4311
|
+
);
|
|
3925
4312
|
|
|
3926
4313
|
// src/transcription/openai-transcription-model.ts
|
|
3927
4314
|
var languageMap = {
|
|
@@ -4089,35 +4476,9 @@ var OpenAITranscriptionModel = class {
|
|
|
4089
4476
|
};
|
|
4090
4477
|
}
|
|
4091
4478
|
};
|
|
4092
|
-
var openaiTranscriptionResponseSchema = z19.object({
|
|
4093
|
-
text: z19.string(),
|
|
4094
|
-
language: z19.string().nullish(),
|
|
4095
|
-
duration: z19.number().nullish(),
|
|
4096
|
-
words: z19.array(
|
|
4097
|
-
z19.object({
|
|
4098
|
-
word: z19.string(),
|
|
4099
|
-
start: z19.number(),
|
|
4100
|
-
end: z19.number()
|
|
4101
|
-
})
|
|
4102
|
-
).nullish(),
|
|
4103
|
-
segments: z19.array(
|
|
4104
|
-
z19.object({
|
|
4105
|
-
id: z19.number(),
|
|
4106
|
-
seek: z19.number(),
|
|
4107
|
-
start: z19.number(),
|
|
4108
|
-
end: z19.number(),
|
|
4109
|
-
text: z19.string(),
|
|
4110
|
-
tokens: z19.array(z19.number()),
|
|
4111
|
-
temperature: z19.number(),
|
|
4112
|
-
avg_logprob: z19.number(),
|
|
4113
|
-
compression_ratio: z19.number(),
|
|
4114
|
-
no_speech_prob: z19.number()
|
|
4115
|
-
})
|
|
4116
|
-
).nullish()
|
|
4117
|
-
});
|
|
4118
4479
|
|
|
4119
4480
|
// src/version.ts
|
|
4120
|
-
var VERSION = true ? "2.0.
|
|
4481
|
+
var VERSION = true ? "2.0.46" : "0.0.0-test";
|
|
4121
4482
|
|
|
4122
4483
|
// src/openai-provider.ts
|
|
4123
4484
|
function createOpenAI(options = {}) {
|