@discomedia/utils 1.0.70 → 1.0.71

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.
@@ -23,6 +23,25 @@ const OPENAI_MODELS = [
23
23
  function isOpenAIModel(model) {
24
24
  return OPENAI_MODELS.includes(model);
25
25
  }
26
+ /**
27
+ * Represents OpenAI image models.
28
+ */
29
+ const OPENAI_IMAGE_MODELS = [
30
+ 'gpt-image-2',
31
+ 'gpt-image-2-2026-04-21',
32
+ 'gpt-image-1.5',
33
+ 'gpt-image-1',
34
+ 'gpt-image-1-mini',
35
+ 'chatgpt-image-latest',
36
+ 'dall-e-2',
37
+ 'dall-e-3',
38
+ ];
39
+ /**
40
+ * Type guard to check if a model is a supported OpenAI image model.
41
+ */
42
+ function isOpenAIImageModel(model) {
43
+ return OPENAI_IMAGE_MODELS.includes(model);
44
+ }
26
45
  /**
27
46
  * Represents OpenRouter models
28
47
  */
@@ -57,8 +76,10 @@ function isOpenRouterModel(model) {
57
76
 
58
77
  var Types = /*#__PURE__*/Object.freeze({
59
78
  __proto__: null,
79
+ OPENAI_IMAGE_MODELS: OPENAI_IMAGE_MODELS,
60
80
  OPENAI_MODELS: OPENAI_MODELS,
61
81
  OPENROUTER_MODELS: OPENROUTER_MODELS,
82
+ isOpenAIImageModel: isOpenAIImageModel,
62
83
  isOpenAIModel: isOpenAIModel,
63
84
  isOpenRouterModel: isOpenRouterModel
64
85
  });
@@ -325,7 +346,7 @@ const safeJSON = (text) => {
325
346
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
326
347
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
327
348
 
328
- const VERSION = '6.35.0'; // x-release-please-version
349
+ const VERSION = '6.37.0'; // x-release-please-version
329
350
 
330
351
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
331
352
  const isRunningInBrowser = () => {
@@ -1145,6 +1166,8 @@ const formatRequestDetails = (details) => {
1145
1166
  details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
1146
1167
  name,
1147
1168
  (name.toLowerCase() === 'authorization' ||
1169
+ name.toLowerCase() === 'api-key' ||
1170
+ name.toLowerCase() === 'x-api-key' ||
1148
1171
  name.toLowerCase() === 'cookie' ||
1149
1172
  name.toLowerCase() === 'set-cookie') ?
1150
1173
  '***'
@@ -1705,6 +1728,36 @@ class ConversationCursorPage extends AbstractPage {
1705
1728
  };
1706
1729
  }
1707
1730
  }
1731
+ class NextCursorPage extends AbstractPage {
1732
+ constructor(client, response, body, options) {
1733
+ super(client, response, body, options);
1734
+ this.data = body.data || [];
1735
+ this.has_more = body.has_more || false;
1736
+ this.next = body.next || null;
1737
+ }
1738
+ getPaginatedItems() {
1739
+ return this.data ?? [];
1740
+ }
1741
+ hasNextPage() {
1742
+ if (this.has_more === false) {
1743
+ return false;
1744
+ }
1745
+ return super.hasNextPage();
1746
+ }
1747
+ nextPageRequestOptions() {
1748
+ const cursor = this.next;
1749
+ if (!cursor) {
1750
+ return null;
1751
+ }
1752
+ return {
1753
+ ...this.options,
1754
+ query: {
1755
+ ...maybeObj(this.options.query),
1756
+ after: cursor,
1757
+ },
1758
+ };
1759
+ }
1760
+ }
1708
1761
 
1709
1762
  const SUBJECT_TOKEN_TYPES = {
1710
1763
  jwt: 'urn:ietf:params:oauth:token-type:jwt',
@@ -2107,7 +2160,7 @@ let Messages$1 = class Messages extends APIResource {
2107
2160
  * ```
2108
2161
  */
2109
2162
  list(completionID, query = {}, options) {
2110
- return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options });
2163
+ return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
2111
2164
  }
2112
2165
  };
2113
2166
 
@@ -3453,123 +3506,1775 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
3453
3506
  runner._run(() => runner._fromReadableStream(stream));
3454
3507
  return runner;
3455
3508
  }
3456
- static runTools(client, params, options) {
3457
- const runner = new ChatCompletionStreamingRunner(
3458
- // @ts-expect-error TODO these types are incompatible
3459
- params);
3460
- const opts = {
3509
+ static runTools(client, params, options) {
3510
+ const runner = new ChatCompletionStreamingRunner(
3511
+ // @ts-expect-error TODO these types are incompatible
3512
+ params);
3513
+ const opts = {
3514
+ ...options,
3515
+ headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
3516
+ };
3517
+ runner._run(() => runner._runTools(client, params, opts));
3518
+ return runner;
3519
+ }
3520
+ }
3521
+
3522
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3523
+ /**
3524
+ * Given a list of messages comprising a conversation, the model will return a response.
3525
+ */
3526
+ let Completions$1 = class Completions extends APIResource {
3527
+ constructor() {
3528
+ super(...arguments);
3529
+ this.messages = new Messages$1(this._client);
3530
+ }
3531
+ create(body, options) {
3532
+ return this._client.post('/chat/completions', {
3533
+ body,
3534
+ ...options,
3535
+ stream: body.stream ?? false,
3536
+ __security: { bearerAuth: true },
3537
+ });
3538
+ }
3539
+ /**
3540
+ * Get a stored chat completion. Only Chat Completions that have been created with
3541
+ * the `store` parameter set to `true` will be returned.
3542
+ *
3543
+ * @example
3544
+ * ```ts
3545
+ * const chatCompletion =
3546
+ * await client.chat.completions.retrieve('completion_id');
3547
+ * ```
3548
+ */
3549
+ retrieve(completionID, options) {
3550
+ return this._client.get(path `/chat/completions/${completionID}`, {
3551
+ ...options,
3552
+ __security: { bearerAuth: true },
3553
+ });
3554
+ }
3555
+ /**
3556
+ * Modify a stored chat completion. Only Chat Completions that have been created
3557
+ * with the `store` parameter set to `true` can be modified. Currently, the only
3558
+ * supported modification is to update the `metadata` field.
3559
+ *
3560
+ * @example
3561
+ * ```ts
3562
+ * const chatCompletion = await client.chat.completions.update(
3563
+ * 'completion_id',
3564
+ * { metadata: { foo: 'string' } },
3565
+ * );
3566
+ * ```
3567
+ */
3568
+ update(completionID, body, options) {
3569
+ return this._client.post(path `/chat/completions/${completionID}`, {
3570
+ body,
3571
+ ...options,
3572
+ __security: { bearerAuth: true },
3573
+ });
3574
+ }
3575
+ /**
3576
+ * List stored Chat Completions. Only Chat Completions that have been stored with
3577
+ * the `store` parameter set to `true` will be returned.
3578
+ *
3579
+ * @example
3580
+ * ```ts
3581
+ * // Automatically fetches more pages as needed.
3582
+ * for await (const chatCompletion of client.chat.completions.list()) {
3583
+ * // ...
3584
+ * }
3585
+ * ```
3586
+ */
3587
+ list(query = {}, options) {
3588
+ return this._client.getAPIList('/chat/completions', (CursorPage), {
3589
+ query,
3590
+ ...options,
3591
+ __security: { bearerAuth: true },
3592
+ });
3593
+ }
3594
+ /**
3595
+ * Delete a stored chat completion. Only Chat Completions that have been created
3596
+ * with the `store` parameter set to `true` can be deleted.
3597
+ *
3598
+ * @example
3599
+ * ```ts
3600
+ * const chatCompletionDeleted =
3601
+ * await client.chat.completions.delete('completion_id');
3602
+ * ```
3603
+ */
3604
+ delete(completionID, options) {
3605
+ return this._client.delete(path `/chat/completions/${completionID}`, {
3606
+ ...options,
3607
+ __security: { bearerAuth: true },
3608
+ });
3609
+ }
3610
+ parse(body, options) {
3611
+ validateInputTools(body.tools);
3612
+ return this._client.chat.completions
3613
+ .create(body, {
3614
+ ...options,
3615
+ headers: {
3616
+ ...options?.headers,
3617
+ 'X-Stainless-Helper-Method': 'chat.completions.parse',
3618
+ },
3619
+ })
3620
+ ._thenUnwrap((completion) => parseChatCompletion(completion, body));
3621
+ }
3622
+ runTools(body, options) {
3623
+ if (body.stream) {
3624
+ return ChatCompletionStreamingRunner.runTools(this._client, body, options);
3625
+ }
3626
+ return ChatCompletionRunner.runTools(this._client, body, options);
3627
+ }
3628
+ /**
3629
+ * Creates a chat completion stream
3630
+ */
3631
+ stream(body, options) {
3632
+ return ChatCompletionStream.createChatCompletion(this._client, body, options);
3633
+ }
3634
+ };
3635
+ Completions$1.Messages = Messages$1;
3636
+
3637
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3638
+ class Chat extends APIResource {
3639
+ constructor() {
3640
+ super(...arguments);
3641
+ this.completions = new Completions$1(this._client);
3642
+ }
3643
+ }
3644
+ Chat.Completions = Completions$1;
3645
+
3646
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3647
+ class AdminAPIKeys extends APIResource {
3648
+ /**
3649
+ * Create an organization admin API key
3650
+ *
3651
+ * @example
3652
+ * ```ts
3653
+ * const adminAPIKey =
3654
+ * await client.admin.organization.adminAPIKeys.create({
3655
+ * name: 'New Admin Key',
3656
+ * });
3657
+ * ```
3658
+ */
3659
+ create(body, options) {
3660
+ return this._client.post('/organization/admin_api_keys', {
3661
+ body,
3662
+ ...options,
3663
+ __security: { adminAPIKeyAuth: true },
3664
+ });
3665
+ }
3666
+ /**
3667
+ * Retrieve a single organization API key
3668
+ *
3669
+ * @example
3670
+ * ```ts
3671
+ * const adminAPIKey =
3672
+ * await client.admin.organization.adminAPIKeys.retrieve(
3673
+ * 'key_id',
3674
+ * );
3675
+ * ```
3676
+ */
3677
+ retrieve(keyID, options) {
3678
+ return this._client.get(path `/organization/admin_api_keys/${keyID}`, {
3679
+ ...options,
3680
+ __security: { adminAPIKeyAuth: true },
3681
+ });
3682
+ }
3683
+ /**
3684
+ * List organization API keys
3685
+ *
3686
+ * @example
3687
+ * ```ts
3688
+ * // Automatically fetches more pages as needed.
3689
+ * for await (const adminAPIKey of client.admin.organization.adminAPIKeys.list()) {
3690
+ * // ...
3691
+ * }
3692
+ * ```
3693
+ */
3694
+ list(query = {}, options) {
3695
+ return this._client.getAPIList('/organization/admin_api_keys', (CursorPage), {
3696
+ query,
3697
+ ...options,
3698
+ __security: { adminAPIKeyAuth: true },
3699
+ });
3700
+ }
3701
+ /**
3702
+ * Delete an organization admin API key
3703
+ *
3704
+ * @example
3705
+ * ```ts
3706
+ * const adminAPIKey =
3707
+ * await client.admin.organization.adminAPIKeys.delete(
3708
+ * 'key_id',
3709
+ * );
3710
+ * ```
3711
+ */
3712
+ delete(keyID, options) {
3713
+ return this._client.delete(path `/organization/admin_api_keys/${keyID}`, {
3714
+ ...options,
3715
+ __security: { adminAPIKeyAuth: true },
3716
+ });
3717
+ }
3718
+ }
3719
+
3720
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3721
+ /**
3722
+ * List user actions and configuration changes within this organization.
3723
+ */
3724
+ class AuditLogs extends APIResource {
3725
+ /**
3726
+ * List user actions and configuration changes within this organization.
3727
+ *
3728
+ * @example
3729
+ * ```ts
3730
+ * // Automatically fetches more pages as needed.
3731
+ * for await (const auditLogListResponse of client.admin.organization.auditLogs.list()) {
3732
+ * // ...
3733
+ * }
3734
+ * ```
3735
+ */
3736
+ list(query = {}, options) {
3737
+ return this._client.getAPIList('/organization/audit_logs', (ConversationCursorPage), {
3738
+ query,
3739
+ ...options,
3740
+ __security: { adminAPIKeyAuth: true },
3741
+ });
3742
+ }
3743
+ }
3744
+
3745
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3746
+ let Certificates$1 = class Certificates extends APIResource {
3747
+ /**
3748
+ * Upload a certificate to the organization. This does **not** automatically
3749
+ * activate the certificate.
3750
+ *
3751
+ * Organizations can upload up to 50 certificates.
3752
+ *
3753
+ * @example
3754
+ * ```ts
3755
+ * const certificate =
3756
+ * await client.admin.organization.certificates.create({
3757
+ * certificate: 'certificate',
3758
+ * });
3759
+ * ```
3760
+ */
3761
+ create(body, options) {
3762
+ return this._client.post('/organization/certificates', {
3763
+ body,
3764
+ ...options,
3765
+ __security: { adminAPIKeyAuth: true },
3766
+ });
3767
+ }
3768
+ /**
3769
+ * Get a certificate that has been uploaded to the organization.
3770
+ *
3771
+ * You can get a certificate regardless of whether it is active or not.
3772
+ *
3773
+ * @example
3774
+ * ```ts
3775
+ * const certificate =
3776
+ * await client.admin.organization.certificates.retrieve(
3777
+ * 'certificate_id',
3778
+ * );
3779
+ * ```
3780
+ */
3781
+ retrieve(certificateID, query = {}, options) {
3782
+ return this._client.get(path `/organization/certificates/${certificateID}`, {
3783
+ query,
3784
+ ...options,
3785
+ __security: { adminAPIKeyAuth: true },
3786
+ });
3787
+ }
3788
+ /**
3789
+ * Modify a certificate. Note that only the name can be modified.
3790
+ *
3791
+ * @example
3792
+ * ```ts
3793
+ * const certificate =
3794
+ * await client.admin.organization.certificates.update(
3795
+ * 'certificate_id',
3796
+ * );
3797
+ * ```
3798
+ */
3799
+ update(certificateID, body, options) {
3800
+ return this._client.post(path `/organization/certificates/${certificateID}`, {
3801
+ body,
3802
+ ...options,
3803
+ __security: { adminAPIKeyAuth: true },
3804
+ });
3805
+ }
3806
+ /**
3807
+ * List uploaded certificates for this organization.
3808
+ *
3809
+ * @example
3810
+ * ```ts
3811
+ * // Automatically fetches more pages as needed.
3812
+ * for await (const certificateListResponse of client.admin.organization.certificates.list()) {
3813
+ * // ...
3814
+ * }
3815
+ * ```
3816
+ */
3817
+ list(query = {}, options) {
3818
+ return this._client.getAPIList('/organization/certificates', (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
3819
+ }
3820
+ /**
3821
+ * Delete a certificate from the organization.
3822
+ *
3823
+ * The certificate must be inactive for the organization and all projects.
3824
+ *
3825
+ * @example
3826
+ * ```ts
3827
+ * const certificate =
3828
+ * await client.admin.organization.certificates.delete(
3829
+ * 'certificate_id',
3830
+ * );
3831
+ * ```
3832
+ */
3833
+ delete(certificateID, options) {
3834
+ return this._client.delete(path `/organization/certificates/${certificateID}`, {
3835
+ ...options,
3836
+ __security: { adminAPIKeyAuth: true },
3837
+ });
3838
+ }
3839
+ /**
3840
+ * Activate certificates at the organization level.
3841
+ *
3842
+ * You can atomically and idempotently activate up to 10 certificates at a time.
3843
+ *
3844
+ * @example
3845
+ * ```ts
3846
+ * // Automatically fetches more pages as needed.
3847
+ * for await (const certificateActivateResponse of client.admin.organization.certificates.activate(
3848
+ * { certificate_ids: ['cert_abc'] },
3849
+ * )) {
3850
+ * // ...
3851
+ * }
3852
+ * ```
3853
+ */
3854
+ activate(body, options) {
3855
+ return this._client.getAPIList('/organization/certificates/activate', (Page), {
3856
+ body,
3857
+ method: 'post',
3858
+ ...options,
3859
+ __security: { adminAPIKeyAuth: true },
3860
+ });
3861
+ }
3862
+ /**
3863
+ * Deactivate certificates at the organization level.
3864
+ *
3865
+ * You can atomically and idempotently deactivate up to 10 certificates at a time.
3866
+ *
3867
+ * @example
3868
+ * ```ts
3869
+ * // Automatically fetches more pages as needed.
3870
+ * for await (const certificateDeactivateResponse of client.admin.organization.certificates.deactivate(
3871
+ * { certificate_ids: ['cert_abc'] },
3872
+ * )) {
3873
+ * // ...
3874
+ * }
3875
+ * ```
3876
+ */
3877
+ deactivate(body, options) {
3878
+ return this._client.getAPIList('/organization/certificates/deactivate', (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
3879
+ }
3880
+ };
3881
+
3882
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3883
+ class Invites extends APIResource {
3884
+ /**
3885
+ * Create an invite for a user to the organization. The invite must be accepted by
3886
+ * the user before they have access to the organization.
3887
+ *
3888
+ * @example
3889
+ * ```ts
3890
+ * const invite =
3891
+ * await client.admin.organization.invites.create({
3892
+ * email: 'email',
3893
+ * role: 'reader',
3894
+ * });
3895
+ * ```
3896
+ */
3897
+ create(body, options) {
3898
+ return this._client.post('/organization/invites', {
3899
+ body,
3900
+ ...options,
3901
+ __security: { adminAPIKeyAuth: true },
3902
+ });
3903
+ }
3904
+ /**
3905
+ * Retrieves an invite.
3906
+ *
3907
+ * @example
3908
+ * ```ts
3909
+ * const invite =
3910
+ * await client.admin.organization.invites.retrieve(
3911
+ * 'invite_id',
3912
+ * );
3913
+ * ```
3914
+ */
3915
+ retrieve(inviteID, options) {
3916
+ return this._client.get(path `/organization/invites/${inviteID}`, {
3917
+ ...options,
3918
+ __security: { adminAPIKeyAuth: true },
3919
+ });
3920
+ }
3921
+ /**
3922
+ * Returns a list of invites in the organization.
3923
+ *
3924
+ * @example
3925
+ * ```ts
3926
+ * // Automatically fetches more pages as needed.
3927
+ * for await (const invite of client.admin.organization.invites.list()) {
3928
+ * // ...
3929
+ * }
3930
+ * ```
3931
+ */
3932
+ list(query = {}, options) {
3933
+ return this._client.getAPIList('/organization/invites', (ConversationCursorPage), {
3934
+ query,
3935
+ ...options,
3936
+ __security: { adminAPIKeyAuth: true },
3937
+ });
3938
+ }
3939
+ /**
3940
+ * Delete an invite. If the invite has already been accepted, it cannot be deleted.
3941
+ *
3942
+ * @example
3943
+ * ```ts
3944
+ * const invite =
3945
+ * await client.admin.organization.invites.delete(
3946
+ * 'invite_id',
3947
+ * );
3948
+ * ```
3949
+ */
3950
+ delete(inviteID, options) {
3951
+ return this._client.delete(path `/organization/invites/${inviteID}`, {
3952
+ ...options,
3953
+ __security: { adminAPIKeyAuth: true },
3954
+ });
3955
+ }
3956
+ }
3957
+
3958
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3959
+ let Roles$5 = class Roles extends APIResource {
3960
+ /**
3961
+ * Creates a custom role for the organization.
3962
+ *
3963
+ * @example
3964
+ * ```ts
3965
+ * const role = await client.admin.organization.roles.create({
3966
+ * permissions: ['string'],
3967
+ * role_name: 'role_name',
3968
+ * });
3969
+ * ```
3970
+ */
3971
+ create(body, options) {
3972
+ return this._client.post('/organization/roles', {
3973
+ body,
3974
+ ...options,
3975
+ __security: { adminAPIKeyAuth: true },
3976
+ });
3977
+ }
3978
+ /**
3979
+ * Updates an existing organization role.
3980
+ *
3981
+ * @example
3982
+ * ```ts
3983
+ * const role = await client.admin.organization.roles.update(
3984
+ * 'role_id',
3985
+ * );
3986
+ * ```
3987
+ */
3988
+ update(roleID, body, options) {
3989
+ return this._client.post(path `/organization/roles/${roleID}`, {
3990
+ body,
3991
+ ...options,
3992
+ __security: { adminAPIKeyAuth: true },
3993
+ });
3994
+ }
3995
+ /**
3996
+ * Lists the roles configured for the organization.
3997
+ *
3998
+ * @example
3999
+ * ```ts
4000
+ * // Automatically fetches more pages as needed.
4001
+ * for await (const role of client.admin.organization.roles.list()) {
4002
+ * // ...
4003
+ * }
4004
+ * ```
4005
+ */
4006
+ list(query = {}, options) {
4007
+ return this._client.getAPIList('/organization/roles', (NextCursorPage), {
4008
+ query,
4009
+ ...options,
4010
+ __security: { adminAPIKeyAuth: true },
4011
+ });
4012
+ }
4013
+ /**
4014
+ * Deletes a custom role from the organization.
4015
+ *
4016
+ * @example
4017
+ * ```ts
4018
+ * const role = await client.admin.organization.roles.delete(
4019
+ * 'role_id',
4020
+ * );
4021
+ * ```
4022
+ */
4023
+ delete(roleID, options) {
4024
+ return this._client.delete(path `/organization/roles/${roleID}`, {
4025
+ ...options,
4026
+ __security: { adminAPIKeyAuth: true },
4027
+ });
4028
+ }
4029
+ };
4030
+
4031
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4032
+ class Usage extends APIResource {
4033
+ /**
4034
+ * Get audio speeches usage details for the organization.
4035
+ *
4036
+ * @example
4037
+ * ```ts
4038
+ * const response =
4039
+ * await client.admin.organization.usage.audioSpeeches({
4040
+ * start_time: 0,
4041
+ * });
4042
+ * ```
4043
+ */
4044
+ audioSpeeches(query, options) {
4045
+ return this._client.get('/organization/usage/audio_speeches', {
4046
+ query,
4047
+ ...options,
4048
+ __security: { adminAPIKeyAuth: true },
4049
+ });
4050
+ }
4051
+ /**
4052
+ * Get audio transcriptions usage details for the organization.
4053
+ *
4054
+ * @example
4055
+ * ```ts
4056
+ * const response =
4057
+ * await client.admin.organization.usage.audioTranscriptions(
4058
+ * { start_time: 0 },
4059
+ * );
4060
+ * ```
4061
+ */
4062
+ audioTranscriptions(query, options) {
4063
+ return this._client.get('/organization/usage/audio_transcriptions', {
4064
+ query,
4065
+ ...options,
4066
+ __security: { adminAPIKeyAuth: true },
4067
+ });
4068
+ }
4069
+ /**
4070
+ * Get code interpreter sessions usage details for the organization.
4071
+ *
4072
+ * @example
4073
+ * ```ts
4074
+ * const response =
4075
+ * await client.admin.organization.usage.codeInterpreterSessions(
4076
+ * { start_time: 0 },
4077
+ * );
4078
+ * ```
4079
+ */
4080
+ codeInterpreterSessions(query, options) {
4081
+ return this._client.get('/organization/usage/code_interpreter_sessions', {
4082
+ query,
4083
+ ...options,
4084
+ __security: { adminAPIKeyAuth: true },
4085
+ });
4086
+ }
4087
+ /**
4088
+ * Get completions usage details for the organization.
4089
+ *
4090
+ * @example
4091
+ * ```ts
4092
+ * const response =
4093
+ * await client.admin.organization.usage.completions({
4094
+ * start_time: 0,
4095
+ * });
4096
+ * ```
4097
+ */
4098
+ completions(query, options) {
4099
+ return this._client.get('/organization/usage/completions', {
4100
+ query,
4101
+ ...options,
4102
+ __security: { adminAPIKeyAuth: true },
4103
+ });
4104
+ }
4105
+ /**
4106
+ * Get costs details for the organization.
4107
+ *
4108
+ * @example
4109
+ * ```ts
4110
+ * const response =
4111
+ * await client.admin.organization.usage.costs({
4112
+ * start_time: 0,
4113
+ * });
4114
+ * ```
4115
+ */
4116
+ costs(query, options) {
4117
+ return this._client.get('/organization/costs', {
4118
+ query,
4119
+ ...options,
4120
+ __security: { adminAPIKeyAuth: true },
4121
+ });
4122
+ }
4123
+ /**
4124
+ * Get embeddings usage details for the organization.
4125
+ *
4126
+ * @example
4127
+ * ```ts
4128
+ * const response =
4129
+ * await client.admin.organization.usage.embeddings({
4130
+ * start_time: 0,
4131
+ * });
4132
+ * ```
4133
+ */
4134
+ embeddings(query, options) {
4135
+ return this._client.get('/organization/usage/embeddings', {
4136
+ query,
4137
+ ...options,
4138
+ __security: { adminAPIKeyAuth: true },
4139
+ });
4140
+ }
4141
+ /**
4142
+ * Get images usage details for the organization.
4143
+ *
4144
+ * @example
4145
+ * ```ts
4146
+ * const response =
4147
+ * await client.admin.organization.usage.images({
4148
+ * start_time: 0,
4149
+ * });
4150
+ * ```
4151
+ */
4152
+ images(query, options) {
4153
+ return this._client.get('/organization/usage/images', {
4154
+ query,
4155
+ ...options,
4156
+ __security: { adminAPIKeyAuth: true },
4157
+ });
4158
+ }
4159
+ /**
4160
+ * Get moderations usage details for the organization.
4161
+ *
4162
+ * @example
4163
+ * ```ts
4164
+ * const response =
4165
+ * await client.admin.organization.usage.moderations({
4166
+ * start_time: 0,
4167
+ * });
4168
+ * ```
4169
+ */
4170
+ moderations(query, options) {
4171
+ return this._client.get('/organization/usage/moderations', {
4172
+ query,
4173
+ ...options,
4174
+ __security: { adminAPIKeyAuth: true },
4175
+ });
4176
+ }
4177
+ /**
4178
+ * Get vector stores usage details for the organization.
4179
+ *
4180
+ * @example
4181
+ * ```ts
4182
+ * const response =
4183
+ * await client.admin.organization.usage.vectorStores({
4184
+ * start_time: 0,
4185
+ * });
4186
+ * ```
4187
+ */
4188
+ vectorStores(query, options) {
4189
+ return this._client.get('/organization/usage/vector_stores', {
4190
+ query,
4191
+ ...options,
4192
+ __security: { adminAPIKeyAuth: true },
4193
+ });
4194
+ }
4195
+ }
4196
+
4197
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4198
+ let Roles$4 = class Roles extends APIResource {
4199
+ /**
4200
+ * Assigns an organization role to a group within the organization.
4201
+ *
4202
+ * @example
4203
+ * ```ts
4204
+ * const role =
4205
+ * await client.admin.organization.groups.roles.create(
4206
+ * 'group_id',
4207
+ * { role_id: 'role_id' },
4208
+ * );
4209
+ * ```
4210
+ */
4211
+ create(groupID, body, options) {
4212
+ return this._client.post(path `/organization/groups/${groupID}/roles`, {
4213
+ body,
4214
+ ...options,
4215
+ __security: { adminAPIKeyAuth: true },
4216
+ });
4217
+ }
4218
+ /**
4219
+ * Lists the organization roles assigned to a group within the organization.
4220
+ *
4221
+ * @example
4222
+ * ```ts
4223
+ * // Automatically fetches more pages as needed.
4224
+ * for await (const roleListResponse of client.admin.organization.groups.roles.list(
4225
+ * 'group_id',
4226
+ * )) {
4227
+ * // ...
4228
+ * }
4229
+ * ```
4230
+ */
4231
+ list(groupID, query = {}, options) {
4232
+ return this._client.getAPIList(path `/organization/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4233
+ }
4234
+ /**
4235
+ * Unassigns an organization role from a group within the organization.
4236
+ *
4237
+ * @example
4238
+ * ```ts
4239
+ * const role =
4240
+ * await client.admin.organization.groups.roles.delete(
4241
+ * 'role_id',
4242
+ * { group_id: 'group_id' },
4243
+ * );
4244
+ * ```
4245
+ */
4246
+ delete(roleID, params, options) {
4247
+ const { group_id } = params;
4248
+ return this._client.delete(path `/organization/groups/${group_id}/roles/${roleID}`, {
4249
+ ...options,
4250
+ __security: { adminAPIKeyAuth: true },
4251
+ });
4252
+ }
4253
+ };
4254
+
4255
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4256
+ let Users$2 = class Users extends APIResource {
4257
+ /**
4258
+ * Adds a user to a group.
4259
+ *
4260
+ * @example
4261
+ * ```ts
4262
+ * const user =
4263
+ * await client.admin.organization.groups.users.create(
4264
+ * 'group_id',
4265
+ * { user_id: 'user_id' },
4266
+ * );
4267
+ * ```
4268
+ */
4269
+ create(groupID, body, options) {
4270
+ return this._client.post(path `/organization/groups/${groupID}/users`, {
4271
+ body,
4272
+ ...options,
4273
+ __security: { adminAPIKeyAuth: true },
4274
+ });
4275
+ }
4276
+ /**
4277
+ * Lists the users assigned to a group.
4278
+ *
4279
+ * @example
4280
+ * ```ts
4281
+ * // Automatically fetches more pages as needed.
4282
+ * for await (const organizationGroupUser of client.admin.organization.groups.users.list(
4283
+ * 'group_id',
4284
+ * )) {
4285
+ * // ...
4286
+ * }
4287
+ * ```
4288
+ */
4289
+ list(groupID, query = {}, options) {
4290
+ return this._client.getAPIList(path `/organization/groups/${groupID}/users`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4291
+ }
4292
+ /**
4293
+ * Removes a user from a group.
4294
+ *
4295
+ * @example
4296
+ * ```ts
4297
+ * const user =
4298
+ * await client.admin.organization.groups.users.delete(
4299
+ * 'user_id',
4300
+ * { group_id: 'group_id' },
4301
+ * );
4302
+ * ```
4303
+ */
4304
+ delete(userID, params, options) {
4305
+ const { group_id } = params;
4306
+ return this._client.delete(path `/organization/groups/${group_id}/users/${userID}`, {
4307
+ ...options,
4308
+ __security: { adminAPIKeyAuth: true },
4309
+ });
4310
+ }
4311
+ };
4312
+
4313
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4314
+ let Groups$1 = class Groups extends APIResource {
4315
+ constructor() {
4316
+ super(...arguments);
4317
+ this.users = new Users$2(this._client);
4318
+ this.roles = new Roles$4(this._client);
4319
+ }
4320
+ /**
4321
+ * Creates a new group in the organization.
4322
+ *
4323
+ * @example
4324
+ * ```ts
4325
+ * const group = await client.admin.organization.groups.create(
4326
+ * { name: 'x' },
4327
+ * );
4328
+ * ```
4329
+ */
4330
+ create(body, options) {
4331
+ return this._client.post('/organization/groups', {
4332
+ body,
4333
+ ...options,
4334
+ __security: { adminAPIKeyAuth: true },
4335
+ });
4336
+ }
4337
+ /**
4338
+ * Updates a group's information.
4339
+ *
4340
+ * @example
4341
+ * ```ts
4342
+ * const group = await client.admin.organization.groups.update(
4343
+ * 'group_id',
4344
+ * { name: 'x' },
4345
+ * );
4346
+ * ```
4347
+ */
4348
+ update(groupID, body, options) {
4349
+ return this._client.post(path `/organization/groups/${groupID}`, {
4350
+ body,
4351
+ ...options,
4352
+ __security: { adminAPIKeyAuth: true },
4353
+ });
4354
+ }
4355
+ /**
4356
+ * Lists all groups in the organization.
4357
+ *
4358
+ * @example
4359
+ * ```ts
4360
+ * // Automatically fetches more pages as needed.
4361
+ * for await (const group of client.admin.organization.groups.list()) {
4362
+ * // ...
4363
+ * }
4364
+ * ```
4365
+ */
4366
+ list(query = {}, options) {
4367
+ return this._client.getAPIList('/organization/groups', (NextCursorPage), {
4368
+ query,
4369
+ ...options,
4370
+ __security: { adminAPIKeyAuth: true },
4371
+ });
4372
+ }
4373
+ /**
4374
+ * Deletes a group from the organization.
4375
+ *
4376
+ * @example
4377
+ * ```ts
4378
+ * const group = await client.admin.organization.groups.delete(
4379
+ * 'group_id',
4380
+ * );
4381
+ * ```
4382
+ */
4383
+ delete(groupID, options) {
4384
+ return this._client.delete(path `/organization/groups/${groupID}`, {
4385
+ ...options,
4386
+ __security: { adminAPIKeyAuth: true },
4387
+ });
4388
+ }
4389
+ };
4390
+ Groups$1.Users = Users$2;
4391
+ Groups$1.Roles = Roles$4;
4392
+
4393
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4394
+ class APIKeys extends APIResource {
4395
+ /**
4396
+ * Retrieves an API key in the project.
4397
+ *
4398
+ * @example
4399
+ * ```ts
4400
+ * const projectAPIKey =
4401
+ * await client.admin.organization.projects.apiKeys.retrieve(
4402
+ * 'api_key_id',
4403
+ * { project_id: 'project_id' },
4404
+ * );
4405
+ * ```
4406
+ */
4407
+ retrieve(apiKeyID, params, options) {
4408
+ const { project_id } = params;
4409
+ return this._client.get(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
4410
+ ...options,
4411
+ __security: { adminAPIKeyAuth: true },
4412
+ });
4413
+ }
4414
+ /**
4415
+ * Returns a list of API keys in the project.
4416
+ *
4417
+ * @example
4418
+ * ```ts
4419
+ * // Automatically fetches more pages as needed.
4420
+ * for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list(
4421
+ * 'project_id',
4422
+ * )) {
4423
+ * // ...
4424
+ * }
4425
+ * ```
4426
+ */
4427
+ list(projectID, query = {}, options) {
4428
+ return this._client.getAPIList(path `/organization/projects/${projectID}/api_keys`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4429
+ }
4430
+ /**
4431
+ * Deletes an API key from the project.
4432
+ *
4433
+ * Returns confirmation of the key deletion, or an error if the key belonged to a
4434
+ * service account.
4435
+ *
4436
+ * @example
4437
+ * ```ts
4438
+ * const apiKey =
4439
+ * await client.admin.organization.projects.apiKeys.delete(
4440
+ * 'api_key_id',
4441
+ * { project_id: 'project_id' },
4442
+ * );
4443
+ * ```
4444
+ */
4445
+ delete(apiKeyID, params, options) {
4446
+ const { project_id } = params;
4447
+ return this._client.delete(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
4448
+ ...options,
4449
+ __security: { adminAPIKeyAuth: true },
4450
+ });
4451
+ }
4452
+ }
4453
+
4454
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4455
+ class Certificates extends APIResource {
4456
+ /**
4457
+ * List certificates for this project.
4458
+ *
4459
+ * @example
4460
+ * ```ts
4461
+ * // Automatically fetches more pages as needed.
4462
+ * for await (const certificateListResponse of client.admin.organization.projects.certificates.list(
4463
+ * 'project_id',
4464
+ * )) {
4465
+ * // ...
4466
+ * }
4467
+ * ```
4468
+ */
4469
+ list(projectID, query = {}, options) {
4470
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4471
+ }
4472
+ /**
4473
+ * Activate certificates at the project level.
4474
+ *
4475
+ * You can atomically and idempotently activate up to 10 certificates at a time.
4476
+ *
4477
+ * @example
4478
+ * ```ts
4479
+ * // Automatically fetches more pages as needed.
4480
+ * for await (const certificateActivateResponse of client.admin.organization.projects.certificates.activate(
4481
+ * 'project_id',
4482
+ * { certificate_ids: ['cert_abc'] },
4483
+ * )) {
4484
+ * // ...
4485
+ * }
4486
+ * ```
4487
+ */
4488
+ activate(projectID, body, options) {
4489
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/activate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
4490
+ }
4491
+ /**
4492
+ * Deactivate certificates at the project level. You can atomically and
4493
+ * idempotently deactivate up to 10 certificates at a time.
4494
+ *
4495
+ * @example
4496
+ * ```ts
4497
+ * // Automatically fetches more pages as needed.
4498
+ * for await (const certificateDeactivateResponse of client.admin.organization.projects.certificates.deactivate(
4499
+ * 'project_id',
4500
+ * { certificate_ids: ['cert_abc'] },
4501
+ * )) {
4502
+ * // ...
4503
+ * }
4504
+ * ```
4505
+ */
4506
+ deactivate(projectID, body, options) {
4507
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/deactivate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
4508
+ }
4509
+ }
4510
+
4511
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4512
+ class RateLimits extends APIResource {
4513
+ /**
4514
+ * Returns the rate limits per model for a project.
4515
+ *
4516
+ * @example
4517
+ * ```ts
4518
+ * // Automatically fetches more pages as needed.
4519
+ * for await (const projectRateLimit of client.admin.organization.projects.rateLimits.listRateLimits(
4520
+ * 'project_id',
4521
+ * )) {
4522
+ * // ...
4523
+ * }
4524
+ * ```
4525
+ */
4526
+ listRateLimits(projectID, query = {}, options) {
4527
+ return this._client.getAPIList(path `/organization/projects/${projectID}/rate_limits`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4528
+ }
4529
+ /**
4530
+ * Updates a project rate limit.
4531
+ *
4532
+ * @example
4533
+ * ```ts
4534
+ * const projectRateLimit =
4535
+ * await client.admin.organization.projects.rateLimits.updateRateLimit(
4536
+ * 'rate_limit_id',
4537
+ * { project_id: 'project_id' },
4538
+ * );
4539
+ * ```
4540
+ */
4541
+ updateRateLimit(rateLimitID, params, options) {
4542
+ const { project_id, ...body } = params;
4543
+ return this._client.post(path `/organization/projects/${project_id}/rate_limits/${rateLimitID}`, {
4544
+ body,
4545
+ ...options,
4546
+ __security: { adminAPIKeyAuth: true },
4547
+ });
4548
+ }
4549
+ }
4550
+
4551
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4552
+ let Roles$3 = class Roles extends APIResource {
4553
+ /**
4554
+ * Creates a custom role for a project.
4555
+ *
4556
+ * @example
4557
+ * ```ts
4558
+ * const role =
4559
+ * await client.admin.organization.projects.roles.create(
4560
+ * 'project_id',
4561
+ * { permissions: ['string'], role_name: 'role_name' },
4562
+ * );
4563
+ * ```
4564
+ */
4565
+ create(projectID, body, options) {
4566
+ return this._client.post(path `/projects/${projectID}/roles`, {
4567
+ body,
4568
+ ...options,
4569
+ __security: { adminAPIKeyAuth: true },
4570
+ });
4571
+ }
4572
+ /**
4573
+ * Updates an existing project role.
4574
+ *
4575
+ * @example
4576
+ * ```ts
4577
+ * const role =
4578
+ * await client.admin.organization.projects.roles.update(
4579
+ * 'role_id',
4580
+ * { project_id: 'project_id' },
4581
+ * );
4582
+ * ```
4583
+ */
4584
+ update(roleID, params, options) {
4585
+ const { project_id, ...body } = params;
4586
+ return this._client.post(path `/projects/${project_id}/roles/${roleID}`, {
4587
+ body,
4588
+ ...options,
4589
+ __security: { adminAPIKeyAuth: true },
4590
+ });
4591
+ }
4592
+ /**
4593
+ * Lists the roles configured for a project.
4594
+ *
4595
+ * @example
4596
+ * ```ts
4597
+ * // Automatically fetches more pages as needed.
4598
+ * for await (const role of client.admin.organization.projects.roles.list(
4599
+ * 'project_id',
4600
+ * )) {
4601
+ * // ...
4602
+ * }
4603
+ * ```
4604
+ */
4605
+ list(projectID, query = {}, options) {
4606
+ return this._client.getAPIList(path `/projects/${projectID}/roles`, (NextCursorPage), {
4607
+ query,
4608
+ ...options,
4609
+ __security: { adminAPIKeyAuth: true },
4610
+ });
4611
+ }
4612
+ /**
4613
+ * Deletes a custom role from a project.
4614
+ *
4615
+ * @example
4616
+ * ```ts
4617
+ * const role =
4618
+ * await client.admin.organization.projects.roles.delete(
4619
+ * 'role_id',
4620
+ * { project_id: 'project_id' },
4621
+ * );
4622
+ * ```
4623
+ */
4624
+ delete(roleID, params, options) {
4625
+ const { project_id } = params;
4626
+ return this._client.delete(path `/projects/${project_id}/roles/${roleID}`, {
4627
+ ...options,
4628
+ __security: { adminAPIKeyAuth: true },
4629
+ });
4630
+ }
4631
+ };
4632
+
4633
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4634
+ class ServiceAccounts extends APIResource {
4635
+ /**
4636
+ * Creates a new service account in the project. This also returns an unredacted
4637
+ * API key for the service account.
4638
+ *
4639
+ * @example
4640
+ * ```ts
4641
+ * const serviceAccount =
4642
+ * await client.admin.organization.projects.serviceAccounts.create(
4643
+ * 'project_id',
4644
+ * { name: 'name' },
4645
+ * );
4646
+ * ```
4647
+ */
4648
+ create(projectID, body, options) {
4649
+ return this._client.post(path `/organization/projects/${projectID}/service_accounts`, {
4650
+ body,
4651
+ ...options,
4652
+ __security: { adminAPIKeyAuth: true },
4653
+ });
4654
+ }
4655
+ /**
4656
+ * Retrieves a service account in the project.
4657
+ *
4658
+ * @example
4659
+ * ```ts
4660
+ * const projectServiceAccount =
4661
+ * await client.admin.organization.projects.serviceAccounts.retrieve(
4662
+ * 'service_account_id',
4663
+ * { project_id: 'project_id' },
4664
+ * );
4665
+ * ```
4666
+ */
4667
+ retrieve(serviceAccountID, params, options) {
4668
+ const { project_id } = params;
4669
+ return this._client.get(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
4670
+ ...options,
4671
+ __security: { adminAPIKeyAuth: true },
4672
+ });
4673
+ }
4674
+ /**
4675
+ * Returns a list of service accounts in the project.
4676
+ *
4677
+ * @example
4678
+ * ```ts
4679
+ * // Automatically fetches more pages as needed.
4680
+ * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
4681
+ * 'project_id',
4682
+ * )) {
4683
+ * // ...
4684
+ * }
4685
+ * ```
4686
+ */
4687
+ list(projectID, query = {}, options) {
4688
+ return this._client.getAPIList(path `/organization/projects/${projectID}/service_accounts`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4689
+ }
4690
+ /**
4691
+ * Deletes a service account from the project.
4692
+ *
4693
+ * Returns confirmation of service account deletion, or an error if the project is
4694
+ * archived (archived projects have no service accounts).
4695
+ *
4696
+ * @example
4697
+ * ```ts
4698
+ * const serviceAccount =
4699
+ * await client.admin.organization.projects.serviceAccounts.delete(
4700
+ * 'service_account_id',
4701
+ * { project_id: 'project_id' },
4702
+ * );
4703
+ * ```
4704
+ */
4705
+ delete(serviceAccountID, params, options) {
4706
+ const { project_id } = params;
4707
+ return this._client.delete(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
4708
+ }
4709
+ }
4710
+
4711
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4712
+ let Roles$2 = class Roles extends APIResource {
4713
+ /**
4714
+ * Assigns a project role to a group within a project.
4715
+ *
4716
+ * @example
4717
+ * ```ts
4718
+ * const role =
4719
+ * await client.admin.organization.projects.groups.roles.create(
4720
+ * 'group_id',
4721
+ * { project_id: 'project_id', role_id: 'role_id' },
4722
+ * );
4723
+ * ```
4724
+ */
4725
+ create(groupID, params, options) {
4726
+ const { project_id, ...body } = params;
4727
+ return this._client.post(path `/projects/${project_id}/groups/${groupID}/roles`, {
4728
+ body,
4729
+ ...options,
4730
+ __security: { adminAPIKeyAuth: true },
4731
+ });
4732
+ }
4733
+ /**
4734
+ * Lists the project roles assigned to a group within a project.
4735
+ *
4736
+ * @example
4737
+ * ```ts
4738
+ * // Automatically fetches more pages as needed.
4739
+ * for await (const roleListResponse of client.admin.organization.projects.groups.roles.list(
4740
+ * 'group_id',
4741
+ * { project_id: 'project_id' },
4742
+ * )) {
4743
+ * // ...
4744
+ * }
4745
+ * ```
4746
+ */
4747
+ list(groupID, params, options) {
4748
+ const { project_id, ...query } = params;
4749
+ return this._client.getAPIList(path `/projects/${project_id}/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4750
+ }
4751
+ /**
4752
+ * Unassigns a project role from a group within a project.
4753
+ *
4754
+ * @example
4755
+ * ```ts
4756
+ * const role =
4757
+ * await client.admin.organization.projects.groups.roles.delete(
4758
+ * 'role_id',
4759
+ * { project_id: 'project_id', group_id: 'group_id' },
4760
+ * );
4761
+ * ```
4762
+ */
4763
+ delete(roleID, params, options) {
4764
+ const { project_id, group_id } = params;
4765
+ return this._client.delete(path `/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
4766
+ ...options,
4767
+ __security: { adminAPIKeyAuth: true },
4768
+ });
4769
+ }
4770
+ };
4771
+
4772
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4773
+ class Groups extends APIResource {
4774
+ constructor() {
4775
+ super(...arguments);
4776
+ this.roles = new Roles$2(this._client);
4777
+ }
4778
+ /**
4779
+ * Grants a group access to a project.
4780
+ *
4781
+ * @example
4782
+ * ```ts
4783
+ * const projectGroup =
4784
+ * await client.admin.organization.projects.groups.create(
4785
+ * 'project_id',
4786
+ * { group_id: 'group_id', role: 'role' },
4787
+ * );
4788
+ * ```
4789
+ */
4790
+ create(projectID, body, options) {
4791
+ return this._client.post(path `/organization/projects/${projectID}/groups`, {
4792
+ body,
4793
+ ...options,
4794
+ __security: { adminAPIKeyAuth: true },
4795
+ });
4796
+ }
4797
+ /**
4798
+ * Lists the groups that have access to a project.
4799
+ *
4800
+ * @example
4801
+ * ```ts
4802
+ * // Automatically fetches more pages as needed.
4803
+ * for await (const projectGroup of client.admin.organization.projects.groups.list(
4804
+ * 'project_id',
4805
+ * )) {
4806
+ * // ...
4807
+ * }
4808
+ * ```
4809
+ */
4810
+ list(projectID, query = {}, options) {
4811
+ return this._client.getAPIList(path `/organization/projects/${projectID}/groups`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4812
+ }
4813
+ /**
4814
+ * Revokes a group's access to a project.
4815
+ *
4816
+ * @example
4817
+ * ```ts
4818
+ * const group =
4819
+ * await client.admin.organization.projects.groups.delete(
4820
+ * 'group_id',
4821
+ * { project_id: 'project_id' },
4822
+ * );
4823
+ * ```
4824
+ */
4825
+ delete(groupID, params, options) {
4826
+ const { project_id } = params;
4827
+ return this._client.delete(path `/organization/projects/${project_id}/groups/${groupID}`, {
4828
+ ...options,
4829
+ __security: { adminAPIKeyAuth: true },
4830
+ });
4831
+ }
4832
+ }
4833
+ Groups.Roles = Roles$2;
4834
+
4835
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4836
+ let Roles$1 = class Roles extends APIResource {
4837
+ /**
4838
+ * Assigns a project role to a user within a project.
4839
+ *
4840
+ * @example
4841
+ * ```ts
4842
+ * const role =
4843
+ * await client.admin.organization.projects.users.roles.create(
4844
+ * 'user_id',
4845
+ * { project_id: 'project_id', role_id: 'role_id' },
4846
+ * );
4847
+ * ```
4848
+ */
4849
+ create(userID, params, options) {
4850
+ const { project_id, ...body } = params;
4851
+ return this._client.post(path `/projects/${project_id}/users/${userID}/roles`, {
4852
+ body,
4853
+ ...options,
4854
+ __security: { adminAPIKeyAuth: true },
4855
+ });
4856
+ }
4857
+ /**
4858
+ * Lists the project roles assigned to a user within a project.
4859
+ *
4860
+ * @example
4861
+ * ```ts
4862
+ * // Automatically fetches more pages as needed.
4863
+ * for await (const roleListResponse of client.admin.organization.projects.users.roles.list(
4864
+ * 'user_id',
4865
+ * { project_id: 'project_id' },
4866
+ * )) {
4867
+ * // ...
4868
+ * }
4869
+ * ```
4870
+ */
4871
+ list(userID, params, options) {
4872
+ const { project_id, ...query } = params;
4873
+ return this._client.getAPIList(path `/projects/${project_id}/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4874
+ }
4875
+ /**
4876
+ * Unassigns a project role from a user within a project.
4877
+ *
4878
+ * @example
4879
+ * ```ts
4880
+ * const role =
4881
+ * await client.admin.organization.projects.users.roles.delete(
4882
+ * 'role_id',
4883
+ * { project_id: 'project_id', user_id: 'user_id' },
4884
+ * );
4885
+ * ```
4886
+ */
4887
+ delete(roleID, params, options) {
4888
+ const { project_id, user_id } = params;
4889
+ return this._client.delete(path `/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
4890
+ ...options,
4891
+ __security: { adminAPIKeyAuth: true },
4892
+ });
4893
+ }
4894
+ };
4895
+
4896
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4897
+ let Users$1 = class Users extends APIResource {
4898
+ constructor() {
4899
+ super(...arguments);
4900
+ this.roles = new Roles$1(this._client);
4901
+ }
4902
+ /**
4903
+ * Adds a user to the project. Users must already be members of the organization to
4904
+ * be added to a project.
4905
+ *
4906
+ * @example
4907
+ * ```ts
4908
+ * const projectUser =
4909
+ * await client.admin.organization.projects.users.create(
4910
+ * 'project_id',
4911
+ * { role: 'role' },
4912
+ * );
4913
+ * ```
4914
+ */
4915
+ create(projectID, body, options) {
4916
+ return this._client.post(path `/organization/projects/${projectID}/users`, {
4917
+ body,
4918
+ ...options,
4919
+ __security: { adminAPIKeyAuth: true },
4920
+ });
4921
+ }
4922
+ /**
4923
+ * Retrieves a user in the project.
4924
+ *
4925
+ * @example
4926
+ * ```ts
4927
+ * const projectUser =
4928
+ * await client.admin.organization.projects.users.retrieve(
4929
+ * 'user_id',
4930
+ * { project_id: 'project_id' },
4931
+ * );
4932
+ * ```
4933
+ */
4934
+ retrieve(userID, params, options) {
4935
+ const { project_id } = params;
4936
+ return this._client.get(path `/organization/projects/${project_id}/users/${userID}`, {
4937
+ ...options,
4938
+ __security: { adminAPIKeyAuth: true },
4939
+ });
4940
+ }
4941
+ /**
4942
+ * Modifies a user's role in the project.
4943
+ *
4944
+ * @example
4945
+ * ```ts
4946
+ * const projectUser =
4947
+ * await client.admin.organization.projects.users.update(
4948
+ * 'user_id',
4949
+ * { project_id: 'project_id' },
4950
+ * );
4951
+ * ```
4952
+ */
4953
+ update(userID, params, options) {
4954
+ const { project_id, ...body } = params;
4955
+ return this._client.post(path `/organization/projects/${project_id}/users/${userID}`, {
4956
+ body,
4957
+ ...options,
4958
+ __security: { adminAPIKeyAuth: true },
4959
+ });
4960
+ }
4961
+ /**
4962
+ * Returns a list of users in the project.
4963
+ *
4964
+ * @example
4965
+ * ```ts
4966
+ * // Automatically fetches more pages as needed.
4967
+ * for await (const projectUser of client.admin.organization.projects.users.list(
4968
+ * 'project_id',
4969
+ * )) {
4970
+ * // ...
4971
+ * }
4972
+ * ```
4973
+ */
4974
+ list(projectID, query = {}, options) {
4975
+ return this._client.getAPIList(path `/organization/projects/${projectID}/users`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4976
+ }
4977
+ /**
4978
+ * Deletes a user from the project.
4979
+ *
4980
+ * Returns confirmation of project user deletion, or an error if the project is
4981
+ * archived (archived projects have no users).
4982
+ *
4983
+ * @example
4984
+ * ```ts
4985
+ * const user =
4986
+ * await client.admin.organization.projects.users.delete(
4987
+ * 'user_id',
4988
+ * { project_id: 'project_id' },
4989
+ * );
4990
+ * ```
4991
+ */
4992
+ delete(userID, params, options) {
4993
+ const { project_id } = params;
4994
+ return this._client.delete(path `/organization/projects/${project_id}/users/${userID}`, {
4995
+ ...options,
4996
+ __security: { adminAPIKeyAuth: true },
4997
+ });
4998
+ }
4999
+ };
5000
+ Users$1.Roles = Roles$1;
5001
+
5002
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5003
+ class Projects extends APIResource {
5004
+ constructor() {
5005
+ super(...arguments);
5006
+ this.users = new Users$1(this._client);
5007
+ this.serviceAccounts = new ServiceAccounts(this._client);
5008
+ this.apiKeys = new APIKeys(this._client);
5009
+ this.rateLimits = new RateLimits(this._client);
5010
+ this.groups = new Groups(this._client);
5011
+ this.roles = new Roles$3(this._client);
5012
+ this.certificates = new Certificates(this._client);
5013
+ }
5014
+ /**
5015
+ * Create a new project in the organization. Projects can be created and archived,
5016
+ * but cannot be deleted.
5017
+ *
5018
+ * @example
5019
+ * ```ts
5020
+ * const project =
5021
+ * await client.admin.organization.projects.create({
5022
+ * name: 'name',
5023
+ * });
5024
+ * ```
5025
+ */
5026
+ create(body, options) {
5027
+ return this._client.post('/organization/projects', {
5028
+ body,
5029
+ ...options,
5030
+ __security: { adminAPIKeyAuth: true },
5031
+ });
5032
+ }
5033
+ /**
5034
+ * Retrieves a project.
5035
+ *
5036
+ * @example
5037
+ * ```ts
5038
+ * const project =
5039
+ * await client.admin.organization.projects.retrieve(
5040
+ * 'project_id',
5041
+ * );
5042
+ * ```
5043
+ */
5044
+ retrieve(projectID, options) {
5045
+ return this._client.get(path `/organization/projects/${projectID}`, {
5046
+ ...options,
5047
+ __security: { adminAPIKeyAuth: true },
5048
+ });
5049
+ }
5050
+ /**
5051
+ * Modifies a project in the organization.
5052
+ *
5053
+ * @example
5054
+ * ```ts
5055
+ * const project =
5056
+ * await client.admin.organization.projects.update(
5057
+ * 'project_id',
5058
+ * );
5059
+ * ```
5060
+ */
5061
+ update(projectID, body, options) {
5062
+ return this._client.post(path `/organization/projects/${projectID}`, {
5063
+ body,
5064
+ ...options,
5065
+ __security: { adminAPIKeyAuth: true },
5066
+ });
5067
+ }
5068
+ /**
5069
+ * Returns a list of projects.
5070
+ *
5071
+ * @example
5072
+ * ```ts
5073
+ * // Automatically fetches more pages as needed.
5074
+ * for await (const project of client.admin.organization.projects.list()) {
5075
+ * // ...
5076
+ * }
5077
+ * ```
5078
+ */
5079
+ list(query = {}, options) {
5080
+ return this._client.getAPIList('/organization/projects', (ConversationCursorPage), {
5081
+ query,
5082
+ ...options,
5083
+ __security: { adminAPIKeyAuth: true },
5084
+ });
5085
+ }
5086
+ /**
5087
+ * Archives a project in the organization. Archived projects cannot be used or
5088
+ * updated.
5089
+ *
5090
+ * @example
5091
+ * ```ts
5092
+ * const project =
5093
+ * await client.admin.organization.projects.archive(
5094
+ * 'project_id',
5095
+ * );
5096
+ * ```
5097
+ */
5098
+ archive(projectID, options) {
5099
+ return this._client.post(path `/organization/projects/${projectID}/archive`, {
5100
+ ...options,
5101
+ __security: { adminAPIKeyAuth: true },
5102
+ });
5103
+ }
5104
+ }
5105
+ Projects.Users = Users$1;
5106
+ Projects.ServiceAccounts = ServiceAccounts;
5107
+ Projects.APIKeys = APIKeys;
5108
+ Projects.RateLimits = RateLimits;
5109
+ Projects.Groups = Groups;
5110
+ Projects.Roles = Roles$3;
5111
+ Projects.Certificates = Certificates;
5112
+
5113
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5114
+ class Roles extends APIResource {
5115
+ /**
5116
+ * Assigns an organization role to a user within the organization.
5117
+ *
5118
+ * @example
5119
+ * ```ts
5120
+ * const role =
5121
+ * await client.admin.organization.users.roles.create(
5122
+ * 'user_id',
5123
+ * { role_id: 'role_id' },
5124
+ * );
5125
+ * ```
5126
+ */
5127
+ create(userID, body, options) {
5128
+ return this._client.post(path `/organization/users/${userID}/roles`, {
5129
+ body,
5130
+ ...options,
5131
+ __security: { adminAPIKeyAuth: true },
5132
+ });
5133
+ }
5134
+ /**
5135
+ * Lists the organization roles assigned to a user within the organization.
5136
+ *
5137
+ * @example
5138
+ * ```ts
5139
+ * // Automatically fetches more pages as needed.
5140
+ * for await (const roleListResponse of client.admin.organization.users.roles.list(
5141
+ * 'user_id',
5142
+ * )) {
5143
+ * // ...
5144
+ * }
5145
+ * ```
5146
+ */
5147
+ list(userID, query = {}, options) {
5148
+ return this._client.getAPIList(path `/organization/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5149
+ }
5150
+ /**
5151
+ * Unassigns an organization role from a user within the organization.
5152
+ *
5153
+ * @example
5154
+ * ```ts
5155
+ * const role =
5156
+ * await client.admin.organization.users.roles.delete(
5157
+ * 'role_id',
5158
+ * { user_id: 'user_id' },
5159
+ * );
5160
+ * ```
5161
+ */
5162
+ delete(roleID, params, options) {
5163
+ const { user_id } = params;
5164
+ return this._client.delete(path `/organization/users/${user_id}/roles/${roleID}`, {
3461
5165
  ...options,
3462
- headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
3463
- };
3464
- runner._run(() => runner._runTools(client, params, opts));
3465
- return runner;
5166
+ __security: { adminAPIKeyAuth: true },
5167
+ });
3466
5168
  }
3467
5169
  }
3468
5170
 
3469
5171
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3470
- /**
3471
- * Given a list of messages comprising a conversation, the model will return a response.
3472
- */
3473
- let Completions$1 = class Completions extends APIResource {
5172
+ class Users extends APIResource {
3474
5173
  constructor() {
3475
5174
  super(...arguments);
3476
- this.messages = new Messages$1(this._client);
3477
- }
3478
- create(body, options) {
3479
- return this._client.post('/chat/completions', { body, ...options, stream: body.stream ?? false });
5175
+ this.roles = new Roles(this._client);
3480
5176
  }
3481
5177
  /**
3482
- * Get a stored chat completion. Only Chat Completions that have been created with
3483
- * the `store` parameter set to `true` will be returned.
5178
+ * Retrieves a user by their identifier.
3484
5179
  *
3485
5180
  * @example
3486
5181
  * ```ts
3487
- * const chatCompletion =
3488
- * await client.chat.completions.retrieve('completion_id');
5182
+ * const organizationUser =
5183
+ * await client.admin.organization.users.retrieve('user_id');
3489
5184
  * ```
3490
5185
  */
3491
- retrieve(completionID, options) {
3492
- return this._client.get(path `/chat/completions/${completionID}`, options);
5186
+ retrieve(userID, options) {
5187
+ return this._client.get(path `/organization/users/${userID}`, {
5188
+ ...options,
5189
+ __security: { adminAPIKeyAuth: true },
5190
+ });
3493
5191
  }
3494
5192
  /**
3495
- * Modify a stored chat completion. Only Chat Completions that have been created
3496
- * with the `store` parameter set to `true` can be modified. Currently, the only
3497
- * supported modification is to update the `metadata` field.
5193
+ * Modifies a user's role in the organization.
3498
5194
  *
3499
5195
  * @example
3500
5196
  * ```ts
3501
- * const chatCompletion = await client.chat.completions.update(
3502
- * 'completion_id',
3503
- * { metadata: { foo: 'string' } },
3504
- * );
5197
+ * const organizationUser =
5198
+ * await client.admin.organization.users.update('user_id');
3505
5199
  * ```
3506
5200
  */
3507
- update(completionID, body, options) {
3508
- return this._client.post(path `/chat/completions/${completionID}`, { body, ...options });
5201
+ update(userID, body, options) {
5202
+ return this._client.post(path `/organization/users/${userID}`, {
5203
+ body,
5204
+ ...options,
5205
+ __security: { adminAPIKeyAuth: true },
5206
+ });
3509
5207
  }
3510
5208
  /**
3511
- * List stored Chat Completions. Only Chat Completions that have been stored with
3512
- * the `store` parameter set to `true` will be returned.
5209
+ * Lists all of the users in the organization.
3513
5210
  *
3514
5211
  * @example
3515
5212
  * ```ts
3516
5213
  * // Automatically fetches more pages as needed.
3517
- * for await (const chatCompletion of client.chat.completions.list()) {
5214
+ * for await (const organizationUser of client.admin.organization.users.list()) {
3518
5215
  * // ...
3519
5216
  * }
3520
5217
  * ```
3521
5218
  */
3522
5219
  list(query = {}, options) {
3523
- return this._client.getAPIList('/chat/completions', (CursorPage), { query, ...options });
5220
+ return this._client.getAPIList('/organization/users', (ConversationCursorPage), {
5221
+ query,
5222
+ ...options,
5223
+ __security: { adminAPIKeyAuth: true },
5224
+ });
3524
5225
  }
3525
5226
  /**
3526
- * Delete a stored chat completion. Only Chat Completions that have been created
3527
- * with the `store` parameter set to `true` can be deleted.
5227
+ * Deletes a user from the organization.
3528
5228
  *
3529
5229
  * @example
3530
5230
  * ```ts
3531
- * const chatCompletionDeleted =
3532
- * await client.chat.completions.delete('completion_id');
5231
+ * const user = await client.admin.organization.users.delete(
5232
+ * 'user_id',
5233
+ * );
3533
5234
  * ```
3534
5235
  */
3535
- delete(completionID, options) {
3536
- return this._client.delete(path `/chat/completions/${completionID}`, options);
3537
- }
3538
- parse(body, options) {
3539
- validateInputTools(body.tools);
3540
- return this._client.chat.completions
3541
- .create(body, {
5236
+ delete(userID, options) {
5237
+ return this._client.delete(path `/organization/users/${userID}`, {
3542
5238
  ...options,
3543
- headers: {
3544
- ...options?.headers,
3545
- 'X-Stainless-Helper-Method': 'chat.completions.parse',
3546
- },
3547
- })
3548
- ._thenUnwrap((completion) => parseChatCompletion(completion, body));
3549
- }
3550
- runTools(body, options) {
3551
- if (body.stream) {
3552
- return ChatCompletionStreamingRunner.runTools(this._client, body, options);
3553
- }
3554
- return ChatCompletionRunner.runTools(this._client, body, options);
3555
- }
3556
- /**
3557
- * Creates a chat completion stream
3558
- */
3559
- stream(body, options) {
3560
- return ChatCompletionStream.createChatCompletion(this._client, body, options);
5239
+ __security: { adminAPIKeyAuth: true },
5240
+ });
3561
5241
  }
3562
- };
3563
- Completions$1.Messages = Messages$1;
5242
+ }
5243
+ Users.Roles = Roles;
3564
5244
 
3565
5245
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3566
- class Chat extends APIResource {
5246
+ class Organization extends APIResource {
3567
5247
  constructor() {
3568
5248
  super(...arguments);
3569
- this.completions = new Completions$1(this._client);
5249
+ this.auditLogs = new AuditLogs(this._client);
5250
+ this.adminAPIKeys = new AdminAPIKeys(this._client);
5251
+ this.usage = new Usage(this._client);
5252
+ this.invites = new Invites(this._client);
5253
+ this.users = new Users(this._client);
5254
+ this.groups = new Groups$1(this._client);
5255
+ this.roles = new Roles$5(this._client);
5256
+ this.certificates = new Certificates$1(this._client);
5257
+ this.projects = new Projects(this._client);
5258
+ }
5259
+ }
5260
+ Organization.AuditLogs = AuditLogs;
5261
+ Organization.AdminAPIKeys = AdminAPIKeys;
5262
+ Organization.Usage = Usage;
5263
+ Organization.Invites = Invites;
5264
+ Organization.Users = Users;
5265
+ Organization.Groups = Groups$1;
5266
+ Organization.Roles = Roles$5;
5267
+ Organization.Certificates = Certificates$1;
5268
+ Organization.Projects = Projects;
5269
+
5270
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5271
+ class Admin extends APIResource {
5272
+ constructor() {
5273
+ super(...arguments);
5274
+ this.organization = new Organization(this._client);
3570
5275
  }
3571
5276
  }
3572
- Chat.Completions = Completions$1;
5277
+ Admin.Organization = Organization;
3573
5278
 
3574
5279
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3575
5280
  const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
@@ -3666,6 +5371,7 @@ class Speech extends APIResource {
3666
5371
  body,
3667
5372
  ...options,
3668
5373
  headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
5374
+ __security: { bearerAuth: true },
3669
5375
  __binaryResponse: true,
3670
5376
  });
3671
5377
  }
@@ -3682,6 +5388,7 @@ class Transcriptions extends APIResource {
3682
5388
  ...options,
3683
5389
  stream: body.stream ?? false,
3684
5390
  __metadata: { model: body.model },
5391
+ __security: { bearerAuth: true },
3685
5392
  }, this._client));
3686
5393
  }
3687
5394
  }
@@ -3692,7 +5399,7 @@ class Transcriptions extends APIResource {
3692
5399
  */
3693
5400
  class Translations extends APIResource {
3694
5401
  create(body, options) {
3695
- return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
5402
+ return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } }, this._client));
3696
5403
  }
3697
5404
  }
3698
5405
 
@@ -3718,19 +5425,23 @@ class Batches extends APIResource {
3718
5425
  * Creates and executes a batch from an uploaded file of requests
3719
5426
  */
3720
5427
  create(body, options) {
3721
- return this._client.post('/batches', { body, ...options });
5428
+ return this._client.post('/batches', { body, ...options, __security: { bearerAuth: true } });
3722
5429
  }
3723
5430
  /**
3724
5431
  * Retrieves a batch.
3725
5432
  */
3726
5433
  retrieve(batchID, options) {
3727
- return this._client.get(path `/batches/${batchID}`, options);
5434
+ return this._client.get(path `/batches/${batchID}`, { ...options, __security: { bearerAuth: true } });
3728
5435
  }
3729
5436
  /**
3730
5437
  * List your organization's batches.
3731
5438
  */
3732
5439
  list(query = {}, options) {
3733
- return this._client.getAPIList('/batches', (CursorPage), { query, ...options });
5440
+ return this._client.getAPIList('/batches', (CursorPage), {
5441
+ query,
5442
+ ...options,
5443
+ __security: { bearerAuth: true },
5444
+ });
3734
5445
  }
3735
5446
  /**
3736
5447
  * Cancels an in-progress batch. The batch will be in status `cancelling` for up to
@@ -3738,7 +5449,10 @@ class Batches extends APIResource {
3738
5449
  * (if any) available in the output file.
3739
5450
  */
3740
5451
  cancel(batchID, options) {
3741
- return this._client.post(path `/batches/${batchID}/cancel`, options);
5452
+ return this._client.post(path `/batches/${batchID}/cancel`, {
5453
+ ...options,
5454
+ __security: { bearerAuth: true },
5455
+ });
3742
5456
  }
3743
5457
  }
3744
5458
 
@@ -3757,6 +5471,7 @@ class Assistants extends APIResource {
3757
5471
  body,
3758
5472
  ...options,
3759
5473
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5474
+ __security: { bearerAuth: true },
3760
5475
  });
3761
5476
  }
3762
5477
  /**
@@ -3768,6 +5483,7 @@ class Assistants extends APIResource {
3768
5483
  return this._client.get(path `/assistants/${assistantID}`, {
3769
5484
  ...options,
3770
5485
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5486
+ __security: { bearerAuth: true },
3771
5487
  });
3772
5488
  }
3773
5489
  /**
@@ -3780,6 +5496,7 @@ class Assistants extends APIResource {
3780
5496
  body,
3781
5497
  ...options,
3782
5498
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5499
+ __security: { bearerAuth: true },
3783
5500
  });
3784
5501
  }
3785
5502
  /**
@@ -3792,6 +5509,7 @@ class Assistants extends APIResource {
3792
5509
  query,
3793
5510
  ...options,
3794
5511
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5512
+ __security: { bearerAuth: true },
3795
5513
  });
3796
5514
  }
3797
5515
  /**
@@ -3803,6 +5521,7 @@ class Assistants extends APIResource {
3803
5521
  return this._client.delete(path `/assistants/${assistantID}`, {
3804
5522
  ...options,
3805
5523
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5524
+ __security: { bearerAuth: true },
3806
5525
  });
3807
5526
  }
3808
5527
  }
@@ -3829,6 +5548,7 @@ let Sessions$1 = class Sessions extends APIResource {
3829
5548
  body,
3830
5549
  ...options,
3831
5550
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5551
+ __security: { bearerAuth: true },
3832
5552
  });
3833
5553
  }
3834
5554
  };
@@ -3855,6 +5575,7 @@ class TranscriptionSessions extends APIResource {
3855
5575
  body,
3856
5576
  ...options,
3857
5577
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5578
+ __security: { bearerAuth: true },
3858
5579
  });
3859
5580
  }
3860
5581
  }
@@ -3892,6 +5613,7 @@ class Sessions extends APIResource {
3892
5613
  body,
3893
5614
  ...options,
3894
5615
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5616
+ __security: { bearerAuth: true },
3895
5617
  });
3896
5618
  }
3897
5619
  /**
@@ -3909,6 +5631,7 @@ class Sessions extends APIResource {
3909
5631
  return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
3910
5632
  ...options,
3911
5633
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5634
+ __security: { bearerAuth: true },
3912
5635
  });
3913
5636
  }
3914
5637
  }
@@ -3928,6 +5651,7 @@ let Threads$1 = class Threads extends APIResource {
3928
5651
  return this._client.get(path `/chatkit/threads/${threadID}`, {
3929
5652
  ...options,
3930
5653
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5654
+ __security: { bearerAuth: true },
3931
5655
  });
3932
5656
  }
3933
5657
  /**
@@ -3946,6 +5670,7 @@ let Threads$1 = class Threads extends APIResource {
3946
5670
  query,
3947
5671
  ...options,
3948
5672
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5673
+ __security: { bearerAuth: true },
3949
5674
  });
3950
5675
  }
3951
5676
  /**
@@ -3962,6 +5687,7 @@ let Threads$1 = class Threads extends APIResource {
3962
5687
  return this._client.delete(path `/chatkit/threads/${threadID}`, {
3963
5688
  ...options,
3964
5689
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5690
+ __security: { bearerAuth: true },
3965
5691
  });
3966
5692
  }
3967
5693
  /**
@@ -3978,7 +5704,12 @@ let Threads$1 = class Threads extends APIResource {
3978
5704
  * ```
3979
5705
  */
3980
5706
  listItems(threadID, query = {}, options) {
3981
- return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), { query, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) });
5707
+ return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), {
5708
+ query,
5709
+ ...options,
5710
+ headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5711
+ __security: { bearerAuth: true },
5712
+ });
3982
5713
  }
3983
5714
  };
3984
5715
 
@@ -4010,6 +5741,7 @@ class Messages extends APIResource {
4010
5741
  body,
4011
5742
  ...options,
4012
5743
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5744
+ __security: { bearerAuth: true },
4013
5745
  });
4014
5746
  }
4015
5747
  /**
@@ -4022,6 +5754,7 @@ class Messages extends APIResource {
4022
5754
  return this._client.get(path `/threads/${thread_id}/messages/${messageID}`, {
4023
5755
  ...options,
4024
5756
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5757
+ __security: { bearerAuth: true },
4025
5758
  });
4026
5759
  }
4027
5760
  /**
@@ -4035,6 +5768,7 @@ class Messages extends APIResource {
4035
5768
  body,
4036
5769
  ...options,
4037
5770
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5771
+ __security: { bearerAuth: true },
4038
5772
  });
4039
5773
  }
4040
5774
  /**
@@ -4047,6 +5781,7 @@ class Messages extends APIResource {
4047
5781
  query,
4048
5782
  ...options,
4049
5783
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5784
+ __security: { bearerAuth: true },
4050
5785
  });
4051
5786
  }
4052
5787
  /**
@@ -4059,6 +5794,7 @@ class Messages extends APIResource {
4059
5794
  return this._client.delete(path `/threads/${thread_id}/messages/${messageID}`, {
4060
5795
  ...options,
4061
5796
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5797
+ __security: { bearerAuth: true },
4062
5798
  });
4063
5799
  }
4064
5800
  }
@@ -4081,6 +5817,7 @@ class Steps extends APIResource {
4081
5817
  query,
4082
5818
  ...options,
4083
5819
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5820
+ __security: { bearerAuth: true },
4084
5821
  });
4085
5822
  }
4086
5823
  /**
@@ -4094,6 +5831,7 @@ class Steps extends APIResource {
4094
5831
  query,
4095
5832
  ...options,
4096
5833
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5834
+ __security: { bearerAuth: true },
4097
5835
  });
4098
5836
  }
4099
5837
  }
@@ -4697,6 +6435,7 @@ let Runs$1 = class Runs extends APIResource {
4697
6435
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
4698
6436
  stream: params.stream ?? false,
4699
6437
  __synthesizeEventData: true,
6438
+ __security: { bearerAuth: true },
4700
6439
  });
4701
6440
  }
4702
6441
  /**
@@ -4709,6 +6448,7 @@ let Runs$1 = class Runs extends APIResource {
4709
6448
  return this._client.get(path `/threads/${thread_id}/runs/${runID}`, {
4710
6449
  ...options,
4711
6450
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6451
+ __security: { bearerAuth: true },
4712
6452
  });
4713
6453
  }
4714
6454
  /**
@@ -4722,6 +6462,7 @@ let Runs$1 = class Runs extends APIResource {
4722
6462
  body,
4723
6463
  ...options,
4724
6464
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6465
+ __security: { bearerAuth: true },
4725
6466
  });
4726
6467
  }
4727
6468
  /**
@@ -4734,6 +6475,7 @@ let Runs$1 = class Runs extends APIResource {
4734
6475
  query,
4735
6476
  ...options,
4736
6477
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6478
+ __security: { bearerAuth: true },
4737
6479
  });
4738
6480
  }
4739
6481
  /**
@@ -4746,6 +6488,7 @@ let Runs$1 = class Runs extends APIResource {
4746
6488
  return this._client.post(path `/threads/${thread_id}/runs/${runID}/cancel`, {
4747
6489
  ...options,
4748
6490
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6491
+ __security: { bearerAuth: true },
4749
6492
  });
4750
6493
  }
4751
6494
  /**
@@ -4828,6 +6571,7 @@ let Runs$1 = class Runs extends APIResource {
4828
6571
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
4829
6572
  stream: params.stream ?? false,
4830
6573
  __synthesizeEventData: true,
6574
+ __security: { bearerAuth: true },
4831
6575
  });
4832
6576
  }
4833
6577
  /**
@@ -4872,6 +6616,7 @@ class Threads extends APIResource {
4872
6616
  body,
4873
6617
  ...options,
4874
6618
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6619
+ __security: { bearerAuth: true },
4875
6620
  });
4876
6621
  }
4877
6622
  /**
@@ -4883,6 +6628,7 @@ class Threads extends APIResource {
4883
6628
  return this._client.get(path `/threads/${threadID}`, {
4884
6629
  ...options,
4885
6630
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6631
+ __security: { bearerAuth: true },
4886
6632
  });
4887
6633
  }
4888
6634
  /**
@@ -4895,6 +6641,7 @@ class Threads extends APIResource {
4895
6641
  body,
4896
6642
  ...options,
4897
6643
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6644
+ __security: { bearerAuth: true },
4898
6645
  });
4899
6646
  }
4900
6647
  /**
@@ -4906,6 +6653,7 @@ class Threads extends APIResource {
4906
6653
  return this._client.delete(path `/threads/${threadID}`, {
4907
6654
  ...options,
4908
6655
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6656
+ __security: { bearerAuth: true },
4909
6657
  });
4910
6658
  }
4911
6659
  createAndRun(body, options) {
@@ -4915,6 +6663,7 @@ class Threads extends APIResource {
4915
6663
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
4916
6664
  stream: body.stream ?? false,
4917
6665
  __synthesizeEventData: true,
6666
+ __security: { bearerAuth: true },
4918
6667
  });
4919
6668
  }
4920
6669
  /**
@@ -4957,7 +6706,12 @@ Beta.Threads = Threads;
4957
6706
  */
4958
6707
  class Completions extends APIResource {
4959
6708
  create(body, options) {
4960
- return this._client.post('/completions', { body, ...options, stream: body.stream ?? false });
6709
+ return this._client.post('/completions', {
6710
+ body,
6711
+ ...options,
6712
+ stream: body.stream ?? false,
6713
+ __security: { bearerAuth: true },
6714
+ });
4961
6715
  }
4962
6716
  }
4963
6717
 
@@ -4971,6 +6725,7 @@ let Content$2 = class Content extends APIResource {
4971
6725
  return this._client.get(path `/containers/${container_id}/files/${fileID}/content`, {
4972
6726
  ...options,
4973
6727
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
6728
+ __security: { bearerAuth: true },
4974
6729
  __binaryResponse: true,
4975
6730
  });
4976
6731
  }
@@ -4989,14 +6744,17 @@ let Files$2 = class Files extends APIResource {
4989
6744
  * a JSON request with a file ID.
4990
6745
  */
4991
6746
  create(containerID, body, options) {
4992
- return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6747
+ return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4993
6748
  }
4994
6749
  /**
4995
6750
  * Retrieve Container File
4996
6751
  */
4997
6752
  retrieve(fileID, params, options) {
4998
6753
  const { container_id } = params;
4999
- return this._client.get(path `/containers/${container_id}/files/${fileID}`, options);
6754
+ return this._client.get(path `/containers/${container_id}/files/${fileID}`, {
6755
+ ...options,
6756
+ __security: { bearerAuth: true },
6757
+ });
5000
6758
  }
5001
6759
  /**
5002
6760
  * List Container files
@@ -5005,6 +6763,7 @@ let Files$2 = class Files extends APIResource {
5005
6763
  return this._client.getAPIList(path `/containers/${containerID}/files`, (CursorPage), {
5006
6764
  query,
5007
6765
  ...options,
6766
+ __security: { bearerAuth: true },
5008
6767
  });
5009
6768
  }
5010
6769
  /**
@@ -5015,6 +6774,7 @@ let Files$2 = class Files extends APIResource {
5015
6774
  return this._client.delete(path `/containers/${container_id}/files/${fileID}`, {
5016
6775
  ...options,
5017
6776
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
6777
+ __security: { bearerAuth: true },
5018
6778
  });
5019
6779
  }
5020
6780
  };
@@ -5030,19 +6790,26 @@ class Containers extends APIResource {
5030
6790
  * Create Container
5031
6791
  */
5032
6792
  create(body, options) {
5033
- return this._client.post('/containers', { body, ...options });
6793
+ return this._client.post('/containers', { body, ...options, __security: { bearerAuth: true } });
5034
6794
  }
5035
6795
  /**
5036
6796
  * Retrieve Container
5037
6797
  */
5038
6798
  retrieve(containerID, options) {
5039
- return this._client.get(path `/containers/${containerID}`, options);
6799
+ return this._client.get(path `/containers/${containerID}`, {
6800
+ ...options,
6801
+ __security: { bearerAuth: true },
6802
+ });
5040
6803
  }
5041
6804
  /**
5042
6805
  * List Containers
5043
6806
  */
5044
6807
  list(query = {}, options) {
5045
- return this._client.getAPIList('/containers', (CursorPage), { query, ...options });
6808
+ return this._client.getAPIList('/containers', (CursorPage), {
6809
+ query,
6810
+ ...options,
6811
+ __security: { bearerAuth: true },
6812
+ });
5046
6813
  }
5047
6814
  /**
5048
6815
  * Delete Container
@@ -5051,6 +6818,7 @@ class Containers extends APIResource {
5051
6818
  return this._client.delete(path `/containers/${containerID}`, {
5052
6819
  ...options,
5053
6820
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
6821
+ __security: { bearerAuth: true },
5054
6822
  });
5055
6823
  }
5056
6824
  }
@@ -5070,6 +6838,7 @@ class Items extends APIResource {
5070
6838
  query: { include },
5071
6839
  body,
5072
6840
  ...options,
6841
+ __security: { bearerAuth: true },
5073
6842
  });
5074
6843
  }
5075
6844
  /**
@@ -5077,20 +6846,27 @@ class Items extends APIResource {
5077
6846
  */
5078
6847
  retrieve(itemID, params, options) {
5079
6848
  const { conversation_id, ...query } = params;
5080
- return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, { query, ...options });
6849
+ return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, {
6850
+ query,
6851
+ ...options,
6852
+ __security: { bearerAuth: true },
6853
+ });
5081
6854
  }
5082
6855
  /**
5083
6856
  * List all items for a conversation with the given ID.
5084
6857
  */
5085
6858
  list(conversationID, query = {}, options) {
5086
- return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options });
6859
+ return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options, __security: { bearerAuth: true } });
5087
6860
  }
5088
6861
  /**
5089
6862
  * Delete an item from a conversation with the given IDs.
5090
6863
  */
5091
6864
  delete(itemID, params, options) {
5092
6865
  const { conversation_id } = params;
5093
- return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, options);
6866
+ return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, {
6867
+ ...options,
6868
+ __security: { bearerAuth: true },
6869
+ });
5094
6870
  }
5095
6871
  }
5096
6872
 
@@ -5107,25 +6883,35 @@ class Conversations extends APIResource {
5107
6883
  * Create a conversation.
5108
6884
  */
5109
6885
  create(body = {}, options) {
5110
- return this._client.post('/conversations', { body, ...options });
6886
+ return this._client.post('/conversations', { body, ...options, __security: { bearerAuth: true } });
5111
6887
  }
5112
6888
  /**
5113
6889
  * Get a conversation
5114
6890
  */
5115
6891
  retrieve(conversationID, options) {
5116
- return this._client.get(path `/conversations/${conversationID}`, options);
6892
+ return this._client.get(path `/conversations/${conversationID}`, {
6893
+ ...options,
6894
+ __security: { bearerAuth: true },
6895
+ });
5117
6896
  }
5118
6897
  /**
5119
6898
  * Update a conversation
5120
6899
  */
5121
6900
  update(conversationID, body, options) {
5122
- return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
6901
+ return this._client.post(path `/conversations/${conversationID}`, {
6902
+ body,
6903
+ ...options,
6904
+ __security: { bearerAuth: true },
6905
+ });
5123
6906
  }
5124
6907
  /**
5125
6908
  * Delete a conversation. Items in the conversation will not be deleted.
5126
6909
  */
5127
6910
  delete(conversationID, options) {
5128
- return this._client.delete(path `/conversations/${conversationID}`, options);
6911
+ return this._client.delete(path `/conversations/${conversationID}`, {
6912
+ ...options,
6913
+ __security: { bearerAuth: true },
6914
+ });
5129
6915
  }
5130
6916
  }
5131
6917
  Conversations.Items = Items;
@@ -5161,6 +6947,7 @@ class Embeddings extends APIResource {
5161
6947
  encoding_format: encoding_format,
5162
6948
  },
5163
6949
  ...options,
6950
+ __security: { bearerAuth: true },
5164
6951
  });
5165
6952
  // if the user specified an encoding_format, return the response as-is
5166
6953
  if (hasUserProvidedEncodingFormat) {
@@ -5193,14 +6980,17 @@ class OutputItems extends APIResource {
5193
6980
  */
5194
6981
  retrieve(outputItemID, params, options) {
5195
6982
  const { eval_id, run_id } = params;
5196
- return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, options);
6983
+ return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, {
6984
+ ...options,
6985
+ __security: { bearerAuth: true },
6986
+ });
5197
6987
  }
5198
6988
  /**
5199
6989
  * Get a list of output items for an evaluation run.
5200
6990
  */
5201
6991
  list(runID, params, options) {
5202
6992
  const { eval_id, ...query } = params;
5203
- return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options });
6993
+ return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5204
6994
  }
5205
6995
  }
5206
6996
 
@@ -5219,14 +7009,21 @@ class Runs extends APIResource {
5219
7009
  * schema specified in the config of the evaluation.
5220
7010
  */
5221
7011
  create(evalID, body, options) {
5222
- return this._client.post(path `/evals/${evalID}/runs`, { body, ...options });
7012
+ return this._client.post(path `/evals/${evalID}/runs`, {
7013
+ body,
7014
+ ...options,
7015
+ __security: { bearerAuth: true },
7016
+ });
5223
7017
  }
5224
7018
  /**
5225
7019
  * Get an evaluation run by ID.
5226
7020
  */
5227
7021
  retrieve(runID, params, options) {
5228
7022
  const { eval_id } = params;
5229
- return this._client.get(path `/evals/${eval_id}/runs/${runID}`, options);
7023
+ return this._client.get(path `/evals/${eval_id}/runs/${runID}`, {
7024
+ ...options,
7025
+ __security: { bearerAuth: true },
7026
+ });
5230
7027
  }
5231
7028
  /**
5232
7029
  * Get a list of runs for an evaluation.
@@ -5235,6 +7032,7 @@ class Runs extends APIResource {
5235
7032
  return this._client.getAPIList(path `/evals/${evalID}/runs`, (CursorPage), {
5236
7033
  query,
5237
7034
  ...options,
7035
+ __security: { bearerAuth: true },
5238
7036
  });
5239
7037
  }
5240
7038
  /**
@@ -5242,14 +7040,20 @@ class Runs extends APIResource {
5242
7040
  */
5243
7041
  delete(runID, params, options) {
5244
7042
  const { eval_id } = params;
5245
- return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, options);
7043
+ return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, {
7044
+ ...options,
7045
+ __security: { bearerAuth: true },
7046
+ });
5246
7047
  }
5247
7048
  /**
5248
7049
  * Cancel an ongoing evaluation run.
5249
7050
  */
5250
7051
  cancel(runID, params, options) {
5251
7052
  const { eval_id } = params;
5252
- return this._client.post(path `/evals/${eval_id}/runs/${runID}`, options);
7053
+ return this._client.post(path `/evals/${eval_id}/runs/${runID}`, {
7054
+ ...options,
7055
+ __security: { bearerAuth: true },
7056
+ });
5253
7057
  }
5254
7058
  }
5255
7059
  Runs.OutputItems = OutputItems;
@@ -5272,31 +7076,35 @@ class Evals extends APIResource {
5272
7076
  * the [Evals guide](https://platform.openai.com/docs/guides/evals).
5273
7077
  */
5274
7078
  create(body, options) {
5275
- return this._client.post('/evals', { body, ...options });
7079
+ return this._client.post('/evals', { body, ...options, __security: { bearerAuth: true } });
5276
7080
  }
5277
7081
  /**
5278
7082
  * Get an evaluation by ID.
5279
7083
  */
5280
7084
  retrieve(evalID, options) {
5281
- return this._client.get(path `/evals/${evalID}`, options);
7085
+ return this._client.get(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
5282
7086
  }
5283
7087
  /**
5284
7088
  * Update certain properties of an evaluation.
5285
7089
  */
5286
7090
  update(evalID, body, options) {
5287
- return this._client.post(path `/evals/${evalID}`, { body, ...options });
7091
+ return this._client.post(path `/evals/${evalID}`, { body, ...options, __security: { bearerAuth: true } });
5288
7092
  }
5289
7093
  /**
5290
7094
  * List evaluations for a project.
5291
7095
  */
5292
7096
  list(query = {}, options) {
5293
- return this._client.getAPIList('/evals', (CursorPage), { query, ...options });
7097
+ return this._client.getAPIList('/evals', (CursorPage), {
7098
+ query,
7099
+ ...options,
7100
+ __security: { bearerAuth: true },
7101
+ });
5294
7102
  }
5295
7103
  /**
5296
7104
  * Delete an evaluation.
5297
7105
  */
5298
7106
  delete(evalID, options) {
5299
- return this._client.delete(path `/evals/${evalID}`, options);
7107
+ return this._client.delete(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
5300
7108
  }
5301
7109
  }
5302
7110
  Evals.Runs = Runs;
@@ -5309,7 +7117,8 @@ let Files$1 = class Files extends APIResource {
5309
7117
  /**
5310
7118
  * Upload a file that can be used across various endpoints. Individual files can be
5311
7119
  * up to 512 MB, and each project can store up to 2.5 TB of files in total. There
5312
- * is no organization-wide storage limit.
7120
+ * is no organization-wide storage limit. Uploads to this endpoint are rate-limited
7121
+ * to 1,000 requests per minute per authenticated user.
5313
7122
  *
5314
7123
  * - The Assistants API supports files up to 2 million tokens and of specific file
5315
7124
  * types. See the
@@ -5324,30 +7133,40 @@ let Files$1 = class Files extends APIResource {
5324
7133
  * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
5325
7134
  * also has a specific required
5326
7135
  * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
7136
+ * - For Retrieval or `file_search` ingestion, upload files here first. If you need
7137
+ * to attach multiple uploaded files to the same vector store, use
7138
+ * [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch)
7139
+ * instead of attaching them one by one. Vector store attachment has separate
7140
+ * limits from file upload, including 2,000 attached files per minute per
7141
+ * organization.
5327
7142
  *
5328
7143
  * Please [contact us](https://help.openai.com/) if you need to increase these
5329
7144
  * storage limits.
5330
7145
  */
5331
7146
  create(body, options) {
5332
- return this._client.post('/files', multipartFormRequestOptions({ body, ...options }, this._client));
7147
+ return this._client.post('/files', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5333
7148
  }
5334
7149
  /**
5335
7150
  * Returns information about a specific file.
5336
7151
  */
5337
7152
  retrieve(fileID, options) {
5338
- return this._client.get(path `/files/${fileID}`, options);
7153
+ return this._client.get(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
5339
7154
  }
5340
7155
  /**
5341
7156
  * Returns a list of files.
5342
7157
  */
5343
7158
  list(query = {}, options) {
5344
- return this._client.getAPIList('/files', (CursorPage), { query, ...options });
7159
+ return this._client.getAPIList('/files', (CursorPage), {
7160
+ query,
7161
+ ...options,
7162
+ __security: { bearerAuth: true },
7163
+ });
5345
7164
  }
5346
7165
  /**
5347
7166
  * Delete a file and remove it from all vector stores.
5348
7167
  */
5349
7168
  delete(fileID, options) {
5350
- return this._client.delete(path `/files/${fileID}`, options);
7169
+ return this._client.delete(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
5351
7170
  }
5352
7171
  /**
5353
7172
  * Returns the contents of the specified file.
@@ -5356,6 +7175,7 @@ let Files$1 = class Files extends APIResource {
5356
7175
  return this._client.get(path `/files/${fileID}/content`, {
5357
7176
  ...options,
5358
7177
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
7178
+ __security: { bearerAuth: true },
5359
7179
  __binaryResponse: true,
5360
7180
  });
5361
7181
  }
@@ -5406,7 +7226,11 @@ let Graders$1 = class Graders extends APIResource {
5406
7226
  * ```
5407
7227
  */
5408
7228
  run(body, options) {
5409
- return this._client.post('/fine_tuning/alpha/graders/run', { body, ...options });
7229
+ return this._client.post('/fine_tuning/alpha/graders/run', {
7230
+ body,
7231
+ ...options,
7232
+ __security: { bearerAuth: true },
7233
+ });
5410
7234
  }
5411
7235
  /**
5412
7236
  * Validate a grader.
@@ -5426,7 +7250,11 @@ let Graders$1 = class Graders extends APIResource {
5426
7250
  * ```
5427
7251
  */
5428
7252
  validate(body, options) {
5429
- return this._client.post('/fine_tuning/alpha/graders/validate', { body, ...options });
7253
+ return this._client.post('/fine_tuning/alpha/graders/validate', {
7254
+ body,
7255
+ ...options,
7256
+ __security: { bearerAuth: true },
7257
+ });
5430
7258
  }
5431
7259
  };
5432
7260
 
@@ -5462,7 +7290,7 @@ class Permissions extends APIResource {
5462
7290
  * ```
5463
7291
  */
5464
7292
  create(fineTunedModelCheckpoint, body, options) {
5465
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options });
7293
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
5466
7294
  }
5467
7295
  /**
5468
7296
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -5476,6 +7304,7 @@ class Permissions extends APIResource {
5476
7304
  return this._client.get(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
5477
7305
  query,
5478
7306
  ...options,
7307
+ __security: { adminAPIKeyAuth: true },
5479
7308
  });
5480
7309
  }
5481
7310
  /**
@@ -5495,7 +7324,7 @@ class Permissions extends APIResource {
5495
7324
  * ```
5496
7325
  */
5497
7326
  list(fineTunedModelCheckpoint, query = {}, options) {
5498
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options });
7327
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5499
7328
  }
5500
7329
  /**
5501
7330
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -5517,7 +7346,7 @@ class Permissions extends APIResource {
5517
7346
  */
5518
7347
  delete(permissionID, params, options) {
5519
7348
  const { fine_tuned_model_checkpoint } = params;
5520
- return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, options);
7349
+ return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, { ...options, __security: { adminAPIKeyAuth: true } });
5521
7350
  }
5522
7351
  }
5523
7352
 
@@ -5549,7 +7378,7 @@ class Checkpoints extends APIResource {
5549
7378
  * ```
5550
7379
  */
5551
7380
  list(fineTuningJobID, query = {}, options) {
5552
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options });
7381
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5553
7382
  }
5554
7383
  }
5555
7384
 
@@ -5580,7 +7409,7 @@ class Jobs extends APIResource {
5580
7409
  * ```
5581
7410
  */
5582
7411
  create(body, options) {
5583
- return this._client.post('/fine_tuning/jobs', { body, ...options });
7412
+ return this._client.post('/fine_tuning/jobs', { body, ...options, __security: { bearerAuth: true } });
5584
7413
  }
5585
7414
  /**
5586
7415
  * Get info about a fine-tuning job.
@@ -5595,7 +7424,10 @@ class Jobs extends APIResource {
5595
7424
  * ```
5596
7425
  */
5597
7426
  retrieve(fineTuningJobID, options) {
5598
- return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, options);
7427
+ return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, {
7428
+ ...options,
7429
+ __security: { bearerAuth: true },
7430
+ });
5599
7431
  }
5600
7432
  /**
5601
7433
  * List your organization's fine-tuning jobs
@@ -5609,7 +7441,11 @@ class Jobs extends APIResource {
5609
7441
  * ```
5610
7442
  */
5611
7443
  list(query = {}, options) {
5612
- return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), { query, ...options });
7444
+ return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), {
7445
+ query,
7446
+ ...options,
7447
+ __security: { bearerAuth: true },
7448
+ });
5613
7449
  }
5614
7450
  /**
5615
7451
  * Immediately cancel a fine-tune job.
@@ -5622,7 +7458,10 @@ class Jobs extends APIResource {
5622
7458
  * ```
5623
7459
  */
5624
7460
  cancel(fineTuningJobID, options) {
5625
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, options);
7461
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, {
7462
+ ...options,
7463
+ __security: { bearerAuth: true },
7464
+ });
5626
7465
  }
5627
7466
  /**
5628
7467
  * Get status updates for a fine-tuning job.
@@ -5638,7 +7477,7 @@ class Jobs extends APIResource {
5638
7477
  * ```
5639
7478
  */
5640
7479
  listEvents(fineTuningJobID, query = {}, options) {
5641
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options });
7480
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5642
7481
  }
5643
7482
  /**
5644
7483
  * Pause a fine-tune job.
@@ -5651,7 +7490,10 @@ class Jobs extends APIResource {
5651
7490
  * ```
5652
7491
  */
5653
7492
  pause(fineTuningJobID, options) {
5654
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, options);
7493
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, {
7494
+ ...options,
7495
+ __security: { bearerAuth: true },
7496
+ });
5655
7497
  }
5656
7498
  /**
5657
7499
  * Resume a fine-tune job.
@@ -5664,7 +7506,10 @@ class Jobs extends APIResource {
5664
7506
  * ```
5665
7507
  */
5666
7508
  resume(fineTuningJobID, options) {
5667
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, options);
7509
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, {
7510
+ ...options,
7511
+ __security: { bearerAuth: true },
7512
+ });
5668
7513
  }
5669
7514
  }
5670
7515
  Jobs.Checkpoints = Checkpoints;
@@ -5713,13 +7558,18 @@ class Images extends APIResource {
5713
7558
  * ```
5714
7559
  */
5715
7560
  createVariation(body, options) {
5716
- return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options }, this._client));
7561
+ return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5717
7562
  }
5718
7563
  edit(body, options) {
5719
- return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false }, this._client));
7564
+ return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false, __security: { bearerAuth: true } }, this._client));
5720
7565
  }
5721
7566
  generate(body, options) {
5722
- return this._client.post('/images/generations', { body, ...options, stream: body.stream ?? false });
7567
+ return this._client.post('/images/generations', {
7568
+ body,
7569
+ ...options,
7570
+ stream: body.stream ?? false,
7571
+ __security: { bearerAuth: true },
7572
+ });
5723
7573
  }
5724
7574
  }
5725
7575
 
@@ -5733,21 +7583,21 @@ class Models extends APIResource {
5733
7583
  * the owner and permissioning.
5734
7584
  */
5735
7585
  retrieve(model, options) {
5736
- return this._client.get(path `/models/${model}`, options);
7586
+ return this._client.get(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
5737
7587
  }
5738
7588
  /**
5739
7589
  * Lists the currently available models, and provides basic information about each
5740
7590
  * one such as the owner and availability.
5741
7591
  */
5742
7592
  list(options) {
5743
- return this._client.getAPIList('/models', (Page), options);
7593
+ return this._client.getAPIList('/models', (Page), { ...options, __security: { bearerAuth: true } });
5744
7594
  }
5745
7595
  /**
5746
7596
  * Delete a fine-tuned model. You must have the Owner role in your organization to
5747
7597
  * delete a model.
5748
7598
  */
5749
7599
  delete(model, options) {
5750
- return this._client.delete(path `/models/${model}`, options);
7600
+ return this._client.delete(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
5751
7601
  }
5752
7602
  }
5753
7603
 
@@ -5761,7 +7611,7 @@ class Moderations extends APIResource {
5761
7611
  * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
5762
7612
  */
5763
7613
  create(body, options) {
5764
- return this._client.post('/moderations', { body, ...options });
7614
+ return this._client.post('/moderations', { body, ...options, __security: { bearerAuth: true } });
5765
7615
  }
5766
7616
  }
5767
7617
 
@@ -5783,6 +7633,7 @@ class Calls extends APIResource {
5783
7633
  body,
5784
7634
  ...options,
5785
7635
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7636
+ __security: { bearerAuth: true },
5786
7637
  });
5787
7638
  }
5788
7639
  /**
@@ -5797,6 +7648,7 @@ class Calls extends APIResource {
5797
7648
  return this._client.post(path `/realtime/calls/${callID}/hangup`, {
5798
7649
  ...options,
5799
7650
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7651
+ __security: { bearerAuth: true },
5800
7652
  });
5801
7653
  }
5802
7654
  /**
@@ -5814,6 +7666,7 @@ class Calls extends APIResource {
5814
7666
  body,
5815
7667
  ...options,
5816
7668
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7669
+ __security: { bearerAuth: true },
5817
7670
  });
5818
7671
  }
5819
7672
  /**
@@ -5829,6 +7682,7 @@ class Calls extends APIResource {
5829
7682
  body,
5830
7683
  ...options,
5831
7684
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7685
+ __security: { bearerAuth: true },
5832
7686
  });
5833
7687
  }
5834
7688
  }
@@ -5859,7 +7713,11 @@ class ClientSecrets extends APIResource {
5859
7713
  * ```
5860
7714
  */
5861
7715
  create(body, options) {
5862
- return this._client.post('/realtime/client_secrets', { body, ...options });
7716
+ return this._client.post('/realtime/client_secrets', {
7717
+ body,
7718
+ ...options,
7719
+ __security: { bearerAuth: true },
7720
+ });
5863
7721
  }
5864
7722
  }
5865
7723
 
@@ -6270,7 +8128,7 @@ class InputItems extends APIResource {
6270
8128
  * ```
6271
8129
  */
6272
8130
  list(responseID, query = {}, options) {
6273
- return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options });
8131
+ return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
6274
8132
  }
6275
8133
  }
6276
8134
 
@@ -6288,7 +8146,11 @@ class InputTokens extends APIResource {
6288
8146
  * ```
6289
8147
  */
6290
8148
  count(body = {}, options) {
6291
- return this._client.post('/responses/input_tokens', { body, ...options });
8149
+ return this._client.post('/responses/input_tokens', {
8150
+ body,
8151
+ ...options,
8152
+ __security: { bearerAuth: true },
8153
+ });
6292
8154
  }
6293
8155
  }
6294
8156
 
@@ -6300,7 +8162,12 @@ class Responses extends APIResource {
6300
8162
  this.inputTokens = new InputTokens(this._client);
6301
8163
  }
6302
8164
  create(body, options) {
6303
- return this._client.post('/responses', { body, ...options, stream: body.stream ?? false })._thenUnwrap((rsp) => {
8165
+ return this._client.post('/responses', {
8166
+ body,
8167
+ ...options,
8168
+ stream: body.stream ?? false,
8169
+ __security: { bearerAuth: true },
8170
+ })._thenUnwrap((rsp) => {
6304
8171
  if ('object' in rsp && rsp.object === 'response') {
6305
8172
  addOutputText(rsp);
6306
8173
  }
@@ -6312,6 +8179,7 @@ class Responses extends APIResource {
6312
8179
  query,
6313
8180
  ...options,
6314
8181
  stream: query?.stream ?? false,
8182
+ __security: { bearerAuth: true },
6315
8183
  })._thenUnwrap((rsp) => {
6316
8184
  if ('object' in rsp && rsp.object === 'response') {
6317
8185
  addOutputText(rsp);
@@ -6333,6 +8201,7 @@ class Responses extends APIResource {
6333
8201
  return this._client.delete(path `/responses/${responseID}`, {
6334
8202
  ...options,
6335
8203
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8204
+ __security: { bearerAuth: true },
6336
8205
  });
6337
8206
  }
6338
8207
  parse(body, options) {
@@ -6359,7 +8228,10 @@ class Responses extends APIResource {
6359
8228
  * ```
6360
8229
  */
6361
8230
  cancel(responseID, options) {
6362
- return this._client.post(path `/responses/${responseID}/cancel`, options);
8231
+ return this._client.post(path `/responses/${responseID}/cancel`, {
8232
+ ...options,
8233
+ __security: { bearerAuth: true },
8234
+ });
6363
8235
  }
6364
8236
  /**
6365
8237
  * Compact a conversation. Returns a compacted response object.
@@ -6377,7 +8249,7 @@ class Responses extends APIResource {
6377
8249
  * ```
6378
8250
  */
6379
8251
  compact(body, options) {
6380
- return this._client.post('/responses/compact', { body, ...options });
8252
+ return this._client.post('/responses/compact', { body, ...options, __security: { bearerAuth: true } });
6381
8253
  }
6382
8254
  }
6383
8255
  Responses.InputItems = InputItems;
@@ -6392,6 +8264,7 @@ let Content$1 = class Content extends APIResource {
6392
8264
  return this._client.get(path `/skills/${skillID}/content`, {
6393
8265
  ...options,
6394
8266
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8267
+ __security: { bearerAuth: true },
6395
8268
  __binaryResponse: true,
6396
8269
  });
6397
8270
  }
@@ -6407,6 +8280,7 @@ class Content extends APIResource {
6407
8280
  return this._client.get(path `/skills/${skill_id}/versions/${version}/content`, {
6408
8281
  ...options,
6409
8282
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8283
+ __security: { bearerAuth: true },
6410
8284
  __binaryResponse: true,
6411
8285
  });
6412
8286
  }
@@ -6422,14 +8296,17 @@ class Versions extends APIResource {
6422
8296
  * Create a new immutable skill version.
6423
8297
  */
6424
8298
  create(skillID, body = {}, options) {
6425
- return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8299
+ return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6426
8300
  }
6427
8301
  /**
6428
8302
  * Get a specific skill version.
6429
8303
  */
6430
8304
  retrieve(version, params, options) {
6431
8305
  const { skill_id } = params;
6432
- return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
8306
+ return this._client.get(path `/skills/${skill_id}/versions/${version}`, {
8307
+ ...options,
8308
+ __security: { bearerAuth: true },
8309
+ });
6433
8310
  }
6434
8311
  /**
6435
8312
  * List skill versions for a skill.
@@ -6438,6 +8315,7 @@ class Versions extends APIResource {
6438
8315
  return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
6439
8316
  query,
6440
8317
  ...options,
8318
+ __security: { bearerAuth: true },
6441
8319
  });
6442
8320
  }
6443
8321
  /**
@@ -6445,7 +8323,10 @@ class Versions extends APIResource {
6445
8323
  */
6446
8324
  delete(version, params, options) {
6447
8325
  const { skill_id } = params;
6448
- return this._client.delete(path `/skills/${skill_id}/versions/${version}`, options);
8326
+ return this._client.delete(path `/skills/${skill_id}/versions/${version}`, {
8327
+ ...options,
8328
+ __security: { bearerAuth: true },
8329
+ });
6449
8330
  }
6450
8331
  }
6451
8332
  Versions.Content = Content;
@@ -6461,31 +8342,39 @@ class Skills extends APIResource {
6461
8342
  * Create a new skill.
6462
8343
  */
6463
8344
  create(body = {}, options) {
6464
- return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8345
+ return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6465
8346
  }
6466
8347
  /**
6467
8348
  * Get a skill by its ID.
6468
8349
  */
6469
8350
  retrieve(skillID, options) {
6470
- return this._client.get(path `/skills/${skillID}`, options);
8351
+ return this._client.get(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
6471
8352
  }
6472
8353
  /**
6473
8354
  * Update the default version pointer for a skill.
6474
8355
  */
6475
8356
  update(skillID, body, options) {
6476
- return this._client.post(path `/skills/${skillID}`, { body, ...options });
8357
+ return this._client.post(path `/skills/${skillID}`, {
8358
+ body,
8359
+ ...options,
8360
+ __security: { bearerAuth: true },
8361
+ });
6477
8362
  }
6478
8363
  /**
6479
8364
  * List all skills for the current project.
6480
8365
  */
6481
8366
  list(query = {}, options) {
6482
- return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
8367
+ return this._client.getAPIList('/skills', (CursorPage), {
8368
+ query,
8369
+ ...options,
8370
+ __security: { bearerAuth: true },
8371
+ });
6483
8372
  }
6484
8373
  /**
6485
8374
  * Delete a skill by its ID.
6486
8375
  */
6487
8376
  delete(skillID, options) {
6488
- return this._client.delete(path `/skills/${skillID}`, options);
8377
+ return this._client.delete(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
6489
8378
  }
6490
8379
  }
6491
8380
  Skills.Content = Content$1;
@@ -6510,7 +8399,7 @@ class Parts extends APIResource {
6510
8399
  * [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
6511
8400
  */
6512
8401
  create(uploadID, body, options) {
6513
- return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options }, this._client));
8402
+ return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6514
8403
  }
6515
8404
  }
6516
8405
 
@@ -6547,7 +8436,7 @@ class Uploads extends APIResource {
6547
8436
  * Returns the Upload object with status `pending`.
6548
8437
  */
6549
8438
  create(body, options) {
6550
- return this._client.post('/uploads', { body, ...options });
8439
+ return this._client.post('/uploads', { body, ...options, __security: { bearerAuth: true } });
6551
8440
  }
6552
8441
  /**
6553
8442
  * Cancels the Upload. No Parts may be added after an Upload is cancelled.
@@ -6555,7 +8444,10 @@ class Uploads extends APIResource {
6555
8444
  * Returns the Upload object with status `cancelled`.
6556
8445
  */
6557
8446
  cancel(uploadID, options) {
6558
- return this._client.post(path `/uploads/${uploadID}/cancel`, options);
8447
+ return this._client.post(path `/uploads/${uploadID}/cancel`, {
8448
+ ...options,
8449
+ __security: { bearerAuth: true },
8450
+ });
6559
8451
  }
6560
8452
  /**
6561
8453
  * Completes the
@@ -6575,7 +8467,11 @@ class Uploads extends APIResource {
6575
8467
  * object.
6576
8468
  */
6577
8469
  complete(uploadID, body, options) {
6578
- return this._client.post(path `/uploads/${uploadID}/complete`, { body, ...options });
8470
+ return this._client.post(path `/uploads/${uploadID}/complete`, {
8471
+ body,
8472
+ ...options,
8473
+ __security: { bearerAuth: true },
8474
+ });
6579
8475
  }
6580
8476
  }
6581
8477
  Uploads.Parts = Parts;
@@ -6612,6 +8508,7 @@ class FileBatches extends APIResource {
6612
8508
  body,
6613
8509
  ...options,
6614
8510
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8511
+ __security: { bearerAuth: true },
6615
8512
  });
6616
8513
  }
6617
8514
  /**
@@ -6622,6 +8519,7 @@ class FileBatches extends APIResource {
6622
8519
  return this._client.get(path `/vector_stores/${vector_store_id}/file_batches/${batchID}`, {
6623
8520
  ...options,
6624
8521
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8522
+ __security: { bearerAuth: true },
6625
8523
  });
6626
8524
  }
6627
8525
  /**
@@ -6633,6 +8531,7 @@ class FileBatches extends APIResource {
6633
8531
  return this._client.post(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/cancel`, {
6634
8532
  ...options,
6635
8533
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8534
+ __security: { bearerAuth: true },
6636
8535
  });
6637
8536
  }
6638
8537
  /**
@@ -6647,7 +8546,12 @@ class FileBatches extends APIResource {
6647
8546
  */
6648
8547
  listFiles(batchID, params, options) {
6649
8548
  const { vector_store_id, ...query } = params;
6650
- return this._client.getAPIList(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, (CursorPage), { query, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]) });
8549
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, (CursorPage), {
8550
+ query,
8551
+ ...options,
8552
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8553
+ __security: { bearerAuth: true },
8554
+ });
6651
8555
  }
6652
8556
  /**
6653
8557
  * Wait for the given file batch to be processed.
@@ -6737,6 +8641,7 @@ class Files extends APIResource {
6737
8641
  body,
6738
8642
  ...options,
6739
8643
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8644
+ __security: { bearerAuth: true },
6740
8645
  });
6741
8646
  }
6742
8647
  /**
@@ -6747,6 +8652,7 @@ class Files extends APIResource {
6747
8652
  return this._client.get(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
6748
8653
  ...options,
6749
8654
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8655
+ __security: { bearerAuth: true },
6750
8656
  });
6751
8657
  }
6752
8658
  /**
@@ -6758,6 +8664,7 @@ class Files extends APIResource {
6758
8664
  body,
6759
8665
  ...options,
6760
8666
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8667
+ __security: { bearerAuth: true },
6761
8668
  });
6762
8669
  }
6763
8670
  /**
@@ -6768,6 +8675,7 @@ class Files extends APIResource {
6768
8675
  query,
6769
8676
  ...options,
6770
8677
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8678
+ __security: { bearerAuth: true },
6771
8679
  });
6772
8680
  }
6773
8681
  /**
@@ -6781,6 +8689,7 @@ class Files extends APIResource {
6781
8689
  return this._client.delete(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
6782
8690
  ...options,
6783
8691
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8692
+ __security: { bearerAuth: true },
6784
8693
  });
6785
8694
  }
6786
8695
  /**
@@ -6854,7 +8763,11 @@ class Files extends APIResource {
6854
8763
  */
6855
8764
  content(fileID, params, options) {
6856
8765
  const { vector_store_id } = params;
6857
- return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), { ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]) });
8766
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), {
8767
+ ...options,
8768
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8769
+ __security: { bearerAuth: true },
8770
+ });
6858
8771
  }
6859
8772
  }
6860
8773
 
@@ -6873,6 +8786,7 @@ class VectorStores extends APIResource {
6873
8786
  body,
6874
8787
  ...options,
6875
8788
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8789
+ __security: { bearerAuth: true },
6876
8790
  });
6877
8791
  }
6878
8792
  /**
@@ -6882,6 +8796,7 @@ class VectorStores extends APIResource {
6882
8796
  return this._client.get(path `/vector_stores/${vectorStoreID}`, {
6883
8797
  ...options,
6884
8798
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8799
+ __security: { bearerAuth: true },
6885
8800
  });
6886
8801
  }
6887
8802
  /**
@@ -6892,6 +8807,7 @@ class VectorStores extends APIResource {
6892
8807
  body,
6893
8808
  ...options,
6894
8809
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8810
+ __security: { bearerAuth: true },
6895
8811
  });
6896
8812
  }
6897
8813
  /**
@@ -6902,6 +8818,7 @@ class VectorStores extends APIResource {
6902
8818
  query,
6903
8819
  ...options,
6904
8820
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8821
+ __security: { bearerAuth: true },
6905
8822
  });
6906
8823
  }
6907
8824
  /**
@@ -6911,6 +8828,7 @@ class VectorStores extends APIResource {
6911
8828
  return this._client.delete(path `/vector_stores/${vectorStoreID}`, {
6912
8829
  ...options,
6913
8830
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8831
+ __security: { bearerAuth: true },
6914
8832
  });
6915
8833
  }
6916
8834
  /**
@@ -6923,6 +8841,7 @@ class VectorStores extends APIResource {
6923
8841
  method: 'post',
6924
8842
  ...options,
6925
8843
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8844
+ __security: { bearerAuth: true },
6926
8845
  });
6927
8846
  }
6928
8847
  }
@@ -6935,31 +8854,35 @@ class Videos extends APIResource {
6935
8854
  * Create a new video generation job from a prompt and optional reference assets.
6936
8855
  */
6937
8856
  create(body, options) {
6938
- return this._client.post('/videos', multipartFormRequestOptions({ body, ...options }, this._client));
8857
+ return this._client.post('/videos', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6939
8858
  }
6940
8859
  /**
6941
8860
  * Fetch the latest metadata for a generated video.
6942
8861
  */
6943
8862
  retrieve(videoID, options) {
6944
- return this._client.get(path `/videos/${videoID}`, options);
8863
+ return this._client.get(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
6945
8864
  }
6946
8865
  /**
6947
8866
  * List recently generated videos for the current project.
6948
8867
  */
6949
8868
  list(query = {}, options) {
6950
- return this._client.getAPIList('/videos', (ConversationCursorPage), { query, ...options });
8869
+ return this._client.getAPIList('/videos', (ConversationCursorPage), {
8870
+ query,
8871
+ ...options,
8872
+ __security: { bearerAuth: true },
8873
+ });
6951
8874
  }
6952
8875
  /**
6953
8876
  * Permanently delete a completed or failed video and its stored assets.
6954
8877
  */
6955
8878
  delete(videoID, options) {
6956
- return this._client.delete(path `/videos/${videoID}`, options);
8879
+ return this._client.delete(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
6957
8880
  }
6958
8881
  /**
6959
8882
  * Create a character from an uploaded video.
6960
8883
  */
6961
8884
  createCharacter(body, options) {
6962
- return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options }, this._client));
8885
+ return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6963
8886
  }
6964
8887
  /**
6965
8888
  * Download the generated video bytes or a derived preview asset.
@@ -6971,6 +8894,7 @@ class Videos extends APIResource {
6971
8894
  query,
6972
8895
  ...options,
6973
8896
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8897
+ __security: { bearerAuth: true },
6974
8898
  __binaryResponse: true,
6975
8899
  });
6976
8900
  }
@@ -6979,25 +8903,28 @@ class Videos extends APIResource {
6979
8903
  * generated video.
6980
8904
  */
6981
8905
  edit(body, options) {
6982
- return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options }, this._client));
8906
+ return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6983
8907
  }
6984
8908
  /**
6985
8909
  * Create an extension of a completed video.
6986
8910
  */
6987
8911
  extend(body, options) {
6988
- return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
8912
+ return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6989
8913
  }
6990
8914
  /**
6991
8915
  * Fetch a character.
6992
8916
  */
6993
8917
  getCharacter(characterID, options) {
6994
- return this._client.get(path `/videos/characters/${characterID}`, options);
8918
+ return this._client.get(path `/videos/characters/${characterID}`, {
8919
+ ...options,
8920
+ __security: { bearerAuth: true },
8921
+ });
6995
8922
  }
6996
8923
  /**
6997
8924
  * Create a remix of a completed video using a refreshed prompt.
6998
8925
  */
6999
8926
  remix(videoID, body, options) {
7000
- return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8927
+ return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7001
8928
  }
7002
8929
  }
7003
8930
 
@@ -7104,7 +9031,8 @@ class OpenAI {
7104
9031
  /**
7105
9032
  * API Client for interfacing with the OpenAI API.
7106
9033
  *
7107
- * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
9034
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? null]
9035
+ * @param {string | null | undefined} [opts.adminAPIKey=process.env['OPENAI_ADMIN_KEY'] ?? null]
7108
9036
  * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
7109
9037
  * @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
7110
9038
  * @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
@@ -7117,7 +9045,7 @@ class OpenAI {
7117
9045
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
7118
9046
  * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
7119
9047
  */
7120
- 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, workloadIdentity, ...opts } = {}) {
9048
+ constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY') ?? null, adminAPIKey = readEnv('OPENAI_ADMIN_KEY') ?? null, organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, workloadIdentity, ...opts } = {}) {
7121
9049
  _OpenAI_instances.add(this);
7122
9050
  _OpenAI_encoder.set(this, void 0);
7123
9051
  /**
@@ -7159,6 +9087,7 @@ class OpenAI {
7159
9087
  * Use Uploads to upload large files in multiple parts.
7160
9088
  */
7161
9089
  this.uploads = new Uploads(this);
9090
+ this.admin = new Admin(this);
7162
9091
  this.responses = new Responses(this);
7163
9092
  this.realtime = new Realtime(this);
7164
9093
  /**
@@ -7172,17 +9101,9 @@ class OpenAI {
7172
9101
  this.containers = new Containers(this);
7173
9102
  this.skills = new Skills(this);
7174
9103
  this.videos = new Videos(this);
7175
- if (workloadIdentity) {
7176
- if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
7177
- throw new OpenAIError('The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.');
7178
- }
7179
- apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
7180
- }
7181
- else if (apiKey === undefined) {
7182
- throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.');
7183
- }
7184
9104
  const options = {
7185
9105
  apiKey,
9106
+ adminAPIKey,
7186
9107
  organization,
7187
9108
  project,
7188
9109
  webhookSecret,
@@ -7190,6 +9111,12 @@ class OpenAI {
7190
9111
  ...opts,
7191
9112
  baseURL: baseURL || `https://api.openai.com/v1`,
7192
9113
  };
9114
+ if (apiKey && workloadIdentity) {
9115
+ throw new OpenAIError('The `apiKey` and `workloadIdentity` options are mutually exclusive');
9116
+ }
9117
+ if (!apiKey && !adminAPIKey && !workloadIdentity) {
9118
+ throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.');
9119
+ }
7193
9120
  if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
7194
9121
  throw new OpenAIError("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");
7195
9122
  }
@@ -7207,11 +9134,23 @@ class OpenAI {
7207
9134
  this.maxRetries = options.maxRetries ?? 2;
7208
9135
  this.fetch = options.fetch ?? getDefaultFetch();
7209
9136
  __classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
9137
+ const customHeadersEnv = readEnv('OPENAI_CUSTOM_HEADERS');
9138
+ if (customHeadersEnv) {
9139
+ const parsed = {};
9140
+ for (const line of customHeadersEnv.split('\n')) {
9141
+ const colon = line.indexOf(':');
9142
+ if (colon >= 0) {
9143
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
9144
+ }
9145
+ }
9146
+ options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
9147
+ }
7210
9148
  this._options = options;
7211
9149
  if (workloadIdentity) {
7212
9150
  this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
7213
9151
  }
7214
- this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
9152
+ this.apiKey = typeof apiKey === 'string' ? apiKey : null;
9153
+ this.adminAPIKey = adminAPIKey;
7215
9154
  this.organization = organization;
7216
9155
  this.project = project;
7217
9156
  this.webhookSecret = webhookSecret;
@@ -7229,7 +9168,8 @@ class OpenAI {
7229
9168
  logLevel: this.logLevel,
7230
9169
  fetch: this.fetch,
7231
9170
  fetchOptions: this.fetchOptions,
7232
- apiKey: this.apiKey,
9171
+ apiKey: this._options.apiKey,
9172
+ adminAPIKey: this.adminAPIKey,
7233
9173
  workloadIdentity: this._options.workloadIdentity,
7234
9174
  organization: this.organization,
7235
9175
  project: this.project,
@@ -7241,12 +9181,45 @@ class OpenAI {
7241
9181
  defaultQuery() {
7242
9182
  return this._options.defaultQuery;
7243
9183
  }
7244
- validateHeaders({ values, nulls }) {
7245
- return;
9184
+ validateHeaders({ values, nulls }, schemes = {
9185
+ bearerAuth: true,
9186
+ adminAPIKeyAuth: true,
9187
+ }) {
9188
+ if (values.get('authorization') || values.get('api-key')) {
9189
+ return;
9190
+ }
9191
+ if (nulls.has('authorization') || nulls.has('api-key')) {
9192
+ return;
9193
+ }
9194
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
9195
+ return;
9196
+ }
9197
+ throw new Error('Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted');
7246
9198
  }
7247
- async authHeaders(opts) {
9199
+ async authHeaders(opts, schemes = {
9200
+ bearerAuth: true,
9201
+ adminAPIKeyAuth: true,
9202
+ }) {
9203
+ return buildHeaders([
9204
+ schemes.bearerAuth ? await this.bearerAuth(opts) : null,
9205
+ schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null,
9206
+ ]);
9207
+ }
9208
+ async bearerAuth(opts) {
9209
+ if (this._workloadIdentityAuth) {
9210
+ return buildHeaders([{ Authorization: `Bearer ${await this._workloadIdentityAuth.getToken()}` }]);
9211
+ }
9212
+ if (this.apiKey == null) {
9213
+ return undefined;
9214
+ }
7248
9215
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
7249
9216
  }
9217
+ async adminAPIKeyAuth(opts) {
9218
+ if (this.adminAPIKey == null) {
9219
+ return undefined;
9220
+ }
9221
+ return buildHeaders([{ Authorization: `Bearer ${this.adminAPIKey}` }]);
9222
+ }
7250
9223
  stringifyQuery(query) {
7251
9224
  return stringifyQuery(query);
7252
9225
  }
@@ -7299,7 +9272,10 @@ class OpenAI {
7299
9272
  * Used as a callback for mutating the given `FinalRequestOptions` object.
7300
9273
  */
7301
9274
  async prepareOptions(options) {
7302
- await this._callApiKey();
9275
+ const security = options.__security ?? { bearerAuth: true };
9276
+ if (security.bearerAuth) {
9277
+ await this._callApiKey();
9278
+ }
7303
9279
  }
7304
9280
  /**
7305
9281
  * Used as a callback for mutating the given `RequestInit` object.
@@ -7356,8 +9332,9 @@ class OpenAI {
7356
9332
  if (options.signal?.aborted) {
7357
9333
  throw new APIUserAbortError();
7358
9334
  }
9335
+ const security = options.__security ?? { bearerAuth: true };
7359
9336
  const controller = new AbortController();
7360
- const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
9337
+ const response = await this.fetchWithAuth(url, req, timeout, controller, security).catch(castToError);
7361
9338
  const headersTime = Date.now();
7362
9339
  if (response instanceof globalThis.Error) {
7363
9340
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -7403,6 +9380,7 @@ class OpenAI {
7403
9380
  if (!response.ok) {
7404
9381
  if (response.status === 401 &&
7405
9382
  this._workloadIdentityAuth &&
9383
+ security.bearerAuth &&
7406
9384
  !options.__metadata?.['hasStreamingBody'] &&
7407
9385
  !options.__metadata?.['workloadIdentityTokenRefreshed']) {
7408
9386
  await CancelReadableStream(response.body);
@@ -7465,8 +9443,11 @@ class OpenAI {
7465
9443
  const request = this.makeRequest(options, null, undefined);
7466
9444
  return new PagePromise(this, request, Page);
7467
9445
  }
7468
- async fetchWithAuth(url, init, timeout, controller) {
7469
- if (this._workloadIdentityAuth) {
9446
+ async fetchWithAuth(url, init, timeout, controller, schemes = {
9447
+ bearerAuth: true,
9448
+ adminAPIKeyAuth: true,
9449
+ }) {
9450
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
7470
9451
  const headers = init.headers;
7471
9452
  const authHeader = headers.get('Authorization');
7472
9453
  if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
@@ -7611,12 +9592,12 @@ class OpenAI {
7611
9592
  'OpenAI-Organization': this.organization,
7612
9593
  'OpenAI-Project': this.project,
7613
9594
  },
7614
- await this.authHeaders(options),
9595
+ await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
7615
9596
  this._options.defaultHeaders,
7616
9597
  bodyHeaders,
7617
9598
  options.headers,
7618
9599
  ]);
7619
- this.validateHeaders(headers);
9600
+ this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
7620
9601
  return headers.values;
7621
9602
  }
7622
9603
  _makeAbort(controller) {
@@ -7713,6 +9694,7 @@ OpenAI.Webhooks = Webhooks;
7713
9694
  OpenAI.Beta = Beta;
7714
9695
  OpenAI.Batches = Batches;
7715
9696
  OpenAI.Uploads = Uploads;
9697
+ OpenAI.Admin = Admin;
7716
9698
  OpenAI.Responses = Responses;
7717
9699
  OpenAI.Realtime = Realtime;
7718
9700
  OpenAI.Conversations = Conversations;
@@ -10272,7 +12254,6 @@ function zodTextFormat(zodObject, name, props) {
10272
12254
  }, (content) => zodObject.parse(JSON.parse(content)));
10273
12255
  }
10274
12256
 
10275
- // llm-openai-config.ts
10276
12257
  const DEFAULT_MODEL = 'gpt-5-mini';
10277
12258
  const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
10278
12259
  const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
@@ -10353,25 +12334,144 @@ const deepseekModelCosts = {
10353
12334
  function shouldUseGPT5HighContextPricing(model, inputTokens) {
10354
12335
  return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
10355
12336
  }
10356
- /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
10357
- const openAiImageCosts = {
10358
- 'gpt-image-1': 0.0075, // $0.0075 per image for gpt-image-1
10359
- 'gpt-image-1.5': 0.0075, // Assumes parity pricing with gpt-image-1 until OpenAI publishes updated rates
12337
+ const DEFAULT_IMAGE_PRICING_QUALITY = 'high';
12338
+ const DEFAULT_IMAGE_PRICING_SIZE = '1024x1024';
12339
+ const PRICED_OPENAI_IMAGE_MODELS = [
12340
+ 'gpt-image-2',
12341
+ 'gpt-image-2-2026-04-21',
12342
+ 'gpt-image-1.5',
12343
+ 'gpt-image-1',
12344
+ 'gpt-image-1-mini',
12345
+ ];
12346
+ const OPENAI_IMAGE_PRICING_SIZES = ['1024x1024', '1024x1536', '1536x1024'];
12347
+ /**
12348
+ * Estimated image output costs in USD per image for common GPT Image sizes.
12349
+ * Last updated May 2026 from the OpenAI image generation guide. Text and image
12350
+ * input token costs for prompts and edit inputs are not included.
12351
+ */
12352
+ const openAiImageCostByQualityAndSize = {
12353
+ 'gpt-image-2': {
12354
+ low: {
12355
+ '1024x1024': 0.006,
12356
+ '1024x1536': 0.005,
12357
+ '1536x1024': 0.005,
12358
+ },
12359
+ medium: {
12360
+ '1024x1024': 0.053,
12361
+ '1024x1536': 0.041,
12362
+ '1536x1024': 0.041,
12363
+ },
12364
+ high: {
12365
+ '1024x1024': 0.211,
12366
+ '1024x1536': 0.165,
12367
+ '1536x1024': 0.165,
12368
+ },
12369
+ },
12370
+ 'gpt-image-2-2026-04-21': {
12371
+ low: {
12372
+ '1024x1024': 0.006,
12373
+ '1024x1536': 0.005,
12374
+ '1536x1024': 0.005,
12375
+ },
12376
+ medium: {
12377
+ '1024x1024': 0.053,
12378
+ '1024x1536': 0.041,
12379
+ '1536x1024': 0.041,
12380
+ },
12381
+ high: {
12382
+ '1024x1024': 0.211,
12383
+ '1024x1536': 0.165,
12384
+ '1536x1024': 0.165,
12385
+ },
12386
+ },
12387
+ 'gpt-image-1.5': {
12388
+ low: {
12389
+ '1024x1024': 0.009,
12390
+ '1024x1536': 0.013,
12391
+ '1536x1024': 0.013,
12392
+ },
12393
+ medium: {
12394
+ '1024x1024': 0.034,
12395
+ '1024x1536': 0.05,
12396
+ '1536x1024': 0.05,
12397
+ },
12398
+ high: {
12399
+ '1024x1024': 0.133,
12400
+ '1024x1536': 0.2,
12401
+ '1536x1024': 0.2,
12402
+ },
12403
+ },
12404
+ 'gpt-image-1': {
12405
+ low: {
12406
+ '1024x1024': 0.011,
12407
+ '1024x1536': 0.016,
12408
+ '1536x1024': 0.016,
12409
+ },
12410
+ medium: {
12411
+ '1024x1024': 0.042,
12412
+ '1024x1536': 0.063,
12413
+ '1536x1024': 0.063,
12414
+ },
12415
+ high: {
12416
+ '1024x1024': 0.167,
12417
+ '1024x1536': 0.25,
12418
+ '1536x1024': 0.25,
12419
+ },
12420
+ },
12421
+ 'gpt-image-1-mini': {
12422
+ low: {
12423
+ '1024x1024': 0.005,
12424
+ '1024x1536': 0.006,
12425
+ '1536x1024': 0.006,
12426
+ },
12427
+ medium: {
12428
+ '1024x1024': 0.011,
12429
+ '1024x1536': 0.015,
12430
+ '1536x1024': 0.015,
12431
+ },
12432
+ high: {
12433
+ '1024x1024': 0.036,
12434
+ '1024x1536': 0.052,
12435
+ '1536x1024': 0.052,
12436
+ },
12437
+ },
10360
12438
  };
12439
+ function isPricedOpenAIImageModel(model) {
12440
+ return PRICED_OPENAI_IMAGE_MODELS.includes(model);
12441
+ }
12442
+ function isOpenAIImagePricingSize(size) {
12443
+ return OPENAI_IMAGE_PRICING_SIZES.includes(size);
12444
+ }
12445
+ function resolveImagePricingQuality(quality) {
12446
+ if (quality === 'low' || quality === 'medium' || quality === 'high') {
12447
+ return quality;
12448
+ }
12449
+ return DEFAULT_IMAGE_PRICING_QUALITY;
12450
+ }
12451
+ function resolveImagePricingSize(size) {
12452
+ if (typeof size === 'string' && isOpenAIImagePricingSize(size)) {
12453
+ return size;
12454
+ }
12455
+ return DEFAULT_IMAGE_PRICING_SIZE;
12456
+ }
10361
12457
  /**
10362
12458
  * Calculates the cost of generating images using OpenAI's Images API.
10363
12459
  *
10364
12460
  * @param model The image generation model name.
10365
12461
  * @param imageCount The number of images generated.
12462
+ * @param quality The requested image quality.
12463
+ * @param size The requested image size.
10366
12464
  * @returns The cost of generating the images in USD.
10367
12465
  */
10368
- function calculateImageCost(model, imageCount) {
12466
+ function calculateImageCost(model, imageCount, quality, size) {
10369
12467
  if (typeof model !== 'string' || typeof imageCount !== 'number' || imageCount <= 0) {
10370
12468
  return 0;
10371
12469
  }
10372
- const costPerImage = openAiImageCosts[model];
10373
- if (!costPerImage)
12470
+ if (!isPricedOpenAIImageModel(model))
10374
12471
  return 0;
12472
+ const pricingQuality = resolveImagePricingQuality(quality);
12473
+ const pricingSize = resolveImagePricingSize(size);
12474
+ const costPerImage = openAiImageCostByQualityAndSize[model][pricingQuality][pricingSize];
10375
12475
  return imageCount * costPerImage;
10376
12476
  }
10377
12477
  /**
@@ -11070,7 +13170,7 @@ async function makeLLMCall(input, options = {}) {
11070
13170
  return await makeResponsesAPICall(processedInput, responsesOptions);
11071
13171
  }
11072
13172
 
11073
- const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
13173
+ const DEFAULT_IMAGE_MODEL = 'gpt-image-2';
11074
13174
  const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
11075
13175
  const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
11076
13176
  /**
@@ -11159,7 +13259,7 @@ async function makeImagesCall(prompt, options = {}) {
11159
13259
  throw new Error('No images returned from OpenAI Images API');
11160
13260
  }
11161
13261
  // Calculate cost
11162
- const cost = calculateImageCost(imageModel, count || 1);
13262
+ const cost = calculateImageCost(imageModel, count || 1, quality, size);
11163
13263
  // Return the response with enhanced usage information
11164
13264
  const enhancedResponse = {
11165
13265
  ...response,
@@ -12534,9 +14634,11 @@ const disco = {
12534
14634
  time,
12535
14635
  };
12536
14636
 
14637
+ exports.OPENAI_IMAGE_MODELS = OPENAI_IMAGE_MODELS;
12537
14638
  exports.OPENAI_MODELS = OPENAI_MODELS;
12538
14639
  exports.OPENROUTER_MODELS = OPENROUTER_MODELS;
12539
14640
  exports.disco = disco;
14641
+ exports.isOpenAIImageModel = isOpenAIImageModel;
12540
14642
  exports.isOpenAIModel = isOpenAIModel;
12541
14643
  exports.isOpenRouterModel = isOpenRouterModel;
12542
14644
  exports.supportsTemperature = supportsTemperature;