@discomedia/utils 1.0.60 → 1.0.62
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/dist/index-frontend.cjs +297 -62
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +297 -62
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +297 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +297 -62
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +215 -43
- package/dist/test.js.map +1 -1
- package/dist/types/llm-config.d.ts +3 -3
- package/dist/types/llm-config.d.ts.map +1 -1
- package/dist/types/llm-images.d.ts.map +1 -1
- package/dist/types/llm-openai.d.ts.map +1 -1
- package/dist/types/types/llm-types.d.ts +3 -3
- package/dist/types/types/llm-types.d.ts.map +1 -1
- package/dist/types-frontend/llm-config.d.ts +3 -3
- package/dist/types-frontend/llm-config.d.ts.map +1 -1
- package/dist/types-frontend/llm-images.d.ts.map +1 -1
- package/dist/types-frontend/llm-openai.d.ts.map +1 -1
- package/dist/types-frontend/types/llm-types.d.ts +3 -3
- package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index-frontend.mjs
CHANGED
|
@@ -7,6 +7,8 @@ function isOpenRouterModel(model) {
|
|
|
7
7
|
'openai/gpt-5-mini',
|
|
8
8
|
'openai/gpt-5-nano',
|
|
9
9
|
'openai/gpt-5.1',
|
|
10
|
+
'openai/gpt-5.4',
|
|
11
|
+
'openai/gpt-5.4-pro',
|
|
10
12
|
'openai/gpt-5.2',
|
|
11
13
|
'openai/gpt-5.2-pro',
|
|
12
14
|
'openai/gpt-5.1-codex',
|
|
@@ -258,7 +260,7 @@ const safeJSON = (text) => {
|
|
|
258
260
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
259
261
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
260
262
|
|
|
261
|
-
const VERSION = '6.
|
|
263
|
+
const VERSION = '6.27.0'; // x-release-please-version
|
|
262
264
|
|
|
263
265
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
264
266
|
const isRunningInBrowser = () => {
|
|
@@ -878,6 +880,11 @@ function stringify(object, opts = {}) {
|
|
|
878
880
|
return joined.length > 0 ? prefix + joined : '';
|
|
879
881
|
}
|
|
880
882
|
|
|
883
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
884
|
+
function stringifyQuery(query) {
|
|
885
|
+
return stringify(query, { arrayFormat: 'brackets' });
|
|
886
|
+
}
|
|
887
|
+
|
|
881
888
|
function concatBytes(buffers) {
|
|
882
889
|
let length = 0;
|
|
883
890
|
for (const buffer of buffers) {
|
|
@@ -1096,7 +1103,7 @@ class Stream {
|
|
|
1096
1103
|
this.controller = controller;
|
|
1097
1104
|
__classPrivateFieldSet(this, _Stream_client, client);
|
|
1098
1105
|
}
|
|
1099
|
-
static fromSSEResponse(response, controller, client) {
|
|
1106
|
+
static fromSSEResponse(response, controller, client, synthesizeEventData) {
|
|
1100
1107
|
let consumed = false;
|
|
1101
1108
|
const logger = client ? loggerFor(client) : console;
|
|
1102
1109
|
async function* iterator() {
|
|
@@ -1126,7 +1133,7 @@ class Stream {
|
|
|
1126
1133
|
if (data && data.error) {
|
|
1127
1134
|
throw new APIError(undefined, data.error, undefined, response.headers);
|
|
1128
1135
|
}
|
|
1129
|
-
yield data;
|
|
1136
|
+
yield synthesizeEventData ? { event: sse.event, data } : data;
|
|
1130
1137
|
}
|
|
1131
1138
|
else {
|
|
1132
1139
|
let data;
|
|
@@ -1376,9 +1383,9 @@ async function defaultParseResponse(client, props) {
|
|
|
1376
1383
|
// Note: there is an invariant here that isn't represented in the type system
|
|
1377
1384
|
// that if you set `stream: true` the response type must also be `Stream<T>`
|
|
1378
1385
|
if (props.options.__streamClass) {
|
|
1379
|
-
return props.options.__streamClass.fromSSEResponse(response, props.controller, client);
|
|
1386
|
+
return props.options.__streamClass.fromSSEResponse(response, props.controller, client, props.options.__synthesizeEventData);
|
|
1380
1387
|
}
|
|
1381
|
-
return Stream.fromSSEResponse(response, props.controller, client);
|
|
1388
|
+
return Stream.fromSSEResponse(response, props.controller, client, props.options.__synthesizeEventData);
|
|
1382
1389
|
}
|
|
1383
1390
|
// fetch refuses to read the body when the status code is 204.
|
|
1384
1391
|
if (response.status === 204) {
|
|
@@ -1931,6 +1938,9 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(sta
|
|
|
1931
1938
|
const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
1932
1939
|
|
|
1933
1940
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1941
|
+
/**
|
|
1942
|
+
* Given a list of messages comprising a conversation, the model will return a response.
|
|
1943
|
+
*/
|
|
1934
1944
|
let Messages$1 = class Messages extends APIResource {
|
|
1935
1945
|
/**
|
|
1936
1946
|
* Get the messages in a stored chat completion. Only Chat Completions that have
|
|
@@ -3293,6 +3303,9 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
|
|
|
3293
3303
|
}
|
|
3294
3304
|
|
|
3295
3305
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3306
|
+
/**
|
|
3307
|
+
* Given a list of messages comprising a conversation, the model will return a response.
|
|
3308
|
+
*/
|
|
3296
3309
|
let Completions$1 = class Completions extends APIResource {
|
|
3297
3310
|
constructor() {
|
|
3298
3311
|
super(...arguments);
|
|
@@ -3463,10 +3476,15 @@ const buildHeaders = (newHeaders) => {
|
|
|
3463
3476
|
};
|
|
3464
3477
|
|
|
3465
3478
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3479
|
+
/**
|
|
3480
|
+
* Turn audio into text or text into audio.
|
|
3481
|
+
*/
|
|
3466
3482
|
class Speech extends APIResource {
|
|
3467
3483
|
/**
|
|
3468
3484
|
* Generates audio from the input text.
|
|
3469
3485
|
*
|
|
3486
|
+
* Returns the audio file content, or a stream of audio events.
|
|
3487
|
+
*
|
|
3470
3488
|
* @example
|
|
3471
3489
|
* ```ts
|
|
3472
3490
|
* const speech = await client.audio.speech.create({
|
|
@@ -3490,6 +3508,9 @@ class Speech extends APIResource {
|
|
|
3490
3508
|
}
|
|
3491
3509
|
|
|
3492
3510
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3511
|
+
/**
|
|
3512
|
+
* Turn audio into text or text into audio.
|
|
3513
|
+
*/
|
|
3493
3514
|
class Transcriptions extends APIResource {
|
|
3494
3515
|
create(body, options) {
|
|
3495
3516
|
return this._client.post('/audio/transcriptions', multipartFormRequestOptions({
|
|
@@ -3502,6 +3523,9 @@ class Transcriptions extends APIResource {
|
|
|
3502
3523
|
}
|
|
3503
3524
|
|
|
3504
3525
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3526
|
+
/**
|
|
3527
|
+
* Turn audio into text or text into audio.
|
|
3528
|
+
*/
|
|
3505
3529
|
class Translations extends APIResource {
|
|
3506
3530
|
create(body, options) {
|
|
3507
3531
|
return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
|
|
@@ -3522,6 +3546,9 @@ Audio.Translations = Translations;
|
|
|
3522
3546
|
Audio.Speech = Speech;
|
|
3523
3547
|
|
|
3524
3548
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3549
|
+
/**
|
|
3550
|
+
* Create large batches of API requests to run asynchronously.
|
|
3551
|
+
*/
|
|
3525
3552
|
class Batches extends APIResource {
|
|
3526
3553
|
/**
|
|
3527
3554
|
* Creates and executes a batch from an uploaded file of requests
|
|
@@ -3552,6 +3579,9 @@ class Batches extends APIResource {
|
|
|
3552
3579
|
}
|
|
3553
3580
|
|
|
3554
3581
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3582
|
+
/**
|
|
3583
|
+
* Build Assistants that can call models and use tools.
|
|
3584
|
+
*/
|
|
3555
3585
|
class Assistants extends APIResource {
|
|
3556
3586
|
/**
|
|
3557
3587
|
* Create an assistant with a model and instructions.
|
|
@@ -3682,7 +3712,7 @@ Realtime$1.TranscriptionSessions = TranscriptionSessions;
|
|
|
3682
3712
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3683
3713
|
class Sessions extends APIResource {
|
|
3684
3714
|
/**
|
|
3685
|
-
* Create a ChatKit session
|
|
3715
|
+
* Create a ChatKit session.
|
|
3686
3716
|
*
|
|
3687
3717
|
* @example
|
|
3688
3718
|
* ```ts
|
|
@@ -3701,7 +3731,9 @@ class Sessions extends APIResource {
|
|
|
3701
3731
|
});
|
|
3702
3732
|
}
|
|
3703
3733
|
/**
|
|
3704
|
-
* Cancel
|
|
3734
|
+
* Cancel an active ChatKit session and return its most recent metadata.
|
|
3735
|
+
*
|
|
3736
|
+
* Cancelling prevents new requests from using the issued client secret.
|
|
3705
3737
|
*
|
|
3706
3738
|
* @example
|
|
3707
3739
|
* ```ts
|
|
@@ -3720,7 +3752,7 @@ class Sessions extends APIResource {
|
|
|
3720
3752
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3721
3753
|
let Threads$1 = class Threads extends APIResource {
|
|
3722
3754
|
/**
|
|
3723
|
-
* Retrieve a ChatKit thread
|
|
3755
|
+
* Retrieve a ChatKit thread by its identifier.
|
|
3724
3756
|
*
|
|
3725
3757
|
* @example
|
|
3726
3758
|
* ```ts
|
|
@@ -3735,7 +3767,7 @@ let Threads$1 = class Threads extends APIResource {
|
|
|
3735
3767
|
});
|
|
3736
3768
|
}
|
|
3737
3769
|
/**
|
|
3738
|
-
* List ChatKit threads
|
|
3770
|
+
* List ChatKit threads with optional pagination and user filters.
|
|
3739
3771
|
*
|
|
3740
3772
|
* @example
|
|
3741
3773
|
* ```ts
|
|
@@ -3753,7 +3785,7 @@ let Threads$1 = class Threads extends APIResource {
|
|
|
3753
3785
|
});
|
|
3754
3786
|
}
|
|
3755
3787
|
/**
|
|
3756
|
-
* Delete a ChatKit thread
|
|
3788
|
+
* Delete a ChatKit thread along with its items and stored attachments.
|
|
3757
3789
|
*
|
|
3758
3790
|
* @example
|
|
3759
3791
|
* ```ts
|
|
@@ -3769,7 +3801,7 @@ let Threads$1 = class Threads extends APIResource {
|
|
|
3769
3801
|
});
|
|
3770
3802
|
}
|
|
3771
3803
|
/**
|
|
3772
|
-
* List ChatKit thread
|
|
3804
|
+
* List items that belong to a ChatKit thread.
|
|
3773
3805
|
*
|
|
3774
3806
|
* @example
|
|
3775
3807
|
* ```ts
|
|
@@ -3799,6 +3831,8 @@ ChatKit.Threads = Threads$1;
|
|
|
3799
3831
|
|
|
3800
3832
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3801
3833
|
/**
|
|
3834
|
+
* Build Assistants that can call models and use tools.
|
|
3835
|
+
*
|
|
3802
3836
|
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
|
3803
3837
|
*/
|
|
3804
3838
|
class Messages extends APIResource {
|
|
@@ -3867,6 +3901,8 @@ class Messages extends APIResource {
|
|
|
3867
3901
|
|
|
3868
3902
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3869
3903
|
/**
|
|
3904
|
+
* Build Assistants that can call models and use tools.
|
|
3905
|
+
*
|
|
3870
3906
|
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
|
3871
3907
|
*/
|
|
3872
3908
|
class Steps extends APIResource {
|
|
@@ -4479,6 +4515,8 @@ _a$1 = AssistantStream, _AssistantStream_addEvent = function _AssistantStream_ad
|
|
|
4479
4515
|
|
|
4480
4516
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4481
4517
|
/**
|
|
4518
|
+
* Build Assistants that can call models and use tools.
|
|
4519
|
+
*
|
|
4482
4520
|
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
|
4483
4521
|
*/
|
|
4484
4522
|
let Runs$1 = class Runs extends APIResource {
|
|
@@ -4494,6 +4532,7 @@ let Runs$1 = class Runs extends APIResource {
|
|
|
4494
4532
|
...options,
|
|
4495
4533
|
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
|
|
4496
4534
|
stream: params.stream ?? false,
|
|
4535
|
+
__synthesizeEventData: true,
|
|
4497
4536
|
});
|
|
4498
4537
|
}
|
|
4499
4538
|
/**
|
|
@@ -4624,6 +4663,7 @@ let Runs$1 = class Runs extends APIResource {
|
|
|
4624
4663
|
...options,
|
|
4625
4664
|
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
|
|
4626
4665
|
stream: params.stream ?? false,
|
|
4666
|
+
__synthesizeEventData: true,
|
|
4627
4667
|
});
|
|
4628
4668
|
}
|
|
4629
4669
|
/**
|
|
@@ -4648,6 +4688,8 @@ Runs$1.Steps = Steps;
|
|
|
4648
4688
|
|
|
4649
4689
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4650
4690
|
/**
|
|
4691
|
+
* Build Assistants that can call models and use tools.
|
|
4692
|
+
*
|
|
4651
4693
|
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
|
4652
4694
|
*/
|
|
4653
4695
|
class Threads extends APIResource {
|
|
@@ -4708,6 +4750,7 @@ class Threads extends APIResource {
|
|
|
4708
4750
|
...options,
|
|
4709
4751
|
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
|
|
4710
4752
|
stream: body.stream ?? false,
|
|
4753
|
+
__synthesizeEventData: true,
|
|
4711
4754
|
});
|
|
4712
4755
|
}
|
|
4713
4756
|
/**
|
|
@@ -4745,6 +4788,9 @@ Beta.Assistants = Assistants;
|
|
|
4745
4788
|
Beta.Threads = Threads;
|
|
4746
4789
|
|
|
4747
4790
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4791
|
+
/**
|
|
4792
|
+
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
|
|
4793
|
+
*/
|
|
4748
4794
|
class Completions extends APIResource {
|
|
4749
4795
|
create(body, options) {
|
|
4750
4796
|
return this._client.post('/completions', { body, ...options, stream: body.stream ?? false });
|
|
@@ -4847,6 +4893,9 @@ class Containers extends APIResource {
|
|
|
4847
4893
|
Containers.Files = Files$2;
|
|
4848
4894
|
|
|
4849
4895
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4896
|
+
/**
|
|
4897
|
+
* Manage conversations and conversation items.
|
|
4898
|
+
*/
|
|
4850
4899
|
class Items extends APIResource {
|
|
4851
4900
|
/**
|
|
4852
4901
|
* Create items in a conversation with the given ID.
|
|
@@ -4882,6 +4931,9 @@ class Items extends APIResource {
|
|
|
4882
4931
|
}
|
|
4883
4932
|
|
|
4884
4933
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4934
|
+
/**
|
|
4935
|
+
* Manage conversations and conversation items.
|
|
4936
|
+
*/
|
|
4885
4937
|
class Conversations extends APIResource {
|
|
4886
4938
|
constructor() {
|
|
4887
4939
|
super(...arguments);
|
|
@@ -4915,6 +4967,9 @@ class Conversations extends APIResource {
|
|
|
4915
4967
|
Conversations.Items = Items;
|
|
4916
4968
|
|
|
4917
4969
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4970
|
+
/**
|
|
4971
|
+
* Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
|
|
4972
|
+
*/
|
|
4918
4973
|
class Embeddings extends APIResource {
|
|
4919
4974
|
/**
|
|
4920
4975
|
* Creates an embedding vector representing the input text.
|
|
@@ -4965,6 +5020,9 @@ class Embeddings extends APIResource {
|
|
|
4965
5020
|
}
|
|
4966
5021
|
|
|
4967
5022
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5023
|
+
/**
|
|
5024
|
+
* Manage and run evals in the OpenAI platform.
|
|
5025
|
+
*/
|
|
4968
5026
|
class OutputItems extends APIResource {
|
|
4969
5027
|
/**
|
|
4970
5028
|
* Get an evaluation run output item by ID.
|
|
@@ -4983,6 +5041,9 @@ class OutputItems extends APIResource {
|
|
|
4983
5041
|
}
|
|
4984
5042
|
|
|
4985
5043
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5044
|
+
/**
|
|
5045
|
+
* Manage and run evals in the OpenAI platform.
|
|
5046
|
+
*/
|
|
4986
5047
|
class Runs extends APIResource {
|
|
4987
5048
|
constructor() {
|
|
4988
5049
|
super(...arguments);
|
|
@@ -5030,6 +5091,9 @@ class Runs extends APIResource {
|
|
|
5030
5091
|
Runs.OutputItems = OutputItems;
|
|
5031
5092
|
|
|
5032
5093
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5094
|
+
/**
|
|
5095
|
+
* Manage and run evals in the OpenAI platform.
|
|
5096
|
+
*/
|
|
5033
5097
|
class Evals extends APIResource {
|
|
5034
5098
|
constructor() {
|
|
5035
5099
|
super(...arguments);
|
|
@@ -5074,6 +5138,9 @@ class Evals extends APIResource {
|
|
|
5074
5138
|
Evals.Runs = Runs;
|
|
5075
5139
|
|
|
5076
5140
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5141
|
+
/**
|
|
5142
|
+
* Files are used to upload documents that can be used with features like Assistants and Fine-tuning.
|
|
5143
|
+
*/
|
|
5077
5144
|
let Files$1 = class Files extends APIResource {
|
|
5078
5145
|
/**
|
|
5079
5146
|
* Upload a file that can be used across various endpoints. Individual files can be
|
|
@@ -5153,6 +5220,9 @@ class Methods extends APIResource {
|
|
|
5153
5220
|
}
|
|
5154
5221
|
|
|
5155
5222
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5223
|
+
/**
|
|
5224
|
+
* Manage fine-tuning jobs to tailor a model to your specific training data.
|
|
5225
|
+
*/
|
|
5156
5226
|
let Graders$1 = class Graders extends APIResource {
|
|
5157
5227
|
/**
|
|
5158
5228
|
* Run a grader.
|
|
@@ -5206,6 +5276,9 @@ class Alpha extends APIResource {
|
|
|
5206
5276
|
Alpha.Graders = Graders$1;
|
|
5207
5277
|
|
|
5208
5278
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5279
|
+
/**
|
|
5280
|
+
* Manage fine-tuning jobs to tailor a model to your specific training data.
|
|
5281
|
+
*/
|
|
5209
5282
|
class Permissions extends APIResource {
|
|
5210
5283
|
/**
|
|
5211
5284
|
* **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
|
|
@@ -5233,13 +5306,7 @@ class Permissions extends APIResource {
|
|
|
5233
5306
|
* Organization owners can use this endpoint to view all permissions for a
|
|
5234
5307
|
* fine-tuned model checkpoint.
|
|
5235
5308
|
*
|
|
5236
|
-
* @
|
|
5237
|
-
* ```ts
|
|
5238
|
-
* const permission =
|
|
5239
|
-
* await client.fineTuning.checkpoints.permissions.retrieve(
|
|
5240
|
-
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
|
5241
|
-
* );
|
|
5242
|
-
* ```
|
|
5309
|
+
* @deprecated Retrieve is deprecated. Please swap to the paginated list method instead.
|
|
5243
5310
|
*/
|
|
5244
5311
|
retrieve(fineTunedModelCheckpoint, query = {}, options) {
|
|
5245
5312
|
return this._client.get(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
|
|
@@ -5247,6 +5314,25 @@ class Permissions extends APIResource {
|
|
|
5247
5314
|
...options,
|
|
5248
5315
|
});
|
|
5249
5316
|
}
|
|
5317
|
+
/**
|
|
5318
|
+
* **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
|
|
5319
|
+
*
|
|
5320
|
+
* Organization owners can use this endpoint to view all permissions for a
|
|
5321
|
+
* fine-tuned model checkpoint.
|
|
5322
|
+
*
|
|
5323
|
+
* @example
|
|
5324
|
+
* ```ts
|
|
5325
|
+
* // Automatically fetches more pages as needed.
|
|
5326
|
+
* for await (const permissionListResponse of client.fineTuning.checkpoints.permissions.list(
|
|
5327
|
+
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
|
5328
|
+
* )) {
|
|
5329
|
+
* // ...
|
|
5330
|
+
* }
|
|
5331
|
+
* ```
|
|
5332
|
+
*/
|
|
5333
|
+
list(fineTunedModelCheckpoint, query = {}, options) {
|
|
5334
|
+
return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options });
|
|
5335
|
+
}
|
|
5250
5336
|
/**
|
|
5251
5337
|
* **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
|
|
5252
5338
|
*
|
|
@@ -5281,6 +5367,9 @@ let Checkpoints$1 = class Checkpoints extends APIResource {
|
|
|
5281
5367
|
Checkpoints$1.Permissions = Permissions;
|
|
5282
5368
|
|
|
5283
5369
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5370
|
+
/**
|
|
5371
|
+
* Manage fine-tuning jobs to tailor a model to your specific training data.
|
|
5372
|
+
*/
|
|
5284
5373
|
class Checkpoints extends APIResource {
|
|
5285
5374
|
/**
|
|
5286
5375
|
* List checkpoints for a fine-tuning job.
|
|
@@ -5301,6 +5390,9 @@ class Checkpoints extends APIResource {
|
|
|
5301
5390
|
}
|
|
5302
5391
|
|
|
5303
5392
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5393
|
+
/**
|
|
5394
|
+
* Manage fine-tuning jobs to tailor a model to your specific training data.
|
|
5395
|
+
*/
|
|
5304
5396
|
class Jobs extends APIResource {
|
|
5305
5397
|
constructor() {
|
|
5306
5398
|
super(...arguments);
|
|
@@ -5442,6 +5534,9 @@ class Graders extends APIResource {
|
|
|
5442
5534
|
Graders.GraderModels = GraderModels;
|
|
5443
5535
|
|
|
5444
5536
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5537
|
+
/**
|
|
5538
|
+
* Given a prompt and/or an input image, the model will generate a new image.
|
|
5539
|
+
*/
|
|
5445
5540
|
class Images extends APIResource {
|
|
5446
5541
|
/**
|
|
5447
5542
|
* Creates a variation of a given image. This endpoint only supports `dall-e-2`.
|
|
@@ -5465,6 +5560,9 @@ class Images extends APIResource {
|
|
|
5465
5560
|
}
|
|
5466
5561
|
|
|
5467
5562
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5563
|
+
/**
|
|
5564
|
+
* List and describe the various models available in the API.
|
|
5565
|
+
*/
|
|
5468
5566
|
class Models extends APIResource {
|
|
5469
5567
|
/**
|
|
5470
5568
|
* Retrieves a model instance, providing basic information about the model such as
|
|
@@ -5490,6 +5588,9 @@ class Models extends APIResource {
|
|
|
5490
5588
|
}
|
|
5491
5589
|
|
|
5492
5590
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5591
|
+
/**
|
|
5592
|
+
* Given text and/or image inputs, classifies if those inputs are potentially harmful.
|
|
5593
|
+
*/
|
|
5493
5594
|
class Moderations extends APIResource {
|
|
5494
5595
|
/**
|
|
5495
5596
|
* Classifies if text and/or image inputs are potentially harmful. Learn more in
|
|
@@ -5573,6 +5674,20 @@ class ClientSecrets extends APIResource {
|
|
|
5573
5674
|
/**
|
|
5574
5675
|
* Create a Realtime client secret with an associated session configuration.
|
|
5575
5676
|
*
|
|
5677
|
+
* Client secrets are short-lived tokens that can be passed to a client app, such
|
|
5678
|
+
* as a web frontend or mobile client, which grants access to the Realtime API
|
|
5679
|
+
* without leaking your main API key. You can configure a custom TTL for each
|
|
5680
|
+
* client secret.
|
|
5681
|
+
*
|
|
5682
|
+
* You can also attach session configuration options to the client secret, which
|
|
5683
|
+
* will be applied to any sessions created using that client secret, but these can
|
|
5684
|
+
* also be overridden by the client connection.
|
|
5685
|
+
*
|
|
5686
|
+
* [Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).
|
|
5687
|
+
*
|
|
5688
|
+
* Returns the created client secret and the effective session object. The client
|
|
5689
|
+
* secret is a string that looks like `ek_1234`.
|
|
5690
|
+
*
|
|
5576
5691
|
* @example
|
|
5577
5692
|
* ```ts
|
|
5578
5693
|
* const clientSecret =
|
|
@@ -5998,7 +6113,10 @@ class InputItems extends APIResource {
|
|
|
5998
6113
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5999
6114
|
class InputTokens extends APIResource {
|
|
6000
6115
|
/**
|
|
6001
|
-
*
|
|
6116
|
+
* Returns input token counts of the request.
|
|
6117
|
+
*
|
|
6118
|
+
* Returns an object with `object` set to `response.input_tokens` and an
|
|
6119
|
+
* `input_tokens` count.
|
|
6002
6120
|
*
|
|
6003
6121
|
* @example
|
|
6004
6122
|
* ```ts
|
|
@@ -6080,12 +6198,17 @@ class Responses extends APIResource {
|
|
|
6080
6198
|
return this._client.post(path `/responses/${responseID}/cancel`, options);
|
|
6081
6199
|
}
|
|
6082
6200
|
/**
|
|
6083
|
-
* Compact conversation
|
|
6201
|
+
* Compact a conversation. Returns a compacted response object.
|
|
6202
|
+
*
|
|
6203
|
+
* Learn when and how to compact long-running conversations in the
|
|
6204
|
+
* [conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
|
|
6205
|
+
* For ZDR-compatible compaction details, see
|
|
6206
|
+
* [Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).
|
|
6084
6207
|
*
|
|
6085
6208
|
* @example
|
|
6086
6209
|
* ```ts
|
|
6087
6210
|
* const compactedResponse = await client.responses.compact({
|
|
6088
|
-
* model: 'gpt-5.
|
|
6211
|
+
* model: 'gpt-5.4',
|
|
6089
6212
|
* });
|
|
6090
6213
|
* ```
|
|
6091
6214
|
*/
|
|
@@ -6099,7 +6222,7 @@ Responses.InputTokens = InputTokens;
|
|
|
6099
6222
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
6100
6223
|
let Content$1 = class Content extends APIResource {
|
|
6101
6224
|
/**
|
|
6102
|
-
*
|
|
6225
|
+
* Download a skill zip bundle by its ID.
|
|
6103
6226
|
*/
|
|
6104
6227
|
retrieve(skillID, options) {
|
|
6105
6228
|
return this._client.get(path `/skills/${skillID}/content`, {
|
|
@@ -6113,7 +6236,7 @@ let Content$1 = class Content extends APIResource {
|
|
|
6113
6236
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
6114
6237
|
class Content extends APIResource {
|
|
6115
6238
|
/**
|
|
6116
|
-
*
|
|
6239
|
+
* Download a skill version zip bundle.
|
|
6117
6240
|
*/
|
|
6118
6241
|
retrieve(version, params, options) {
|
|
6119
6242
|
const { skill_id } = params;
|
|
@@ -6132,20 +6255,20 @@ class Versions extends APIResource {
|
|
|
6132
6255
|
this.content = new Content(this._client);
|
|
6133
6256
|
}
|
|
6134
6257
|
/**
|
|
6135
|
-
* Create
|
|
6258
|
+
* Create a new immutable skill version.
|
|
6136
6259
|
*/
|
|
6137
6260
|
create(skillID, body = {}, options) {
|
|
6138
6261
|
return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
|
|
6139
6262
|
}
|
|
6140
6263
|
/**
|
|
6141
|
-
* Get
|
|
6264
|
+
* Get a specific skill version.
|
|
6142
6265
|
*/
|
|
6143
6266
|
retrieve(version, params, options) {
|
|
6144
6267
|
const { skill_id } = params;
|
|
6145
6268
|
return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
|
|
6146
6269
|
}
|
|
6147
6270
|
/**
|
|
6148
|
-
* List
|
|
6271
|
+
* List skill versions for a skill.
|
|
6149
6272
|
*/
|
|
6150
6273
|
list(skillID, query = {}, options) {
|
|
6151
6274
|
return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
|
|
@@ -6154,7 +6277,7 @@ class Versions extends APIResource {
|
|
|
6154
6277
|
});
|
|
6155
6278
|
}
|
|
6156
6279
|
/**
|
|
6157
|
-
* Delete
|
|
6280
|
+
* Delete a skill version.
|
|
6158
6281
|
*/
|
|
6159
6282
|
delete(version, params, options) {
|
|
6160
6283
|
const { skill_id } = params;
|
|
@@ -6171,31 +6294,31 @@ class Skills extends APIResource {
|
|
|
6171
6294
|
this.versions = new Versions(this._client);
|
|
6172
6295
|
}
|
|
6173
6296
|
/**
|
|
6174
|
-
* Create
|
|
6297
|
+
* Create a new skill.
|
|
6175
6298
|
*/
|
|
6176
6299
|
create(body = {}, options) {
|
|
6177
6300
|
return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
|
|
6178
6301
|
}
|
|
6179
6302
|
/**
|
|
6180
|
-
* Get
|
|
6303
|
+
* Get a skill by its ID.
|
|
6181
6304
|
*/
|
|
6182
6305
|
retrieve(skillID, options) {
|
|
6183
6306
|
return this._client.get(path `/skills/${skillID}`, options);
|
|
6184
6307
|
}
|
|
6185
6308
|
/**
|
|
6186
|
-
* Update
|
|
6309
|
+
* Update the default version pointer for a skill.
|
|
6187
6310
|
*/
|
|
6188
6311
|
update(skillID, body, options) {
|
|
6189
6312
|
return this._client.post(path `/skills/${skillID}`, { body, ...options });
|
|
6190
6313
|
}
|
|
6191
6314
|
/**
|
|
6192
|
-
* List
|
|
6315
|
+
* List all skills for the current project.
|
|
6193
6316
|
*/
|
|
6194
6317
|
list(query = {}, options) {
|
|
6195
6318
|
return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
|
|
6196
6319
|
}
|
|
6197
6320
|
/**
|
|
6198
|
-
* Delete
|
|
6321
|
+
* Delete a skill by its ID.
|
|
6199
6322
|
*/
|
|
6200
6323
|
delete(skillID, options) {
|
|
6201
6324
|
return this._client.delete(path `/skills/${skillID}`, options);
|
|
@@ -6205,6 +6328,9 @@ Skills.Content = Content$1;
|
|
|
6205
6328
|
Skills.Versions = Versions;
|
|
6206
6329
|
|
|
6207
6330
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
6331
|
+
/**
|
|
6332
|
+
* Use Uploads to upload large files in multiple parts.
|
|
6333
|
+
*/
|
|
6208
6334
|
class Parts extends APIResource {
|
|
6209
6335
|
/**
|
|
6210
6336
|
* Adds a
|
|
@@ -6225,6 +6351,9 @@ class Parts extends APIResource {
|
|
|
6225
6351
|
}
|
|
6226
6352
|
|
|
6227
6353
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
6354
|
+
/**
|
|
6355
|
+
* Use Uploads to upload large files in multiple parts.
|
|
6356
|
+
*/
|
|
6228
6357
|
class Uploads extends APIResource {
|
|
6229
6358
|
constructor() {
|
|
6230
6359
|
super(...arguments);
|
|
@@ -6250,12 +6379,16 @@ class Uploads extends APIResource {
|
|
|
6250
6379
|
* For guidance on the proper filename extensions for each purpose, please follow
|
|
6251
6380
|
* the documentation on
|
|
6252
6381
|
* [creating a File](https://platform.openai.com/docs/api-reference/files/create).
|
|
6382
|
+
*
|
|
6383
|
+
* Returns the Upload object with status `pending`.
|
|
6253
6384
|
*/
|
|
6254
6385
|
create(body, options) {
|
|
6255
6386
|
return this._client.post('/uploads', { body, ...options });
|
|
6256
6387
|
}
|
|
6257
6388
|
/**
|
|
6258
6389
|
* Cancels the Upload. No Parts may be added after an Upload is cancelled.
|
|
6390
|
+
*
|
|
6391
|
+
* Returns the Upload object with status `cancelled`.
|
|
6259
6392
|
*/
|
|
6260
6393
|
cancel(uploadID, options) {
|
|
6261
6394
|
return this._client.post(path `/uploads/${uploadID}/cancel`, options);
|
|
@@ -6273,7 +6406,9 @@ class Uploads extends APIResource {
|
|
|
6273
6406
|
*
|
|
6274
6407
|
* The number of bytes uploaded upon completion must match the number of bytes
|
|
6275
6408
|
* initially specified when creating the Upload object. No Parts may be added after
|
|
6276
|
-
* an Upload is completed.
|
|
6409
|
+
* an Upload is completed. Returns the Upload object with status `completed`,
|
|
6410
|
+
* including an additional `file` property containing the created usable File
|
|
6411
|
+
* object.
|
|
6277
6412
|
*/
|
|
6278
6413
|
complete(uploadID, body, options) {
|
|
6279
6414
|
return this._client.post(path `/uploads/${uploadID}/complete`, { body, ...options });
|
|
@@ -6633,31 +6768,33 @@ VectorStores.FileBatches = FileBatches;
|
|
|
6633
6768
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
6634
6769
|
class Videos extends APIResource {
|
|
6635
6770
|
/**
|
|
6636
|
-
* Create a video
|
|
6771
|
+
* Create a new video generation job from a prompt and optional reference assets.
|
|
6637
6772
|
*/
|
|
6638
6773
|
create(body, options) {
|
|
6639
6774
|
return this._client.post('/videos', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
|
|
6640
6775
|
}
|
|
6641
6776
|
/**
|
|
6642
|
-
*
|
|
6777
|
+
* Fetch the latest metadata for a generated video.
|
|
6643
6778
|
*/
|
|
6644
6779
|
retrieve(videoID, options) {
|
|
6645
6780
|
return this._client.get(path `/videos/${videoID}`, options);
|
|
6646
6781
|
}
|
|
6647
6782
|
/**
|
|
6648
|
-
* List videos
|
|
6783
|
+
* List recently generated videos for the current project.
|
|
6649
6784
|
*/
|
|
6650
6785
|
list(query = {}, options) {
|
|
6651
6786
|
return this._client.getAPIList('/videos', (ConversationCursorPage), { query, ...options });
|
|
6652
6787
|
}
|
|
6653
6788
|
/**
|
|
6654
|
-
*
|
|
6789
|
+
* Permanently delete a completed or failed video and its stored assets.
|
|
6655
6790
|
*/
|
|
6656
6791
|
delete(videoID, options) {
|
|
6657
6792
|
return this._client.delete(path `/videos/${videoID}`, options);
|
|
6658
6793
|
}
|
|
6659
6794
|
/**
|
|
6660
|
-
* Download video
|
|
6795
|
+
* Download the generated video bytes or a derived preview asset.
|
|
6796
|
+
*
|
|
6797
|
+
* Streams the rendered video content for the specified video job.
|
|
6661
6798
|
*/
|
|
6662
6799
|
downloadContent(videoID, query = {}, options) {
|
|
6663
6800
|
return this._client.get(path `/videos/${videoID}/content`, {
|
|
@@ -6668,7 +6805,7 @@ class Videos extends APIResource {
|
|
|
6668
6805
|
});
|
|
6669
6806
|
}
|
|
6670
6807
|
/**
|
|
6671
|
-
* Create a video
|
|
6808
|
+
* Create a remix of a completed video using a refreshed prompt.
|
|
6672
6809
|
*/
|
|
6673
6810
|
remix(videoID, body, options) {
|
|
6674
6811
|
return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
|
|
@@ -6793,24 +6930,54 @@ class OpenAI {
|
|
|
6793
6930
|
constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
6794
6931
|
_OpenAI_instances.add(this);
|
|
6795
6932
|
_OpenAI_encoder.set(this, void 0);
|
|
6933
|
+
/**
|
|
6934
|
+
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
|
|
6935
|
+
*/
|
|
6796
6936
|
this.completions = new Completions(this);
|
|
6797
6937
|
this.chat = new Chat(this);
|
|
6938
|
+
/**
|
|
6939
|
+
* Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
|
|
6940
|
+
*/
|
|
6798
6941
|
this.embeddings = new Embeddings(this);
|
|
6942
|
+
/**
|
|
6943
|
+
* Files are used to upload documents that can be used with features like Assistants and Fine-tuning.
|
|
6944
|
+
*/
|
|
6799
6945
|
this.files = new Files$1(this);
|
|
6946
|
+
/**
|
|
6947
|
+
* Given a prompt and/or an input image, the model will generate a new image.
|
|
6948
|
+
*/
|
|
6800
6949
|
this.images = new Images(this);
|
|
6801
6950
|
this.audio = new Audio(this);
|
|
6951
|
+
/**
|
|
6952
|
+
* Given text and/or image inputs, classifies if those inputs are potentially harmful.
|
|
6953
|
+
*/
|
|
6802
6954
|
this.moderations = new Moderations(this);
|
|
6955
|
+
/**
|
|
6956
|
+
* List and describe the various models available in the API.
|
|
6957
|
+
*/
|
|
6803
6958
|
this.models = new Models(this);
|
|
6804
6959
|
this.fineTuning = new FineTuning(this);
|
|
6805
6960
|
this.graders = new Graders(this);
|
|
6806
6961
|
this.vectorStores = new VectorStores(this);
|
|
6807
6962
|
this.webhooks = new Webhooks(this);
|
|
6808
6963
|
this.beta = new Beta(this);
|
|
6964
|
+
/**
|
|
6965
|
+
* Create large batches of API requests to run asynchronously.
|
|
6966
|
+
*/
|
|
6809
6967
|
this.batches = new Batches(this);
|
|
6968
|
+
/**
|
|
6969
|
+
* Use Uploads to upload large files in multiple parts.
|
|
6970
|
+
*/
|
|
6810
6971
|
this.uploads = new Uploads(this);
|
|
6811
6972
|
this.responses = new Responses(this);
|
|
6812
6973
|
this.realtime = new Realtime(this);
|
|
6974
|
+
/**
|
|
6975
|
+
* Manage conversations and conversation items.
|
|
6976
|
+
*/
|
|
6813
6977
|
this.conversations = new Conversations(this);
|
|
6978
|
+
/**
|
|
6979
|
+
* Manage and run evals in the OpenAI platform.
|
|
6980
|
+
*/
|
|
6814
6981
|
this.evals = new Evals(this);
|
|
6815
6982
|
this.containers = new Containers(this);
|
|
6816
6983
|
this.skills = new Skills(this);
|
|
@@ -6880,7 +7047,7 @@ class OpenAI {
|
|
|
6880
7047
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
6881
7048
|
}
|
|
6882
7049
|
stringifyQuery(query) {
|
|
6883
|
-
return
|
|
7050
|
+
return stringifyQuery(query);
|
|
6884
7051
|
}
|
|
6885
7052
|
getUserAgent() {
|
|
6886
7053
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -7149,9 +7316,9 @@ class OpenAI {
|
|
|
7149
7316
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
7150
7317
|
}
|
|
7151
7318
|
}
|
|
7152
|
-
// If the API asks us to wait a certain amount of time
|
|
7153
|
-
//
|
|
7154
|
-
if (
|
|
7319
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
7320
|
+
// says, but otherwise calculate a default
|
|
7321
|
+
if (timeoutMillis === undefined) {
|
|
7155
7322
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
7156
7323
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
7157
7324
|
}
|
|
@@ -7248,6 +7415,13 @@ class OpenAI {
|
|
|
7248
7415
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
7249
7416
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
7250
7417
|
}
|
|
7418
|
+
else if (typeof body === 'object' &&
|
|
7419
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
7420
|
+
return {
|
|
7421
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
7422
|
+
body: this.stringifyQuery(body),
|
|
7423
|
+
};
|
|
7424
|
+
}
|
|
7251
7425
|
else {
|
|
7252
7426
|
return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
|
|
7253
7427
|
}
|
|
@@ -7298,78 +7472,107 @@ OpenAI.Videos = Videos;
|
|
|
7298
7472
|
|
|
7299
7473
|
// llm-openai-config.ts
|
|
7300
7474
|
const DEFAULT_MODEL = 'gpt-4.1-mini';
|
|
7301
|
-
|
|
7475
|
+
const GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
|
|
7476
|
+
const GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
|
|
7477
|
+
const GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
|
|
7478
|
+
/** Token costs in USD per 1M tokens. Last updated Mar 2026. */
|
|
7302
7479
|
const openAiModelCosts = {
|
|
7303
7480
|
'gpt-4o': {
|
|
7304
7481
|
inputCost: 2.5 / 1_000_000,
|
|
7482
|
+
cacheHitCost: 1.25 / 1_000_000,
|
|
7305
7483
|
outputCost: 10 / 1_000_000,
|
|
7306
7484
|
},
|
|
7307
7485
|
'gpt-4o-mini': {
|
|
7308
7486
|
inputCost: 0.15 / 1_000_000,
|
|
7487
|
+
cacheHitCost: 0.075 / 1_000_000,
|
|
7309
7488
|
outputCost: 0.6 / 1_000_000,
|
|
7310
7489
|
},
|
|
7311
7490
|
'o1-mini': {
|
|
7312
7491
|
inputCost: 1.1 / 1_000_000,
|
|
7492
|
+
cacheHitCost: 0.55 / 1_000_000,
|
|
7313
7493
|
outputCost: 4.4 / 1_000_000,
|
|
7314
7494
|
},
|
|
7315
7495
|
'o1': {
|
|
7316
7496
|
inputCost: 15 / 1_000_000,
|
|
7497
|
+
cacheHitCost: 7.5 / 1_000_000,
|
|
7317
7498
|
outputCost: 60 / 1_000_000,
|
|
7318
7499
|
},
|
|
7319
7500
|
'o3-mini': {
|
|
7320
7501
|
inputCost: 1.1 / 1_000_000,
|
|
7502
|
+
cacheHitCost: 0.55 / 1_000_000,
|
|
7321
7503
|
outputCost: 4.4 / 1_000_000,
|
|
7322
7504
|
},
|
|
7323
7505
|
'o3': {
|
|
7324
7506
|
inputCost: 2 / 1_000_000,
|
|
7507
|
+
cacheHitCost: 0.5 / 1_000_000,
|
|
7325
7508
|
outputCost: 8 / 1_000_000,
|
|
7326
7509
|
},
|
|
7327
7510
|
'gpt-4.1': {
|
|
7328
7511
|
inputCost: 2 / 1_000_000,
|
|
7512
|
+
cacheHitCost: 0.5 / 1_000_000,
|
|
7329
7513
|
outputCost: 8 / 1_000_000,
|
|
7330
7514
|
},
|
|
7331
7515
|
'gpt-4.1-mini': {
|
|
7332
7516
|
inputCost: 0.4 / 1_000_000,
|
|
7517
|
+
cacheHitCost: 0.1 / 1_000_000,
|
|
7333
7518
|
outputCost: 1.6 / 1_000_000,
|
|
7334
7519
|
},
|
|
7335
7520
|
'gpt-4.1-nano': {
|
|
7336
7521
|
inputCost: 0.1 / 1_000_000,
|
|
7522
|
+
cacheHitCost: 0.025 / 1_000_000,
|
|
7337
7523
|
outputCost: 0.4 / 1_000_000,
|
|
7338
7524
|
},
|
|
7339
7525
|
'gpt-5': {
|
|
7340
7526
|
inputCost: 1.25 / 1_000_000,
|
|
7527
|
+
cacheHitCost: 0.125 / 1_000_000,
|
|
7341
7528
|
outputCost: 10 / 1_000_000,
|
|
7342
7529
|
},
|
|
7343
7530
|
'gpt-5-mini': {
|
|
7344
7531
|
inputCost: 0.25 / 1_000_000,
|
|
7532
|
+
cacheHitCost: 0.025 / 1_000_000,
|
|
7345
7533
|
outputCost: 2 / 1_000_000,
|
|
7346
7534
|
},
|
|
7347
7535
|
'gpt-5-nano': {
|
|
7348
7536
|
inputCost: 0.05 / 1_000_000,
|
|
7537
|
+
cacheHitCost: 0.005 / 1_000_000,
|
|
7349
7538
|
outputCost: 0.4 / 1_000_000,
|
|
7350
7539
|
},
|
|
7351
7540
|
'gpt-5.1': {
|
|
7352
7541
|
inputCost: 1.25 / 1_000_000,
|
|
7542
|
+
cacheHitCost: 0.125 / 1_000_000,
|
|
7353
7543
|
outputCost: 10 / 1_000_000,
|
|
7354
7544
|
},
|
|
7545
|
+
'gpt-5.4': {
|
|
7546
|
+
inputCost: 2.5 / 1_000_000,
|
|
7547
|
+
cacheHitCost: 0.25 / 1_000_000,
|
|
7548
|
+
outputCost: 15 / 1_000_000,
|
|
7549
|
+
},
|
|
7550
|
+
'gpt-5.4-pro': {
|
|
7551
|
+
inputCost: 30 / 1_000_000,
|
|
7552
|
+
outputCost: 180 / 1_000_000,
|
|
7553
|
+
},
|
|
7355
7554
|
'gpt-5.2': {
|
|
7356
|
-
inputCost: 1.
|
|
7357
|
-
|
|
7555
|
+
inputCost: 1.75 / 1_000_000,
|
|
7556
|
+
cacheHitCost: 0.175 / 1_000_000,
|
|
7557
|
+
outputCost: 14 / 1_000_000,
|
|
7358
7558
|
},
|
|
7359
7559
|
'gpt-5.2-pro': {
|
|
7360
|
-
inputCost:
|
|
7361
|
-
outputCost:
|
|
7560
|
+
inputCost: 21 / 1_000_000,
|
|
7561
|
+
outputCost: 168 / 1_000_000,
|
|
7362
7562
|
},
|
|
7363
7563
|
'gpt-5.1-codex': {
|
|
7364
|
-
inputCost: 1.
|
|
7365
|
-
|
|
7564
|
+
inputCost: 1.25 / 1_000_000,
|
|
7565
|
+
cacheHitCost: 0.125 / 1_000_000,
|
|
7566
|
+
outputCost: 10 / 1_000_000,
|
|
7366
7567
|
},
|
|
7367
7568
|
'gpt-5.1-codex-max': {
|
|
7368
|
-
inputCost: 1.
|
|
7369
|
-
|
|
7569
|
+
inputCost: 1.25 / 1_000_000,
|
|
7570
|
+
cacheHitCost: 0.125 / 1_000_000,
|
|
7571
|
+
outputCost: 10 / 1_000_000,
|
|
7370
7572
|
},
|
|
7371
7573
|
'o4-mini': {
|
|
7372
7574
|
inputCost: 1.1 / 1_000_000,
|
|
7575
|
+
cacheHitCost: 0.275 / 1_000_000,
|
|
7373
7576
|
outputCost: 4.4 / 1_000_000,
|
|
7374
7577
|
},
|
|
7375
7578
|
};
|
|
@@ -7385,6 +7588,9 @@ const deepseekModelCosts = {
|
|
|
7385
7588
|
outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
|
|
7386
7589
|
},
|
|
7387
7590
|
};
|
|
7591
|
+
function shouldUseGPT54HighContextPricing(model, inputTokens) {
|
|
7592
|
+
return (model === 'gpt-5.4' || model === 'gpt-5.4-pro') && inputTokens > GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS;
|
|
7593
|
+
}
|
|
7388
7594
|
/** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
|
|
7389
7595
|
const openAiImageCosts = {
|
|
7390
7596
|
'gpt-image-1': 0.0075, // $0.0075 per image for gpt-image-1
|
|
@@ -7413,8 +7619,8 @@ function calculateImageCost(model, imageCount) {
|
|
|
7413
7619
|
* @param model The name of the language model. Supported models are listed in the `openAiModelCosts` and `deepseekModelCosts` objects.
|
|
7414
7620
|
* @param inputTokens The number of input tokens passed to the language model.
|
|
7415
7621
|
* @param outputTokens The number of output tokens generated by the language model.
|
|
7416
|
-
* @param reasoningTokens The number of output tokens generated by the language model for reasoning.
|
|
7417
|
-
* @param cacheHitTokens The number of input tokens
|
|
7622
|
+
* @param reasoningTokens The number of output tokens generated by the language model for reasoning.
|
|
7623
|
+
* @param cacheHitTokens The number of input tokens billed at cached-input rates.
|
|
7418
7624
|
* @returns The cost of calling the language model in USD.
|
|
7419
7625
|
*/
|
|
7420
7626
|
function calculateCost(provider, model, inputTokens, outputTokens, reasoningTokens, cacheHitTokens) {
|
|
@@ -7429,12 +7635,18 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
|
|
|
7429
7635
|
const modelCosts = provider === 'deepseek' ? deepseekModelCosts[model] : openAiModelCosts[model];
|
|
7430
7636
|
if (!modelCosts)
|
|
7431
7637
|
return 0;
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7638
|
+
const boundedCacheHitTokens = Math.min(Math.max(cacheHitTokens || 0, 0), inputTokens);
|
|
7639
|
+
let inputCost = inputTokens * modelCosts.inputCost;
|
|
7640
|
+
if (typeof modelCosts.cacheHitCost === 'number' && boundedCacheHitTokens > 0) {
|
|
7641
|
+
inputCost = boundedCacheHitTokens * modelCosts.cacheHitCost + (inputTokens - boundedCacheHitTokens) * modelCosts.inputCost;
|
|
7642
|
+
}
|
|
7643
|
+
let outputCost = outputTokens * modelCosts.outputCost;
|
|
7644
|
+
let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
|
|
7645
|
+
if (provider === 'openai' && shouldUseGPT54HighContextPricing(model, inputTokens)) {
|
|
7646
|
+
inputCost *= GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER;
|
|
7647
|
+
outputCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
7648
|
+
reasoningCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
7649
|
+
}
|
|
7438
7650
|
return inputCost + outputCost + reasoningCost;
|
|
7439
7651
|
}
|
|
7440
7652
|
|
|
@@ -7832,6 +8044,8 @@ const isSupportedModel = (model) => {
|
|
|
7832
8044
|
'gpt-5-mini',
|
|
7833
8045
|
'gpt-5-nano',
|
|
7834
8046
|
'gpt-5.1',
|
|
8047
|
+
'gpt-5.4',
|
|
8048
|
+
'gpt-5.4-pro',
|
|
7835
8049
|
'gpt-5.2',
|
|
7836
8050
|
'gpt-5.2-pro',
|
|
7837
8051
|
'gpt-5.1-codex',
|
|
@@ -7858,6 +8072,8 @@ function supportsTemperature(model) {
|
|
|
7858
8072
|
'gpt-5-mini',
|
|
7859
8073
|
'gpt-5-nano',
|
|
7860
8074
|
'gpt-5.1',
|
|
8075
|
+
'gpt-5.4',
|
|
8076
|
+
'gpt-5.4-pro',
|
|
7861
8077
|
'gpt-5.2',
|
|
7862
8078
|
'gpt-5.2-pro',
|
|
7863
8079
|
'gpt-5.1-codex',
|
|
@@ -7885,6 +8101,8 @@ function isGPT5Model(model) {
|
|
|
7885
8101
|
'gpt-5-mini',
|
|
7886
8102
|
'gpt-5-nano',
|
|
7887
8103
|
'gpt-5.1',
|
|
8104
|
+
'gpt-5.4',
|
|
8105
|
+
'gpt-5.4-pro',
|
|
7888
8106
|
'gpt-5.2',
|
|
7889
8107
|
'gpt-5.2-pro',
|
|
7890
8108
|
'gpt-5.1-codex',
|
|
@@ -7892,6 +8110,12 @@ function isGPT5Model(model) {
|
|
|
7892
8110
|
];
|
|
7893
8111
|
return gpt5Models.includes(model);
|
|
7894
8112
|
}
|
|
8113
|
+
function supportsStructuredOutputs(model) {
|
|
8114
|
+
return normalizeModelName(model) !== 'gpt-5.4-pro';
|
|
8115
|
+
}
|
|
8116
|
+
function supportsDistillation(model) {
|
|
8117
|
+
return normalizeModelName(model) !== 'gpt-5.4-pro';
|
|
8118
|
+
}
|
|
7895
8119
|
/**
|
|
7896
8120
|
* Makes a call to OpenAI's Responses API for more advanced use cases with built-in tools.
|
|
7897
8121
|
*
|
|
@@ -7934,8 +8158,15 @@ const makeResponsesAPICall = async (input, options = {}) => {
|
|
|
7934
8158
|
input,
|
|
7935
8159
|
...cleanOptions,
|
|
7936
8160
|
};
|
|
8161
|
+
if (requestBody.text?.format?.type === 'json_schema' && !supportsStructuredOutputs(normalizedModel)) {
|
|
8162
|
+
throw new Error(`Model ${normalizedModel} does not support structured outputs`);
|
|
8163
|
+
}
|
|
8164
|
+
if (requestBody.store && !supportsDistillation(normalizedModel)) {
|
|
8165
|
+
throw new Error(`Model ${normalizedModel} does not support distillation`);
|
|
8166
|
+
}
|
|
7937
8167
|
// Make the API call to the Responses endpoint
|
|
7938
8168
|
const response = await openai.responses.create(requestBody);
|
|
8169
|
+
const cacheHitTokens = response.usage?.input_tokens_details?.cached_tokens || 0;
|
|
7939
8170
|
// Extract tool calls from the output
|
|
7940
8171
|
const toolCalls = response.output
|
|
7941
8172
|
?.filter((item) => item.type === 'function_call')
|
|
@@ -7975,7 +8206,8 @@ const makeResponsesAPICall = async (input, options = {}) => {
|
|
|
7975
8206
|
reasoning_tokens: response.usage?.output_tokens_details?.reasoning_tokens || 0,
|
|
7976
8207
|
provider: 'openai',
|
|
7977
8208
|
model: normalizedModel,
|
|
7978
|
-
|
|
8209
|
+
cache_hit_tokens: cacheHitTokens,
|
|
8210
|
+
cost: calculateCost('openai', normalizedModel, response.usage?.input_tokens || 0, response.usage?.output_tokens || 0, response.usage?.output_tokens_details?.reasoning_tokens || 0, cacheHitTokens),
|
|
7979
8211
|
},
|
|
7980
8212
|
tool_calls: toolCalls,
|
|
7981
8213
|
...(codeInterpreterOutputs ? { code_interpreter_outputs: codeInterpreterOutputs } : {}),
|
|
@@ -8007,7 +8239,8 @@ const makeResponsesAPICall = async (input, options = {}) => {
|
|
|
8007
8239
|
reasoning_tokens: response.usage?.output_tokens_details?.reasoning_tokens || 0,
|
|
8008
8240
|
provider: 'openai',
|
|
8009
8241
|
model: normalizedModel,
|
|
8010
|
-
|
|
8242
|
+
cache_hit_tokens: cacheHitTokens,
|
|
8243
|
+
cost: calculateCost('openai', normalizedModel, response.usage?.input_tokens || 0, response.usage?.output_tokens || 0, response.usage?.output_tokens_details?.reasoning_tokens || 0, cacheHitTokens),
|
|
8011
8244
|
},
|
|
8012
8245
|
tool_calls: toolCalls,
|
|
8013
8246
|
...(codeInterpreterOutputs ? { code_interpreter_outputs: codeInterpreterOutputs } : {}),
|
|
@@ -8139,6 +8372,8 @@ const MULTIMODAL_VISION_MODELS = new Set([
|
|
|
8139
8372
|
'gpt-5-mini',
|
|
8140
8373
|
'gpt-5-nano',
|
|
8141
8374
|
'gpt-5.1',
|
|
8375
|
+
'gpt-5.4',
|
|
8376
|
+
'gpt-5.4-pro',
|
|
8142
8377
|
'gpt-5.2',
|
|
8143
8378
|
'gpt-5.2-pro',
|
|
8144
8379
|
'gpt-5.1-codex',
|