@discomedia/utils 1.0.69 → 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.
package/dist/test.js CHANGED
@@ -389,33 +389,36 @@ const OPENAI_MODELS = [
389
389
  function isOpenAIModel(model) {
390
390
  return OPENAI_MODELS.includes(model);
391
391
  }
392
+ /**
393
+ * Represents OpenRouter models
394
+ */
395
+ const OPENROUTER_MODELS = [
396
+ 'openai/gpt-5',
397
+ 'openai/gpt-5-mini',
398
+ 'openai/gpt-5.4-mini',
399
+ 'openai/gpt-5-nano',
400
+ 'openai/gpt-5.1',
401
+ 'openai/gpt-5.4',
402
+ 'openai/gpt-5.4-pro',
403
+ 'openai/gpt-5.5',
404
+ 'openai/gpt-5.5-pro',
405
+ 'openai/gpt-5.2',
406
+ 'openai/gpt-5.2-pro',
407
+ 'openai/gpt-5.1-codex',
408
+ 'openai/gpt-5.1-codex-max',
409
+ 'openai/gpt-oss-120b',
410
+ 'z.ai/glm-4.5',
411
+ 'z.ai/glm-4.5-air',
412
+ 'google/gemini-2.5-flash',
413
+ 'google/gemini-2.5-flash-lite',
414
+ 'deepseek/deepseek-r1-0528',
415
+ 'deepseek/deepseek-chat-v3-0324',
416
+ ];
392
417
  /**
393
418
  * Type guard to check if a model is an OpenRouter model
394
419
  */
395
420
  function isOpenRouterModel(model) {
396
- const openRouterModels = [
397
- 'openai/gpt-5',
398
- 'openai/gpt-5-mini',
399
- 'openai/gpt-5.4-mini',
400
- 'openai/gpt-5-nano',
401
- 'openai/gpt-5.1',
402
- 'openai/gpt-5.4',
403
- 'openai/gpt-5.4-pro',
404
- 'openai/gpt-5.5',
405
- 'openai/gpt-5.5-pro',
406
- 'openai/gpt-5.2',
407
- 'openai/gpt-5.2-pro',
408
- 'openai/gpt-5.1-codex',
409
- 'openai/gpt-5.1-codex-max',
410
- 'openai/gpt-oss-120b',
411
- 'z.ai/glm-4.5',
412
- 'z.ai/glm-4.5-air',
413
- 'google/gemini-2.5-flash',
414
- 'google/gemini-2.5-flash-lite',
415
- 'deepseek/deepseek-r1-0528',
416
- 'deepseek/deepseek-chat-v3-0324',
417
- ];
418
- return openRouterModels.includes(model);
421
+ return OPENROUTER_MODELS.includes(model);
419
422
  }
420
423
 
421
424
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
@@ -680,7 +683,7 @@ const safeJSON = (text) => {
680
683
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
681
684
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
682
685
 
683
- const VERSION = '6.35.0'; // x-release-please-version
686
+ const VERSION = '6.37.0'; // x-release-please-version
684
687
 
685
688
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
686
689
  const isRunningInBrowser = () => {
@@ -1500,6 +1503,8 @@ const formatRequestDetails = (details) => {
1500
1503
  details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
1501
1504
  name,
1502
1505
  (name.toLowerCase() === 'authorization' ||
1506
+ name.toLowerCase() === 'api-key' ||
1507
+ name.toLowerCase() === 'x-api-key' ||
1503
1508
  name.toLowerCase() === 'cookie' ||
1504
1509
  name.toLowerCase() === 'set-cookie') ?
1505
1510
  '***'
@@ -2060,6 +2065,36 @@ class ConversationCursorPage extends AbstractPage {
2060
2065
  };
2061
2066
  }
2062
2067
  }
2068
+ class NextCursorPage extends AbstractPage {
2069
+ constructor(client, response, body, options) {
2070
+ super(client, response, body, options);
2071
+ this.data = body.data || [];
2072
+ this.has_more = body.has_more || false;
2073
+ this.next = body.next || null;
2074
+ }
2075
+ getPaginatedItems() {
2076
+ return this.data ?? [];
2077
+ }
2078
+ hasNextPage() {
2079
+ if (this.has_more === false) {
2080
+ return false;
2081
+ }
2082
+ return super.hasNextPage();
2083
+ }
2084
+ nextPageRequestOptions() {
2085
+ const cursor = this.next;
2086
+ if (!cursor) {
2087
+ return null;
2088
+ }
2089
+ return {
2090
+ ...this.options,
2091
+ query: {
2092
+ ...maybeObj(this.options.query),
2093
+ after: cursor,
2094
+ },
2095
+ };
2096
+ }
2097
+ }
2063
2098
 
2064
2099
  const SUBJECT_TOKEN_TYPES = {
2065
2100
  jwt: 'urn:ietf:params:oauth:token-type:jwt',
@@ -2462,7 +2497,7 @@ let Messages$1 = class Messages extends APIResource {
2462
2497
  * ```
2463
2498
  */
2464
2499
  list(completionID, query = {}, options) {
2465
- return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options });
2500
+ return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
2466
2501
  }
2467
2502
  };
2468
2503
 
@@ -3814,117 +3849,1769 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
3814
3849
  params);
3815
3850
  const opts = {
3816
3851
  ...options,
3817
- headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
3818
- };
3819
- runner._run(() => runner._runTools(client, params, opts));
3820
- return runner;
3852
+ headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
3853
+ };
3854
+ runner._run(() => runner._runTools(client, params, opts));
3855
+ return runner;
3856
+ }
3857
+ }
3858
+
3859
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3860
+ /**
3861
+ * Given a list of messages comprising a conversation, the model will return a response.
3862
+ */
3863
+ let Completions$1 = class Completions extends APIResource {
3864
+ constructor() {
3865
+ super(...arguments);
3866
+ this.messages = new Messages$1(this._client);
3867
+ }
3868
+ create(body, options) {
3869
+ return this._client.post('/chat/completions', {
3870
+ body,
3871
+ ...options,
3872
+ stream: body.stream ?? false,
3873
+ __security: { bearerAuth: true },
3874
+ });
3875
+ }
3876
+ /**
3877
+ * Get a stored chat completion. Only Chat Completions that have been created with
3878
+ * the `store` parameter set to `true` will be returned.
3879
+ *
3880
+ * @example
3881
+ * ```ts
3882
+ * const chatCompletion =
3883
+ * await client.chat.completions.retrieve('completion_id');
3884
+ * ```
3885
+ */
3886
+ retrieve(completionID, options) {
3887
+ return this._client.get(path `/chat/completions/${completionID}`, {
3888
+ ...options,
3889
+ __security: { bearerAuth: true },
3890
+ });
3891
+ }
3892
+ /**
3893
+ * Modify a stored chat completion. Only Chat Completions that have been created
3894
+ * with the `store` parameter set to `true` can be modified. Currently, the only
3895
+ * supported modification is to update the `metadata` field.
3896
+ *
3897
+ * @example
3898
+ * ```ts
3899
+ * const chatCompletion = await client.chat.completions.update(
3900
+ * 'completion_id',
3901
+ * { metadata: { foo: 'string' } },
3902
+ * );
3903
+ * ```
3904
+ */
3905
+ update(completionID, body, options) {
3906
+ return this._client.post(path `/chat/completions/${completionID}`, {
3907
+ body,
3908
+ ...options,
3909
+ __security: { bearerAuth: true },
3910
+ });
3911
+ }
3912
+ /**
3913
+ * List stored Chat Completions. Only Chat Completions that have been stored with
3914
+ * the `store` parameter set to `true` will be returned.
3915
+ *
3916
+ * @example
3917
+ * ```ts
3918
+ * // Automatically fetches more pages as needed.
3919
+ * for await (const chatCompletion of client.chat.completions.list()) {
3920
+ * // ...
3921
+ * }
3922
+ * ```
3923
+ */
3924
+ list(query = {}, options) {
3925
+ return this._client.getAPIList('/chat/completions', (CursorPage), {
3926
+ query,
3927
+ ...options,
3928
+ __security: { bearerAuth: true },
3929
+ });
3930
+ }
3931
+ /**
3932
+ * Delete a stored chat completion. Only Chat Completions that have been created
3933
+ * with the `store` parameter set to `true` can be deleted.
3934
+ *
3935
+ * @example
3936
+ * ```ts
3937
+ * const chatCompletionDeleted =
3938
+ * await client.chat.completions.delete('completion_id');
3939
+ * ```
3940
+ */
3941
+ delete(completionID, options) {
3942
+ return this._client.delete(path `/chat/completions/${completionID}`, {
3943
+ ...options,
3944
+ __security: { bearerAuth: true },
3945
+ });
3946
+ }
3947
+ parse(body, options) {
3948
+ validateInputTools(body.tools);
3949
+ return this._client.chat.completions
3950
+ .create(body, {
3951
+ ...options,
3952
+ headers: {
3953
+ ...options?.headers,
3954
+ 'X-Stainless-Helper-Method': 'chat.completions.parse',
3955
+ },
3956
+ })
3957
+ ._thenUnwrap((completion) => parseChatCompletion(completion, body));
3958
+ }
3959
+ runTools(body, options) {
3960
+ if (body.stream) {
3961
+ return ChatCompletionStreamingRunner.runTools(this._client, body, options);
3962
+ }
3963
+ return ChatCompletionRunner.runTools(this._client, body, options);
3964
+ }
3965
+ /**
3966
+ * Creates a chat completion stream
3967
+ */
3968
+ stream(body, options) {
3969
+ return ChatCompletionStream.createChatCompletion(this._client, body, options);
3970
+ }
3971
+ };
3972
+ Completions$1.Messages = Messages$1;
3973
+
3974
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3975
+ class Chat extends APIResource {
3976
+ constructor() {
3977
+ super(...arguments);
3978
+ this.completions = new Completions$1(this._client);
3979
+ }
3980
+ }
3981
+ Chat.Completions = Completions$1;
3982
+
3983
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3984
+ class AdminAPIKeys extends APIResource {
3985
+ /**
3986
+ * Create an organization admin API key
3987
+ *
3988
+ * @example
3989
+ * ```ts
3990
+ * const adminAPIKey =
3991
+ * await client.admin.organization.adminAPIKeys.create({
3992
+ * name: 'New Admin Key',
3993
+ * });
3994
+ * ```
3995
+ */
3996
+ create(body, options) {
3997
+ return this._client.post('/organization/admin_api_keys', {
3998
+ body,
3999
+ ...options,
4000
+ __security: { adminAPIKeyAuth: true },
4001
+ });
4002
+ }
4003
+ /**
4004
+ * Retrieve a single organization API key
4005
+ *
4006
+ * @example
4007
+ * ```ts
4008
+ * const adminAPIKey =
4009
+ * await client.admin.organization.adminAPIKeys.retrieve(
4010
+ * 'key_id',
4011
+ * );
4012
+ * ```
4013
+ */
4014
+ retrieve(keyID, options) {
4015
+ return this._client.get(path `/organization/admin_api_keys/${keyID}`, {
4016
+ ...options,
4017
+ __security: { adminAPIKeyAuth: true },
4018
+ });
4019
+ }
4020
+ /**
4021
+ * List organization API keys
4022
+ *
4023
+ * @example
4024
+ * ```ts
4025
+ * // Automatically fetches more pages as needed.
4026
+ * for await (const adminAPIKey of client.admin.organization.adminAPIKeys.list()) {
4027
+ * // ...
4028
+ * }
4029
+ * ```
4030
+ */
4031
+ list(query = {}, options) {
4032
+ return this._client.getAPIList('/organization/admin_api_keys', (CursorPage), {
4033
+ query,
4034
+ ...options,
4035
+ __security: { adminAPIKeyAuth: true },
4036
+ });
4037
+ }
4038
+ /**
4039
+ * Delete an organization admin API key
4040
+ *
4041
+ * @example
4042
+ * ```ts
4043
+ * const adminAPIKey =
4044
+ * await client.admin.organization.adminAPIKeys.delete(
4045
+ * 'key_id',
4046
+ * );
4047
+ * ```
4048
+ */
4049
+ delete(keyID, options) {
4050
+ return this._client.delete(path `/organization/admin_api_keys/${keyID}`, {
4051
+ ...options,
4052
+ __security: { adminAPIKeyAuth: true },
4053
+ });
4054
+ }
4055
+ }
4056
+
4057
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4058
+ /**
4059
+ * List user actions and configuration changes within this organization.
4060
+ */
4061
+ class AuditLogs extends APIResource {
4062
+ /**
4063
+ * List user actions and configuration changes within this organization.
4064
+ *
4065
+ * @example
4066
+ * ```ts
4067
+ * // Automatically fetches more pages as needed.
4068
+ * for await (const auditLogListResponse of client.admin.organization.auditLogs.list()) {
4069
+ * // ...
4070
+ * }
4071
+ * ```
4072
+ */
4073
+ list(query = {}, options) {
4074
+ return this._client.getAPIList('/organization/audit_logs', (ConversationCursorPage), {
4075
+ query,
4076
+ ...options,
4077
+ __security: { adminAPIKeyAuth: true },
4078
+ });
4079
+ }
4080
+ }
4081
+
4082
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4083
+ let Certificates$1 = class Certificates extends APIResource {
4084
+ /**
4085
+ * Upload a certificate to the organization. This does **not** automatically
4086
+ * activate the certificate.
4087
+ *
4088
+ * Organizations can upload up to 50 certificates.
4089
+ *
4090
+ * @example
4091
+ * ```ts
4092
+ * const certificate =
4093
+ * await client.admin.organization.certificates.create({
4094
+ * certificate: 'certificate',
4095
+ * });
4096
+ * ```
4097
+ */
4098
+ create(body, options) {
4099
+ return this._client.post('/organization/certificates', {
4100
+ body,
4101
+ ...options,
4102
+ __security: { adminAPIKeyAuth: true },
4103
+ });
4104
+ }
4105
+ /**
4106
+ * Get a certificate that has been uploaded to the organization.
4107
+ *
4108
+ * You can get a certificate regardless of whether it is active or not.
4109
+ *
4110
+ * @example
4111
+ * ```ts
4112
+ * const certificate =
4113
+ * await client.admin.organization.certificates.retrieve(
4114
+ * 'certificate_id',
4115
+ * );
4116
+ * ```
4117
+ */
4118
+ retrieve(certificateID, query = {}, options) {
4119
+ return this._client.get(path `/organization/certificates/${certificateID}`, {
4120
+ query,
4121
+ ...options,
4122
+ __security: { adminAPIKeyAuth: true },
4123
+ });
4124
+ }
4125
+ /**
4126
+ * Modify a certificate. Note that only the name can be modified.
4127
+ *
4128
+ * @example
4129
+ * ```ts
4130
+ * const certificate =
4131
+ * await client.admin.organization.certificates.update(
4132
+ * 'certificate_id',
4133
+ * );
4134
+ * ```
4135
+ */
4136
+ update(certificateID, body, options) {
4137
+ return this._client.post(path `/organization/certificates/${certificateID}`, {
4138
+ body,
4139
+ ...options,
4140
+ __security: { adminAPIKeyAuth: true },
4141
+ });
4142
+ }
4143
+ /**
4144
+ * List uploaded certificates for this organization.
4145
+ *
4146
+ * @example
4147
+ * ```ts
4148
+ * // Automatically fetches more pages as needed.
4149
+ * for await (const certificateListResponse of client.admin.organization.certificates.list()) {
4150
+ * // ...
4151
+ * }
4152
+ * ```
4153
+ */
4154
+ list(query = {}, options) {
4155
+ return this._client.getAPIList('/organization/certificates', (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4156
+ }
4157
+ /**
4158
+ * Delete a certificate from the organization.
4159
+ *
4160
+ * The certificate must be inactive for the organization and all projects.
4161
+ *
4162
+ * @example
4163
+ * ```ts
4164
+ * const certificate =
4165
+ * await client.admin.organization.certificates.delete(
4166
+ * 'certificate_id',
4167
+ * );
4168
+ * ```
4169
+ */
4170
+ delete(certificateID, options) {
4171
+ return this._client.delete(path `/organization/certificates/${certificateID}`, {
4172
+ ...options,
4173
+ __security: { adminAPIKeyAuth: true },
4174
+ });
4175
+ }
4176
+ /**
4177
+ * Activate certificates at the organization level.
4178
+ *
4179
+ * You can atomically and idempotently activate up to 10 certificates at a time.
4180
+ *
4181
+ * @example
4182
+ * ```ts
4183
+ * // Automatically fetches more pages as needed.
4184
+ * for await (const certificateActivateResponse of client.admin.organization.certificates.activate(
4185
+ * { certificate_ids: ['cert_abc'] },
4186
+ * )) {
4187
+ * // ...
4188
+ * }
4189
+ * ```
4190
+ */
4191
+ activate(body, options) {
4192
+ return this._client.getAPIList('/organization/certificates/activate', (Page), {
4193
+ body,
4194
+ method: 'post',
4195
+ ...options,
4196
+ __security: { adminAPIKeyAuth: true },
4197
+ });
4198
+ }
4199
+ /**
4200
+ * Deactivate certificates at the organization level.
4201
+ *
4202
+ * You can atomically and idempotently deactivate up to 10 certificates at a time.
4203
+ *
4204
+ * @example
4205
+ * ```ts
4206
+ * // Automatically fetches more pages as needed.
4207
+ * for await (const certificateDeactivateResponse of client.admin.organization.certificates.deactivate(
4208
+ * { certificate_ids: ['cert_abc'] },
4209
+ * )) {
4210
+ * // ...
4211
+ * }
4212
+ * ```
4213
+ */
4214
+ deactivate(body, options) {
4215
+ return this._client.getAPIList('/organization/certificates/deactivate', (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
4216
+ }
4217
+ };
4218
+
4219
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4220
+ class Invites extends APIResource {
4221
+ /**
4222
+ * Create an invite for a user to the organization. The invite must be accepted by
4223
+ * the user before they have access to the organization.
4224
+ *
4225
+ * @example
4226
+ * ```ts
4227
+ * const invite =
4228
+ * await client.admin.organization.invites.create({
4229
+ * email: 'email',
4230
+ * role: 'reader',
4231
+ * });
4232
+ * ```
4233
+ */
4234
+ create(body, options) {
4235
+ return this._client.post('/organization/invites', {
4236
+ body,
4237
+ ...options,
4238
+ __security: { adminAPIKeyAuth: true },
4239
+ });
4240
+ }
4241
+ /**
4242
+ * Retrieves an invite.
4243
+ *
4244
+ * @example
4245
+ * ```ts
4246
+ * const invite =
4247
+ * await client.admin.organization.invites.retrieve(
4248
+ * 'invite_id',
4249
+ * );
4250
+ * ```
4251
+ */
4252
+ retrieve(inviteID, options) {
4253
+ return this._client.get(path `/organization/invites/${inviteID}`, {
4254
+ ...options,
4255
+ __security: { adminAPIKeyAuth: true },
4256
+ });
4257
+ }
4258
+ /**
4259
+ * Returns a list of invites in the organization.
4260
+ *
4261
+ * @example
4262
+ * ```ts
4263
+ * // Automatically fetches more pages as needed.
4264
+ * for await (const invite of client.admin.organization.invites.list()) {
4265
+ * // ...
4266
+ * }
4267
+ * ```
4268
+ */
4269
+ list(query = {}, options) {
4270
+ return this._client.getAPIList('/organization/invites', (ConversationCursorPage), {
4271
+ query,
4272
+ ...options,
4273
+ __security: { adminAPIKeyAuth: true },
4274
+ });
4275
+ }
4276
+ /**
4277
+ * Delete an invite. If the invite has already been accepted, it cannot be deleted.
4278
+ *
4279
+ * @example
4280
+ * ```ts
4281
+ * const invite =
4282
+ * await client.admin.organization.invites.delete(
4283
+ * 'invite_id',
4284
+ * );
4285
+ * ```
4286
+ */
4287
+ delete(inviteID, options) {
4288
+ return this._client.delete(path `/organization/invites/${inviteID}`, {
4289
+ ...options,
4290
+ __security: { adminAPIKeyAuth: true },
4291
+ });
4292
+ }
4293
+ }
4294
+
4295
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4296
+ let Roles$5 = class Roles extends APIResource {
4297
+ /**
4298
+ * Creates a custom role for the organization.
4299
+ *
4300
+ * @example
4301
+ * ```ts
4302
+ * const role = await client.admin.organization.roles.create({
4303
+ * permissions: ['string'],
4304
+ * role_name: 'role_name',
4305
+ * });
4306
+ * ```
4307
+ */
4308
+ create(body, options) {
4309
+ return this._client.post('/organization/roles', {
4310
+ body,
4311
+ ...options,
4312
+ __security: { adminAPIKeyAuth: true },
4313
+ });
4314
+ }
4315
+ /**
4316
+ * Updates an existing organization role.
4317
+ *
4318
+ * @example
4319
+ * ```ts
4320
+ * const role = await client.admin.organization.roles.update(
4321
+ * 'role_id',
4322
+ * );
4323
+ * ```
4324
+ */
4325
+ update(roleID, body, options) {
4326
+ return this._client.post(path `/organization/roles/${roleID}`, {
4327
+ body,
4328
+ ...options,
4329
+ __security: { adminAPIKeyAuth: true },
4330
+ });
4331
+ }
4332
+ /**
4333
+ * Lists the roles configured for the organization.
4334
+ *
4335
+ * @example
4336
+ * ```ts
4337
+ * // Automatically fetches more pages as needed.
4338
+ * for await (const role of client.admin.organization.roles.list()) {
4339
+ * // ...
4340
+ * }
4341
+ * ```
4342
+ */
4343
+ list(query = {}, options) {
4344
+ return this._client.getAPIList('/organization/roles', (NextCursorPage), {
4345
+ query,
4346
+ ...options,
4347
+ __security: { adminAPIKeyAuth: true },
4348
+ });
4349
+ }
4350
+ /**
4351
+ * Deletes a custom role from the organization.
4352
+ *
4353
+ * @example
4354
+ * ```ts
4355
+ * const role = await client.admin.organization.roles.delete(
4356
+ * 'role_id',
4357
+ * );
4358
+ * ```
4359
+ */
4360
+ delete(roleID, options) {
4361
+ return this._client.delete(path `/organization/roles/${roleID}`, {
4362
+ ...options,
4363
+ __security: { adminAPIKeyAuth: true },
4364
+ });
4365
+ }
4366
+ };
4367
+
4368
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4369
+ class Usage extends APIResource {
4370
+ /**
4371
+ * Get audio speeches usage details for the organization.
4372
+ *
4373
+ * @example
4374
+ * ```ts
4375
+ * const response =
4376
+ * await client.admin.organization.usage.audioSpeeches({
4377
+ * start_time: 0,
4378
+ * });
4379
+ * ```
4380
+ */
4381
+ audioSpeeches(query, options) {
4382
+ return this._client.get('/organization/usage/audio_speeches', {
4383
+ query,
4384
+ ...options,
4385
+ __security: { adminAPIKeyAuth: true },
4386
+ });
4387
+ }
4388
+ /**
4389
+ * Get audio transcriptions usage details for the organization.
4390
+ *
4391
+ * @example
4392
+ * ```ts
4393
+ * const response =
4394
+ * await client.admin.organization.usage.audioTranscriptions(
4395
+ * { start_time: 0 },
4396
+ * );
4397
+ * ```
4398
+ */
4399
+ audioTranscriptions(query, options) {
4400
+ return this._client.get('/organization/usage/audio_transcriptions', {
4401
+ query,
4402
+ ...options,
4403
+ __security: { adminAPIKeyAuth: true },
4404
+ });
4405
+ }
4406
+ /**
4407
+ * Get code interpreter sessions usage details for the organization.
4408
+ *
4409
+ * @example
4410
+ * ```ts
4411
+ * const response =
4412
+ * await client.admin.organization.usage.codeInterpreterSessions(
4413
+ * { start_time: 0 },
4414
+ * );
4415
+ * ```
4416
+ */
4417
+ codeInterpreterSessions(query, options) {
4418
+ return this._client.get('/organization/usage/code_interpreter_sessions', {
4419
+ query,
4420
+ ...options,
4421
+ __security: { adminAPIKeyAuth: true },
4422
+ });
4423
+ }
4424
+ /**
4425
+ * Get completions usage details for the organization.
4426
+ *
4427
+ * @example
4428
+ * ```ts
4429
+ * const response =
4430
+ * await client.admin.organization.usage.completions({
4431
+ * start_time: 0,
4432
+ * });
4433
+ * ```
4434
+ */
4435
+ completions(query, options) {
4436
+ return this._client.get('/organization/usage/completions', {
4437
+ query,
4438
+ ...options,
4439
+ __security: { adminAPIKeyAuth: true },
4440
+ });
4441
+ }
4442
+ /**
4443
+ * Get costs details for the organization.
4444
+ *
4445
+ * @example
4446
+ * ```ts
4447
+ * const response =
4448
+ * await client.admin.organization.usage.costs({
4449
+ * start_time: 0,
4450
+ * });
4451
+ * ```
4452
+ */
4453
+ costs(query, options) {
4454
+ return this._client.get('/organization/costs', {
4455
+ query,
4456
+ ...options,
4457
+ __security: { adminAPIKeyAuth: true },
4458
+ });
4459
+ }
4460
+ /**
4461
+ * Get embeddings usage details for the organization.
4462
+ *
4463
+ * @example
4464
+ * ```ts
4465
+ * const response =
4466
+ * await client.admin.organization.usage.embeddings({
4467
+ * start_time: 0,
4468
+ * });
4469
+ * ```
4470
+ */
4471
+ embeddings(query, options) {
4472
+ return this._client.get('/organization/usage/embeddings', {
4473
+ query,
4474
+ ...options,
4475
+ __security: { adminAPIKeyAuth: true },
4476
+ });
4477
+ }
4478
+ /**
4479
+ * Get images usage details for the organization.
4480
+ *
4481
+ * @example
4482
+ * ```ts
4483
+ * const response =
4484
+ * await client.admin.organization.usage.images({
4485
+ * start_time: 0,
4486
+ * });
4487
+ * ```
4488
+ */
4489
+ images(query, options) {
4490
+ return this._client.get('/organization/usage/images', {
4491
+ query,
4492
+ ...options,
4493
+ __security: { adminAPIKeyAuth: true },
4494
+ });
4495
+ }
4496
+ /**
4497
+ * Get moderations usage details for the organization.
4498
+ *
4499
+ * @example
4500
+ * ```ts
4501
+ * const response =
4502
+ * await client.admin.organization.usage.moderations({
4503
+ * start_time: 0,
4504
+ * });
4505
+ * ```
4506
+ */
4507
+ moderations(query, options) {
4508
+ return this._client.get('/organization/usage/moderations', {
4509
+ query,
4510
+ ...options,
4511
+ __security: { adminAPIKeyAuth: true },
4512
+ });
4513
+ }
4514
+ /**
4515
+ * Get vector stores usage details for the organization.
4516
+ *
4517
+ * @example
4518
+ * ```ts
4519
+ * const response =
4520
+ * await client.admin.organization.usage.vectorStores({
4521
+ * start_time: 0,
4522
+ * });
4523
+ * ```
4524
+ */
4525
+ vectorStores(query, options) {
4526
+ return this._client.get('/organization/usage/vector_stores', {
4527
+ query,
4528
+ ...options,
4529
+ __security: { adminAPIKeyAuth: true },
4530
+ });
4531
+ }
4532
+ }
4533
+
4534
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4535
+ let Roles$4 = class Roles extends APIResource {
4536
+ /**
4537
+ * Assigns an organization role to a group within the organization.
4538
+ *
4539
+ * @example
4540
+ * ```ts
4541
+ * const role =
4542
+ * await client.admin.organization.groups.roles.create(
4543
+ * 'group_id',
4544
+ * { role_id: 'role_id' },
4545
+ * );
4546
+ * ```
4547
+ */
4548
+ create(groupID, body, options) {
4549
+ return this._client.post(path `/organization/groups/${groupID}/roles`, {
4550
+ body,
4551
+ ...options,
4552
+ __security: { adminAPIKeyAuth: true },
4553
+ });
4554
+ }
4555
+ /**
4556
+ * Lists the organization roles assigned to a group within the organization.
4557
+ *
4558
+ * @example
4559
+ * ```ts
4560
+ * // Automatically fetches more pages as needed.
4561
+ * for await (const roleListResponse of client.admin.organization.groups.roles.list(
4562
+ * 'group_id',
4563
+ * )) {
4564
+ * // ...
4565
+ * }
4566
+ * ```
4567
+ */
4568
+ list(groupID, query = {}, options) {
4569
+ return this._client.getAPIList(path `/organization/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4570
+ }
4571
+ /**
4572
+ * Unassigns an organization role from a group within the organization.
4573
+ *
4574
+ * @example
4575
+ * ```ts
4576
+ * const role =
4577
+ * await client.admin.organization.groups.roles.delete(
4578
+ * 'role_id',
4579
+ * { group_id: 'group_id' },
4580
+ * );
4581
+ * ```
4582
+ */
4583
+ delete(roleID, params, options) {
4584
+ const { group_id } = params;
4585
+ return this._client.delete(path `/organization/groups/${group_id}/roles/${roleID}`, {
4586
+ ...options,
4587
+ __security: { adminAPIKeyAuth: true },
4588
+ });
4589
+ }
4590
+ };
4591
+
4592
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4593
+ let Users$2 = class Users extends APIResource {
4594
+ /**
4595
+ * Adds a user to a group.
4596
+ *
4597
+ * @example
4598
+ * ```ts
4599
+ * const user =
4600
+ * await client.admin.organization.groups.users.create(
4601
+ * 'group_id',
4602
+ * { user_id: 'user_id' },
4603
+ * );
4604
+ * ```
4605
+ */
4606
+ create(groupID, body, options) {
4607
+ return this._client.post(path `/organization/groups/${groupID}/users`, {
4608
+ body,
4609
+ ...options,
4610
+ __security: { adminAPIKeyAuth: true },
4611
+ });
4612
+ }
4613
+ /**
4614
+ * Lists the users assigned to a group.
4615
+ *
4616
+ * @example
4617
+ * ```ts
4618
+ * // Automatically fetches more pages as needed.
4619
+ * for await (const organizationGroupUser of client.admin.organization.groups.users.list(
4620
+ * 'group_id',
4621
+ * )) {
4622
+ * // ...
4623
+ * }
4624
+ * ```
4625
+ */
4626
+ list(groupID, query = {}, options) {
4627
+ return this._client.getAPIList(path `/organization/groups/${groupID}/users`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4628
+ }
4629
+ /**
4630
+ * Removes a user from a group.
4631
+ *
4632
+ * @example
4633
+ * ```ts
4634
+ * const user =
4635
+ * await client.admin.organization.groups.users.delete(
4636
+ * 'user_id',
4637
+ * { group_id: 'group_id' },
4638
+ * );
4639
+ * ```
4640
+ */
4641
+ delete(userID, params, options) {
4642
+ const { group_id } = params;
4643
+ return this._client.delete(path `/organization/groups/${group_id}/users/${userID}`, {
4644
+ ...options,
4645
+ __security: { adminAPIKeyAuth: true },
4646
+ });
4647
+ }
4648
+ };
4649
+
4650
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4651
+ let Groups$1 = class Groups extends APIResource {
4652
+ constructor() {
4653
+ super(...arguments);
4654
+ this.users = new Users$2(this._client);
4655
+ this.roles = new Roles$4(this._client);
4656
+ }
4657
+ /**
4658
+ * Creates a new group in the organization.
4659
+ *
4660
+ * @example
4661
+ * ```ts
4662
+ * const group = await client.admin.organization.groups.create(
4663
+ * { name: 'x' },
4664
+ * );
4665
+ * ```
4666
+ */
4667
+ create(body, options) {
4668
+ return this._client.post('/organization/groups', {
4669
+ body,
4670
+ ...options,
4671
+ __security: { adminAPIKeyAuth: true },
4672
+ });
4673
+ }
4674
+ /**
4675
+ * Updates a group's information.
4676
+ *
4677
+ * @example
4678
+ * ```ts
4679
+ * const group = await client.admin.organization.groups.update(
4680
+ * 'group_id',
4681
+ * { name: 'x' },
4682
+ * );
4683
+ * ```
4684
+ */
4685
+ update(groupID, body, options) {
4686
+ return this._client.post(path `/organization/groups/${groupID}`, {
4687
+ body,
4688
+ ...options,
4689
+ __security: { adminAPIKeyAuth: true },
4690
+ });
4691
+ }
4692
+ /**
4693
+ * Lists all groups in the organization.
4694
+ *
4695
+ * @example
4696
+ * ```ts
4697
+ * // Automatically fetches more pages as needed.
4698
+ * for await (const group of client.admin.organization.groups.list()) {
4699
+ * // ...
4700
+ * }
4701
+ * ```
4702
+ */
4703
+ list(query = {}, options) {
4704
+ return this._client.getAPIList('/organization/groups', (NextCursorPage), {
4705
+ query,
4706
+ ...options,
4707
+ __security: { adminAPIKeyAuth: true },
4708
+ });
4709
+ }
4710
+ /**
4711
+ * Deletes a group from the organization.
4712
+ *
4713
+ * @example
4714
+ * ```ts
4715
+ * const group = await client.admin.organization.groups.delete(
4716
+ * 'group_id',
4717
+ * );
4718
+ * ```
4719
+ */
4720
+ delete(groupID, options) {
4721
+ return this._client.delete(path `/organization/groups/${groupID}`, {
4722
+ ...options,
4723
+ __security: { adminAPIKeyAuth: true },
4724
+ });
4725
+ }
4726
+ };
4727
+ Groups$1.Users = Users$2;
4728
+ Groups$1.Roles = Roles$4;
4729
+
4730
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4731
+ class APIKeys extends APIResource {
4732
+ /**
4733
+ * Retrieves an API key in the project.
4734
+ *
4735
+ * @example
4736
+ * ```ts
4737
+ * const projectAPIKey =
4738
+ * await client.admin.organization.projects.apiKeys.retrieve(
4739
+ * 'api_key_id',
4740
+ * { project_id: 'project_id' },
4741
+ * );
4742
+ * ```
4743
+ */
4744
+ retrieve(apiKeyID, params, options) {
4745
+ const { project_id } = params;
4746
+ return this._client.get(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
4747
+ ...options,
4748
+ __security: { adminAPIKeyAuth: true },
4749
+ });
4750
+ }
4751
+ /**
4752
+ * Returns a list of API keys in the project.
4753
+ *
4754
+ * @example
4755
+ * ```ts
4756
+ * // Automatically fetches more pages as needed.
4757
+ * for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list(
4758
+ * 'project_id',
4759
+ * )) {
4760
+ * // ...
4761
+ * }
4762
+ * ```
4763
+ */
4764
+ list(projectID, query = {}, options) {
4765
+ return this._client.getAPIList(path `/organization/projects/${projectID}/api_keys`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4766
+ }
4767
+ /**
4768
+ * Deletes an API key from the project.
4769
+ *
4770
+ * Returns confirmation of the key deletion, or an error if the key belonged to a
4771
+ * service account.
4772
+ *
4773
+ * @example
4774
+ * ```ts
4775
+ * const apiKey =
4776
+ * await client.admin.organization.projects.apiKeys.delete(
4777
+ * 'api_key_id',
4778
+ * { project_id: 'project_id' },
4779
+ * );
4780
+ * ```
4781
+ */
4782
+ delete(apiKeyID, params, options) {
4783
+ const { project_id } = params;
4784
+ return this._client.delete(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
4785
+ ...options,
4786
+ __security: { adminAPIKeyAuth: true },
4787
+ });
4788
+ }
4789
+ }
4790
+
4791
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4792
+ class Certificates extends APIResource {
4793
+ /**
4794
+ * List certificates for this project.
4795
+ *
4796
+ * @example
4797
+ * ```ts
4798
+ * // Automatically fetches more pages as needed.
4799
+ * for await (const certificateListResponse of client.admin.organization.projects.certificates.list(
4800
+ * 'project_id',
4801
+ * )) {
4802
+ * // ...
4803
+ * }
4804
+ * ```
4805
+ */
4806
+ list(projectID, query = {}, options) {
4807
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4808
+ }
4809
+ /**
4810
+ * Activate certificates at the project level.
4811
+ *
4812
+ * You can atomically and idempotently activate up to 10 certificates at a time.
4813
+ *
4814
+ * @example
4815
+ * ```ts
4816
+ * // Automatically fetches more pages as needed.
4817
+ * for await (const certificateActivateResponse of client.admin.organization.projects.certificates.activate(
4818
+ * 'project_id',
4819
+ * { certificate_ids: ['cert_abc'] },
4820
+ * )) {
4821
+ * // ...
4822
+ * }
4823
+ * ```
4824
+ */
4825
+ activate(projectID, body, options) {
4826
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/activate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
4827
+ }
4828
+ /**
4829
+ * Deactivate certificates at the project level. You can atomically and
4830
+ * idempotently deactivate up to 10 certificates at a time.
4831
+ *
4832
+ * @example
4833
+ * ```ts
4834
+ * // Automatically fetches more pages as needed.
4835
+ * for await (const certificateDeactivateResponse of client.admin.organization.projects.certificates.deactivate(
4836
+ * 'project_id',
4837
+ * { certificate_ids: ['cert_abc'] },
4838
+ * )) {
4839
+ * // ...
4840
+ * }
4841
+ * ```
4842
+ */
4843
+ deactivate(projectID, body, options) {
4844
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/deactivate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
4845
+ }
4846
+ }
4847
+
4848
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4849
+ class RateLimits extends APIResource {
4850
+ /**
4851
+ * Returns the rate limits per model for a project.
4852
+ *
4853
+ * @example
4854
+ * ```ts
4855
+ * // Automatically fetches more pages as needed.
4856
+ * for await (const projectRateLimit of client.admin.organization.projects.rateLimits.listRateLimits(
4857
+ * 'project_id',
4858
+ * )) {
4859
+ * // ...
4860
+ * }
4861
+ * ```
4862
+ */
4863
+ listRateLimits(projectID, query = {}, options) {
4864
+ return this._client.getAPIList(path `/organization/projects/${projectID}/rate_limits`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4865
+ }
4866
+ /**
4867
+ * Updates a project rate limit.
4868
+ *
4869
+ * @example
4870
+ * ```ts
4871
+ * const projectRateLimit =
4872
+ * await client.admin.organization.projects.rateLimits.updateRateLimit(
4873
+ * 'rate_limit_id',
4874
+ * { project_id: 'project_id' },
4875
+ * );
4876
+ * ```
4877
+ */
4878
+ updateRateLimit(rateLimitID, params, options) {
4879
+ const { project_id, ...body } = params;
4880
+ return this._client.post(path `/organization/projects/${project_id}/rate_limits/${rateLimitID}`, {
4881
+ body,
4882
+ ...options,
4883
+ __security: { adminAPIKeyAuth: true },
4884
+ });
4885
+ }
4886
+ }
4887
+
4888
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4889
+ let Roles$3 = class Roles extends APIResource {
4890
+ /**
4891
+ * Creates a custom role for a project.
4892
+ *
4893
+ * @example
4894
+ * ```ts
4895
+ * const role =
4896
+ * await client.admin.organization.projects.roles.create(
4897
+ * 'project_id',
4898
+ * { permissions: ['string'], role_name: 'role_name' },
4899
+ * );
4900
+ * ```
4901
+ */
4902
+ create(projectID, body, options) {
4903
+ return this._client.post(path `/projects/${projectID}/roles`, {
4904
+ body,
4905
+ ...options,
4906
+ __security: { adminAPIKeyAuth: true },
4907
+ });
4908
+ }
4909
+ /**
4910
+ * Updates an existing project role.
4911
+ *
4912
+ * @example
4913
+ * ```ts
4914
+ * const role =
4915
+ * await client.admin.organization.projects.roles.update(
4916
+ * 'role_id',
4917
+ * { project_id: 'project_id' },
4918
+ * );
4919
+ * ```
4920
+ */
4921
+ update(roleID, params, options) {
4922
+ const { project_id, ...body } = params;
4923
+ return this._client.post(path `/projects/${project_id}/roles/${roleID}`, {
4924
+ body,
4925
+ ...options,
4926
+ __security: { adminAPIKeyAuth: true },
4927
+ });
4928
+ }
4929
+ /**
4930
+ * Lists the roles configured for a project.
4931
+ *
4932
+ * @example
4933
+ * ```ts
4934
+ * // Automatically fetches more pages as needed.
4935
+ * for await (const role of client.admin.organization.projects.roles.list(
4936
+ * 'project_id',
4937
+ * )) {
4938
+ * // ...
4939
+ * }
4940
+ * ```
4941
+ */
4942
+ list(projectID, query = {}, options) {
4943
+ return this._client.getAPIList(path `/projects/${projectID}/roles`, (NextCursorPage), {
4944
+ query,
4945
+ ...options,
4946
+ __security: { adminAPIKeyAuth: true },
4947
+ });
4948
+ }
4949
+ /**
4950
+ * Deletes a custom role from a project.
4951
+ *
4952
+ * @example
4953
+ * ```ts
4954
+ * const role =
4955
+ * await client.admin.organization.projects.roles.delete(
4956
+ * 'role_id',
4957
+ * { project_id: 'project_id' },
4958
+ * );
4959
+ * ```
4960
+ */
4961
+ delete(roleID, params, options) {
4962
+ const { project_id } = params;
4963
+ return this._client.delete(path `/projects/${project_id}/roles/${roleID}`, {
4964
+ ...options,
4965
+ __security: { adminAPIKeyAuth: true },
4966
+ });
4967
+ }
4968
+ };
4969
+
4970
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4971
+ class ServiceAccounts extends APIResource {
4972
+ /**
4973
+ * Creates a new service account in the project. This also returns an unredacted
4974
+ * API key for the service account.
4975
+ *
4976
+ * @example
4977
+ * ```ts
4978
+ * const serviceAccount =
4979
+ * await client.admin.organization.projects.serviceAccounts.create(
4980
+ * 'project_id',
4981
+ * { name: 'name' },
4982
+ * );
4983
+ * ```
4984
+ */
4985
+ create(projectID, body, options) {
4986
+ return this._client.post(path `/organization/projects/${projectID}/service_accounts`, {
4987
+ body,
4988
+ ...options,
4989
+ __security: { adminAPIKeyAuth: true },
4990
+ });
4991
+ }
4992
+ /**
4993
+ * Retrieves a service account in the project.
4994
+ *
4995
+ * @example
4996
+ * ```ts
4997
+ * const projectServiceAccount =
4998
+ * await client.admin.organization.projects.serviceAccounts.retrieve(
4999
+ * 'service_account_id',
5000
+ * { project_id: 'project_id' },
5001
+ * );
5002
+ * ```
5003
+ */
5004
+ retrieve(serviceAccountID, params, options) {
5005
+ const { project_id } = params;
5006
+ return this._client.get(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
5007
+ ...options,
5008
+ __security: { adminAPIKeyAuth: true },
5009
+ });
5010
+ }
5011
+ /**
5012
+ * Returns a list of service accounts in the project.
5013
+ *
5014
+ * @example
5015
+ * ```ts
5016
+ * // Automatically fetches more pages as needed.
5017
+ * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
5018
+ * 'project_id',
5019
+ * )) {
5020
+ * // ...
5021
+ * }
5022
+ * ```
5023
+ */
5024
+ list(projectID, query = {}, options) {
5025
+ return this._client.getAPIList(path `/organization/projects/${projectID}/service_accounts`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5026
+ }
5027
+ /**
5028
+ * Deletes a service account from the project.
5029
+ *
5030
+ * Returns confirmation of service account deletion, or an error if the project is
5031
+ * archived (archived projects have no service accounts).
5032
+ *
5033
+ * @example
5034
+ * ```ts
5035
+ * const serviceAccount =
5036
+ * await client.admin.organization.projects.serviceAccounts.delete(
5037
+ * 'service_account_id',
5038
+ * { project_id: 'project_id' },
5039
+ * );
5040
+ * ```
5041
+ */
5042
+ delete(serviceAccountID, params, options) {
5043
+ const { project_id } = params;
5044
+ return this._client.delete(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
5045
+ }
5046
+ }
5047
+
5048
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5049
+ let Roles$2 = class Roles extends APIResource {
5050
+ /**
5051
+ * Assigns a project role to a group within a project.
5052
+ *
5053
+ * @example
5054
+ * ```ts
5055
+ * const role =
5056
+ * await client.admin.organization.projects.groups.roles.create(
5057
+ * 'group_id',
5058
+ * { project_id: 'project_id', role_id: 'role_id' },
5059
+ * );
5060
+ * ```
5061
+ */
5062
+ create(groupID, params, options) {
5063
+ const { project_id, ...body } = params;
5064
+ return this._client.post(path `/projects/${project_id}/groups/${groupID}/roles`, {
5065
+ body,
5066
+ ...options,
5067
+ __security: { adminAPIKeyAuth: true },
5068
+ });
5069
+ }
5070
+ /**
5071
+ * Lists the project roles assigned to a group within a project.
5072
+ *
5073
+ * @example
5074
+ * ```ts
5075
+ * // Automatically fetches more pages as needed.
5076
+ * for await (const roleListResponse of client.admin.organization.projects.groups.roles.list(
5077
+ * 'group_id',
5078
+ * { project_id: 'project_id' },
5079
+ * )) {
5080
+ * // ...
5081
+ * }
5082
+ * ```
5083
+ */
5084
+ list(groupID, params, options) {
5085
+ const { project_id, ...query } = params;
5086
+ return this._client.getAPIList(path `/projects/${project_id}/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5087
+ }
5088
+ /**
5089
+ * Unassigns a project role from a group within a project.
5090
+ *
5091
+ * @example
5092
+ * ```ts
5093
+ * const role =
5094
+ * await client.admin.organization.projects.groups.roles.delete(
5095
+ * 'role_id',
5096
+ * { project_id: 'project_id', group_id: 'group_id' },
5097
+ * );
5098
+ * ```
5099
+ */
5100
+ delete(roleID, params, options) {
5101
+ const { project_id, group_id } = params;
5102
+ return this._client.delete(path `/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
5103
+ ...options,
5104
+ __security: { adminAPIKeyAuth: true },
5105
+ });
5106
+ }
5107
+ };
5108
+
5109
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5110
+ class Groups extends APIResource {
5111
+ constructor() {
5112
+ super(...arguments);
5113
+ this.roles = new Roles$2(this._client);
5114
+ }
5115
+ /**
5116
+ * Grants a group access to a project.
5117
+ *
5118
+ * @example
5119
+ * ```ts
5120
+ * const projectGroup =
5121
+ * await client.admin.organization.projects.groups.create(
5122
+ * 'project_id',
5123
+ * { group_id: 'group_id', role: 'role' },
5124
+ * );
5125
+ * ```
5126
+ */
5127
+ create(projectID, body, options) {
5128
+ return this._client.post(path `/organization/projects/${projectID}/groups`, {
5129
+ body,
5130
+ ...options,
5131
+ __security: { adminAPIKeyAuth: true },
5132
+ });
5133
+ }
5134
+ /**
5135
+ * Lists the groups that have access to a project.
5136
+ *
5137
+ * @example
5138
+ * ```ts
5139
+ * // Automatically fetches more pages as needed.
5140
+ * for await (const projectGroup of client.admin.organization.projects.groups.list(
5141
+ * 'project_id',
5142
+ * )) {
5143
+ * // ...
5144
+ * }
5145
+ * ```
5146
+ */
5147
+ list(projectID, query = {}, options) {
5148
+ return this._client.getAPIList(path `/organization/projects/${projectID}/groups`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5149
+ }
5150
+ /**
5151
+ * Revokes a group's access to a project.
5152
+ *
5153
+ * @example
5154
+ * ```ts
5155
+ * const group =
5156
+ * await client.admin.organization.projects.groups.delete(
5157
+ * 'group_id',
5158
+ * { project_id: 'project_id' },
5159
+ * );
5160
+ * ```
5161
+ */
5162
+ delete(groupID, params, options) {
5163
+ const { project_id } = params;
5164
+ return this._client.delete(path `/organization/projects/${project_id}/groups/${groupID}`, {
5165
+ ...options,
5166
+ __security: { adminAPIKeyAuth: true },
5167
+ });
5168
+ }
5169
+ }
5170
+ Groups.Roles = Roles$2;
5171
+
5172
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5173
+ let Roles$1 = class Roles extends APIResource {
5174
+ /**
5175
+ * Assigns a project role to a user within a project.
5176
+ *
5177
+ * @example
5178
+ * ```ts
5179
+ * const role =
5180
+ * await client.admin.organization.projects.users.roles.create(
5181
+ * 'user_id',
5182
+ * { project_id: 'project_id', role_id: 'role_id' },
5183
+ * );
5184
+ * ```
5185
+ */
5186
+ create(userID, params, options) {
5187
+ const { project_id, ...body } = params;
5188
+ return this._client.post(path `/projects/${project_id}/users/${userID}/roles`, {
5189
+ body,
5190
+ ...options,
5191
+ __security: { adminAPIKeyAuth: true },
5192
+ });
5193
+ }
5194
+ /**
5195
+ * Lists the project roles assigned to a user within a project.
5196
+ *
5197
+ * @example
5198
+ * ```ts
5199
+ * // Automatically fetches more pages as needed.
5200
+ * for await (const roleListResponse of client.admin.organization.projects.users.roles.list(
5201
+ * 'user_id',
5202
+ * { project_id: 'project_id' },
5203
+ * )) {
5204
+ * // ...
5205
+ * }
5206
+ * ```
5207
+ */
5208
+ list(userID, params, options) {
5209
+ const { project_id, ...query } = params;
5210
+ return this._client.getAPIList(path `/projects/${project_id}/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5211
+ }
5212
+ /**
5213
+ * Unassigns a project role from a user within a project.
5214
+ *
5215
+ * @example
5216
+ * ```ts
5217
+ * const role =
5218
+ * await client.admin.organization.projects.users.roles.delete(
5219
+ * 'role_id',
5220
+ * { project_id: 'project_id', user_id: 'user_id' },
5221
+ * );
5222
+ * ```
5223
+ */
5224
+ delete(roleID, params, options) {
5225
+ const { project_id, user_id } = params;
5226
+ return this._client.delete(path `/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
5227
+ ...options,
5228
+ __security: { adminAPIKeyAuth: true },
5229
+ });
5230
+ }
5231
+ };
5232
+
5233
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5234
+ let Users$1 = class Users extends APIResource {
5235
+ constructor() {
5236
+ super(...arguments);
5237
+ this.roles = new Roles$1(this._client);
5238
+ }
5239
+ /**
5240
+ * Adds a user to the project. Users must already be members of the organization to
5241
+ * be added to a project.
5242
+ *
5243
+ * @example
5244
+ * ```ts
5245
+ * const projectUser =
5246
+ * await client.admin.organization.projects.users.create(
5247
+ * 'project_id',
5248
+ * { role: 'role' },
5249
+ * );
5250
+ * ```
5251
+ */
5252
+ create(projectID, body, options) {
5253
+ return this._client.post(path `/organization/projects/${projectID}/users`, {
5254
+ body,
5255
+ ...options,
5256
+ __security: { adminAPIKeyAuth: true },
5257
+ });
5258
+ }
5259
+ /**
5260
+ * Retrieves a user in the project.
5261
+ *
5262
+ * @example
5263
+ * ```ts
5264
+ * const projectUser =
5265
+ * await client.admin.organization.projects.users.retrieve(
5266
+ * 'user_id',
5267
+ * { project_id: 'project_id' },
5268
+ * );
5269
+ * ```
5270
+ */
5271
+ retrieve(userID, params, options) {
5272
+ const { project_id } = params;
5273
+ return this._client.get(path `/organization/projects/${project_id}/users/${userID}`, {
5274
+ ...options,
5275
+ __security: { adminAPIKeyAuth: true },
5276
+ });
5277
+ }
5278
+ /**
5279
+ * Modifies a user's role in the project.
5280
+ *
5281
+ * @example
5282
+ * ```ts
5283
+ * const projectUser =
5284
+ * await client.admin.organization.projects.users.update(
5285
+ * 'user_id',
5286
+ * { project_id: 'project_id' },
5287
+ * );
5288
+ * ```
5289
+ */
5290
+ update(userID, params, options) {
5291
+ const { project_id, ...body } = params;
5292
+ return this._client.post(path `/organization/projects/${project_id}/users/${userID}`, {
5293
+ body,
5294
+ ...options,
5295
+ __security: { adminAPIKeyAuth: true },
5296
+ });
5297
+ }
5298
+ /**
5299
+ * Returns a list of users in the project.
5300
+ *
5301
+ * @example
5302
+ * ```ts
5303
+ * // Automatically fetches more pages as needed.
5304
+ * for await (const projectUser of client.admin.organization.projects.users.list(
5305
+ * 'project_id',
5306
+ * )) {
5307
+ * // ...
5308
+ * }
5309
+ * ```
5310
+ */
5311
+ list(projectID, query = {}, options) {
5312
+ return this._client.getAPIList(path `/organization/projects/${projectID}/users`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5313
+ }
5314
+ /**
5315
+ * Deletes a user from the project.
5316
+ *
5317
+ * Returns confirmation of project user deletion, or an error if the project is
5318
+ * archived (archived projects have no users).
5319
+ *
5320
+ * @example
5321
+ * ```ts
5322
+ * const user =
5323
+ * await client.admin.organization.projects.users.delete(
5324
+ * 'user_id',
5325
+ * { project_id: 'project_id' },
5326
+ * );
5327
+ * ```
5328
+ */
5329
+ delete(userID, params, options) {
5330
+ const { project_id } = params;
5331
+ return this._client.delete(path `/organization/projects/${project_id}/users/${userID}`, {
5332
+ ...options,
5333
+ __security: { adminAPIKeyAuth: true },
5334
+ });
5335
+ }
5336
+ };
5337
+ Users$1.Roles = Roles$1;
5338
+
5339
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5340
+ class Projects extends APIResource {
5341
+ constructor() {
5342
+ super(...arguments);
5343
+ this.users = new Users$1(this._client);
5344
+ this.serviceAccounts = new ServiceAccounts(this._client);
5345
+ this.apiKeys = new APIKeys(this._client);
5346
+ this.rateLimits = new RateLimits(this._client);
5347
+ this.groups = new Groups(this._client);
5348
+ this.roles = new Roles$3(this._client);
5349
+ this.certificates = new Certificates(this._client);
5350
+ }
5351
+ /**
5352
+ * Create a new project in the organization. Projects can be created and archived,
5353
+ * but cannot be deleted.
5354
+ *
5355
+ * @example
5356
+ * ```ts
5357
+ * const project =
5358
+ * await client.admin.organization.projects.create({
5359
+ * name: 'name',
5360
+ * });
5361
+ * ```
5362
+ */
5363
+ create(body, options) {
5364
+ return this._client.post('/organization/projects', {
5365
+ body,
5366
+ ...options,
5367
+ __security: { adminAPIKeyAuth: true },
5368
+ });
5369
+ }
5370
+ /**
5371
+ * Retrieves a project.
5372
+ *
5373
+ * @example
5374
+ * ```ts
5375
+ * const project =
5376
+ * await client.admin.organization.projects.retrieve(
5377
+ * 'project_id',
5378
+ * );
5379
+ * ```
5380
+ */
5381
+ retrieve(projectID, options) {
5382
+ return this._client.get(path `/organization/projects/${projectID}`, {
5383
+ ...options,
5384
+ __security: { adminAPIKeyAuth: true },
5385
+ });
5386
+ }
5387
+ /**
5388
+ * Modifies a project in the organization.
5389
+ *
5390
+ * @example
5391
+ * ```ts
5392
+ * const project =
5393
+ * await client.admin.organization.projects.update(
5394
+ * 'project_id',
5395
+ * );
5396
+ * ```
5397
+ */
5398
+ update(projectID, body, options) {
5399
+ return this._client.post(path `/organization/projects/${projectID}`, {
5400
+ body,
5401
+ ...options,
5402
+ __security: { adminAPIKeyAuth: true },
5403
+ });
5404
+ }
5405
+ /**
5406
+ * Returns a list of projects.
5407
+ *
5408
+ * @example
5409
+ * ```ts
5410
+ * // Automatically fetches more pages as needed.
5411
+ * for await (const project of client.admin.organization.projects.list()) {
5412
+ * // ...
5413
+ * }
5414
+ * ```
5415
+ */
5416
+ list(query = {}, options) {
5417
+ return this._client.getAPIList('/organization/projects', (ConversationCursorPage), {
5418
+ query,
5419
+ ...options,
5420
+ __security: { adminAPIKeyAuth: true },
5421
+ });
5422
+ }
5423
+ /**
5424
+ * Archives a project in the organization. Archived projects cannot be used or
5425
+ * updated.
5426
+ *
5427
+ * @example
5428
+ * ```ts
5429
+ * const project =
5430
+ * await client.admin.organization.projects.archive(
5431
+ * 'project_id',
5432
+ * );
5433
+ * ```
5434
+ */
5435
+ archive(projectID, options) {
5436
+ return this._client.post(path `/organization/projects/${projectID}/archive`, {
5437
+ ...options,
5438
+ __security: { adminAPIKeyAuth: true },
5439
+ });
5440
+ }
5441
+ }
5442
+ Projects.Users = Users$1;
5443
+ Projects.ServiceAccounts = ServiceAccounts;
5444
+ Projects.APIKeys = APIKeys;
5445
+ Projects.RateLimits = RateLimits;
5446
+ Projects.Groups = Groups;
5447
+ Projects.Roles = Roles$3;
5448
+ Projects.Certificates = Certificates;
5449
+
5450
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5451
+ class Roles extends APIResource {
5452
+ /**
5453
+ * Assigns an organization role to a user within the organization.
5454
+ *
5455
+ * @example
5456
+ * ```ts
5457
+ * const role =
5458
+ * await client.admin.organization.users.roles.create(
5459
+ * 'user_id',
5460
+ * { role_id: 'role_id' },
5461
+ * );
5462
+ * ```
5463
+ */
5464
+ create(userID, body, options) {
5465
+ return this._client.post(path `/organization/users/${userID}/roles`, {
5466
+ body,
5467
+ ...options,
5468
+ __security: { adminAPIKeyAuth: true },
5469
+ });
5470
+ }
5471
+ /**
5472
+ * Lists the organization roles assigned to a user within the organization.
5473
+ *
5474
+ * @example
5475
+ * ```ts
5476
+ * // Automatically fetches more pages as needed.
5477
+ * for await (const roleListResponse of client.admin.organization.users.roles.list(
5478
+ * 'user_id',
5479
+ * )) {
5480
+ * // ...
5481
+ * }
5482
+ * ```
5483
+ */
5484
+ list(userID, query = {}, options) {
5485
+ return this._client.getAPIList(path `/organization/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5486
+ }
5487
+ /**
5488
+ * Unassigns an organization role from a user within the organization.
5489
+ *
5490
+ * @example
5491
+ * ```ts
5492
+ * const role =
5493
+ * await client.admin.organization.users.roles.delete(
5494
+ * 'role_id',
5495
+ * { user_id: 'user_id' },
5496
+ * );
5497
+ * ```
5498
+ */
5499
+ delete(roleID, params, options) {
5500
+ const { user_id } = params;
5501
+ return this._client.delete(path `/organization/users/${user_id}/roles/${roleID}`, {
5502
+ ...options,
5503
+ __security: { adminAPIKeyAuth: true },
5504
+ });
3821
5505
  }
3822
5506
  }
3823
5507
 
3824
5508
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3825
- /**
3826
- * Given a list of messages comprising a conversation, the model will return a response.
3827
- */
3828
- let Completions$1 = class Completions extends APIResource {
5509
+ class Users extends APIResource {
3829
5510
  constructor() {
3830
5511
  super(...arguments);
3831
- this.messages = new Messages$1(this._client);
3832
- }
3833
- create(body, options) {
3834
- return this._client.post('/chat/completions', { body, ...options, stream: body.stream ?? false });
5512
+ this.roles = new Roles(this._client);
3835
5513
  }
3836
5514
  /**
3837
- * Get a stored chat completion. Only Chat Completions that have been created with
3838
- * the `store` parameter set to `true` will be returned.
5515
+ * Retrieves a user by their identifier.
3839
5516
  *
3840
5517
  * @example
3841
5518
  * ```ts
3842
- * const chatCompletion =
3843
- * await client.chat.completions.retrieve('completion_id');
5519
+ * const organizationUser =
5520
+ * await client.admin.organization.users.retrieve('user_id');
3844
5521
  * ```
3845
5522
  */
3846
- retrieve(completionID, options) {
3847
- return this._client.get(path `/chat/completions/${completionID}`, options);
5523
+ retrieve(userID, options) {
5524
+ return this._client.get(path `/organization/users/${userID}`, {
5525
+ ...options,
5526
+ __security: { adminAPIKeyAuth: true },
5527
+ });
3848
5528
  }
3849
5529
  /**
3850
- * Modify a stored chat completion. Only Chat Completions that have been created
3851
- * with the `store` parameter set to `true` can be modified. Currently, the only
3852
- * supported modification is to update the `metadata` field.
5530
+ * Modifies a user's role in the organization.
3853
5531
  *
3854
5532
  * @example
3855
5533
  * ```ts
3856
- * const chatCompletion = await client.chat.completions.update(
3857
- * 'completion_id',
3858
- * { metadata: { foo: 'string' } },
3859
- * );
5534
+ * const organizationUser =
5535
+ * await client.admin.organization.users.update('user_id');
3860
5536
  * ```
3861
5537
  */
3862
- update(completionID, body, options) {
3863
- return this._client.post(path `/chat/completions/${completionID}`, { body, ...options });
5538
+ update(userID, body, options) {
5539
+ return this._client.post(path `/organization/users/${userID}`, {
5540
+ body,
5541
+ ...options,
5542
+ __security: { adminAPIKeyAuth: true },
5543
+ });
3864
5544
  }
3865
5545
  /**
3866
- * List stored Chat Completions. Only Chat Completions that have been stored with
3867
- * the `store` parameter set to `true` will be returned.
5546
+ * Lists all of the users in the organization.
3868
5547
  *
3869
5548
  * @example
3870
5549
  * ```ts
3871
5550
  * // Automatically fetches more pages as needed.
3872
- * for await (const chatCompletion of client.chat.completions.list()) {
5551
+ * for await (const organizationUser of client.admin.organization.users.list()) {
3873
5552
  * // ...
3874
5553
  * }
3875
5554
  * ```
3876
5555
  */
3877
5556
  list(query = {}, options) {
3878
- return this._client.getAPIList('/chat/completions', (CursorPage), { query, ...options });
5557
+ return this._client.getAPIList('/organization/users', (ConversationCursorPage), {
5558
+ query,
5559
+ ...options,
5560
+ __security: { adminAPIKeyAuth: true },
5561
+ });
3879
5562
  }
3880
5563
  /**
3881
- * Delete a stored chat completion. Only Chat Completions that have been created
3882
- * with the `store` parameter set to `true` can be deleted.
5564
+ * Deletes a user from the organization.
3883
5565
  *
3884
5566
  * @example
3885
5567
  * ```ts
3886
- * const chatCompletionDeleted =
3887
- * await client.chat.completions.delete('completion_id');
5568
+ * const user = await client.admin.organization.users.delete(
5569
+ * 'user_id',
5570
+ * );
3888
5571
  * ```
3889
5572
  */
3890
- delete(completionID, options) {
3891
- return this._client.delete(path `/chat/completions/${completionID}`, options);
3892
- }
3893
- parse(body, options) {
3894
- validateInputTools(body.tools);
3895
- return this._client.chat.completions
3896
- .create(body, {
5573
+ delete(userID, options) {
5574
+ return this._client.delete(path `/organization/users/${userID}`, {
3897
5575
  ...options,
3898
- headers: {
3899
- ...options?.headers,
3900
- 'X-Stainless-Helper-Method': 'chat.completions.parse',
3901
- },
3902
- })
3903
- ._thenUnwrap((completion) => parseChatCompletion(completion, body));
3904
- }
3905
- runTools(body, options) {
3906
- if (body.stream) {
3907
- return ChatCompletionStreamingRunner.runTools(this._client, body, options);
3908
- }
3909
- return ChatCompletionRunner.runTools(this._client, body, options);
3910
- }
3911
- /**
3912
- * Creates a chat completion stream
3913
- */
3914
- stream(body, options) {
3915
- return ChatCompletionStream.createChatCompletion(this._client, body, options);
5576
+ __security: { adminAPIKeyAuth: true },
5577
+ });
3916
5578
  }
3917
- };
3918
- Completions$1.Messages = Messages$1;
5579
+ }
5580
+ Users.Roles = Roles;
3919
5581
 
3920
5582
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3921
- class Chat extends APIResource {
5583
+ class Organization extends APIResource {
3922
5584
  constructor() {
3923
5585
  super(...arguments);
3924
- this.completions = new Completions$1(this._client);
5586
+ this.auditLogs = new AuditLogs(this._client);
5587
+ this.adminAPIKeys = new AdminAPIKeys(this._client);
5588
+ this.usage = new Usage(this._client);
5589
+ this.invites = new Invites(this._client);
5590
+ this.users = new Users(this._client);
5591
+ this.groups = new Groups$1(this._client);
5592
+ this.roles = new Roles$5(this._client);
5593
+ this.certificates = new Certificates$1(this._client);
5594
+ this.projects = new Projects(this._client);
5595
+ }
5596
+ }
5597
+ Organization.AuditLogs = AuditLogs;
5598
+ Organization.AdminAPIKeys = AdminAPIKeys;
5599
+ Organization.Usage = Usage;
5600
+ Organization.Invites = Invites;
5601
+ Organization.Users = Users;
5602
+ Organization.Groups = Groups$1;
5603
+ Organization.Roles = Roles$5;
5604
+ Organization.Certificates = Certificates$1;
5605
+ Organization.Projects = Projects;
5606
+
5607
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5608
+ class Admin extends APIResource {
5609
+ constructor() {
5610
+ super(...arguments);
5611
+ this.organization = new Organization(this._client);
3925
5612
  }
3926
5613
  }
3927
- Chat.Completions = Completions$1;
5614
+ Admin.Organization = Organization;
3928
5615
 
3929
5616
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3930
5617
  const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
@@ -4021,6 +5708,7 @@ class Speech extends APIResource {
4021
5708
  body,
4022
5709
  ...options,
4023
5710
  headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
5711
+ __security: { bearerAuth: true },
4024
5712
  __binaryResponse: true,
4025
5713
  });
4026
5714
  }
@@ -4037,6 +5725,7 @@ class Transcriptions extends APIResource {
4037
5725
  ...options,
4038
5726
  stream: body.stream ?? false,
4039
5727
  __metadata: { model: body.model },
5728
+ __security: { bearerAuth: true },
4040
5729
  }, this._client));
4041
5730
  }
4042
5731
  }
@@ -4047,7 +5736,7 @@ class Transcriptions extends APIResource {
4047
5736
  */
4048
5737
  class Translations extends APIResource {
4049
5738
  create(body, options) {
4050
- return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
5739
+ return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } }, this._client));
4051
5740
  }
4052
5741
  }
4053
5742
 
@@ -4073,19 +5762,23 @@ class Batches extends APIResource {
4073
5762
  * Creates and executes a batch from an uploaded file of requests
4074
5763
  */
4075
5764
  create(body, options) {
4076
- return this._client.post('/batches', { body, ...options });
5765
+ return this._client.post('/batches', { body, ...options, __security: { bearerAuth: true } });
4077
5766
  }
4078
5767
  /**
4079
5768
  * Retrieves a batch.
4080
5769
  */
4081
5770
  retrieve(batchID, options) {
4082
- return this._client.get(path `/batches/${batchID}`, options);
5771
+ return this._client.get(path `/batches/${batchID}`, { ...options, __security: { bearerAuth: true } });
4083
5772
  }
4084
5773
  /**
4085
5774
  * List your organization's batches.
4086
5775
  */
4087
5776
  list(query = {}, options) {
4088
- return this._client.getAPIList('/batches', (CursorPage), { query, ...options });
5777
+ return this._client.getAPIList('/batches', (CursorPage), {
5778
+ query,
5779
+ ...options,
5780
+ __security: { bearerAuth: true },
5781
+ });
4089
5782
  }
4090
5783
  /**
4091
5784
  * Cancels an in-progress batch. The batch will be in status `cancelling` for up to
@@ -4093,7 +5786,10 @@ class Batches extends APIResource {
4093
5786
  * (if any) available in the output file.
4094
5787
  */
4095
5788
  cancel(batchID, options) {
4096
- return this._client.post(path `/batches/${batchID}/cancel`, options);
5789
+ return this._client.post(path `/batches/${batchID}/cancel`, {
5790
+ ...options,
5791
+ __security: { bearerAuth: true },
5792
+ });
4097
5793
  }
4098
5794
  }
4099
5795
 
@@ -4112,6 +5808,7 @@ class Assistants extends APIResource {
4112
5808
  body,
4113
5809
  ...options,
4114
5810
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5811
+ __security: { bearerAuth: true },
4115
5812
  });
4116
5813
  }
4117
5814
  /**
@@ -4123,6 +5820,7 @@ class Assistants extends APIResource {
4123
5820
  return this._client.get(path `/assistants/${assistantID}`, {
4124
5821
  ...options,
4125
5822
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5823
+ __security: { bearerAuth: true },
4126
5824
  });
4127
5825
  }
4128
5826
  /**
@@ -4135,6 +5833,7 @@ class Assistants extends APIResource {
4135
5833
  body,
4136
5834
  ...options,
4137
5835
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5836
+ __security: { bearerAuth: true },
4138
5837
  });
4139
5838
  }
4140
5839
  /**
@@ -4147,6 +5846,7 @@ class Assistants extends APIResource {
4147
5846
  query,
4148
5847
  ...options,
4149
5848
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5849
+ __security: { bearerAuth: true },
4150
5850
  });
4151
5851
  }
4152
5852
  /**
@@ -4158,6 +5858,7 @@ class Assistants extends APIResource {
4158
5858
  return this._client.delete(path `/assistants/${assistantID}`, {
4159
5859
  ...options,
4160
5860
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5861
+ __security: { bearerAuth: true },
4161
5862
  });
4162
5863
  }
4163
5864
  }
@@ -4184,6 +5885,7 @@ let Sessions$1 = class Sessions extends APIResource {
4184
5885
  body,
4185
5886
  ...options,
4186
5887
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5888
+ __security: { bearerAuth: true },
4187
5889
  });
4188
5890
  }
4189
5891
  };
@@ -4210,6 +5912,7 @@ class TranscriptionSessions extends APIResource {
4210
5912
  body,
4211
5913
  ...options,
4212
5914
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5915
+ __security: { bearerAuth: true },
4213
5916
  });
4214
5917
  }
4215
5918
  }
@@ -4247,6 +5950,7 @@ class Sessions extends APIResource {
4247
5950
  body,
4248
5951
  ...options,
4249
5952
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5953
+ __security: { bearerAuth: true },
4250
5954
  });
4251
5955
  }
4252
5956
  /**
@@ -4264,6 +5968,7 @@ class Sessions extends APIResource {
4264
5968
  return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
4265
5969
  ...options,
4266
5970
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5971
+ __security: { bearerAuth: true },
4267
5972
  });
4268
5973
  }
4269
5974
  }
@@ -4283,6 +5988,7 @@ let Threads$1 = class Threads extends APIResource {
4283
5988
  return this._client.get(path `/chatkit/threads/${threadID}`, {
4284
5989
  ...options,
4285
5990
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
5991
+ __security: { bearerAuth: true },
4286
5992
  });
4287
5993
  }
4288
5994
  /**
@@ -4301,6 +6007,7 @@ let Threads$1 = class Threads extends APIResource {
4301
6007
  query,
4302
6008
  ...options,
4303
6009
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
6010
+ __security: { bearerAuth: true },
4304
6011
  });
4305
6012
  }
4306
6013
  /**
@@ -4317,6 +6024,7 @@ let Threads$1 = class Threads extends APIResource {
4317
6024
  return this._client.delete(path `/chatkit/threads/${threadID}`, {
4318
6025
  ...options,
4319
6026
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
6027
+ __security: { bearerAuth: true },
4320
6028
  });
4321
6029
  }
4322
6030
  /**
@@ -4333,7 +6041,12 @@ let Threads$1 = class Threads extends APIResource {
4333
6041
  * ```
4334
6042
  */
4335
6043
  listItems(threadID, query = {}, options) {
4336
- return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), { query, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) });
6044
+ return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), {
6045
+ query,
6046
+ ...options,
6047
+ headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
6048
+ __security: { bearerAuth: true },
6049
+ });
4337
6050
  }
4338
6051
  };
4339
6052
 
@@ -4365,6 +6078,7 @@ class Messages extends APIResource {
4365
6078
  body,
4366
6079
  ...options,
4367
6080
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6081
+ __security: { bearerAuth: true },
4368
6082
  });
4369
6083
  }
4370
6084
  /**
@@ -4377,6 +6091,7 @@ class Messages extends APIResource {
4377
6091
  return this._client.get(path `/threads/${thread_id}/messages/${messageID}`, {
4378
6092
  ...options,
4379
6093
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6094
+ __security: { bearerAuth: true },
4380
6095
  });
4381
6096
  }
4382
6097
  /**
@@ -4390,6 +6105,7 @@ class Messages extends APIResource {
4390
6105
  body,
4391
6106
  ...options,
4392
6107
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6108
+ __security: { bearerAuth: true },
4393
6109
  });
4394
6110
  }
4395
6111
  /**
@@ -4402,6 +6118,7 @@ class Messages extends APIResource {
4402
6118
  query,
4403
6119
  ...options,
4404
6120
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6121
+ __security: { bearerAuth: true },
4405
6122
  });
4406
6123
  }
4407
6124
  /**
@@ -4414,6 +6131,7 @@ class Messages extends APIResource {
4414
6131
  return this._client.delete(path `/threads/${thread_id}/messages/${messageID}`, {
4415
6132
  ...options,
4416
6133
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6134
+ __security: { bearerAuth: true },
4417
6135
  });
4418
6136
  }
4419
6137
  }
@@ -4436,6 +6154,7 @@ class Steps extends APIResource {
4436
6154
  query,
4437
6155
  ...options,
4438
6156
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6157
+ __security: { bearerAuth: true },
4439
6158
  });
4440
6159
  }
4441
6160
  /**
@@ -4449,6 +6168,7 @@ class Steps extends APIResource {
4449
6168
  query,
4450
6169
  ...options,
4451
6170
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6171
+ __security: { bearerAuth: true },
4452
6172
  });
4453
6173
  }
4454
6174
  }
@@ -5052,6 +6772,7 @@ let Runs$1 = class Runs extends APIResource {
5052
6772
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5053
6773
  stream: params.stream ?? false,
5054
6774
  __synthesizeEventData: true,
6775
+ __security: { bearerAuth: true },
5055
6776
  });
5056
6777
  }
5057
6778
  /**
@@ -5064,6 +6785,7 @@ let Runs$1 = class Runs extends APIResource {
5064
6785
  return this._client.get(path `/threads/${thread_id}/runs/${runID}`, {
5065
6786
  ...options,
5066
6787
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6788
+ __security: { bearerAuth: true },
5067
6789
  });
5068
6790
  }
5069
6791
  /**
@@ -5077,6 +6799,7 @@ let Runs$1 = class Runs extends APIResource {
5077
6799
  body,
5078
6800
  ...options,
5079
6801
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6802
+ __security: { bearerAuth: true },
5080
6803
  });
5081
6804
  }
5082
6805
  /**
@@ -5089,6 +6812,7 @@ let Runs$1 = class Runs extends APIResource {
5089
6812
  query,
5090
6813
  ...options,
5091
6814
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6815
+ __security: { bearerAuth: true },
5092
6816
  });
5093
6817
  }
5094
6818
  /**
@@ -5101,6 +6825,7 @@ let Runs$1 = class Runs extends APIResource {
5101
6825
  return this._client.post(path `/threads/${thread_id}/runs/${runID}/cancel`, {
5102
6826
  ...options,
5103
6827
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6828
+ __security: { bearerAuth: true },
5104
6829
  });
5105
6830
  }
5106
6831
  /**
@@ -5183,6 +6908,7 @@ let Runs$1 = class Runs extends APIResource {
5183
6908
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5184
6909
  stream: params.stream ?? false,
5185
6910
  __synthesizeEventData: true,
6911
+ __security: { bearerAuth: true },
5186
6912
  });
5187
6913
  }
5188
6914
  /**
@@ -5227,6 +6953,7 @@ class Threads extends APIResource {
5227
6953
  body,
5228
6954
  ...options,
5229
6955
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6956
+ __security: { bearerAuth: true },
5230
6957
  });
5231
6958
  }
5232
6959
  /**
@@ -5238,6 +6965,7 @@ class Threads extends APIResource {
5238
6965
  return this._client.get(path `/threads/${threadID}`, {
5239
6966
  ...options,
5240
6967
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6968
+ __security: { bearerAuth: true },
5241
6969
  });
5242
6970
  }
5243
6971
  /**
@@ -5250,6 +6978,7 @@ class Threads extends APIResource {
5250
6978
  body,
5251
6979
  ...options,
5252
6980
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6981
+ __security: { bearerAuth: true },
5253
6982
  });
5254
6983
  }
5255
6984
  /**
@@ -5261,6 +6990,7 @@ class Threads extends APIResource {
5261
6990
  return this._client.delete(path `/threads/${threadID}`, {
5262
6991
  ...options,
5263
6992
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6993
+ __security: { bearerAuth: true },
5264
6994
  });
5265
6995
  }
5266
6996
  createAndRun(body, options) {
@@ -5270,6 +7000,7 @@ class Threads extends APIResource {
5270
7000
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5271
7001
  stream: body.stream ?? false,
5272
7002
  __synthesizeEventData: true,
7003
+ __security: { bearerAuth: true },
5273
7004
  });
5274
7005
  }
5275
7006
  /**
@@ -5312,7 +7043,12 @@ Beta.Threads = Threads;
5312
7043
  */
5313
7044
  class Completions extends APIResource {
5314
7045
  create(body, options) {
5315
- return this._client.post('/completions', { body, ...options, stream: body.stream ?? false });
7046
+ return this._client.post('/completions', {
7047
+ body,
7048
+ ...options,
7049
+ stream: body.stream ?? false,
7050
+ __security: { bearerAuth: true },
7051
+ });
5316
7052
  }
5317
7053
  }
5318
7054
 
@@ -5326,6 +7062,7 @@ let Content$2 = class Content extends APIResource {
5326
7062
  return this._client.get(path `/containers/${container_id}/files/${fileID}/content`, {
5327
7063
  ...options,
5328
7064
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
7065
+ __security: { bearerAuth: true },
5329
7066
  __binaryResponse: true,
5330
7067
  });
5331
7068
  }
@@ -5344,14 +7081,17 @@ let Files$2 = class Files extends APIResource {
5344
7081
  * a JSON request with a file ID.
5345
7082
  */
5346
7083
  create(containerID, body, options) {
5347
- return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
7084
+ return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5348
7085
  }
5349
7086
  /**
5350
7087
  * Retrieve Container File
5351
7088
  */
5352
7089
  retrieve(fileID, params, options) {
5353
7090
  const { container_id } = params;
5354
- return this._client.get(path `/containers/${container_id}/files/${fileID}`, options);
7091
+ return this._client.get(path `/containers/${container_id}/files/${fileID}`, {
7092
+ ...options,
7093
+ __security: { bearerAuth: true },
7094
+ });
5355
7095
  }
5356
7096
  /**
5357
7097
  * List Container files
@@ -5360,6 +7100,7 @@ let Files$2 = class Files extends APIResource {
5360
7100
  return this._client.getAPIList(path `/containers/${containerID}/files`, (CursorPage), {
5361
7101
  query,
5362
7102
  ...options,
7103
+ __security: { bearerAuth: true },
5363
7104
  });
5364
7105
  }
5365
7106
  /**
@@ -5370,6 +7111,7 @@ let Files$2 = class Files extends APIResource {
5370
7111
  return this._client.delete(path `/containers/${container_id}/files/${fileID}`, {
5371
7112
  ...options,
5372
7113
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7114
+ __security: { bearerAuth: true },
5373
7115
  });
5374
7116
  }
5375
7117
  };
@@ -5385,19 +7127,26 @@ class Containers extends APIResource {
5385
7127
  * Create Container
5386
7128
  */
5387
7129
  create(body, options) {
5388
- return this._client.post('/containers', { body, ...options });
7130
+ return this._client.post('/containers', { body, ...options, __security: { bearerAuth: true } });
5389
7131
  }
5390
7132
  /**
5391
7133
  * Retrieve Container
5392
7134
  */
5393
7135
  retrieve(containerID, options) {
5394
- return this._client.get(path `/containers/${containerID}`, options);
7136
+ return this._client.get(path `/containers/${containerID}`, {
7137
+ ...options,
7138
+ __security: { bearerAuth: true },
7139
+ });
5395
7140
  }
5396
7141
  /**
5397
7142
  * List Containers
5398
7143
  */
5399
7144
  list(query = {}, options) {
5400
- return this._client.getAPIList('/containers', (CursorPage), { query, ...options });
7145
+ return this._client.getAPIList('/containers', (CursorPage), {
7146
+ query,
7147
+ ...options,
7148
+ __security: { bearerAuth: true },
7149
+ });
5401
7150
  }
5402
7151
  /**
5403
7152
  * Delete Container
@@ -5406,6 +7155,7 @@ class Containers extends APIResource {
5406
7155
  return this._client.delete(path `/containers/${containerID}`, {
5407
7156
  ...options,
5408
7157
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7158
+ __security: { bearerAuth: true },
5409
7159
  });
5410
7160
  }
5411
7161
  }
@@ -5425,6 +7175,7 @@ class Items extends APIResource {
5425
7175
  query: { include },
5426
7176
  body,
5427
7177
  ...options,
7178
+ __security: { bearerAuth: true },
5428
7179
  });
5429
7180
  }
5430
7181
  /**
@@ -5432,20 +7183,27 @@ class Items extends APIResource {
5432
7183
  */
5433
7184
  retrieve(itemID, params, options) {
5434
7185
  const { conversation_id, ...query } = params;
5435
- return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, { query, ...options });
7186
+ return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, {
7187
+ query,
7188
+ ...options,
7189
+ __security: { bearerAuth: true },
7190
+ });
5436
7191
  }
5437
7192
  /**
5438
7193
  * List all items for a conversation with the given ID.
5439
7194
  */
5440
7195
  list(conversationID, query = {}, options) {
5441
- return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options });
7196
+ return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options, __security: { bearerAuth: true } });
5442
7197
  }
5443
7198
  /**
5444
7199
  * Delete an item from a conversation with the given IDs.
5445
7200
  */
5446
7201
  delete(itemID, params, options) {
5447
7202
  const { conversation_id } = params;
5448
- return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, options);
7203
+ return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, {
7204
+ ...options,
7205
+ __security: { bearerAuth: true },
7206
+ });
5449
7207
  }
5450
7208
  }
5451
7209
 
@@ -5462,25 +7220,35 @@ class Conversations extends APIResource {
5462
7220
  * Create a conversation.
5463
7221
  */
5464
7222
  create(body = {}, options) {
5465
- return this._client.post('/conversations', { body, ...options });
7223
+ return this._client.post('/conversations', { body, ...options, __security: { bearerAuth: true } });
5466
7224
  }
5467
7225
  /**
5468
7226
  * Get a conversation
5469
7227
  */
5470
7228
  retrieve(conversationID, options) {
5471
- return this._client.get(path `/conversations/${conversationID}`, options);
7229
+ return this._client.get(path `/conversations/${conversationID}`, {
7230
+ ...options,
7231
+ __security: { bearerAuth: true },
7232
+ });
5472
7233
  }
5473
7234
  /**
5474
7235
  * Update a conversation
5475
7236
  */
5476
7237
  update(conversationID, body, options) {
5477
- return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
7238
+ return this._client.post(path `/conversations/${conversationID}`, {
7239
+ body,
7240
+ ...options,
7241
+ __security: { bearerAuth: true },
7242
+ });
5478
7243
  }
5479
7244
  /**
5480
7245
  * Delete a conversation. Items in the conversation will not be deleted.
5481
7246
  */
5482
7247
  delete(conversationID, options) {
5483
- return this._client.delete(path `/conversations/${conversationID}`, options);
7248
+ return this._client.delete(path `/conversations/${conversationID}`, {
7249
+ ...options,
7250
+ __security: { bearerAuth: true },
7251
+ });
5484
7252
  }
5485
7253
  }
5486
7254
  Conversations.Items = Items;
@@ -5516,6 +7284,7 @@ class Embeddings extends APIResource {
5516
7284
  encoding_format: encoding_format,
5517
7285
  },
5518
7286
  ...options,
7287
+ __security: { bearerAuth: true },
5519
7288
  });
5520
7289
  // if the user specified an encoding_format, return the response as-is
5521
7290
  if (hasUserProvidedEncodingFormat) {
@@ -5548,14 +7317,17 @@ class OutputItems extends APIResource {
5548
7317
  */
5549
7318
  retrieve(outputItemID, params, options) {
5550
7319
  const { eval_id, run_id } = params;
5551
- return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, options);
7320
+ return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, {
7321
+ ...options,
7322
+ __security: { bearerAuth: true },
7323
+ });
5552
7324
  }
5553
7325
  /**
5554
7326
  * Get a list of output items for an evaluation run.
5555
7327
  */
5556
7328
  list(runID, params, options) {
5557
7329
  const { eval_id, ...query } = params;
5558
- return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options });
7330
+ return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5559
7331
  }
5560
7332
  }
5561
7333
 
@@ -5574,14 +7346,21 @@ class Runs extends APIResource {
5574
7346
  * schema specified in the config of the evaluation.
5575
7347
  */
5576
7348
  create(evalID, body, options) {
5577
- return this._client.post(path `/evals/${evalID}/runs`, { body, ...options });
7349
+ return this._client.post(path `/evals/${evalID}/runs`, {
7350
+ body,
7351
+ ...options,
7352
+ __security: { bearerAuth: true },
7353
+ });
5578
7354
  }
5579
7355
  /**
5580
7356
  * Get an evaluation run by ID.
5581
7357
  */
5582
7358
  retrieve(runID, params, options) {
5583
7359
  const { eval_id } = params;
5584
- return this._client.get(path `/evals/${eval_id}/runs/${runID}`, options);
7360
+ return this._client.get(path `/evals/${eval_id}/runs/${runID}`, {
7361
+ ...options,
7362
+ __security: { bearerAuth: true },
7363
+ });
5585
7364
  }
5586
7365
  /**
5587
7366
  * Get a list of runs for an evaluation.
@@ -5590,6 +7369,7 @@ class Runs extends APIResource {
5590
7369
  return this._client.getAPIList(path `/evals/${evalID}/runs`, (CursorPage), {
5591
7370
  query,
5592
7371
  ...options,
7372
+ __security: { bearerAuth: true },
5593
7373
  });
5594
7374
  }
5595
7375
  /**
@@ -5597,14 +7377,20 @@ class Runs extends APIResource {
5597
7377
  */
5598
7378
  delete(runID, params, options) {
5599
7379
  const { eval_id } = params;
5600
- return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, options);
7380
+ return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, {
7381
+ ...options,
7382
+ __security: { bearerAuth: true },
7383
+ });
5601
7384
  }
5602
7385
  /**
5603
7386
  * Cancel an ongoing evaluation run.
5604
7387
  */
5605
7388
  cancel(runID, params, options) {
5606
7389
  const { eval_id } = params;
5607
- return this._client.post(path `/evals/${eval_id}/runs/${runID}`, options);
7390
+ return this._client.post(path `/evals/${eval_id}/runs/${runID}`, {
7391
+ ...options,
7392
+ __security: { bearerAuth: true },
7393
+ });
5608
7394
  }
5609
7395
  }
5610
7396
  Runs.OutputItems = OutputItems;
@@ -5627,31 +7413,35 @@ class Evals extends APIResource {
5627
7413
  * the [Evals guide](https://platform.openai.com/docs/guides/evals).
5628
7414
  */
5629
7415
  create(body, options) {
5630
- return this._client.post('/evals', { body, ...options });
7416
+ return this._client.post('/evals', { body, ...options, __security: { bearerAuth: true } });
5631
7417
  }
5632
7418
  /**
5633
7419
  * Get an evaluation by ID.
5634
7420
  */
5635
7421
  retrieve(evalID, options) {
5636
- return this._client.get(path `/evals/${evalID}`, options);
7422
+ return this._client.get(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
5637
7423
  }
5638
7424
  /**
5639
7425
  * Update certain properties of an evaluation.
5640
7426
  */
5641
7427
  update(evalID, body, options) {
5642
- return this._client.post(path `/evals/${evalID}`, { body, ...options });
7428
+ return this._client.post(path `/evals/${evalID}`, { body, ...options, __security: { bearerAuth: true } });
5643
7429
  }
5644
7430
  /**
5645
7431
  * List evaluations for a project.
5646
7432
  */
5647
7433
  list(query = {}, options) {
5648
- return this._client.getAPIList('/evals', (CursorPage), { query, ...options });
7434
+ return this._client.getAPIList('/evals', (CursorPage), {
7435
+ query,
7436
+ ...options,
7437
+ __security: { bearerAuth: true },
7438
+ });
5649
7439
  }
5650
7440
  /**
5651
7441
  * Delete an evaluation.
5652
7442
  */
5653
7443
  delete(evalID, options) {
5654
- return this._client.delete(path `/evals/${evalID}`, options);
7444
+ return this._client.delete(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
5655
7445
  }
5656
7446
  }
5657
7447
  Evals.Runs = Runs;
@@ -5664,7 +7454,8 @@ let Files$1 = class Files extends APIResource {
5664
7454
  /**
5665
7455
  * Upload a file that can be used across various endpoints. Individual files can be
5666
7456
  * up to 512 MB, and each project can store up to 2.5 TB of files in total. There
5667
- * is no organization-wide storage limit.
7457
+ * is no organization-wide storage limit. Uploads to this endpoint are rate-limited
7458
+ * to 1,000 requests per minute per authenticated user.
5668
7459
  *
5669
7460
  * - The Assistants API supports files up to 2 million tokens and of specific file
5670
7461
  * types. See the
@@ -5679,30 +7470,40 @@ let Files$1 = class Files extends APIResource {
5679
7470
  * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
5680
7471
  * also has a specific required
5681
7472
  * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
7473
+ * - For Retrieval or `file_search` ingestion, upload files here first. If you need
7474
+ * to attach multiple uploaded files to the same vector store, use
7475
+ * [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch)
7476
+ * instead of attaching them one by one. Vector store attachment has separate
7477
+ * limits from file upload, including 2,000 attached files per minute per
7478
+ * organization.
5682
7479
  *
5683
7480
  * Please [contact us](https://help.openai.com/) if you need to increase these
5684
7481
  * storage limits.
5685
7482
  */
5686
7483
  create(body, options) {
5687
- return this._client.post('/files', multipartFormRequestOptions({ body, ...options }, this._client));
7484
+ return this._client.post('/files', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5688
7485
  }
5689
7486
  /**
5690
7487
  * Returns information about a specific file.
5691
7488
  */
5692
7489
  retrieve(fileID, options) {
5693
- return this._client.get(path `/files/${fileID}`, options);
7490
+ return this._client.get(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
5694
7491
  }
5695
7492
  /**
5696
7493
  * Returns a list of files.
5697
7494
  */
5698
7495
  list(query = {}, options) {
5699
- return this._client.getAPIList('/files', (CursorPage), { query, ...options });
7496
+ return this._client.getAPIList('/files', (CursorPage), {
7497
+ query,
7498
+ ...options,
7499
+ __security: { bearerAuth: true },
7500
+ });
5700
7501
  }
5701
7502
  /**
5702
7503
  * Delete a file and remove it from all vector stores.
5703
7504
  */
5704
7505
  delete(fileID, options) {
5705
- return this._client.delete(path `/files/${fileID}`, options);
7506
+ return this._client.delete(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
5706
7507
  }
5707
7508
  /**
5708
7509
  * Returns the contents of the specified file.
@@ -5711,6 +7512,7 @@ let Files$1 = class Files extends APIResource {
5711
7512
  return this._client.get(path `/files/${fileID}/content`, {
5712
7513
  ...options,
5713
7514
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
7515
+ __security: { bearerAuth: true },
5714
7516
  __binaryResponse: true,
5715
7517
  });
5716
7518
  }
@@ -5761,7 +7563,11 @@ let Graders$1 = class Graders extends APIResource {
5761
7563
  * ```
5762
7564
  */
5763
7565
  run(body, options) {
5764
- return this._client.post('/fine_tuning/alpha/graders/run', { body, ...options });
7566
+ return this._client.post('/fine_tuning/alpha/graders/run', {
7567
+ body,
7568
+ ...options,
7569
+ __security: { bearerAuth: true },
7570
+ });
5765
7571
  }
5766
7572
  /**
5767
7573
  * Validate a grader.
@@ -5781,7 +7587,11 @@ let Graders$1 = class Graders extends APIResource {
5781
7587
  * ```
5782
7588
  */
5783
7589
  validate(body, options) {
5784
- return this._client.post('/fine_tuning/alpha/graders/validate', { body, ...options });
7590
+ return this._client.post('/fine_tuning/alpha/graders/validate', {
7591
+ body,
7592
+ ...options,
7593
+ __security: { bearerAuth: true },
7594
+ });
5785
7595
  }
5786
7596
  };
5787
7597
 
@@ -5817,7 +7627,7 @@ class Permissions extends APIResource {
5817
7627
  * ```
5818
7628
  */
5819
7629
  create(fineTunedModelCheckpoint, body, options) {
5820
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options });
7630
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
5821
7631
  }
5822
7632
  /**
5823
7633
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -5831,6 +7641,7 @@ class Permissions extends APIResource {
5831
7641
  return this._client.get(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
5832
7642
  query,
5833
7643
  ...options,
7644
+ __security: { adminAPIKeyAuth: true },
5834
7645
  });
5835
7646
  }
5836
7647
  /**
@@ -5850,7 +7661,7 @@ class Permissions extends APIResource {
5850
7661
  * ```
5851
7662
  */
5852
7663
  list(fineTunedModelCheckpoint, query = {}, options) {
5853
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options });
7664
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5854
7665
  }
5855
7666
  /**
5856
7667
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -5872,7 +7683,7 @@ class Permissions extends APIResource {
5872
7683
  */
5873
7684
  delete(permissionID, params, options) {
5874
7685
  const { fine_tuned_model_checkpoint } = params;
5875
- return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, options);
7686
+ return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, { ...options, __security: { adminAPIKeyAuth: true } });
5876
7687
  }
5877
7688
  }
5878
7689
 
@@ -5904,7 +7715,7 @@ class Checkpoints extends APIResource {
5904
7715
  * ```
5905
7716
  */
5906
7717
  list(fineTuningJobID, query = {}, options) {
5907
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options });
7718
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5908
7719
  }
5909
7720
  }
5910
7721
 
@@ -5935,7 +7746,7 @@ class Jobs extends APIResource {
5935
7746
  * ```
5936
7747
  */
5937
7748
  create(body, options) {
5938
- return this._client.post('/fine_tuning/jobs', { body, ...options });
7749
+ return this._client.post('/fine_tuning/jobs', { body, ...options, __security: { bearerAuth: true } });
5939
7750
  }
5940
7751
  /**
5941
7752
  * Get info about a fine-tuning job.
@@ -5950,7 +7761,10 @@ class Jobs extends APIResource {
5950
7761
  * ```
5951
7762
  */
5952
7763
  retrieve(fineTuningJobID, options) {
5953
- return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, options);
7764
+ return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, {
7765
+ ...options,
7766
+ __security: { bearerAuth: true },
7767
+ });
5954
7768
  }
5955
7769
  /**
5956
7770
  * List your organization's fine-tuning jobs
@@ -5964,7 +7778,11 @@ class Jobs extends APIResource {
5964
7778
  * ```
5965
7779
  */
5966
7780
  list(query = {}, options) {
5967
- return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), { query, ...options });
7781
+ return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), {
7782
+ query,
7783
+ ...options,
7784
+ __security: { bearerAuth: true },
7785
+ });
5968
7786
  }
5969
7787
  /**
5970
7788
  * Immediately cancel a fine-tune job.
@@ -5977,7 +7795,10 @@ class Jobs extends APIResource {
5977
7795
  * ```
5978
7796
  */
5979
7797
  cancel(fineTuningJobID, options) {
5980
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, options);
7798
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, {
7799
+ ...options,
7800
+ __security: { bearerAuth: true },
7801
+ });
5981
7802
  }
5982
7803
  /**
5983
7804
  * Get status updates for a fine-tuning job.
@@ -5993,7 +7814,7 @@ class Jobs extends APIResource {
5993
7814
  * ```
5994
7815
  */
5995
7816
  listEvents(fineTuningJobID, query = {}, options) {
5996
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options });
7817
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
5997
7818
  }
5998
7819
  /**
5999
7820
  * Pause a fine-tune job.
@@ -6006,7 +7827,10 @@ class Jobs extends APIResource {
6006
7827
  * ```
6007
7828
  */
6008
7829
  pause(fineTuningJobID, options) {
6009
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, options);
7830
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, {
7831
+ ...options,
7832
+ __security: { bearerAuth: true },
7833
+ });
6010
7834
  }
6011
7835
  /**
6012
7836
  * Resume a fine-tune job.
@@ -6019,7 +7843,10 @@ class Jobs extends APIResource {
6019
7843
  * ```
6020
7844
  */
6021
7845
  resume(fineTuningJobID, options) {
6022
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, options);
7846
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, {
7847
+ ...options,
7848
+ __security: { bearerAuth: true },
7849
+ });
6023
7850
  }
6024
7851
  }
6025
7852
  Jobs.Checkpoints = Checkpoints;
@@ -6068,13 +7895,18 @@ class Images extends APIResource {
6068
7895
  * ```
6069
7896
  */
6070
7897
  createVariation(body, options) {
6071
- return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options }, this._client));
7898
+ return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6072
7899
  }
6073
7900
  edit(body, options) {
6074
- return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false }, this._client));
7901
+ return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false, __security: { bearerAuth: true } }, this._client));
6075
7902
  }
6076
7903
  generate(body, options) {
6077
- return this._client.post('/images/generations', { body, ...options, stream: body.stream ?? false });
7904
+ return this._client.post('/images/generations', {
7905
+ body,
7906
+ ...options,
7907
+ stream: body.stream ?? false,
7908
+ __security: { bearerAuth: true },
7909
+ });
6078
7910
  }
6079
7911
  }
6080
7912
 
@@ -6088,21 +7920,21 @@ class Models extends APIResource {
6088
7920
  * the owner and permissioning.
6089
7921
  */
6090
7922
  retrieve(model, options) {
6091
- return this._client.get(path `/models/${model}`, options);
7923
+ return this._client.get(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
6092
7924
  }
6093
7925
  /**
6094
7926
  * Lists the currently available models, and provides basic information about each
6095
7927
  * one such as the owner and availability.
6096
7928
  */
6097
7929
  list(options) {
6098
- return this._client.getAPIList('/models', (Page), options);
7930
+ return this._client.getAPIList('/models', (Page), { ...options, __security: { bearerAuth: true } });
6099
7931
  }
6100
7932
  /**
6101
7933
  * Delete a fine-tuned model. You must have the Owner role in your organization to
6102
7934
  * delete a model.
6103
7935
  */
6104
7936
  delete(model, options) {
6105
- return this._client.delete(path `/models/${model}`, options);
7937
+ return this._client.delete(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
6106
7938
  }
6107
7939
  }
6108
7940
 
@@ -6116,7 +7948,7 @@ class Moderations extends APIResource {
6116
7948
  * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
6117
7949
  */
6118
7950
  create(body, options) {
6119
- return this._client.post('/moderations', { body, ...options });
7951
+ return this._client.post('/moderations', { body, ...options, __security: { bearerAuth: true } });
6120
7952
  }
6121
7953
  }
6122
7954
 
@@ -6138,6 +7970,7 @@ class Calls extends APIResource {
6138
7970
  body,
6139
7971
  ...options,
6140
7972
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7973
+ __security: { bearerAuth: true },
6141
7974
  });
6142
7975
  }
6143
7976
  /**
@@ -6152,6 +7985,7 @@ class Calls extends APIResource {
6152
7985
  return this._client.post(path `/realtime/calls/${callID}/hangup`, {
6153
7986
  ...options,
6154
7987
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
7988
+ __security: { bearerAuth: true },
6155
7989
  });
6156
7990
  }
6157
7991
  /**
@@ -6169,6 +8003,7 @@ class Calls extends APIResource {
6169
8003
  body,
6170
8004
  ...options,
6171
8005
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8006
+ __security: { bearerAuth: true },
6172
8007
  });
6173
8008
  }
6174
8009
  /**
@@ -6184,6 +8019,7 @@ class Calls extends APIResource {
6184
8019
  body,
6185
8020
  ...options,
6186
8021
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8022
+ __security: { bearerAuth: true },
6187
8023
  });
6188
8024
  }
6189
8025
  }
@@ -6214,7 +8050,11 @@ class ClientSecrets extends APIResource {
6214
8050
  * ```
6215
8051
  */
6216
8052
  create(body, options) {
6217
- return this._client.post('/realtime/client_secrets', { body, ...options });
8053
+ return this._client.post('/realtime/client_secrets', {
8054
+ body,
8055
+ ...options,
8056
+ __security: { bearerAuth: true },
8057
+ });
6218
8058
  }
6219
8059
  }
6220
8060
 
@@ -6625,7 +8465,7 @@ class InputItems extends APIResource {
6625
8465
  * ```
6626
8466
  */
6627
8467
  list(responseID, query = {}, options) {
6628
- return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options });
8468
+ return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
6629
8469
  }
6630
8470
  }
6631
8471
 
@@ -6643,7 +8483,11 @@ class InputTokens extends APIResource {
6643
8483
  * ```
6644
8484
  */
6645
8485
  count(body = {}, options) {
6646
- return this._client.post('/responses/input_tokens', { body, ...options });
8486
+ return this._client.post('/responses/input_tokens', {
8487
+ body,
8488
+ ...options,
8489
+ __security: { bearerAuth: true },
8490
+ });
6647
8491
  }
6648
8492
  }
6649
8493
 
@@ -6655,7 +8499,12 @@ class Responses extends APIResource {
6655
8499
  this.inputTokens = new InputTokens(this._client);
6656
8500
  }
6657
8501
  create(body, options) {
6658
- return this._client.post('/responses', { body, ...options, stream: body.stream ?? false })._thenUnwrap((rsp) => {
8502
+ return this._client.post('/responses', {
8503
+ body,
8504
+ ...options,
8505
+ stream: body.stream ?? false,
8506
+ __security: { bearerAuth: true },
8507
+ })._thenUnwrap((rsp) => {
6659
8508
  if ('object' in rsp && rsp.object === 'response') {
6660
8509
  addOutputText(rsp);
6661
8510
  }
@@ -6667,6 +8516,7 @@ class Responses extends APIResource {
6667
8516
  query,
6668
8517
  ...options,
6669
8518
  stream: query?.stream ?? false,
8519
+ __security: { bearerAuth: true },
6670
8520
  })._thenUnwrap((rsp) => {
6671
8521
  if ('object' in rsp && rsp.object === 'response') {
6672
8522
  addOutputText(rsp);
@@ -6688,6 +8538,7 @@ class Responses extends APIResource {
6688
8538
  return this._client.delete(path `/responses/${responseID}`, {
6689
8539
  ...options,
6690
8540
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8541
+ __security: { bearerAuth: true },
6691
8542
  });
6692
8543
  }
6693
8544
  parse(body, options) {
@@ -6714,7 +8565,10 @@ class Responses extends APIResource {
6714
8565
  * ```
6715
8566
  */
6716
8567
  cancel(responseID, options) {
6717
- return this._client.post(path `/responses/${responseID}/cancel`, options);
8568
+ return this._client.post(path `/responses/${responseID}/cancel`, {
8569
+ ...options,
8570
+ __security: { bearerAuth: true },
8571
+ });
6718
8572
  }
6719
8573
  /**
6720
8574
  * Compact a conversation. Returns a compacted response object.
@@ -6732,7 +8586,7 @@ class Responses extends APIResource {
6732
8586
  * ```
6733
8587
  */
6734
8588
  compact(body, options) {
6735
- return this._client.post('/responses/compact', { body, ...options });
8589
+ return this._client.post('/responses/compact', { body, ...options, __security: { bearerAuth: true } });
6736
8590
  }
6737
8591
  }
6738
8592
  Responses.InputItems = InputItems;
@@ -6747,6 +8601,7 @@ let Content$1 = class Content extends APIResource {
6747
8601
  return this._client.get(path `/skills/${skillID}/content`, {
6748
8602
  ...options,
6749
8603
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8604
+ __security: { bearerAuth: true },
6750
8605
  __binaryResponse: true,
6751
8606
  });
6752
8607
  }
@@ -6762,6 +8617,7 @@ class Content extends APIResource {
6762
8617
  return this._client.get(path `/skills/${skill_id}/versions/${version}/content`, {
6763
8618
  ...options,
6764
8619
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8620
+ __security: { bearerAuth: true },
6765
8621
  __binaryResponse: true,
6766
8622
  });
6767
8623
  }
@@ -6777,14 +8633,17 @@ class Versions extends APIResource {
6777
8633
  * Create a new immutable skill version.
6778
8634
  */
6779
8635
  create(skillID, body = {}, options) {
6780
- return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8636
+ return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6781
8637
  }
6782
8638
  /**
6783
8639
  * Get a specific skill version.
6784
8640
  */
6785
8641
  retrieve(version, params, options) {
6786
8642
  const { skill_id } = params;
6787
- return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
8643
+ return this._client.get(path `/skills/${skill_id}/versions/${version}`, {
8644
+ ...options,
8645
+ __security: { bearerAuth: true },
8646
+ });
6788
8647
  }
6789
8648
  /**
6790
8649
  * List skill versions for a skill.
@@ -6793,6 +8652,7 @@ class Versions extends APIResource {
6793
8652
  return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
6794
8653
  query,
6795
8654
  ...options,
8655
+ __security: { bearerAuth: true },
6796
8656
  });
6797
8657
  }
6798
8658
  /**
@@ -6800,7 +8660,10 @@ class Versions extends APIResource {
6800
8660
  */
6801
8661
  delete(version, params, options) {
6802
8662
  const { skill_id } = params;
6803
- return this._client.delete(path `/skills/${skill_id}/versions/${version}`, options);
8663
+ return this._client.delete(path `/skills/${skill_id}/versions/${version}`, {
8664
+ ...options,
8665
+ __security: { bearerAuth: true },
8666
+ });
6804
8667
  }
6805
8668
  }
6806
8669
  Versions.Content = Content;
@@ -6816,31 +8679,39 @@ class Skills extends APIResource {
6816
8679
  * Create a new skill.
6817
8680
  */
6818
8681
  create(body = {}, options) {
6819
- return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8682
+ return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6820
8683
  }
6821
8684
  /**
6822
8685
  * Get a skill by its ID.
6823
8686
  */
6824
8687
  retrieve(skillID, options) {
6825
- return this._client.get(path `/skills/${skillID}`, options);
8688
+ return this._client.get(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
6826
8689
  }
6827
8690
  /**
6828
8691
  * Update the default version pointer for a skill.
6829
8692
  */
6830
8693
  update(skillID, body, options) {
6831
- return this._client.post(path `/skills/${skillID}`, { body, ...options });
8694
+ return this._client.post(path `/skills/${skillID}`, {
8695
+ body,
8696
+ ...options,
8697
+ __security: { bearerAuth: true },
8698
+ });
6832
8699
  }
6833
8700
  /**
6834
8701
  * List all skills for the current project.
6835
8702
  */
6836
8703
  list(query = {}, options) {
6837
- return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
8704
+ return this._client.getAPIList('/skills', (CursorPage), {
8705
+ query,
8706
+ ...options,
8707
+ __security: { bearerAuth: true },
8708
+ });
6838
8709
  }
6839
8710
  /**
6840
8711
  * Delete a skill by its ID.
6841
8712
  */
6842
8713
  delete(skillID, options) {
6843
- return this._client.delete(path `/skills/${skillID}`, options);
8714
+ return this._client.delete(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
6844
8715
  }
6845
8716
  }
6846
8717
  Skills.Content = Content$1;
@@ -6865,7 +8736,7 @@ class Parts extends APIResource {
6865
8736
  * [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
6866
8737
  */
6867
8738
  create(uploadID, body, options) {
6868
- return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options }, this._client));
8739
+ return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6869
8740
  }
6870
8741
  }
6871
8742
 
@@ -6902,7 +8773,7 @@ class Uploads extends APIResource {
6902
8773
  * Returns the Upload object with status `pending`.
6903
8774
  */
6904
8775
  create(body, options) {
6905
- return this._client.post('/uploads', { body, ...options });
8776
+ return this._client.post('/uploads', { body, ...options, __security: { bearerAuth: true } });
6906
8777
  }
6907
8778
  /**
6908
8779
  * Cancels the Upload. No Parts may be added after an Upload is cancelled.
@@ -6910,7 +8781,10 @@ class Uploads extends APIResource {
6910
8781
  * Returns the Upload object with status `cancelled`.
6911
8782
  */
6912
8783
  cancel(uploadID, options) {
6913
- return this._client.post(path `/uploads/${uploadID}/cancel`, options);
8784
+ return this._client.post(path `/uploads/${uploadID}/cancel`, {
8785
+ ...options,
8786
+ __security: { bearerAuth: true },
8787
+ });
6914
8788
  }
6915
8789
  /**
6916
8790
  * Completes the
@@ -6930,7 +8804,11 @@ class Uploads extends APIResource {
6930
8804
  * object.
6931
8805
  */
6932
8806
  complete(uploadID, body, options) {
6933
- return this._client.post(path `/uploads/${uploadID}/complete`, { body, ...options });
8807
+ return this._client.post(path `/uploads/${uploadID}/complete`, {
8808
+ body,
8809
+ ...options,
8810
+ __security: { bearerAuth: true },
8811
+ });
6934
8812
  }
6935
8813
  }
6936
8814
  Uploads.Parts = Parts;
@@ -6967,6 +8845,7 @@ class FileBatches extends APIResource {
6967
8845
  body,
6968
8846
  ...options,
6969
8847
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8848
+ __security: { bearerAuth: true },
6970
8849
  });
6971
8850
  }
6972
8851
  /**
@@ -6977,6 +8856,7 @@ class FileBatches extends APIResource {
6977
8856
  return this._client.get(path `/vector_stores/${vector_store_id}/file_batches/${batchID}`, {
6978
8857
  ...options,
6979
8858
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8859
+ __security: { bearerAuth: true },
6980
8860
  });
6981
8861
  }
6982
8862
  /**
@@ -6988,6 +8868,7 @@ class FileBatches extends APIResource {
6988
8868
  return this._client.post(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/cancel`, {
6989
8869
  ...options,
6990
8870
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8871
+ __security: { bearerAuth: true },
6991
8872
  });
6992
8873
  }
6993
8874
  /**
@@ -7002,7 +8883,12 @@ class FileBatches extends APIResource {
7002
8883
  */
7003
8884
  listFiles(batchID, params, options) {
7004
8885
  const { vector_store_id, ...query } = params;
7005
- 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]) });
8886
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, (CursorPage), {
8887
+ query,
8888
+ ...options,
8889
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8890
+ __security: { bearerAuth: true },
8891
+ });
7006
8892
  }
7007
8893
  /**
7008
8894
  * Wait for the given file batch to be processed.
@@ -7092,6 +8978,7 @@ class Files extends APIResource {
7092
8978
  body,
7093
8979
  ...options,
7094
8980
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8981
+ __security: { bearerAuth: true },
7095
8982
  });
7096
8983
  }
7097
8984
  /**
@@ -7102,6 +8989,7 @@ class Files extends APIResource {
7102
8989
  return this._client.get(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
7103
8990
  ...options,
7104
8991
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8992
+ __security: { bearerAuth: true },
7105
8993
  });
7106
8994
  }
7107
8995
  /**
@@ -7113,6 +9001,7 @@ class Files extends APIResource {
7113
9001
  body,
7114
9002
  ...options,
7115
9003
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9004
+ __security: { bearerAuth: true },
7116
9005
  });
7117
9006
  }
7118
9007
  /**
@@ -7123,6 +9012,7 @@ class Files extends APIResource {
7123
9012
  query,
7124
9013
  ...options,
7125
9014
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9015
+ __security: { bearerAuth: true },
7126
9016
  });
7127
9017
  }
7128
9018
  /**
@@ -7136,6 +9026,7 @@ class Files extends APIResource {
7136
9026
  return this._client.delete(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
7137
9027
  ...options,
7138
9028
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9029
+ __security: { bearerAuth: true },
7139
9030
  });
7140
9031
  }
7141
9032
  /**
@@ -7209,7 +9100,11 @@ class Files extends APIResource {
7209
9100
  */
7210
9101
  content(fileID, params, options) {
7211
9102
  const { vector_store_id } = params;
7212
- return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), { ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]) });
9103
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), {
9104
+ ...options,
9105
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9106
+ __security: { bearerAuth: true },
9107
+ });
7213
9108
  }
7214
9109
  }
7215
9110
 
@@ -7228,6 +9123,7 @@ class VectorStores extends APIResource {
7228
9123
  body,
7229
9124
  ...options,
7230
9125
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9126
+ __security: { bearerAuth: true },
7231
9127
  });
7232
9128
  }
7233
9129
  /**
@@ -7237,6 +9133,7 @@ class VectorStores extends APIResource {
7237
9133
  return this._client.get(path `/vector_stores/${vectorStoreID}`, {
7238
9134
  ...options,
7239
9135
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9136
+ __security: { bearerAuth: true },
7240
9137
  });
7241
9138
  }
7242
9139
  /**
@@ -7247,6 +9144,7 @@ class VectorStores extends APIResource {
7247
9144
  body,
7248
9145
  ...options,
7249
9146
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9147
+ __security: { bearerAuth: true },
7250
9148
  });
7251
9149
  }
7252
9150
  /**
@@ -7257,6 +9155,7 @@ class VectorStores extends APIResource {
7257
9155
  query,
7258
9156
  ...options,
7259
9157
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9158
+ __security: { bearerAuth: true },
7260
9159
  });
7261
9160
  }
7262
9161
  /**
@@ -7266,6 +9165,7 @@ class VectorStores extends APIResource {
7266
9165
  return this._client.delete(path `/vector_stores/${vectorStoreID}`, {
7267
9166
  ...options,
7268
9167
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9168
+ __security: { bearerAuth: true },
7269
9169
  });
7270
9170
  }
7271
9171
  /**
@@ -7278,6 +9178,7 @@ class VectorStores extends APIResource {
7278
9178
  method: 'post',
7279
9179
  ...options,
7280
9180
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9181
+ __security: { bearerAuth: true },
7281
9182
  });
7282
9183
  }
7283
9184
  }
@@ -7290,31 +9191,35 @@ class Videos extends APIResource {
7290
9191
  * Create a new video generation job from a prompt and optional reference assets.
7291
9192
  */
7292
9193
  create(body, options) {
7293
- return this._client.post('/videos', multipartFormRequestOptions({ body, ...options }, this._client));
9194
+ return this._client.post('/videos', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7294
9195
  }
7295
9196
  /**
7296
9197
  * Fetch the latest metadata for a generated video.
7297
9198
  */
7298
9199
  retrieve(videoID, options) {
7299
- return this._client.get(path `/videos/${videoID}`, options);
9200
+ return this._client.get(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
7300
9201
  }
7301
9202
  /**
7302
9203
  * List recently generated videos for the current project.
7303
9204
  */
7304
9205
  list(query = {}, options) {
7305
- return this._client.getAPIList('/videos', (ConversationCursorPage), { query, ...options });
9206
+ return this._client.getAPIList('/videos', (ConversationCursorPage), {
9207
+ query,
9208
+ ...options,
9209
+ __security: { bearerAuth: true },
9210
+ });
7306
9211
  }
7307
9212
  /**
7308
9213
  * Permanently delete a completed or failed video and its stored assets.
7309
9214
  */
7310
9215
  delete(videoID, options) {
7311
- return this._client.delete(path `/videos/${videoID}`, options);
9216
+ return this._client.delete(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
7312
9217
  }
7313
9218
  /**
7314
9219
  * Create a character from an uploaded video.
7315
9220
  */
7316
9221
  createCharacter(body, options) {
7317
- return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options }, this._client));
9222
+ return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7318
9223
  }
7319
9224
  /**
7320
9225
  * Download the generated video bytes or a derived preview asset.
@@ -7326,6 +9231,7 @@ class Videos extends APIResource {
7326
9231
  query,
7327
9232
  ...options,
7328
9233
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
9234
+ __security: { bearerAuth: true },
7329
9235
  __binaryResponse: true,
7330
9236
  });
7331
9237
  }
@@ -7334,25 +9240,28 @@ class Videos extends APIResource {
7334
9240
  * generated video.
7335
9241
  */
7336
9242
  edit(body, options) {
7337
- return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options }, this._client));
9243
+ return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7338
9244
  }
7339
9245
  /**
7340
9246
  * Create an extension of a completed video.
7341
9247
  */
7342
9248
  extend(body, options) {
7343
- return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
9249
+ return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7344
9250
  }
7345
9251
  /**
7346
9252
  * Fetch a character.
7347
9253
  */
7348
9254
  getCharacter(characterID, options) {
7349
- return this._client.get(path `/videos/characters/${characterID}`, options);
9255
+ return this._client.get(path `/videos/characters/${characterID}`, {
9256
+ ...options,
9257
+ __security: { bearerAuth: true },
9258
+ });
7350
9259
  }
7351
9260
  /**
7352
9261
  * Create a remix of a completed video using a refreshed prompt.
7353
9262
  */
7354
9263
  remix(videoID, body, options) {
7355
- return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
9264
+ return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7356
9265
  }
7357
9266
  }
7358
9267
 
@@ -7459,7 +9368,8 @@ class OpenAI {
7459
9368
  /**
7460
9369
  * API Client for interfacing with the OpenAI API.
7461
9370
  *
7462
- * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
9371
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? null]
9372
+ * @param {string | null | undefined} [opts.adminAPIKey=process.env['OPENAI_ADMIN_KEY'] ?? null]
7463
9373
  * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
7464
9374
  * @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
7465
9375
  * @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
@@ -7472,7 +9382,7 @@ class OpenAI {
7472
9382
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
7473
9383
  * @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.
7474
9384
  */
7475
- 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 } = {}) {
9385
+ 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 } = {}) {
7476
9386
  _OpenAI_instances.add(this);
7477
9387
  _OpenAI_encoder.set(this, void 0);
7478
9388
  /**
@@ -7514,6 +9424,7 @@ class OpenAI {
7514
9424
  * Use Uploads to upload large files in multiple parts.
7515
9425
  */
7516
9426
  this.uploads = new Uploads(this);
9427
+ this.admin = new Admin(this);
7517
9428
  this.responses = new Responses(this);
7518
9429
  this.realtime = new Realtime(this);
7519
9430
  /**
@@ -7527,17 +9438,9 @@ class OpenAI {
7527
9438
  this.containers = new Containers(this);
7528
9439
  this.skills = new Skills(this);
7529
9440
  this.videos = new Videos(this);
7530
- if (workloadIdentity) {
7531
- if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
7532
- throw new OpenAIError('The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.');
7533
- }
7534
- apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
7535
- }
7536
- else if (apiKey === undefined) {
7537
- throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.');
7538
- }
7539
9441
  const options = {
7540
9442
  apiKey,
9443
+ adminAPIKey,
7541
9444
  organization,
7542
9445
  project,
7543
9446
  webhookSecret,
@@ -7545,6 +9448,12 @@ class OpenAI {
7545
9448
  ...opts,
7546
9449
  baseURL: baseURL || `https://api.openai.com/v1`,
7547
9450
  };
9451
+ if (apiKey && workloadIdentity) {
9452
+ throw new OpenAIError('The `apiKey` and `workloadIdentity` options are mutually exclusive');
9453
+ }
9454
+ if (!apiKey && !adminAPIKey && !workloadIdentity) {
9455
+ throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.');
9456
+ }
7548
9457
  if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
7549
9458
  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");
7550
9459
  }
@@ -7562,11 +9471,23 @@ class OpenAI {
7562
9471
  this.maxRetries = options.maxRetries ?? 2;
7563
9472
  this.fetch = options.fetch ?? getDefaultFetch();
7564
9473
  __classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
9474
+ const customHeadersEnv = readEnv('OPENAI_CUSTOM_HEADERS');
9475
+ if (customHeadersEnv) {
9476
+ const parsed = {};
9477
+ for (const line of customHeadersEnv.split('\n')) {
9478
+ const colon = line.indexOf(':');
9479
+ if (colon >= 0) {
9480
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
9481
+ }
9482
+ }
9483
+ options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
9484
+ }
7565
9485
  this._options = options;
7566
9486
  if (workloadIdentity) {
7567
9487
  this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
7568
9488
  }
7569
- this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
9489
+ this.apiKey = typeof apiKey === 'string' ? apiKey : null;
9490
+ this.adminAPIKey = adminAPIKey;
7570
9491
  this.organization = organization;
7571
9492
  this.project = project;
7572
9493
  this.webhookSecret = webhookSecret;
@@ -7584,7 +9505,8 @@ class OpenAI {
7584
9505
  logLevel: this.logLevel,
7585
9506
  fetch: this.fetch,
7586
9507
  fetchOptions: this.fetchOptions,
7587
- apiKey: this.apiKey,
9508
+ apiKey: this._options.apiKey,
9509
+ adminAPIKey: this.adminAPIKey,
7588
9510
  workloadIdentity: this._options.workloadIdentity,
7589
9511
  organization: this.organization,
7590
9512
  project: this.project,
@@ -7596,12 +9518,45 @@ class OpenAI {
7596
9518
  defaultQuery() {
7597
9519
  return this._options.defaultQuery;
7598
9520
  }
7599
- validateHeaders({ values, nulls }) {
7600
- return;
9521
+ validateHeaders({ values, nulls }, schemes = {
9522
+ bearerAuth: true,
9523
+ adminAPIKeyAuth: true,
9524
+ }) {
9525
+ if (values.get('authorization') || values.get('api-key')) {
9526
+ return;
9527
+ }
9528
+ if (nulls.has('authorization') || nulls.has('api-key')) {
9529
+ return;
9530
+ }
9531
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
9532
+ return;
9533
+ }
9534
+ 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');
9535
+ }
9536
+ async authHeaders(opts, schemes = {
9537
+ bearerAuth: true,
9538
+ adminAPIKeyAuth: true,
9539
+ }) {
9540
+ return buildHeaders([
9541
+ schemes.bearerAuth ? await this.bearerAuth(opts) : null,
9542
+ schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null,
9543
+ ]);
7601
9544
  }
7602
- async authHeaders(opts) {
9545
+ async bearerAuth(opts) {
9546
+ if (this._workloadIdentityAuth) {
9547
+ return buildHeaders([{ Authorization: `Bearer ${await this._workloadIdentityAuth.getToken()}` }]);
9548
+ }
9549
+ if (this.apiKey == null) {
9550
+ return undefined;
9551
+ }
7603
9552
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
7604
9553
  }
9554
+ async adminAPIKeyAuth(opts) {
9555
+ if (this.adminAPIKey == null) {
9556
+ return undefined;
9557
+ }
9558
+ return buildHeaders([{ Authorization: `Bearer ${this.adminAPIKey}` }]);
9559
+ }
7605
9560
  stringifyQuery(query) {
7606
9561
  return stringifyQuery(query);
7607
9562
  }
@@ -7654,7 +9609,10 @@ class OpenAI {
7654
9609
  * Used as a callback for mutating the given `FinalRequestOptions` object.
7655
9610
  */
7656
9611
  async prepareOptions(options) {
7657
- await this._callApiKey();
9612
+ const security = options.__security ?? { bearerAuth: true };
9613
+ if (security.bearerAuth) {
9614
+ await this._callApiKey();
9615
+ }
7658
9616
  }
7659
9617
  /**
7660
9618
  * Used as a callback for mutating the given `RequestInit` object.
@@ -7711,8 +9669,9 @@ class OpenAI {
7711
9669
  if (options.signal?.aborted) {
7712
9670
  throw new APIUserAbortError();
7713
9671
  }
9672
+ const security = options.__security ?? { bearerAuth: true };
7714
9673
  const controller = new AbortController();
7715
- const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
9674
+ const response = await this.fetchWithAuth(url, req, timeout, controller, security).catch(castToError);
7716
9675
  const headersTime = Date.now();
7717
9676
  if (response instanceof globalThis.Error) {
7718
9677
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -7758,6 +9717,7 @@ class OpenAI {
7758
9717
  if (!response.ok) {
7759
9718
  if (response.status === 401 &&
7760
9719
  this._workloadIdentityAuth &&
9720
+ security.bearerAuth &&
7761
9721
  !options.__metadata?.['hasStreamingBody'] &&
7762
9722
  !options.__metadata?.['workloadIdentityTokenRefreshed']) {
7763
9723
  await CancelReadableStream(response.body);
@@ -7820,8 +9780,11 @@ class OpenAI {
7820
9780
  const request = this.makeRequest(options, null, undefined);
7821
9781
  return new PagePromise(this, request, Page);
7822
9782
  }
7823
- async fetchWithAuth(url, init, timeout, controller) {
7824
- if (this._workloadIdentityAuth) {
9783
+ async fetchWithAuth(url, init, timeout, controller, schemes = {
9784
+ bearerAuth: true,
9785
+ adminAPIKeyAuth: true,
9786
+ }) {
9787
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
7825
9788
  const headers = init.headers;
7826
9789
  const authHeader = headers.get('Authorization');
7827
9790
  if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
@@ -7966,12 +9929,12 @@ class OpenAI {
7966
9929
  'OpenAI-Organization': this.organization,
7967
9930
  'OpenAI-Project': this.project,
7968
9931
  },
7969
- await this.authHeaders(options),
9932
+ await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
7970
9933
  this._options.defaultHeaders,
7971
9934
  bodyHeaders,
7972
9935
  options.headers,
7973
9936
  ]);
7974
- this.validateHeaders(headers);
9937
+ this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
7975
9938
  return headers.values;
7976
9939
  }
7977
9940
  _makeAbort(controller) {
@@ -8068,6 +10031,7 @@ OpenAI.Webhooks = Webhooks;
8068
10031
  OpenAI.Beta = Beta;
8069
10032
  OpenAI.Batches = Batches;
8070
10033
  OpenAI.Uploads = Uploads;
10034
+ OpenAI.Admin = Admin;
8071
10035
  OpenAI.Responses = Responses;
8072
10036
  OpenAI.Realtime = Realtime;
8073
10037
  OpenAI.Conversations = Conversations;
@@ -9069,7 +11033,7 @@ class Doc {
9069
11033
  const version = {
9070
11034
  major: 4,
9071
11035
  minor: 4,
9072
- patch: 2,
11036
+ patch: 3,
9073
11037
  };
9074
11038
 
9075
11039
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -10067,6 +12031,7 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
10067
12031
  });
10068
12032
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
10069
12033
  $ZodType.init(inst, def);
12034
+ inst._zod.optin = "optional";
10070
12035
  inst._zod.parse = (payload, ctx) => {
10071
12036
  if (ctx.direction === "backward") {
10072
12037
  throw new $ZodEncodeError(inst.constructor.name);
@@ -10076,6 +12041,7 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) =>
10076
12041
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
10077
12042
  return output.then((output) => {
10078
12043
  payload.value = output;
12044
+ payload.fallback = true;
10079
12045
  return payload;
10080
12046
  });
10081
12047
  }
@@ -10083,11 +12049,12 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) =>
10083
12049
  throw new $ZodAsyncError();
10084
12050
  }
10085
12051
  payload.value = _out;
12052
+ payload.fallback = true;
10086
12053
  return payload;
10087
12054
  };
10088
12055
  });
10089
12056
  function handleOptionalResult(result, input) {
10090
- if (result.issues.length && input === undefined) {
12057
+ if (input === undefined && (result.issues.length || result.fallback)) {
10091
12058
  return { issues: [], value: undefined };
10092
12059
  }
10093
12060
  return result;
@@ -10105,10 +12072,11 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
10105
12072
  });
10106
12073
  inst._zod.parse = (payload, ctx) => {
10107
12074
  if (def.innerType._zod.optin === "optional") {
12075
+ const input = payload.value;
10108
12076
  const result = def.innerType._zod.run(payload, ctx);
10109
12077
  if (result instanceof Promise)
10110
- return result.then((r) => handleOptionalResult(r, payload.value));
10111
- return handleOptionalResult(result, payload.value);
12078
+ return result.then((r) => handleOptionalResult(r, input));
12079
+ return handleOptionalResult(result, input);
10112
12080
  }
10113
12081
  if (payload.value === undefined) {
10114
12082
  return payload;
@@ -10218,7 +12186,7 @@ function handleNonOptionalResult(payload, inst) {
10218
12186
  }
10219
12187
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
10220
12188
  $ZodType.init(inst, def);
10221
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
12189
+ inst._zod.optin = "optional";
10222
12190
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
10223
12191
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
10224
12192
  inst._zod.parse = (payload, ctx) => {
@@ -10239,6 +12207,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
10239
12207
  input: payload.value,
10240
12208
  });
10241
12209
  payload.issues = [];
12210
+ payload.fallback = true;
10242
12211
  }
10243
12212
  return payload;
10244
12213
  });
@@ -10253,6 +12222,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
10253
12222
  input: payload.value,
10254
12223
  });
10255
12224
  payload.issues = [];
12225
+ payload.fallback = true;
10256
12226
  }
10257
12227
  return payload;
10258
12228
  };
@@ -10284,7 +12254,7 @@ function handlePipeResult(left, next, ctx) {
10284
12254
  left.aborted = true;
10285
12255
  return left;
10286
12256
  }
10287
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
12257
+ return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
10288
12258
  }
10289
12259
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
10290
12260
  $ZodType.init(inst, def);
@@ -12553,10 +14523,12 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
12553
14523
  if (output instanceof Promise) {
12554
14524
  return output.then((output) => {
12555
14525
  payload.value = output;
14526
+ payload.fallback = true;
12556
14527
  return payload;
12557
14528
  });
12558
14529
  }
12559
14530
  payload.value = output;
14531
+ payload.fallback = true;
12560
14532
  return payload;
12561
14533
  };
12562
14534
  });
@@ -14165,7 +16137,6 @@ function zodTextFormat(zodObject, name, props) {
14165
16137
  }, (content) => zodObject.parse(JSON.parse(content)));
14166
16138
  }
14167
16139
 
14168
- // llm-openai-config.ts
14169
16140
  const DEFAULT_MODEL = 'gpt-5-mini';
14170
16141
  const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
14171
16142
  const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
@@ -14246,25 +16217,144 @@ const deepseekModelCosts = {
14246
16217
  function shouldUseGPT5HighContextPricing(model, inputTokens) {
14247
16218
  return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
14248
16219
  }
14249
- /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
14250
- const openAiImageCosts = {
14251
- 'gpt-image-1': 0.0075, // $0.0075 per image for gpt-image-1
14252
- 'gpt-image-1.5': 0.0075, // Assumes parity pricing with gpt-image-1 until OpenAI publishes updated rates
16220
+ const DEFAULT_IMAGE_PRICING_QUALITY = 'high';
16221
+ const DEFAULT_IMAGE_PRICING_SIZE = '1024x1024';
16222
+ const PRICED_OPENAI_IMAGE_MODELS = [
16223
+ 'gpt-image-2',
16224
+ 'gpt-image-2-2026-04-21',
16225
+ 'gpt-image-1.5',
16226
+ 'gpt-image-1',
16227
+ 'gpt-image-1-mini',
16228
+ ];
16229
+ const OPENAI_IMAGE_PRICING_SIZES = ['1024x1024', '1024x1536', '1536x1024'];
16230
+ /**
16231
+ * Estimated image output costs in USD per image for common GPT Image sizes.
16232
+ * Last updated May 2026 from the OpenAI image generation guide. Text and image
16233
+ * input token costs for prompts and edit inputs are not included.
16234
+ */
16235
+ const openAiImageCostByQualityAndSize = {
16236
+ 'gpt-image-2': {
16237
+ low: {
16238
+ '1024x1024': 0.006,
16239
+ '1024x1536': 0.005,
16240
+ '1536x1024': 0.005,
16241
+ },
16242
+ medium: {
16243
+ '1024x1024': 0.053,
16244
+ '1024x1536': 0.041,
16245
+ '1536x1024': 0.041,
16246
+ },
16247
+ high: {
16248
+ '1024x1024': 0.211,
16249
+ '1024x1536': 0.165,
16250
+ '1536x1024': 0.165,
16251
+ },
16252
+ },
16253
+ 'gpt-image-2-2026-04-21': {
16254
+ low: {
16255
+ '1024x1024': 0.006,
16256
+ '1024x1536': 0.005,
16257
+ '1536x1024': 0.005,
16258
+ },
16259
+ medium: {
16260
+ '1024x1024': 0.053,
16261
+ '1024x1536': 0.041,
16262
+ '1536x1024': 0.041,
16263
+ },
16264
+ high: {
16265
+ '1024x1024': 0.211,
16266
+ '1024x1536': 0.165,
16267
+ '1536x1024': 0.165,
16268
+ },
16269
+ },
16270
+ 'gpt-image-1.5': {
16271
+ low: {
16272
+ '1024x1024': 0.009,
16273
+ '1024x1536': 0.013,
16274
+ '1536x1024': 0.013,
16275
+ },
16276
+ medium: {
16277
+ '1024x1024': 0.034,
16278
+ '1024x1536': 0.05,
16279
+ '1536x1024': 0.05,
16280
+ },
16281
+ high: {
16282
+ '1024x1024': 0.133,
16283
+ '1024x1536': 0.2,
16284
+ '1536x1024': 0.2,
16285
+ },
16286
+ },
16287
+ 'gpt-image-1': {
16288
+ low: {
16289
+ '1024x1024': 0.011,
16290
+ '1024x1536': 0.016,
16291
+ '1536x1024': 0.016,
16292
+ },
16293
+ medium: {
16294
+ '1024x1024': 0.042,
16295
+ '1024x1536': 0.063,
16296
+ '1536x1024': 0.063,
16297
+ },
16298
+ high: {
16299
+ '1024x1024': 0.167,
16300
+ '1024x1536': 0.25,
16301
+ '1536x1024': 0.25,
16302
+ },
16303
+ },
16304
+ 'gpt-image-1-mini': {
16305
+ low: {
16306
+ '1024x1024': 0.005,
16307
+ '1024x1536': 0.006,
16308
+ '1536x1024': 0.006,
16309
+ },
16310
+ medium: {
16311
+ '1024x1024': 0.011,
16312
+ '1024x1536': 0.015,
16313
+ '1536x1024': 0.015,
16314
+ },
16315
+ high: {
16316
+ '1024x1024': 0.036,
16317
+ '1024x1536': 0.052,
16318
+ '1536x1024': 0.052,
16319
+ },
16320
+ },
14253
16321
  };
16322
+ function isPricedOpenAIImageModel(model) {
16323
+ return PRICED_OPENAI_IMAGE_MODELS.includes(model);
16324
+ }
16325
+ function isOpenAIImagePricingSize(size) {
16326
+ return OPENAI_IMAGE_PRICING_SIZES.includes(size);
16327
+ }
16328
+ function resolveImagePricingQuality(quality) {
16329
+ if (quality === 'low' || quality === 'medium' || quality === 'high') {
16330
+ return quality;
16331
+ }
16332
+ return DEFAULT_IMAGE_PRICING_QUALITY;
16333
+ }
16334
+ function resolveImagePricingSize(size) {
16335
+ if (typeof size === 'string' && isOpenAIImagePricingSize(size)) {
16336
+ return size;
16337
+ }
16338
+ return DEFAULT_IMAGE_PRICING_SIZE;
16339
+ }
14254
16340
  /**
14255
16341
  * Calculates the cost of generating images using OpenAI's Images API.
14256
16342
  *
14257
16343
  * @param model The image generation model name.
14258
16344
  * @param imageCount The number of images generated.
16345
+ * @param quality The requested image quality.
16346
+ * @param size The requested image size.
14259
16347
  * @returns The cost of generating the images in USD.
14260
16348
  */
14261
- function calculateImageCost(model, imageCount) {
16349
+ function calculateImageCost(model, imageCount, quality, size) {
14262
16350
  if (typeof model !== 'string' || typeof imageCount !== 'number' || imageCount <= 0) {
14263
16351
  return 0;
14264
16352
  }
14265
- const costPerImage = openAiImageCosts[model];
14266
- if (!costPerImage)
16353
+ if (!isPricedOpenAIImageModel(model))
14267
16354
  return 0;
16355
+ const pricingQuality = resolveImagePricingQuality(quality);
16356
+ const pricingSize = resolveImagePricingSize(size);
16357
+ const costPerImage = openAiImageCostByQualityAndSize[model][pricingQuality][pricingSize];
14268
16358
  return imageCount * costPerImage;
14269
16359
  }
14270
16360
  /**
@@ -14955,7 +17045,7 @@ async function makeLLMCall(input, options = {}) {
14955
17045
  return await makeResponsesAPICall(processedInput, responsesOptions);
14956
17046
  }
14957
17047
 
14958
- const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
17048
+ const DEFAULT_IMAGE_MODEL = 'gpt-image-2';
14959
17049
  const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
14960
17050
  const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
14961
17051
  /**
@@ -15044,7 +17134,7 @@ async function makeImagesCall(prompt, options = {}) {
15044
17134
  throw new Error('No images returned from OpenAI Images API');
15045
17135
  }
15046
17136
  // Calculate cost
15047
- const cost = calculateImageCost(imageModel, count || 1);
17137
+ const cost = calculateImageCost(imageModel, count || 1, quality, size);
15048
17138
  // Return the response with enhanced usage information
15049
17139
  const enhancedResponse = {
15050
17140
  ...response,
@@ -22306,9 +24396,20 @@ function testOpenAIModelDeprecation() {
22306
24396
  if (OPENAI_MODELS.length !== supportedModels.length) {
22307
24397
  throw new Error(`Expected ${supportedModels.length} direct OpenAI models, received ${OPENAI_MODELS.length}`);
22308
24398
  }
24399
+ const expectedOpenRouterModel = 'openai/gpt-5-mini';
24400
+ if (!OPENROUTER_MODELS.includes(expectedOpenRouterModel)) {
24401
+ throw new Error(`Expected OPENROUTER_MODELS to include ${expectedOpenRouterModel}`);
24402
+ }
24403
+ if (!isOpenRouterModel(expectedOpenRouterModel)) {
24404
+ throw new Error(`Expected ${expectedOpenRouterModel} to be accepted as an OpenRouter model`);
24405
+ }
24406
+ if (isOpenRouterModel('openai/gpt-4o-mini')) {
24407
+ throw new Error('Expected openai/gpt-4o-mini to be excluded from OpenRouter runtime models');
24408
+ }
22309
24409
  console.log('\n[OpenAI] Model deprecation test');
22310
24410
  console.log(` Default model: ${DEFAULT_MODEL}`);
22311
24411
  console.log(` Supported direct OpenAI models: ${OPENAI_MODELS.join(', ')}`);
24412
+ console.log(` Supported OpenRouter models: ${OPENROUTER_MODELS.join(', ')}`);
22312
24413
  }
22313
24414
  async function testLLMStructuredOutputWithZod() {
22314
24415
  if (!process.env.OPENAI_API_KEY) {