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