@ai-sdk/openai 4.0.56 → 4.0.58
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 +14 -0
- package/dist/index.d.ts +19 -16
- package/dist/index.js +94 -63
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +31 -22
- package/dist/internal/index.js +39 -46
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +4 -2
- package/package.json +1 -1
- package/src/chat/openai-chat-language-model-options.ts +2 -1
- package/src/openai-responses-batch.ts +60 -5
- package/src/responses/convert-openai-responses-usage.ts +17 -12
- package/src/responses/openai-responses-api.ts +43 -62
- package/src/responses/openai-responses-language-model-options.ts +2 -1
- package/src/responses/openai-responses-prepare-tools.ts +1 -0
- package/src/tool/image-generation.ts +16 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.58
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b54e551: fix(openai): support documented Responses image generation options
|
|
8
|
+
- 17d3436: feat(openai): add support for ultrafast service tier
|
|
9
|
+
|
|
10
|
+
## 4.0.57
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 048ce06: feat(batch): surface the uploaded input file on the batch start result (`providerMetadata.<provider>.inputFileId` / `inputFileExpiresAt`) and accept an `inputFileExpiresAfter` provider option on the OpenAI and xAI batch input file upload
|
|
15
|
+
- 7243530: fix(openai): preserve complete Responses API raw usage objects
|
|
16
|
+
|
|
3
17
|
## 4.0.56
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
|
|
|
15
15
|
store?: boolean | undefined;
|
|
16
16
|
metadata?: Record<string, string> | undefined;
|
|
17
17
|
prediction?: Record<string, any> | undefined;
|
|
18
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
|
|
18
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
|
|
19
19
|
strictJsonSchema?: boolean | undefined;
|
|
20
20
|
textVerbosity?: "low" | "medium" | "high" | undefined;
|
|
21
21
|
promptCacheKey?: string | undefined;
|
|
@@ -255,20 +255,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
255
255
|
incomplete_details?: {
|
|
256
256
|
reason: string;
|
|
257
257
|
} | null | undefined;
|
|
258
|
-
usage?: {
|
|
258
|
+
usage?: (Record<string, JSONValue | undefined> & {
|
|
259
259
|
input_tokens: number;
|
|
260
260
|
output_tokens: number;
|
|
261
|
-
input_tokens_details?: {
|
|
261
|
+
input_tokens_details?: (Record<string, JSONValue | undefined> & {
|
|
262
262
|
cached_tokens?: number | null | undefined;
|
|
263
263
|
cache_write_tokens?: number | null | undefined;
|
|
264
264
|
orchestration_input_tokens?: number | null | undefined;
|
|
265
265
|
orchestration_input_cached_tokens?: number | null | undefined;
|
|
266
|
-
} | null | undefined;
|
|
267
|
-
output_tokens_details?: {
|
|
266
|
+
}) | null | undefined;
|
|
267
|
+
output_tokens_details?: (Record<string, JSONValue | undefined> & {
|
|
268
268
|
reasoning_tokens?: number | null | undefined;
|
|
269
269
|
orchestration_output_tokens?: number | null | undefined;
|
|
270
|
-
} | null | undefined;
|
|
271
|
-
|
|
270
|
+
}) | null | undefined;
|
|
271
|
+
total_tokens?: number | undefined;
|
|
272
|
+
}) | null | undefined;
|
|
272
273
|
reasoning?: {
|
|
273
274
|
context?: string | null | undefined;
|
|
274
275
|
} | null | undefined;
|
|
@@ -285,20 +286,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
285
286
|
incomplete_details?: {
|
|
286
287
|
reason: string;
|
|
287
288
|
} | null | undefined;
|
|
288
|
-
usage?: {
|
|
289
|
+
usage?: (Record<string, JSONValue | undefined> & {
|
|
289
290
|
input_tokens: number;
|
|
290
291
|
output_tokens: number;
|
|
291
|
-
input_tokens_details?: {
|
|
292
|
+
input_tokens_details?: (Record<string, JSONValue | undefined> & {
|
|
292
293
|
cached_tokens?: number | null | undefined;
|
|
293
294
|
cache_write_tokens?: number | null | undefined;
|
|
294
295
|
orchestration_input_tokens?: number | null | undefined;
|
|
295
296
|
orchestration_input_cached_tokens?: number | null | undefined;
|
|
296
|
-
} | null | undefined;
|
|
297
|
-
output_tokens_details?: {
|
|
297
|
+
}) | null | undefined;
|
|
298
|
+
output_tokens_details?: (Record<string, JSONValue | undefined> & {
|
|
298
299
|
reasoning_tokens?: number | null | undefined;
|
|
299
300
|
orchestration_output_tokens?: number | null | undefined;
|
|
300
|
-
} | null | undefined;
|
|
301
|
-
|
|
301
|
+
}) | null | undefined;
|
|
302
|
+
total_tokens?: number | undefined;
|
|
303
|
+
}) | null | undefined;
|
|
302
304
|
reasoning?: {
|
|
303
305
|
context?: string | null | undefined;
|
|
304
306
|
} | null | undefined;
|
|
@@ -1126,6 +1128,7 @@ declare const openaiTools: {
|
|
|
1126
1128
|
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
1127
1129
|
*/
|
|
1128
1130
|
imageGeneration: (args?: {
|
|
1131
|
+
action?: "generate" | "edit" | "auto";
|
|
1129
1132
|
background?: "auto" | "opaque" | "transparent";
|
|
1130
1133
|
inputFidelity?: "low" | "high";
|
|
1131
1134
|
inputImageMask?: {
|
|
@@ -1133,12 +1136,12 @@ declare const openaiTools: {
|
|
|
1133
1136
|
imageUrl?: string;
|
|
1134
1137
|
};
|
|
1135
1138
|
model?: string;
|
|
1136
|
-
moderation?: "auto";
|
|
1139
|
+
moderation?: "auto" | "low";
|
|
1137
1140
|
outputCompression?: number;
|
|
1138
1141
|
outputFormat?: "png" | "jpeg" | "webp";
|
|
1139
1142
|
partialImages?: number;
|
|
1140
1143
|
quality?: "auto" | "low" | "medium" | "high";
|
|
1141
|
-
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024";
|
|
1144
|
+
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | (string & {});
|
|
1142
1145
|
}) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
1143
1146
|
result: string;
|
|
1144
1147
|
}, {}>;
|
|
@@ -1383,7 +1386,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1383
1386
|
reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
|
|
1384
1387
|
reasoningSummary?: string | null | undefined;
|
|
1385
1388
|
safetyIdentifier?: string | null | undefined;
|
|
1386
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
|
|
1389
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | null | undefined;
|
|
1387
1390
|
store?: boolean | null | undefined;
|
|
1388
1391
|
passThroughUnsupportedFiles?: boolean | undefined;
|
|
1389
1392
|
strictJsonSchema?: boolean | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -837,11 +837,12 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
837
837
|
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
838
838
|
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
839
839
|
* - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
|
|
840
|
+
* - 'ultrafast': Access-controlled Ultrafast processing. Only available for gpt-5.6-sol.
|
|
840
841
|
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
841
842
|
*
|
|
842
843
|
* @default 'auto'
|
|
843
844
|
*/
|
|
844
|
-
serviceTier: z3.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
845
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).optional(),
|
|
845
846
|
/**
|
|
846
847
|
* Whether to use strict JSON schema validation.
|
|
847
848
|
*
|
|
@@ -2957,6 +2958,7 @@ import { z as z17 } from "zod/v4";
|
|
|
2957
2958
|
var imageGenerationArgsSchema = lazySchema16(
|
|
2958
2959
|
() => zodSchema16(
|
|
2959
2960
|
z17.object({
|
|
2961
|
+
action: z17.enum(["generate", "edit", "auto"]).optional(),
|
|
2960
2962
|
background: z17.enum(["auto", "opaque", "transparent"]).optional(),
|
|
2961
2963
|
inputFidelity: z17.enum(["low", "high"]).optional(),
|
|
2962
2964
|
inputImageMask: z17.object({
|
|
@@ -2964,12 +2966,15 @@ var imageGenerationArgsSchema = lazySchema16(
|
|
|
2964
2966
|
imageUrl: z17.string().optional()
|
|
2965
2967
|
}).optional(),
|
|
2966
2968
|
model: z17.string().optional(),
|
|
2967
|
-
moderation: z17.enum(["auto"]).optional(),
|
|
2969
|
+
moderation: z17.enum(["auto", "low"]).optional(),
|
|
2968
2970
|
outputCompression: z17.number().int().min(0).max(100).optional(),
|
|
2969
2971
|
outputFormat: z17.enum(["png", "jpeg", "webp"]).optional(),
|
|
2970
2972
|
partialImages: z17.number().int().min(0).max(3).optional(),
|
|
2971
2973
|
quality: z17.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2972
|
-
size: z17.
|
|
2974
|
+
size: z17.union([
|
|
2975
|
+
z17.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
|
|
2976
|
+
z17.string().regex(/^\d+x\d+$/)
|
|
2977
|
+
]).optional()
|
|
2973
2978
|
}).strict()
|
|
2974
2979
|
)
|
|
2975
2980
|
);
|
|
@@ -3529,6 +3534,7 @@ import {
|
|
|
3529
3534
|
getFromApi as getFromApi2,
|
|
3530
3535
|
lazySchema as lazySchema26,
|
|
3531
3536
|
normalizeBatchRequestCounts,
|
|
3537
|
+
parseProviderOptions as parseProviderOptions8,
|
|
3532
3538
|
postJsonToApi as postJsonToApi6,
|
|
3533
3539
|
postToApi,
|
|
3534
3540
|
safeValidateTypes,
|
|
@@ -3623,6 +3629,31 @@ var jsonValueSchema2 = z25.lazy(
|
|
|
3623
3629
|
z25.record(z25.string(), jsonValueSchema2.optional())
|
|
3624
3630
|
])
|
|
3625
3631
|
);
|
|
3632
|
+
var jsonObjectSchema = z25.record(z25.string(), jsonValueSchema2.optional());
|
|
3633
|
+
var openaiResponsesUsageSchema = z25.intersection(
|
|
3634
|
+
jsonObjectSchema,
|
|
3635
|
+
z25.object({
|
|
3636
|
+
input_tokens: z25.number(),
|
|
3637
|
+
input_tokens_details: z25.intersection(
|
|
3638
|
+
jsonObjectSchema,
|
|
3639
|
+
z25.object({
|
|
3640
|
+
cached_tokens: z25.number().nullish(),
|
|
3641
|
+
cache_write_tokens: z25.number().nullish(),
|
|
3642
|
+
orchestration_input_tokens: z25.number().nullish(),
|
|
3643
|
+
orchestration_input_cached_tokens: z25.number().nullish()
|
|
3644
|
+
})
|
|
3645
|
+
).nullish(),
|
|
3646
|
+
output_tokens: z25.number(),
|
|
3647
|
+
output_tokens_details: z25.intersection(
|
|
3648
|
+
jsonObjectSchema,
|
|
3649
|
+
z25.object({
|
|
3650
|
+
reasoning_tokens: z25.number().nullish(),
|
|
3651
|
+
orchestration_output_tokens: z25.number().nullish()
|
|
3652
|
+
})
|
|
3653
|
+
).nullish(),
|
|
3654
|
+
total_tokens: z25.number().optional()
|
|
3655
|
+
})
|
|
3656
|
+
);
|
|
3626
3657
|
var openaiResponsesComputerSafetyCheckSchema = z25.object({
|
|
3627
3658
|
id: z25.string(),
|
|
3628
3659
|
code: z25.string().nullish(),
|
|
@@ -3819,20 +3850,7 @@ var openaiResponsesChunkSchema = lazySchema24(
|
|
|
3819
3850
|
type: z25.enum(["response.completed", "response.incomplete"]),
|
|
3820
3851
|
response: z25.object({
|
|
3821
3852
|
incomplete_details: z25.object({ reason: z25.string() }).nullish(),
|
|
3822
|
-
usage:
|
|
3823
|
-
input_tokens: z25.number(),
|
|
3824
|
-
input_tokens_details: z25.object({
|
|
3825
|
-
cached_tokens: z25.number().nullish(),
|
|
3826
|
-
cache_write_tokens: z25.number().nullish(),
|
|
3827
|
-
orchestration_input_tokens: z25.number().nullish(),
|
|
3828
|
-
orchestration_input_cached_tokens: z25.number().nullish()
|
|
3829
|
-
}).nullish(),
|
|
3830
|
-
output_tokens: z25.number(),
|
|
3831
|
-
output_tokens_details: z25.object({
|
|
3832
|
-
reasoning_tokens: z25.number().nullish(),
|
|
3833
|
-
orchestration_output_tokens: z25.number().nullish()
|
|
3834
|
-
}).nullish()
|
|
3835
|
-
}).nullish(),
|
|
3853
|
+
usage: openaiResponsesUsageSchema.nullish(),
|
|
3836
3854
|
reasoning: z25.object({
|
|
3837
3855
|
context: z25.string().nullish()
|
|
3838
3856
|
}).nullish(),
|
|
@@ -3848,20 +3866,7 @@ var openaiResponsesChunkSchema = lazySchema24(
|
|
|
3848
3866
|
message: z25.string()
|
|
3849
3867
|
}).nullish(),
|
|
3850
3868
|
incomplete_details: z25.object({ reason: z25.string() }).nullish(),
|
|
3851
|
-
usage:
|
|
3852
|
-
input_tokens: z25.number(),
|
|
3853
|
-
input_tokens_details: z25.object({
|
|
3854
|
-
cached_tokens: z25.number().nullish(),
|
|
3855
|
-
cache_write_tokens: z25.number().nullish(),
|
|
3856
|
-
orchestration_input_tokens: z25.number().nullish(),
|
|
3857
|
-
orchestration_input_cached_tokens: z25.number().nullish()
|
|
3858
|
-
}).nullish(),
|
|
3859
|
-
output_tokens: z25.number(),
|
|
3860
|
-
output_tokens_details: z25.object({
|
|
3861
|
-
reasoning_tokens: z25.number().nullish(),
|
|
3862
|
-
orchestration_output_tokens: z25.number().nullish()
|
|
3863
|
-
}).nullish()
|
|
3864
|
-
}).nullish(),
|
|
3869
|
+
usage: openaiResponsesUsageSchema.nullish(),
|
|
3865
3870
|
reasoning: z25.object({
|
|
3866
3871
|
context: z25.string().nullish()
|
|
3867
3872
|
}).nullish(),
|
|
@@ -4651,20 +4656,7 @@ var openaiResponsesResponseSchema = lazySchema24(
|
|
|
4651
4656
|
context: z25.string().nullish()
|
|
4652
4657
|
}).nullish(),
|
|
4653
4658
|
incomplete_details: z25.object({ reason: z25.string() }).nullish(),
|
|
4654
|
-
usage:
|
|
4655
|
-
input_tokens: z25.number(),
|
|
4656
|
-
input_tokens_details: z25.object({
|
|
4657
|
-
cached_tokens: z25.number().nullish(),
|
|
4658
|
-
cache_write_tokens: z25.number().nullish(),
|
|
4659
|
-
orchestration_input_tokens: z25.number().nullish(),
|
|
4660
|
-
orchestration_input_cached_tokens: z25.number().nullish()
|
|
4661
|
-
}).nullish(),
|
|
4662
|
-
output_tokens: z25.number(),
|
|
4663
|
-
output_tokens_details: z25.object({
|
|
4664
|
-
reasoning_tokens: z25.number().nullish(),
|
|
4665
|
-
orchestration_output_tokens: z25.number().nullish()
|
|
4666
|
-
}).nullish()
|
|
4667
|
-
}).nullish()
|
|
4659
|
+
usage: openaiResponsesUsageSchema.nullish()
|
|
4668
4660
|
})
|
|
4669
4661
|
)
|
|
4670
4662
|
);
|
|
@@ -6106,10 +6098,11 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
|
|
|
6106
6098
|
* Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
|
|
6107
6099
|
* Set to 'priority' for faster processing with Enterprise access (available for gpt-4, gpt-5, gpt-5-mini, o3, o4-mini; gpt-5-nano is not supported).
|
|
6108
6100
|
* Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
|
|
6101
|
+
* Set to 'ultrafast' for access-controlled Ultrafast processing (available only for gpt-5.6-sol).
|
|
6109
6102
|
*
|
|
6110
6103
|
* Defaults to 'auto'.
|
|
6111
6104
|
*/
|
|
6112
|
-
serviceTier: z27.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
6105
|
+
serviceTier: z27.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).nullish(),
|
|
6113
6106
|
/**
|
|
6114
6107
|
* Whether to store the generation. Defaults to `true`.
|
|
6115
6108
|
*/
|
|
@@ -6381,6 +6374,7 @@ async function prepareResponsesTools({
|
|
|
6381
6374
|
});
|
|
6382
6375
|
openaiTools2.push({
|
|
6383
6376
|
type: "image_generation",
|
|
6377
|
+
action: args.action,
|
|
6384
6378
|
background: args.background,
|
|
6385
6379
|
input_fidelity: args.inputFidelity,
|
|
6386
6380
|
input_image_mask: args.inputImageMask ? {
|
|
@@ -8924,7 +8918,19 @@ function escapeJSONDelta(delta) {
|
|
|
8924
8918
|
|
|
8925
8919
|
// src/openai-responses-batch.ts
|
|
8926
8920
|
var openaiBatchEndpoint = "/v1/responses";
|
|
8927
|
-
var
|
|
8921
|
+
var openaiBatchInputFileDefaultExpiresAfterSeconds = 48 * 60 * 60;
|
|
8922
|
+
var openaiBatchProviderOptionsSchema = lazySchema26(
|
|
8923
|
+
() => zodSchema26(
|
|
8924
|
+
z28.object({
|
|
8925
|
+
/**
|
|
8926
|
+
* TTL in seconds for the uploaded batch input file, measured from
|
|
8927
|
+
* upload time. OpenAI accepts integers between 3600 (1 hour) and
|
|
8928
|
+
* 2592000 (30 days) inclusive. Defaults to 48 hours.
|
|
8929
|
+
*/
|
|
8930
|
+
inputFileExpiresAfter: z28.number().int().min(3600).max(2592e3).optional()
|
|
8931
|
+
})
|
|
8932
|
+
)
|
|
8933
|
+
);
|
|
8928
8934
|
var openaiBatchResponseSchema = lazySchema26(
|
|
8929
8935
|
() => zodSchema26(
|
|
8930
8936
|
z28.object({
|
|
@@ -8971,7 +8977,7 @@ var OpenAIResponsesBatch = class {
|
|
|
8971
8977
|
this.options = options;
|
|
8972
8978
|
}
|
|
8973
8979
|
async startBatch(options) {
|
|
8974
|
-
var _a2, _b, _c, _d, _e;
|
|
8980
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
8975
8981
|
const fileParts = [];
|
|
8976
8982
|
const warnings = options.webhookUrl == null ? [] : [
|
|
8977
8983
|
{
|
|
@@ -8982,6 +8988,10 @@ var OpenAIResponsesBatch = class {
|
|
|
8982
8988
|
}
|
|
8983
8989
|
}
|
|
8984
8990
|
];
|
|
8991
|
+
const batchOptions = await this.parseBatchProviderOptions(
|
|
8992
|
+
options.providerOptions
|
|
8993
|
+
);
|
|
8994
|
+
const inputFileExpiresAfterSeconds = (_a2 = batchOptions == null ? void 0 : batchOptions.inputFileExpiresAfter) != null ? _a2 : openaiBatchInputFileDefaultExpiresAfterSeconds;
|
|
8985
8995
|
for (const request of options.requests) {
|
|
8986
8996
|
const preparedRequest = await this.options.prepareRequest(request);
|
|
8987
8997
|
fileParts.push(
|
|
@@ -8996,7 +9006,7 @@ var OpenAIResponsesBatch = class {
|
|
|
8996
9006
|
for (const warning of preparedRequest.warnings) {
|
|
8997
9007
|
warnings.push({ requestId: request.id, warning });
|
|
8998
9008
|
}
|
|
8999
|
-
for (const tool of (
|
|
9009
|
+
for (const tool of (_b = request.options.tools) != null ? _b : []) {
|
|
9000
9010
|
if (tool.type === "provider" && !openAIBatchConvertibleProviderToolIds.has(tool.id)) {
|
|
9001
9011
|
warnings.push({
|
|
9002
9012
|
requestId: request.id,
|
|
@@ -9020,19 +9030,17 @@ var OpenAIResponsesBatch = class {
|
|
|
9020
9030
|
formData.append("expires_after[anchor]", "created_at");
|
|
9021
9031
|
formData.append(
|
|
9022
9032
|
"expires_after[seconds]",
|
|
9023
|
-
String(
|
|
9033
|
+
String(inputFileExpiresAfterSeconds)
|
|
9024
9034
|
);
|
|
9025
9035
|
const { value: uploadedFile } = await postToApi({
|
|
9026
9036
|
url: this.getUrl("/files"),
|
|
9027
|
-
headers: combineHeaders7((
|
|
9037
|
+
headers: combineHeaders7((_d = (_c = this.options.config).headers) == null ? void 0 : _d.call(_c), options.headers),
|
|
9028
9038
|
body: {
|
|
9029
9039
|
content: formData,
|
|
9030
9040
|
values: {
|
|
9031
9041
|
purpose: "batch",
|
|
9032
9042
|
"expires_after[anchor]": "created_at",
|
|
9033
|
-
"expires_after[seconds]": String(
|
|
9034
|
-
openaiBatchInputFileExpiresAfterSeconds
|
|
9035
|
-
),
|
|
9043
|
+
"expires_after[seconds]": String(inputFileExpiresAfterSeconds),
|
|
9036
9044
|
file: {
|
|
9037
9045
|
name: filename,
|
|
9038
9046
|
type: file.type,
|
|
@@ -9049,7 +9057,7 @@ var OpenAIResponsesBatch = class {
|
|
|
9049
9057
|
});
|
|
9050
9058
|
const { value: batch } = await postJsonToApi6({
|
|
9051
9059
|
url: this.getUrl("/batches"),
|
|
9052
|
-
headers: combineHeaders7((
|
|
9060
|
+
headers: combineHeaders7((_f = (_e = this.options.config).headers) == null ? void 0 : _f.call(_e), options.headers),
|
|
9053
9061
|
body: {
|
|
9054
9062
|
input_file_id: uploadedFile.id,
|
|
9055
9063
|
endpoint: openaiBatchEndpoint,
|
|
@@ -9062,12 +9070,35 @@ var OpenAIResponsesBatch = class {
|
|
|
9062
9070
|
abortSignal: options.abortSignal,
|
|
9063
9071
|
fetch: this.options.config.fetch
|
|
9064
9072
|
});
|
|
9073
|
+
const inputFileExpiresAt = convertUnixTimestamp(uploadedFile.expires_at);
|
|
9065
9074
|
return {
|
|
9066
9075
|
batchId: batch.id,
|
|
9067
9076
|
...convertOpenAIBatchStatus(batch),
|
|
9077
|
+
providerMetadata: {
|
|
9078
|
+
openai: {
|
|
9079
|
+
inputFileId: uploadedFile.id,
|
|
9080
|
+
...inputFileExpiresAt != null ? { inputFileExpiresAt } : {}
|
|
9081
|
+
}
|
|
9082
|
+
},
|
|
9068
9083
|
warnings
|
|
9069
9084
|
};
|
|
9070
9085
|
}
|
|
9086
|
+
async parseBatchProviderOptions(providerOptions) {
|
|
9087
|
+
const providerOptionsName = this.options.config.provider.includes("azure") ? "azure" : "openai";
|
|
9088
|
+
let batchOptions = await parseProviderOptions8({
|
|
9089
|
+
provider: providerOptionsName,
|
|
9090
|
+
providerOptions,
|
|
9091
|
+
schema: openaiBatchProviderOptionsSchema
|
|
9092
|
+
});
|
|
9093
|
+
if (batchOptions == null && providerOptionsName !== "openai") {
|
|
9094
|
+
batchOptions = await parseProviderOptions8({
|
|
9095
|
+
provider: "openai",
|
|
9096
|
+
providerOptions,
|
|
9097
|
+
schema: openaiBatchProviderOptionsSchema
|
|
9098
|
+
});
|
|
9099
|
+
}
|
|
9100
|
+
return batchOptions;
|
|
9101
|
+
}
|
|
9071
9102
|
async getBatchStatus(options) {
|
|
9072
9103
|
const batch = await this.retrieveBatch(options);
|
|
9073
9104
|
return convertOpenAIBatchStatus(batch);
|
|
@@ -9896,7 +9927,7 @@ var OpenAIRealtimeModel = class {
|
|
|
9896
9927
|
import {
|
|
9897
9928
|
combineHeaders as combineHeaders8,
|
|
9898
9929
|
createBinaryResponseHandler,
|
|
9899
|
-
parseProviderOptions as
|
|
9930
|
+
parseProviderOptions as parseProviderOptions9,
|
|
9900
9931
|
postJsonToApi as postJsonToApi7,
|
|
9901
9932
|
serializeModelOptions as serializeModelOptions6,
|
|
9902
9933
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
|
|
@@ -9947,7 +9978,7 @@ var OpenAISpeechModel = class _OpenAISpeechModel {
|
|
|
9947
9978
|
providerOptions
|
|
9948
9979
|
}) {
|
|
9949
9980
|
const warnings = [];
|
|
9950
|
-
const openAIOptions = await
|
|
9981
|
+
const openAIOptions = await parseProviderOptions9({
|
|
9951
9982
|
provider: "openai",
|
|
9952
9983
|
providerOptions,
|
|
9953
9984
|
schema: openaiSpeechModelOptionsSchema
|
|
@@ -10039,7 +10070,7 @@ import {
|
|
|
10039
10070
|
createJsonResponseHandler as createJsonResponseHandler8,
|
|
10040
10071
|
connectToWebSocket,
|
|
10041
10072
|
mediaTypeToExtension,
|
|
10042
|
-
parseProviderOptions as
|
|
10073
|
+
parseProviderOptions as parseProviderOptions10,
|
|
10043
10074
|
postFormDataToApi as postFormDataToApi3,
|
|
10044
10075
|
safeParseJSON as safeParseJSON2,
|
|
10045
10076
|
serializeModelOptions as serializeModelOptions7,
|
|
@@ -10218,7 +10249,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10218
10249
|
providerOptions
|
|
10219
10250
|
}) {
|
|
10220
10251
|
const warnings = [];
|
|
10221
|
-
const openAIOptions = await
|
|
10252
|
+
const openAIOptions = await parseProviderOptions10({
|
|
10222
10253
|
provider: "openai",
|
|
10223
10254
|
providerOptions,
|
|
10224
10255
|
schema: openAITranscriptionModelOptions
|
|
@@ -10327,7 +10358,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10327
10358
|
});
|
|
10328
10359
|
}
|
|
10329
10360
|
const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
10330
|
-
const openAIOptions = await
|
|
10361
|
+
const openAIOptions = await parseProviderOptions10({
|
|
10331
10362
|
provider: "openai",
|
|
10332
10363
|
providerOptions: options.providerOptions,
|
|
10333
10364
|
schema: openAITranscriptionModelOptions
|
|
@@ -10569,7 +10600,7 @@ import {
|
|
|
10569
10600
|
combineHeaders as combineHeaders10,
|
|
10570
10601
|
connectToWebSocket as connectToWebSocket2,
|
|
10571
10602
|
convertToBase64 as convertToBase644,
|
|
10572
|
-
parseProviderOptions as
|
|
10603
|
+
parseProviderOptions as parseProviderOptions11,
|
|
10573
10604
|
safeParseJSON as safeParseJSON3,
|
|
10574
10605
|
serializeModelOptions as serializeModelOptions8,
|
|
10575
10606
|
toWebSocketUrl as toWebSocketUrl2,
|
|
@@ -10616,7 +10647,7 @@ var OpenAISpeechTranslationModel = class _OpenAISpeechTranslationModel {
|
|
|
10616
10647
|
});
|
|
10617
10648
|
}
|
|
10618
10649
|
const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
10619
|
-
await
|
|
10650
|
+
await parseProviderOptions11({
|
|
10620
10651
|
provider: "openai",
|
|
10621
10652
|
providerOptions: options.providerOptions,
|
|
10622
10653
|
schema: openAISpeechTranslationModelOptions
|
|
@@ -10963,7 +10994,7 @@ var OpenAISkills = class {
|
|
|
10963
10994
|
};
|
|
10964
10995
|
|
|
10965
10996
|
// src/version.ts
|
|
10966
|
-
var VERSION = true ? "4.0.
|
|
10997
|
+
var VERSION = true ? "4.0.58" : "0.0.0-test";
|
|
10967
10998
|
|
|
10968
10999
|
// src/openai-provider.ts
|
|
10969
11000
|
function createOpenAI(options = {}) {
|