@discomedia/utils 1.0.70 → 1.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1162,6 +1162,25 @@ const OPENAI_MODELS = [
1162
1162
  function isOpenAIModel(model) {
1163
1163
  return OPENAI_MODELS.includes(model);
1164
1164
  }
1165
+ /**
1166
+ * Represents OpenAI image models.
1167
+ */
1168
+ const OPENAI_IMAGE_MODELS = [
1169
+ 'gpt-image-2',
1170
+ 'gpt-image-2-2026-04-21',
1171
+ 'gpt-image-1.5',
1172
+ 'gpt-image-1',
1173
+ 'gpt-image-1-mini',
1174
+ 'chatgpt-image-latest',
1175
+ 'dall-e-2',
1176
+ 'dall-e-3',
1177
+ ];
1178
+ /**
1179
+ * Type guard to check if a model is a supported OpenAI image model.
1180
+ */
1181
+ function isOpenAIImageModel(model) {
1182
+ return OPENAI_IMAGE_MODELS.includes(model);
1183
+ }
1165
1184
  /**
1166
1185
  * Represents OpenRouter models
1167
1186
  */
@@ -1196,8 +1215,10 @@ function isOpenRouterModel(model) {
1196
1215
 
1197
1216
  var Types = /*#__PURE__*/Object.freeze({
1198
1217
  __proto__: null,
1218
+ OPENAI_IMAGE_MODELS: OPENAI_IMAGE_MODELS,
1199
1219
  OPENAI_MODELS: OPENAI_MODELS,
1200
1220
  OPENROUTER_MODELS: OPENROUTER_MODELS,
1221
+ isOpenAIImageModel: isOpenAIImageModel,
1201
1222
  isOpenAIModel: isOpenAIModel,
1202
1223
  isOpenRouterModel: isOpenRouterModel
1203
1224
  });
@@ -1677,7 +1698,7 @@ const safeJSON = (text) => {
1677
1698
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1678
1699
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1679
1700
 
1680
- const VERSION = '6.35.0'; // x-release-please-version
1701
+ const VERSION = '6.37.0'; // x-release-please-version
1681
1702
 
1682
1703
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1683
1704
  const isRunningInBrowser = () => {
@@ -2497,6 +2518,8 @@ const formatRequestDetails = (details) => {
2497
2518
  details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
2498
2519
  name,
2499
2520
  (name.toLowerCase() === 'authorization' ||
2521
+ name.toLowerCase() === 'api-key' ||
2522
+ name.toLowerCase() === 'x-api-key' ||
2500
2523
  name.toLowerCase() === 'cookie' ||
2501
2524
  name.toLowerCase() === 'set-cookie') ?
2502
2525
  '***'
@@ -3057,6 +3080,36 @@ class ConversationCursorPage extends AbstractPage {
3057
3080
  };
3058
3081
  }
3059
3082
  }
3083
+ class NextCursorPage extends AbstractPage {
3084
+ constructor(client, response, body, options) {
3085
+ super(client, response, body, options);
3086
+ this.data = body.data || [];
3087
+ this.has_more = body.has_more || false;
3088
+ this.next = body.next || null;
3089
+ }
3090
+ getPaginatedItems() {
3091
+ return this.data ?? [];
3092
+ }
3093
+ hasNextPage() {
3094
+ if (this.has_more === false) {
3095
+ return false;
3096
+ }
3097
+ return super.hasNextPage();
3098
+ }
3099
+ nextPageRequestOptions() {
3100
+ const cursor = this.next;
3101
+ if (!cursor) {
3102
+ return null;
3103
+ }
3104
+ return {
3105
+ ...this.options,
3106
+ query: {
3107
+ ...maybeObj(this.options.query),
3108
+ after: cursor,
3109
+ },
3110
+ };
3111
+ }
3112
+ }
3060
3113
 
3061
3114
  const SUBJECT_TOKEN_TYPES = {
3062
3115
  jwt: 'urn:ietf:params:oauth:token-type:jwt',
@@ -3459,7 +3512,7 @@ let Messages$1 = class Messages extends APIResource {
3459
3512
  * ```
3460
3513
  */
3461
3514
  list(completionID, query = {}, options) {
3462
- return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options });
3515
+ return this._client.getAPIList(path `/chat/completions/${completionID}/messages`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
3463
3516
  }
3464
3517
  };
3465
3518
 
@@ -4805,123 +4858,1775 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
4805
4858
  runner._run(() => runner._fromReadableStream(stream));
4806
4859
  return runner;
4807
4860
  }
4808
- static runTools(client, params, options) {
4809
- const runner = new ChatCompletionStreamingRunner(
4810
- // @ts-expect-error TODO these types are incompatible
4811
- params);
4812
- const opts = {
4861
+ static runTools(client, params, options) {
4862
+ const runner = new ChatCompletionStreamingRunner(
4863
+ // @ts-expect-error TODO these types are incompatible
4864
+ params);
4865
+ const opts = {
4866
+ ...options,
4867
+ headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
4868
+ };
4869
+ runner._run(() => runner._runTools(client, params, opts));
4870
+ return runner;
4871
+ }
4872
+ }
4873
+
4874
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4875
+ /**
4876
+ * Given a list of messages comprising a conversation, the model will return a response.
4877
+ */
4878
+ let Completions$1 = class Completions extends APIResource {
4879
+ constructor() {
4880
+ super(...arguments);
4881
+ this.messages = new Messages$1(this._client);
4882
+ }
4883
+ create(body, options) {
4884
+ return this._client.post('/chat/completions', {
4885
+ body,
4886
+ ...options,
4887
+ stream: body.stream ?? false,
4888
+ __security: { bearerAuth: true },
4889
+ });
4890
+ }
4891
+ /**
4892
+ * Get a stored chat completion. Only Chat Completions that have been created with
4893
+ * the `store` parameter set to `true` will be returned.
4894
+ *
4895
+ * @example
4896
+ * ```ts
4897
+ * const chatCompletion =
4898
+ * await client.chat.completions.retrieve('completion_id');
4899
+ * ```
4900
+ */
4901
+ retrieve(completionID, options) {
4902
+ return this._client.get(path `/chat/completions/${completionID}`, {
4903
+ ...options,
4904
+ __security: { bearerAuth: true },
4905
+ });
4906
+ }
4907
+ /**
4908
+ * Modify a stored chat completion. Only Chat Completions that have been created
4909
+ * with the `store` parameter set to `true` can be modified. Currently, the only
4910
+ * supported modification is to update the `metadata` field.
4911
+ *
4912
+ * @example
4913
+ * ```ts
4914
+ * const chatCompletion = await client.chat.completions.update(
4915
+ * 'completion_id',
4916
+ * { metadata: { foo: 'string' } },
4917
+ * );
4918
+ * ```
4919
+ */
4920
+ update(completionID, body, options) {
4921
+ return this._client.post(path `/chat/completions/${completionID}`, {
4922
+ body,
4923
+ ...options,
4924
+ __security: { bearerAuth: true },
4925
+ });
4926
+ }
4927
+ /**
4928
+ * List stored Chat Completions. Only Chat Completions that have been stored with
4929
+ * the `store` parameter set to `true` will be returned.
4930
+ *
4931
+ * @example
4932
+ * ```ts
4933
+ * // Automatically fetches more pages as needed.
4934
+ * for await (const chatCompletion of client.chat.completions.list()) {
4935
+ * // ...
4936
+ * }
4937
+ * ```
4938
+ */
4939
+ list(query = {}, options) {
4940
+ return this._client.getAPIList('/chat/completions', (CursorPage), {
4941
+ query,
4942
+ ...options,
4943
+ __security: { bearerAuth: true },
4944
+ });
4945
+ }
4946
+ /**
4947
+ * Delete a stored chat completion. Only Chat Completions that have been created
4948
+ * with the `store` parameter set to `true` can be deleted.
4949
+ *
4950
+ * @example
4951
+ * ```ts
4952
+ * const chatCompletionDeleted =
4953
+ * await client.chat.completions.delete('completion_id');
4954
+ * ```
4955
+ */
4956
+ delete(completionID, options) {
4957
+ return this._client.delete(path `/chat/completions/${completionID}`, {
4958
+ ...options,
4959
+ __security: { bearerAuth: true },
4960
+ });
4961
+ }
4962
+ parse(body, options) {
4963
+ validateInputTools(body.tools);
4964
+ return this._client.chat.completions
4965
+ .create(body, {
4966
+ ...options,
4967
+ headers: {
4968
+ ...options?.headers,
4969
+ 'X-Stainless-Helper-Method': 'chat.completions.parse',
4970
+ },
4971
+ })
4972
+ ._thenUnwrap((completion) => parseChatCompletion(completion, body));
4973
+ }
4974
+ runTools(body, options) {
4975
+ if (body.stream) {
4976
+ return ChatCompletionStreamingRunner.runTools(this._client, body, options);
4977
+ }
4978
+ return ChatCompletionRunner.runTools(this._client, body, options);
4979
+ }
4980
+ /**
4981
+ * Creates a chat completion stream
4982
+ */
4983
+ stream(body, options) {
4984
+ return ChatCompletionStream.createChatCompletion(this._client, body, options);
4985
+ }
4986
+ };
4987
+ Completions$1.Messages = Messages$1;
4988
+
4989
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4990
+ class Chat extends APIResource {
4991
+ constructor() {
4992
+ super(...arguments);
4993
+ this.completions = new Completions$1(this._client);
4994
+ }
4995
+ }
4996
+ Chat.Completions = Completions$1;
4997
+
4998
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4999
+ class AdminAPIKeys extends APIResource {
5000
+ /**
5001
+ * Create an organization admin API key
5002
+ *
5003
+ * @example
5004
+ * ```ts
5005
+ * const adminAPIKey =
5006
+ * await client.admin.organization.adminAPIKeys.create({
5007
+ * name: 'New Admin Key',
5008
+ * });
5009
+ * ```
5010
+ */
5011
+ create(body, options) {
5012
+ return this._client.post('/organization/admin_api_keys', {
5013
+ body,
5014
+ ...options,
5015
+ __security: { adminAPIKeyAuth: true },
5016
+ });
5017
+ }
5018
+ /**
5019
+ * Retrieve a single organization API key
5020
+ *
5021
+ * @example
5022
+ * ```ts
5023
+ * const adminAPIKey =
5024
+ * await client.admin.organization.adminAPIKeys.retrieve(
5025
+ * 'key_id',
5026
+ * );
5027
+ * ```
5028
+ */
5029
+ retrieve(keyID, options) {
5030
+ return this._client.get(path `/organization/admin_api_keys/${keyID}`, {
5031
+ ...options,
5032
+ __security: { adminAPIKeyAuth: true },
5033
+ });
5034
+ }
5035
+ /**
5036
+ * List organization API keys
5037
+ *
5038
+ * @example
5039
+ * ```ts
5040
+ * // Automatically fetches more pages as needed.
5041
+ * for await (const adminAPIKey of client.admin.organization.adminAPIKeys.list()) {
5042
+ * // ...
5043
+ * }
5044
+ * ```
5045
+ */
5046
+ list(query = {}, options) {
5047
+ return this._client.getAPIList('/organization/admin_api_keys', (CursorPage), {
5048
+ query,
5049
+ ...options,
5050
+ __security: { adminAPIKeyAuth: true },
5051
+ });
5052
+ }
5053
+ /**
5054
+ * Delete an organization admin API key
5055
+ *
5056
+ * @example
5057
+ * ```ts
5058
+ * const adminAPIKey =
5059
+ * await client.admin.organization.adminAPIKeys.delete(
5060
+ * 'key_id',
5061
+ * );
5062
+ * ```
5063
+ */
5064
+ delete(keyID, options) {
5065
+ return this._client.delete(path `/organization/admin_api_keys/${keyID}`, {
5066
+ ...options,
5067
+ __security: { adminAPIKeyAuth: true },
5068
+ });
5069
+ }
5070
+ }
5071
+
5072
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5073
+ /**
5074
+ * List user actions and configuration changes within this organization.
5075
+ */
5076
+ class AuditLogs extends APIResource {
5077
+ /**
5078
+ * List user actions and configuration changes within this organization.
5079
+ *
5080
+ * @example
5081
+ * ```ts
5082
+ * // Automatically fetches more pages as needed.
5083
+ * for await (const auditLogListResponse of client.admin.organization.auditLogs.list()) {
5084
+ * // ...
5085
+ * }
5086
+ * ```
5087
+ */
5088
+ list(query = {}, options) {
5089
+ return this._client.getAPIList('/organization/audit_logs', (ConversationCursorPage), {
5090
+ query,
5091
+ ...options,
5092
+ __security: { adminAPIKeyAuth: true },
5093
+ });
5094
+ }
5095
+ }
5096
+
5097
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5098
+ let Certificates$1 = class Certificates extends APIResource {
5099
+ /**
5100
+ * Upload a certificate to the organization. This does **not** automatically
5101
+ * activate the certificate.
5102
+ *
5103
+ * Organizations can upload up to 50 certificates.
5104
+ *
5105
+ * @example
5106
+ * ```ts
5107
+ * const certificate =
5108
+ * await client.admin.organization.certificates.create({
5109
+ * certificate: 'certificate',
5110
+ * });
5111
+ * ```
5112
+ */
5113
+ create(body, options) {
5114
+ return this._client.post('/organization/certificates', {
5115
+ body,
5116
+ ...options,
5117
+ __security: { adminAPIKeyAuth: true },
5118
+ });
5119
+ }
5120
+ /**
5121
+ * Get a certificate that has been uploaded to the organization.
5122
+ *
5123
+ * You can get a certificate regardless of whether it is active or not.
5124
+ *
5125
+ * @example
5126
+ * ```ts
5127
+ * const certificate =
5128
+ * await client.admin.organization.certificates.retrieve(
5129
+ * 'certificate_id',
5130
+ * );
5131
+ * ```
5132
+ */
5133
+ retrieve(certificateID, query = {}, options) {
5134
+ return this._client.get(path `/organization/certificates/${certificateID}`, {
5135
+ query,
5136
+ ...options,
5137
+ __security: { adminAPIKeyAuth: true },
5138
+ });
5139
+ }
5140
+ /**
5141
+ * Modify a certificate. Note that only the name can be modified.
5142
+ *
5143
+ * @example
5144
+ * ```ts
5145
+ * const certificate =
5146
+ * await client.admin.organization.certificates.update(
5147
+ * 'certificate_id',
5148
+ * );
5149
+ * ```
5150
+ */
5151
+ update(certificateID, body, options) {
5152
+ return this._client.post(path `/organization/certificates/${certificateID}`, {
5153
+ body,
5154
+ ...options,
5155
+ __security: { adminAPIKeyAuth: true },
5156
+ });
5157
+ }
5158
+ /**
5159
+ * List uploaded certificates for this organization.
5160
+ *
5161
+ * @example
5162
+ * ```ts
5163
+ * // Automatically fetches more pages as needed.
5164
+ * for await (const certificateListResponse of client.admin.organization.certificates.list()) {
5165
+ * // ...
5166
+ * }
5167
+ * ```
5168
+ */
5169
+ list(query = {}, options) {
5170
+ return this._client.getAPIList('/organization/certificates', (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5171
+ }
5172
+ /**
5173
+ * Delete a certificate from the organization.
5174
+ *
5175
+ * The certificate must be inactive for the organization and all projects.
5176
+ *
5177
+ * @example
5178
+ * ```ts
5179
+ * const certificate =
5180
+ * await client.admin.organization.certificates.delete(
5181
+ * 'certificate_id',
5182
+ * );
5183
+ * ```
5184
+ */
5185
+ delete(certificateID, options) {
5186
+ return this._client.delete(path `/organization/certificates/${certificateID}`, {
5187
+ ...options,
5188
+ __security: { adminAPIKeyAuth: true },
5189
+ });
5190
+ }
5191
+ /**
5192
+ * Activate certificates at the organization level.
5193
+ *
5194
+ * You can atomically and idempotently activate up to 10 certificates at a time.
5195
+ *
5196
+ * @example
5197
+ * ```ts
5198
+ * // Automatically fetches more pages as needed.
5199
+ * for await (const certificateActivateResponse of client.admin.organization.certificates.activate(
5200
+ * { certificate_ids: ['cert_abc'] },
5201
+ * )) {
5202
+ * // ...
5203
+ * }
5204
+ * ```
5205
+ */
5206
+ activate(body, options) {
5207
+ return this._client.getAPIList('/organization/certificates/activate', (Page), {
5208
+ body,
5209
+ method: 'post',
5210
+ ...options,
5211
+ __security: { adminAPIKeyAuth: true },
5212
+ });
5213
+ }
5214
+ /**
5215
+ * Deactivate certificates at the organization level.
5216
+ *
5217
+ * You can atomically and idempotently deactivate up to 10 certificates at a time.
5218
+ *
5219
+ * @example
5220
+ * ```ts
5221
+ * // Automatically fetches more pages as needed.
5222
+ * for await (const certificateDeactivateResponse of client.admin.organization.certificates.deactivate(
5223
+ * { certificate_ids: ['cert_abc'] },
5224
+ * )) {
5225
+ * // ...
5226
+ * }
5227
+ * ```
5228
+ */
5229
+ deactivate(body, options) {
5230
+ return this._client.getAPIList('/organization/certificates/deactivate', (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
5231
+ }
5232
+ };
5233
+
5234
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5235
+ class Invites extends APIResource {
5236
+ /**
5237
+ * Create an invite for a user to the organization. The invite must be accepted by
5238
+ * the user before they have access to the organization.
5239
+ *
5240
+ * @example
5241
+ * ```ts
5242
+ * const invite =
5243
+ * await client.admin.organization.invites.create({
5244
+ * email: 'email',
5245
+ * role: 'reader',
5246
+ * });
5247
+ * ```
5248
+ */
5249
+ create(body, options) {
5250
+ return this._client.post('/organization/invites', {
5251
+ body,
5252
+ ...options,
5253
+ __security: { adminAPIKeyAuth: true },
5254
+ });
5255
+ }
5256
+ /**
5257
+ * Retrieves an invite.
5258
+ *
5259
+ * @example
5260
+ * ```ts
5261
+ * const invite =
5262
+ * await client.admin.organization.invites.retrieve(
5263
+ * 'invite_id',
5264
+ * );
5265
+ * ```
5266
+ */
5267
+ retrieve(inviteID, options) {
5268
+ return this._client.get(path `/organization/invites/${inviteID}`, {
5269
+ ...options,
5270
+ __security: { adminAPIKeyAuth: true },
5271
+ });
5272
+ }
5273
+ /**
5274
+ * Returns a list of invites in the organization.
5275
+ *
5276
+ * @example
5277
+ * ```ts
5278
+ * // Automatically fetches more pages as needed.
5279
+ * for await (const invite of client.admin.organization.invites.list()) {
5280
+ * // ...
5281
+ * }
5282
+ * ```
5283
+ */
5284
+ list(query = {}, options) {
5285
+ return this._client.getAPIList('/organization/invites', (ConversationCursorPage), {
5286
+ query,
5287
+ ...options,
5288
+ __security: { adminAPIKeyAuth: true },
5289
+ });
5290
+ }
5291
+ /**
5292
+ * Delete an invite. If the invite has already been accepted, it cannot be deleted.
5293
+ *
5294
+ * @example
5295
+ * ```ts
5296
+ * const invite =
5297
+ * await client.admin.organization.invites.delete(
5298
+ * 'invite_id',
5299
+ * );
5300
+ * ```
5301
+ */
5302
+ delete(inviteID, options) {
5303
+ return this._client.delete(path `/organization/invites/${inviteID}`, {
5304
+ ...options,
5305
+ __security: { adminAPIKeyAuth: true },
5306
+ });
5307
+ }
5308
+ }
5309
+
5310
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5311
+ let Roles$5 = class Roles extends APIResource {
5312
+ /**
5313
+ * Creates a custom role for the organization.
5314
+ *
5315
+ * @example
5316
+ * ```ts
5317
+ * const role = await client.admin.organization.roles.create({
5318
+ * permissions: ['string'],
5319
+ * role_name: 'role_name',
5320
+ * });
5321
+ * ```
5322
+ */
5323
+ create(body, options) {
5324
+ return this._client.post('/organization/roles', {
5325
+ body,
5326
+ ...options,
5327
+ __security: { adminAPIKeyAuth: true },
5328
+ });
5329
+ }
5330
+ /**
5331
+ * Updates an existing organization role.
5332
+ *
5333
+ * @example
5334
+ * ```ts
5335
+ * const role = await client.admin.organization.roles.update(
5336
+ * 'role_id',
5337
+ * );
5338
+ * ```
5339
+ */
5340
+ update(roleID, body, options) {
5341
+ return this._client.post(path `/organization/roles/${roleID}`, {
5342
+ body,
5343
+ ...options,
5344
+ __security: { adminAPIKeyAuth: true },
5345
+ });
5346
+ }
5347
+ /**
5348
+ * Lists the roles configured for the organization.
5349
+ *
5350
+ * @example
5351
+ * ```ts
5352
+ * // Automatically fetches more pages as needed.
5353
+ * for await (const role of client.admin.organization.roles.list()) {
5354
+ * // ...
5355
+ * }
5356
+ * ```
5357
+ */
5358
+ list(query = {}, options) {
5359
+ return this._client.getAPIList('/organization/roles', (NextCursorPage), {
5360
+ query,
5361
+ ...options,
5362
+ __security: { adminAPIKeyAuth: true },
5363
+ });
5364
+ }
5365
+ /**
5366
+ * Deletes a custom role from the organization.
5367
+ *
5368
+ * @example
5369
+ * ```ts
5370
+ * const role = await client.admin.organization.roles.delete(
5371
+ * 'role_id',
5372
+ * );
5373
+ * ```
5374
+ */
5375
+ delete(roleID, options) {
5376
+ return this._client.delete(path `/organization/roles/${roleID}`, {
5377
+ ...options,
5378
+ __security: { adminAPIKeyAuth: true },
5379
+ });
5380
+ }
5381
+ };
5382
+
5383
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5384
+ class Usage extends APIResource {
5385
+ /**
5386
+ * Get audio speeches usage details for the organization.
5387
+ *
5388
+ * @example
5389
+ * ```ts
5390
+ * const response =
5391
+ * await client.admin.organization.usage.audioSpeeches({
5392
+ * start_time: 0,
5393
+ * });
5394
+ * ```
5395
+ */
5396
+ audioSpeeches(query, options) {
5397
+ return this._client.get('/organization/usage/audio_speeches', {
5398
+ query,
5399
+ ...options,
5400
+ __security: { adminAPIKeyAuth: true },
5401
+ });
5402
+ }
5403
+ /**
5404
+ * Get audio transcriptions usage details for the organization.
5405
+ *
5406
+ * @example
5407
+ * ```ts
5408
+ * const response =
5409
+ * await client.admin.organization.usage.audioTranscriptions(
5410
+ * { start_time: 0 },
5411
+ * );
5412
+ * ```
5413
+ */
5414
+ audioTranscriptions(query, options) {
5415
+ return this._client.get('/organization/usage/audio_transcriptions', {
5416
+ query,
5417
+ ...options,
5418
+ __security: { adminAPIKeyAuth: true },
5419
+ });
5420
+ }
5421
+ /**
5422
+ * Get code interpreter sessions usage details for the organization.
5423
+ *
5424
+ * @example
5425
+ * ```ts
5426
+ * const response =
5427
+ * await client.admin.organization.usage.codeInterpreterSessions(
5428
+ * { start_time: 0 },
5429
+ * );
5430
+ * ```
5431
+ */
5432
+ codeInterpreterSessions(query, options) {
5433
+ return this._client.get('/organization/usage/code_interpreter_sessions', {
5434
+ query,
5435
+ ...options,
5436
+ __security: { adminAPIKeyAuth: true },
5437
+ });
5438
+ }
5439
+ /**
5440
+ * Get completions usage details for the organization.
5441
+ *
5442
+ * @example
5443
+ * ```ts
5444
+ * const response =
5445
+ * await client.admin.organization.usage.completions({
5446
+ * start_time: 0,
5447
+ * });
5448
+ * ```
5449
+ */
5450
+ completions(query, options) {
5451
+ return this._client.get('/organization/usage/completions', {
5452
+ query,
5453
+ ...options,
5454
+ __security: { adminAPIKeyAuth: true },
5455
+ });
5456
+ }
5457
+ /**
5458
+ * Get costs details for the organization.
5459
+ *
5460
+ * @example
5461
+ * ```ts
5462
+ * const response =
5463
+ * await client.admin.organization.usage.costs({
5464
+ * start_time: 0,
5465
+ * });
5466
+ * ```
5467
+ */
5468
+ costs(query, options) {
5469
+ return this._client.get('/organization/costs', {
5470
+ query,
5471
+ ...options,
5472
+ __security: { adminAPIKeyAuth: true },
5473
+ });
5474
+ }
5475
+ /**
5476
+ * Get embeddings usage details for the organization.
5477
+ *
5478
+ * @example
5479
+ * ```ts
5480
+ * const response =
5481
+ * await client.admin.organization.usage.embeddings({
5482
+ * start_time: 0,
5483
+ * });
5484
+ * ```
5485
+ */
5486
+ embeddings(query, options) {
5487
+ return this._client.get('/organization/usage/embeddings', {
5488
+ query,
5489
+ ...options,
5490
+ __security: { adminAPIKeyAuth: true },
5491
+ });
5492
+ }
5493
+ /**
5494
+ * Get images usage details for the organization.
5495
+ *
5496
+ * @example
5497
+ * ```ts
5498
+ * const response =
5499
+ * await client.admin.organization.usage.images({
5500
+ * start_time: 0,
5501
+ * });
5502
+ * ```
5503
+ */
5504
+ images(query, options) {
5505
+ return this._client.get('/organization/usage/images', {
5506
+ query,
5507
+ ...options,
5508
+ __security: { adminAPIKeyAuth: true },
5509
+ });
5510
+ }
5511
+ /**
5512
+ * Get moderations usage details for the organization.
5513
+ *
5514
+ * @example
5515
+ * ```ts
5516
+ * const response =
5517
+ * await client.admin.organization.usage.moderations({
5518
+ * start_time: 0,
5519
+ * });
5520
+ * ```
5521
+ */
5522
+ moderations(query, options) {
5523
+ return this._client.get('/organization/usage/moderations', {
5524
+ query,
5525
+ ...options,
5526
+ __security: { adminAPIKeyAuth: true },
5527
+ });
5528
+ }
5529
+ /**
5530
+ * Get vector stores usage details for the organization.
5531
+ *
5532
+ * @example
5533
+ * ```ts
5534
+ * const response =
5535
+ * await client.admin.organization.usage.vectorStores({
5536
+ * start_time: 0,
5537
+ * });
5538
+ * ```
5539
+ */
5540
+ vectorStores(query, options) {
5541
+ return this._client.get('/organization/usage/vector_stores', {
5542
+ query,
5543
+ ...options,
5544
+ __security: { adminAPIKeyAuth: true },
5545
+ });
5546
+ }
5547
+ }
5548
+
5549
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5550
+ let Roles$4 = class Roles extends APIResource {
5551
+ /**
5552
+ * Assigns an organization role to a group within the organization.
5553
+ *
5554
+ * @example
5555
+ * ```ts
5556
+ * const role =
5557
+ * await client.admin.organization.groups.roles.create(
5558
+ * 'group_id',
5559
+ * { role_id: 'role_id' },
5560
+ * );
5561
+ * ```
5562
+ */
5563
+ create(groupID, body, options) {
5564
+ return this._client.post(path `/organization/groups/${groupID}/roles`, {
5565
+ body,
5566
+ ...options,
5567
+ __security: { adminAPIKeyAuth: true },
5568
+ });
5569
+ }
5570
+ /**
5571
+ * Lists the organization roles assigned to a group within the organization.
5572
+ *
5573
+ * @example
5574
+ * ```ts
5575
+ * // Automatically fetches more pages as needed.
5576
+ * for await (const roleListResponse of client.admin.organization.groups.roles.list(
5577
+ * 'group_id',
5578
+ * )) {
5579
+ * // ...
5580
+ * }
5581
+ * ```
5582
+ */
5583
+ list(groupID, query = {}, options) {
5584
+ return this._client.getAPIList(path `/organization/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5585
+ }
5586
+ /**
5587
+ * Unassigns an organization role from a group within the organization.
5588
+ *
5589
+ * @example
5590
+ * ```ts
5591
+ * const role =
5592
+ * await client.admin.organization.groups.roles.delete(
5593
+ * 'role_id',
5594
+ * { group_id: 'group_id' },
5595
+ * );
5596
+ * ```
5597
+ */
5598
+ delete(roleID, params, options) {
5599
+ const { group_id } = params;
5600
+ return this._client.delete(path `/organization/groups/${group_id}/roles/${roleID}`, {
5601
+ ...options,
5602
+ __security: { adminAPIKeyAuth: true },
5603
+ });
5604
+ }
5605
+ };
5606
+
5607
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5608
+ let Users$2 = class Users extends APIResource {
5609
+ /**
5610
+ * Adds a user to a group.
5611
+ *
5612
+ * @example
5613
+ * ```ts
5614
+ * const user =
5615
+ * await client.admin.organization.groups.users.create(
5616
+ * 'group_id',
5617
+ * { user_id: 'user_id' },
5618
+ * );
5619
+ * ```
5620
+ */
5621
+ create(groupID, body, options) {
5622
+ return this._client.post(path `/organization/groups/${groupID}/users`, {
5623
+ body,
5624
+ ...options,
5625
+ __security: { adminAPIKeyAuth: true },
5626
+ });
5627
+ }
5628
+ /**
5629
+ * Lists the users assigned to a group.
5630
+ *
5631
+ * @example
5632
+ * ```ts
5633
+ * // Automatically fetches more pages as needed.
5634
+ * for await (const organizationGroupUser of client.admin.organization.groups.users.list(
5635
+ * 'group_id',
5636
+ * )) {
5637
+ * // ...
5638
+ * }
5639
+ * ```
5640
+ */
5641
+ list(groupID, query = {}, options) {
5642
+ return this._client.getAPIList(path `/organization/groups/${groupID}/users`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5643
+ }
5644
+ /**
5645
+ * Removes a user from a group.
5646
+ *
5647
+ * @example
5648
+ * ```ts
5649
+ * const user =
5650
+ * await client.admin.organization.groups.users.delete(
5651
+ * 'user_id',
5652
+ * { group_id: 'group_id' },
5653
+ * );
5654
+ * ```
5655
+ */
5656
+ delete(userID, params, options) {
5657
+ const { group_id } = params;
5658
+ return this._client.delete(path `/organization/groups/${group_id}/users/${userID}`, {
5659
+ ...options,
5660
+ __security: { adminAPIKeyAuth: true },
5661
+ });
5662
+ }
5663
+ };
5664
+
5665
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5666
+ let Groups$1 = class Groups extends APIResource {
5667
+ constructor() {
5668
+ super(...arguments);
5669
+ this.users = new Users$2(this._client);
5670
+ this.roles = new Roles$4(this._client);
5671
+ }
5672
+ /**
5673
+ * Creates a new group in the organization.
5674
+ *
5675
+ * @example
5676
+ * ```ts
5677
+ * const group = await client.admin.organization.groups.create(
5678
+ * { name: 'x' },
5679
+ * );
5680
+ * ```
5681
+ */
5682
+ create(body, options) {
5683
+ return this._client.post('/organization/groups', {
5684
+ body,
5685
+ ...options,
5686
+ __security: { adminAPIKeyAuth: true },
5687
+ });
5688
+ }
5689
+ /**
5690
+ * Updates a group's information.
5691
+ *
5692
+ * @example
5693
+ * ```ts
5694
+ * const group = await client.admin.organization.groups.update(
5695
+ * 'group_id',
5696
+ * { name: 'x' },
5697
+ * );
5698
+ * ```
5699
+ */
5700
+ update(groupID, body, options) {
5701
+ return this._client.post(path `/organization/groups/${groupID}`, {
5702
+ body,
5703
+ ...options,
5704
+ __security: { adminAPIKeyAuth: true },
5705
+ });
5706
+ }
5707
+ /**
5708
+ * Lists all groups in the organization.
5709
+ *
5710
+ * @example
5711
+ * ```ts
5712
+ * // Automatically fetches more pages as needed.
5713
+ * for await (const group of client.admin.organization.groups.list()) {
5714
+ * // ...
5715
+ * }
5716
+ * ```
5717
+ */
5718
+ list(query = {}, options) {
5719
+ return this._client.getAPIList('/organization/groups', (NextCursorPage), {
5720
+ query,
5721
+ ...options,
5722
+ __security: { adminAPIKeyAuth: true },
5723
+ });
5724
+ }
5725
+ /**
5726
+ * Deletes a group from the organization.
5727
+ *
5728
+ * @example
5729
+ * ```ts
5730
+ * const group = await client.admin.organization.groups.delete(
5731
+ * 'group_id',
5732
+ * );
5733
+ * ```
5734
+ */
5735
+ delete(groupID, options) {
5736
+ return this._client.delete(path `/organization/groups/${groupID}`, {
5737
+ ...options,
5738
+ __security: { adminAPIKeyAuth: true },
5739
+ });
5740
+ }
5741
+ };
5742
+ Groups$1.Users = Users$2;
5743
+ Groups$1.Roles = Roles$4;
5744
+
5745
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5746
+ class APIKeys extends APIResource {
5747
+ /**
5748
+ * Retrieves an API key in the project.
5749
+ *
5750
+ * @example
5751
+ * ```ts
5752
+ * const projectAPIKey =
5753
+ * await client.admin.organization.projects.apiKeys.retrieve(
5754
+ * 'api_key_id',
5755
+ * { project_id: 'project_id' },
5756
+ * );
5757
+ * ```
5758
+ */
5759
+ retrieve(apiKeyID, params, options) {
5760
+ const { project_id } = params;
5761
+ return this._client.get(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
5762
+ ...options,
5763
+ __security: { adminAPIKeyAuth: true },
5764
+ });
5765
+ }
5766
+ /**
5767
+ * Returns a list of API keys in the project.
5768
+ *
5769
+ * @example
5770
+ * ```ts
5771
+ * // Automatically fetches more pages as needed.
5772
+ * for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list(
5773
+ * 'project_id',
5774
+ * )) {
5775
+ * // ...
5776
+ * }
5777
+ * ```
5778
+ */
5779
+ list(projectID, query = {}, options) {
5780
+ return this._client.getAPIList(path `/organization/projects/${projectID}/api_keys`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5781
+ }
5782
+ /**
5783
+ * Deletes an API key from the project.
5784
+ *
5785
+ * Returns confirmation of the key deletion, or an error if the key belonged to a
5786
+ * service account.
5787
+ *
5788
+ * @example
5789
+ * ```ts
5790
+ * const apiKey =
5791
+ * await client.admin.organization.projects.apiKeys.delete(
5792
+ * 'api_key_id',
5793
+ * { project_id: 'project_id' },
5794
+ * );
5795
+ * ```
5796
+ */
5797
+ delete(apiKeyID, params, options) {
5798
+ const { project_id } = params;
5799
+ return this._client.delete(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
5800
+ ...options,
5801
+ __security: { adminAPIKeyAuth: true },
5802
+ });
5803
+ }
5804
+ }
5805
+
5806
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5807
+ class Certificates extends APIResource {
5808
+ /**
5809
+ * List certificates for this project.
5810
+ *
5811
+ * @example
5812
+ * ```ts
5813
+ * // Automatically fetches more pages as needed.
5814
+ * for await (const certificateListResponse of client.admin.organization.projects.certificates.list(
5815
+ * 'project_id',
5816
+ * )) {
5817
+ * // ...
5818
+ * }
5819
+ * ```
5820
+ */
5821
+ list(projectID, query = {}, options) {
5822
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5823
+ }
5824
+ /**
5825
+ * Activate certificates at the project level.
5826
+ *
5827
+ * You can atomically and idempotently activate up to 10 certificates at a time.
5828
+ *
5829
+ * @example
5830
+ * ```ts
5831
+ * // Automatically fetches more pages as needed.
5832
+ * for await (const certificateActivateResponse of client.admin.organization.projects.certificates.activate(
5833
+ * 'project_id',
5834
+ * { certificate_ids: ['cert_abc'] },
5835
+ * )) {
5836
+ * // ...
5837
+ * }
5838
+ * ```
5839
+ */
5840
+ activate(projectID, body, options) {
5841
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/activate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
5842
+ }
5843
+ /**
5844
+ * Deactivate certificates at the project level. You can atomically and
5845
+ * idempotently deactivate up to 10 certificates at a time.
5846
+ *
5847
+ * @example
5848
+ * ```ts
5849
+ * // Automatically fetches more pages as needed.
5850
+ * for await (const certificateDeactivateResponse of client.admin.organization.projects.certificates.deactivate(
5851
+ * 'project_id',
5852
+ * { certificate_ids: ['cert_abc'] },
5853
+ * )) {
5854
+ * // ...
5855
+ * }
5856
+ * ```
5857
+ */
5858
+ deactivate(projectID, body, options) {
5859
+ return this._client.getAPIList(path `/organization/projects/${projectID}/certificates/deactivate`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
5860
+ }
5861
+ }
5862
+
5863
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5864
+ class RateLimits extends APIResource {
5865
+ /**
5866
+ * Returns the rate limits per model for a project.
5867
+ *
5868
+ * @example
5869
+ * ```ts
5870
+ * // Automatically fetches more pages as needed.
5871
+ * for await (const projectRateLimit of client.admin.organization.projects.rateLimits.listRateLimits(
5872
+ * 'project_id',
5873
+ * )) {
5874
+ * // ...
5875
+ * }
5876
+ * ```
5877
+ */
5878
+ listRateLimits(projectID, query = {}, options) {
5879
+ return this._client.getAPIList(path `/organization/projects/${projectID}/rate_limits`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5880
+ }
5881
+ /**
5882
+ * Updates a project rate limit.
5883
+ *
5884
+ * @example
5885
+ * ```ts
5886
+ * const projectRateLimit =
5887
+ * await client.admin.organization.projects.rateLimits.updateRateLimit(
5888
+ * 'rate_limit_id',
5889
+ * { project_id: 'project_id' },
5890
+ * );
5891
+ * ```
5892
+ */
5893
+ updateRateLimit(rateLimitID, params, options) {
5894
+ const { project_id, ...body } = params;
5895
+ return this._client.post(path `/organization/projects/${project_id}/rate_limits/${rateLimitID}`, {
5896
+ body,
5897
+ ...options,
5898
+ __security: { adminAPIKeyAuth: true },
5899
+ });
5900
+ }
5901
+ }
5902
+
5903
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5904
+ let Roles$3 = class Roles extends APIResource {
5905
+ /**
5906
+ * Creates a custom role for a project.
5907
+ *
5908
+ * @example
5909
+ * ```ts
5910
+ * const role =
5911
+ * await client.admin.organization.projects.roles.create(
5912
+ * 'project_id',
5913
+ * { permissions: ['string'], role_name: 'role_name' },
5914
+ * );
5915
+ * ```
5916
+ */
5917
+ create(projectID, body, options) {
5918
+ return this._client.post(path `/projects/${projectID}/roles`, {
5919
+ body,
5920
+ ...options,
5921
+ __security: { adminAPIKeyAuth: true },
5922
+ });
5923
+ }
5924
+ /**
5925
+ * Updates an existing project role.
5926
+ *
5927
+ * @example
5928
+ * ```ts
5929
+ * const role =
5930
+ * await client.admin.organization.projects.roles.update(
5931
+ * 'role_id',
5932
+ * { project_id: 'project_id' },
5933
+ * );
5934
+ * ```
5935
+ */
5936
+ update(roleID, params, options) {
5937
+ const { project_id, ...body } = params;
5938
+ return this._client.post(path `/projects/${project_id}/roles/${roleID}`, {
5939
+ body,
5940
+ ...options,
5941
+ __security: { adminAPIKeyAuth: true },
5942
+ });
5943
+ }
5944
+ /**
5945
+ * Lists the roles configured for a project.
5946
+ *
5947
+ * @example
5948
+ * ```ts
5949
+ * // Automatically fetches more pages as needed.
5950
+ * for await (const role of client.admin.organization.projects.roles.list(
5951
+ * 'project_id',
5952
+ * )) {
5953
+ * // ...
5954
+ * }
5955
+ * ```
5956
+ */
5957
+ list(projectID, query = {}, options) {
5958
+ return this._client.getAPIList(path `/projects/${projectID}/roles`, (NextCursorPage), {
5959
+ query,
5960
+ ...options,
5961
+ __security: { adminAPIKeyAuth: true },
5962
+ });
5963
+ }
5964
+ /**
5965
+ * Deletes a custom role from a project.
5966
+ *
5967
+ * @example
5968
+ * ```ts
5969
+ * const role =
5970
+ * await client.admin.organization.projects.roles.delete(
5971
+ * 'role_id',
5972
+ * { project_id: 'project_id' },
5973
+ * );
5974
+ * ```
5975
+ */
5976
+ delete(roleID, params, options) {
5977
+ const { project_id } = params;
5978
+ return this._client.delete(path `/projects/${project_id}/roles/${roleID}`, {
5979
+ ...options,
5980
+ __security: { adminAPIKeyAuth: true },
5981
+ });
5982
+ }
5983
+ };
5984
+
5985
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5986
+ class ServiceAccounts extends APIResource {
5987
+ /**
5988
+ * Creates a new service account in the project. This also returns an unredacted
5989
+ * API key for the service account.
5990
+ *
5991
+ * @example
5992
+ * ```ts
5993
+ * const serviceAccount =
5994
+ * await client.admin.organization.projects.serviceAccounts.create(
5995
+ * 'project_id',
5996
+ * { name: 'name' },
5997
+ * );
5998
+ * ```
5999
+ */
6000
+ create(projectID, body, options) {
6001
+ return this._client.post(path `/organization/projects/${projectID}/service_accounts`, {
6002
+ body,
6003
+ ...options,
6004
+ __security: { adminAPIKeyAuth: true },
6005
+ });
6006
+ }
6007
+ /**
6008
+ * Retrieves a service account in the project.
6009
+ *
6010
+ * @example
6011
+ * ```ts
6012
+ * const projectServiceAccount =
6013
+ * await client.admin.organization.projects.serviceAccounts.retrieve(
6014
+ * 'service_account_id',
6015
+ * { project_id: 'project_id' },
6016
+ * );
6017
+ * ```
6018
+ */
6019
+ retrieve(serviceAccountID, params, options) {
6020
+ const { project_id } = params;
6021
+ return this._client.get(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
6022
+ ...options,
6023
+ __security: { adminAPIKeyAuth: true },
6024
+ });
6025
+ }
6026
+ /**
6027
+ * Returns a list of service accounts in the project.
6028
+ *
6029
+ * @example
6030
+ * ```ts
6031
+ * // Automatically fetches more pages as needed.
6032
+ * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
6033
+ * 'project_id',
6034
+ * )) {
6035
+ * // ...
6036
+ * }
6037
+ * ```
6038
+ */
6039
+ list(projectID, query = {}, options) {
6040
+ return this._client.getAPIList(path `/organization/projects/${projectID}/service_accounts`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6041
+ }
6042
+ /**
6043
+ * Deletes a service account from the project.
6044
+ *
6045
+ * Returns confirmation of service account deletion, or an error if the project is
6046
+ * archived (archived projects have no service accounts).
6047
+ *
6048
+ * @example
6049
+ * ```ts
6050
+ * const serviceAccount =
6051
+ * await client.admin.organization.projects.serviceAccounts.delete(
6052
+ * 'service_account_id',
6053
+ * { project_id: 'project_id' },
6054
+ * );
6055
+ * ```
6056
+ */
6057
+ delete(serviceAccountID, params, options) {
6058
+ const { project_id } = params;
6059
+ return this._client.delete(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
6060
+ }
6061
+ }
6062
+
6063
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6064
+ let Roles$2 = class Roles extends APIResource {
6065
+ /**
6066
+ * Assigns a project role to a group within a project.
6067
+ *
6068
+ * @example
6069
+ * ```ts
6070
+ * const role =
6071
+ * await client.admin.organization.projects.groups.roles.create(
6072
+ * 'group_id',
6073
+ * { project_id: 'project_id', role_id: 'role_id' },
6074
+ * );
6075
+ * ```
6076
+ */
6077
+ create(groupID, params, options) {
6078
+ const { project_id, ...body } = params;
6079
+ return this._client.post(path `/projects/${project_id}/groups/${groupID}/roles`, {
6080
+ body,
6081
+ ...options,
6082
+ __security: { adminAPIKeyAuth: true },
6083
+ });
6084
+ }
6085
+ /**
6086
+ * Lists the project roles assigned to a group within a project.
6087
+ *
6088
+ * @example
6089
+ * ```ts
6090
+ * // Automatically fetches more pages as needed.
6091
+ * for await (const roleListResponse of client.admin.organization.projects.groups.roles.list(
6092
+ * 'group_id',
6093
+ * { project_id: 'project_id' },
6094
+ * )) {
6095
+ * // ...
6096
+ * }
6097
+ * ```
6098
+ */
6099
+ list(groupID, params, options) {
6100
+ const { project_id, ...query } = params;
6101
+ return this._client.getAPIList(path `/projects/${project_id}/groups/${groupID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6102
+ }
6103
+ /**
6104
+ * Unassigns a project role from a group within a project.
6105
+ *
6106
+ * @example
6107
+ * ```ts
6108
+ * const role =
6109
+ * await client.admin.organization.projects.groups.roles.delete(
6110
+ * 'role_id',
6111
+ * { project_id: 'project_id', group_id: 'group_id' },
6112
+ * );
6113
+ * ```
6114
+ */
6115
+ delete(roleID, params, options) {
6116
+ const { project_id, group_id } = params;
6117
+ return this._client.delete(path `/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
6118
+ ...options,
6119
+ __security: { adminAPIKeyAuth: true },
6120
+ });
6121
+ }
6122
+ };
6123
+
6124
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6125
+ class Groups extends APIResource {
6126
+ constructor() {
6127
+ super(...arguments);
6128
+ this.roles = new Roles$2(this._client);
6129
+ }
6130
+ /**
6131
+ * Grants a group access to a project.
6132
+ *
6133
+ * @example
6134
+ * ```ts
6135
+ * const projectGroup =
6136
+ * await client.admin.organization.projects.groups.create(
6137
+ * 'project_id',
6138
+ * { group_id: 'group_id', role: 'role' },
6139
+ * );
6140
+ * ```
6141
+ */
6142
+ create(projectID, body, options) {
6143
+ return this._client.post(path `/organization/projects/${projectID}/groups`, {
6144
+ body,
6145
+ ...options,
6146
+ __security: { adminAPIKeyAuth: true },
6147
+ });
6148
+ }
6149
+ /**
6150
+ * Lists the groups that have access to a project.
6151
+ *
6152
+ * @example
6153
+ * ```ts
6154
+ * // Automatically fetches more pages as needed.
6155
+ * for await (const projectGroup of client.admin.organization.projects.groups.list(
6156
+ * 'project_id',
6157
+ * )) {
6158
+ * // ...
6159
+ * }
6160
+ * ```
6161
+ */
6162
+ list(projectID, query = {}, options) {
6163
+ return this._client.getAPIList(path `/organization/projects/${projectID}/groups`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6164
+ }
6165
+ /**
6166
+ * Revokes a group's access to a project.
6167
+ *
6168
+ * @example
6169
+ * ```ts
6170
+ * const group =
6171
+ * await client.admin.organization.projects.groups.delete(
6172
+ * 'group_id',
6173
+ * { project_id: 'project_id' },
6174
+ * );
6175
+ * ```
6176
+ */
6177
+ delete(groupID, params, options) {
6178
+ const { project_id } = params;
6179
+ return this._client.delete(path `/organization/projects/${project_id}/groups/${groupID}`, {
6180
+ ...options,
6181
+ __security: { adminAPIKeyAuth: true },
6182
+ });
6183
+ }
6184
+ }
6185
+ Groups.Roles = Roles$2;
6186
+
6187
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6188
+ let Roles$1 = class Roles extends APIResource {
6189
+ /**
6190
+ * Assigns a project role to a user within a project.
6191
+ *
6192
+ * @example
6193
+ * ```ts
6194
+ * const role =
6195
+ * await client.admin.organization.projects.users.roles.create(
6196
+ * 'user_id',
6197
+ * { project_id: 'project_id', role_id: 'role_id' },
6198
+ * );
6199
+ * ```
6200
+ */
6201
+ create(userID, params, options) {
6202
+ const { project_id, ...body } = params;
6203
+ return this._client.post(path `/projects/${project_id}/users/${userID}/roles`, {
6204
+ body,
6205
+ ...options,
6206
+ __security: { adminAPIKeyAuth: true },
6207
+ });
6208
+ }
6209
+ /**
6210
+ * Lists the project roles assigned to a user within a project.
6211
+ *
6212
+ * @example
6213
+ * ```ts
6214
+ * // Automatically fetches more pages as needed.
6215
+ * for await (const roleListResponse of client.admin.organization.projects.users.roles.list(
6216
+ * 'user_id',
6217
+ * { project_id: 'project_id' },
6218
+ * )) {
6219
+ * // ...
6220
+ * }
6221
+ * ```
6222
+ */
6223
+ list(userID, params, options) {
6224
+ const { project_id, ...query } = params;
6225
+ return this._client.getAPIList(path `/projects/${project_id}/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6226
+ }
6227
+ /**
6228
+ * Unassigns a project role from a user within a project.
6229
+ *
6230
+ * @example
6231
+ * ```ts
6232
+ * const role =
6233
+ * await client.admin.organization.projects.users.roles.delete(
6234
+ * 'role_id',
6235
+ * { project_id: 'project_id', user_id: 'user_id' },
6236
+ * );
6237
+ * ```
6238
+ */
6239
+ delete(roleID, params, options) {
6240
+ const { project_id, user_id } = params;
6241
+ return this._client.delete(path `/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
6242
+ ...options,
6243
+ __security: { adminAPIKeyAuth: true },
6244
+ });
6245
+ }
6246
+ };
6247
+
6248
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6249
+ let Users$1 = class Users extends APIResource {
6250
+ constructor() {
6251
+ super(...arguments);
6252
+ this.roles = new Roles$1(this._client);
6253
+ }
6254
+ /**
6255
+ * Adds a user to the project. Users must already be members of the organization to
6256
+ * be added to a project.
6257
+ *
6258
+ * @example
6259
+ * ```ts
6260
+ * const projectUser =
6261
+ * await client.admin.organization.projects.users.create(
6262
+ * 'project_id',
6263
+ * { role: 'role' },
6264
+ * );
6265
+ * ```
6266
+ */
6267
+ create(projectID, body, options) {
6268
+ return this._client.post(path `/organization/projects/${projectID}/users`, {
6269
+ body,
6270
+ ...options,
6271
+ __security: { adminAPIKeyAuth: true },
6272
+ });
6273
+ }
6274
+ /**
6275
+ * Retrieves a user in the project.
6276
+ *
6277
+ * @example
6278
+ * ```ts
6279
+ * const projectUser =
6280
+ * await client.admin.organization.projects.users.retrieve(
6281
+ * 'user_id',
6282
+ * { project_id: 'project_id' },
6283
+ * );
6284
+ * ```
6285
+ */
6286
+ retrieve(userID, params, options) {
6287
+ const { project_id } = params;
6288
+ return this._client.get(path `/organization/projects/${project_id}/users/${userID}`, {
6289
+ ...options,
6290
+ __security: { adminAPIKeyAuth: true },
6291
+ });
6292
+ }
6293
+ /**
6294
+ * Modifies a user's role in the project.
6295
+ *
6296
+ * @example
6297
+ * ```ts
6298
+ * const projectUser =
6299
+ * await client.admin.organization.projects.users.update(
6300
+ * 'user_id',
6301
+ * { project_id: 'project_id' },
6302
+ * );
6303
+ * ```
6304
+ */
6305
+ update(userID, params, options) {
6306
+ const { project_id, ...body } = params;
6307
+ return this._client.post(path `/organization/projects/${project_id}/users/${userID}`, {
6308
+ body,
6309
+ ...options,
6310
+ __security: { adminAPIKeyAuth: true },
6311
+ });
6312
+ }
6313
+ /**
6314
+ * Returns a list of users in the project.
6315
+ *
6316
+ * @example
6317
+ * ```ts
6318
+ * // Automatically fetches more pages as needed.
6319
+ * for await (const projectUser of client.admin.organization.projects.users.list(
6320
+ * 'project_id',
6321
+ * )) {
6322
+ * // ...
6323
+ * }
6324
+ * ```
6325
+ */
6326
+ list(projectID, query = {}, options) {
6327
+ return this._client.getAPIList(path `/organization/projects/${projectID}/users`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6328
+ }
6329
+ /**
6330
+ * Deletes a user from the project.
6331
+ *
6332
+ * Returns confirmation of project user deletion, or an error if the project is
6333
+ * archived (archived projects have no users).
6334
+ *
6335
+ * @example
6336
+ * ```ts
6337
+ * const user =
6338
+ * await client.admin.organization.projects.users.delete(
6339
+ * 'user_id',
6340
+ * { project_id: 'project_id' },
6341
+ * );
6342
+ * ```
6343
+ */
6344
+ delete(userID, params, options) {
6345
+ const { project_id } = params;
6346
+ return this._client.delete(path `/organization/projects/${project_id}/users/${userID}`, {
6347
+ ...options,
6348
+ __security: { adminAPIKeyAuth: true },
6349
+ });
6350
+ }
6351
+ };
6352
+ Users$1.Roles = Roles$1;
6353
+
6354
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6355
+ class Projects extends APIResource {
6356
+ constructor() {
6357
+ super(...arguments);
6358
+ this.users = new Users$1(this._client);
6359
+ this.serviceAccounts = new ServiceAccounts(this._client);
6360
+ this.apiKeys = new APIKeys(this._client);
6361
+ this.rateLimits = new RateLimits(this._client);
6362
+ this.groups = new Groups(this._client);
6363
+ this.roles = new Roles$3(this._client);
6364
+ this.certificates = new Certificates(this._client);
6365
+ }
6366
+ /**
6367
+ * Create a new project in the organization. Projects can be created and archived,
6368
+ * but cannot be deleted.
6369
+ *
6370
+ * @example
6371
+ * ```ts
6372
+ * const project =
6373
+ * await client.admin.organization.projects.create({
6374
+ * name: 'name',
6375
+ * });
6376
+ * ```
6377
+ */
6378
+ create(body, options) {
6379
+ return this._client.post('/organization/projects', {
6380
+ body,
6381
+ ...options,
6382
+ __security: { adminAPIKeyAuth: true },
6383
+ });
6384
+ }
6385
+ /**
6386
+ * Retrieves a project.
6387
+ *
6388
+ * @example
6389
+ * ```ts
6390
+ * const project =
6391
+ * await client.admin.organization.projects.retrieve(
6392
+ * 'project_id',
6393
+ * );
6394
+ * ```
6395
+ */
6396
+ retrieve(projectID, options) {
6397
+ return this._client.get(path `/organization/projects/${projectID}`, {
6398
+ ...options,
6399
+ __security: { adminAPIKeyAuth: true },
6400
+ });
6401
+ }
6402
+ /**
6403
+ * Modifies a project in the organization.
6404
+ *
6405
+ * @example
6406
+ * ```ts
6407
+ * const project =
6408
+ * await client.admin.organization.projects.update(
6409
+ * 'project_id',
6410
+ * );
6411
+ * ```
6412
+ */
6413
+ update(projectID, body, options) {
6414
+ return this._client.post(path `/organization/projects/${projectID}`, {
6415
+ body,
6416
+ ...options,
6417
+ __security: { adminAPIKeyAuth: true },
6418
+ });
6419
+ }
6420
+ /**
6421
+ * Returns a list of projects.
6422
+ *
6423
+ * @example
6424
+ * ```ts
6425
+ * // Automatically fetches more pages as needed.
6426
+ * for await (const project of client.admin.organization.projects.list()) {
6427
+ * // ...
6428
+ * }
6429
+ * ```
6430
+ */
6431
+ list(query = {}, options) {
6432
+ return this._client.getAPIList('/organization/projects', (ConversationCursorPage), {
6433
+ query,
6434
+ ...options,
6435
+ __security: { adminAPIKeyAuth: true },
6436
+ });
6437
+ }
6438
+ /**
6439
+ * Archives a project in the organization. Archived projects cannot be used or
6440
+ * updated.
6441
+ *
6442
+ * @example
6443
+ * ```ts
6444
+ * const project =
6445
+ * await client.admin.organization.projects.archive(
6446
+ * 'project_id',
6447
+ * );
6448
+ * ```
6449
+ */
6450
+ archive(projectID, options) {
6451
+ return this._client.post(path `/organization/projects/${projectID}/archive`, {
6452
+ ...options,
6453
+ __security: { adminAPIKeyAuth: true },
6454
+ });
6455
+ }
6456
+ }
6457
+ Projects.Users = Users$1;
6458
+ Projects.ServiceAccounts = ServiceAccounts;
6459
+ Projects.APIKeys = APIKeys;
6460
+ Projects.RateLimits = RateLimits;
6461
+ Projects.Groups = Groups;
6462
+ Projects.Roles = Roles$3;
6463
+ Projects.Certificates = Certificates;
6464
+
6465
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6466
+ class Roles extends APIResource {
6467
+ /**
6468
+ * Assigns an organization role to a user within the organization.
6469
+ *
6470
+ * @example
6471
+ * ```ts
6472
+ * const role =
6473
+ * await client.admin.organization.users.roles.create(
6474
+ * 'user_id',
6475
+ * { role_id: 'role_id' },
6476
+ * );
6477
+ * ```
6478
+ */
6479
+ create(userID, body, options) {
6480
+ return this._client.post(path `/organization/users/${userID}/roles`, {
6481
+ body,
6482
+ ...options,
6483
+ __security: { adminAPIKeyAuth: true },
6484
+ });
6485
+ }
6486
+ /**
6487
+ * Lists the organization roles assigned to a user within the organization.
6488
+ *
6489
+ * @example
6490
+ * ```ts
6491
+ * // Automatically fetches more pages as needed.
6492
+ * for await (const roleListResponse of client.admin.organization.users.roles.list(
6493
+ * 'user_id',
6494
+ * )) {
6495
+ * // ...
6496
+ * }
6497
+ * ```
6498
+ */
6499
+ list(userID, query = {}, options) {
6500
+ return this._client.getAPIList(path `/organization/users/${userID}/roles`, (NextCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6501
+ }
6502
+ /**
6503
+ * Unassigns an organization role from a user within the organization.
6504
+ *
6505
+ * @example
6506
+ * ```ts
6507
+ * const role =
6508
+ * await client.admin.organization.users.roles.delete(
6509
+ * 'role_id',
6510
+ * { user_id: 'user_id' },
6511
+ * );
6512
+ * ```
6513
+ */
6514
+ delete(roleID, params, options) {
6515
+ const { user_id } = params;
6516
+ return this._client.delete(path `/organization/users/${user_id}/roles/${roleID}`, {
4813
6517
  ...options,
4814
- headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
4815
- };
4816
- runner._run(() => runner._runTools(client, params, opts));
4817
- return runner;
6518
+ __security: { adminAPIKeyAuth: true },
6519
+ });
4818
6520
  }
4819
6521
  }
4820
6522
 
4821
6523
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4822
- /**
4823
- * Given a list of messages comprising a conversation, the model will return a response.
4824
- */
4825
- let Completions$1 = class Completions extends APIResource {
6524
+ class Users extends APIResource {
4826
6525
  constructor() {
4827
6526
  super(...arguments);
4828
- this.messages = new Messages$1(this._client);
4829
- }
4830
- create(body, options) {
4831
- return this._client.post('/chat/completions', { body, ...options, stream: body.stream ?? false });
6527
+ this.roles = new Roles(this._client);
4832
6528
  }
4833
6529
  /**
4834
- * Get a stored chat completion. Only Chat Completions that have been created with
4835
- * the `store` parameter set to `true` will be returned.
6530
+ * Retrieves a user by their identifier.
4836
6531
  *
4837
6532
  * @example
4838
6533
  * ```ts
4839
- * const chatCompletion =
4840
- * await client.chat.completions.retrieve('completion_id');
6534
+ * const organizationUser =
6535
+ * await client.admin.organization.users.retrieve('user_id');
4841
6536
  * ```
4842
6537
  */
4843
- retrieve(completionID, options) {
4844
- return this._client.get(path `/chat/completions/${completionID}`, options);
6538
+ retrieve(userID, options) {
6539
+ return this._client.get(path `/organization/users/${userID}`, {
6540
+ ...options,
6541
+ __security: { adminAPIKeyAuth: true },
6542
+ });
4845
6543
  }
4846
6544
  /**
4847
- * Modify a stored chat completion. Only Chat Completions that have been created
4848
- * with the `store` parameter set to `true` can be modified. Currently, the only
4849
- * supported modification is to update the `metadata` field.
6545
+ * Modifies a user's role in the organization.
4850
6546
  *
4851
6547
  * @example
4852
6548
  * ```ts
4853
- * const chatCompletion = await client.chat.completions.update(
4854
- * 'completion_id',
4855
- * { metadata: { foo: 'string' } },
4856
- * );
6549
+ * const organizationUser =
6550
+ * await client.admin.organization.users.update('user_id');
4857
6551
  * ```
4858
6552
  */
4859
- update(completionID, body, options) {
4860
- return this._client.post(path `/chat/completions/${completionID}`, { body, ...options });
6553
+ update(userID, body, options) {
6554
+ return this._client.post(path `/organization/users/${userID}`, {
6555
+ body,
6556
+ ...options,
6557
+ __security: { adminAPIKeyAuth: true },
6558
+ });
4861
6559
  }
4862
6560
  /**
4863
- * List stored Chat Completions. Only Chat Completions that have been stored with
4864
- * the `store` parameter set to `true` will be returned.
6561
+ * Lists all of the users in the organization.
4865
6562
  *
4866
6563
  * @example
4867
6564
  * ```ts
4868
6565
  * // Automatically fetches more pages as needed.
4869
- * for await (const chatCompletion of client.chat.completions.list()) {
6566
+ * for await (const organizationUser of client.admin.organization.users.list()) {
4870
6567
  * // ...
4871
6568
  * }
4872
6569
  * ```
4873
6570
  */
4874
6571
  list(query = {}, options) {
4875
- return this._client.getAPIList('/chat/completions', (CursorPage), { query, ...options });
6572
+ return this._client.getAPIList('/organization/users', (ConversationCursorPage), {
6573
+ query,
6574
+ ...options,
6575
+ __security: { adminAPIKeyAuth: true },
6576
+ });
4876
6577
  }
4877
6578
  /**
4878
- * Delete a stored chat completion. Only Chat Completions that have been created
4879
- * with the `store` parameter set to `true` can be deleted.
6579
+ * Deletes a user from the organization.
4880
6580
  *
4881
6581
  * @example
4882
6582
  * ```ts
4883
- * const chatCompletionDeleted =
4884
- * await client.chat.completions.delete('completion_id');
6583
+ * const user = await client.admin.organization.users.delete(
6584
+ * 'user_id',
6585
+ * );
4885
6586
  * ```
4886
6587
  */
4887
- delete(completionID, options) {
4888
- return this._client.delete(path `/chat/completions/${completionID}`, options);
4889
- }
4890
- parse(body, options) {
4891
- validateInputTools(body.tools);
4892
- return this._client.chat.completions
4893
- .create(body, {
6588
+ delete(userID, options) {
6589
+ return this._client.delete(path `/organization/users/${userID}`, {
4894
6590
  ...options,
4895
- headers: {
4896
- ...options?.headers,
4897
- 'X-Stainless-Helper-Method': 'chat.completions.parse',
4898
- },
4899
- })
4900
- ._thenUnwrap((completion) => parseChatCompletion(completion, body));
4901
- }
4902
- runTools(body, options) {
4903
- if (body.stream) {
4904
- return ChatCompletionStreamingRunner.runTools(this._client, body, options);
4905
- }
4906
- return ChatCompletionRunner.runTools(this._client, body, options);
4907
- }
4908
- /**
4909
- * Creates a chat completion stream
4910
- */
4911
- stream(body, options) {
4912
- return ChatCompletionStream.createChatCompletion(this._client, body, options);
6591
+ __security: { adminAPIKeyAuth: true },
6592
+ });
4913
6593
  }
4914
- };
4915
- Completions$1.Messages = Messages$1;
6594
+ }
6595
+ Users.Roles = Roles;
4916
6596
 
4917
6597
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4918
- class Chat extends APIResource {
6598
+ class Organization extends APIResource {
4919
6599
  constructor() {
4920
6600
  super(...arguments);
4921
- this.completions = new Completions$1(this._client);
6601
+ this.auditLogs = new AuditLogs(this._client);
6602
+ this.adminAPIKeys = new AdminAPIKeys(this._client);
6603
+ this.usage = new Usage(this._client);
6604
+ this.invites = new Invites(this._client);
6605
+ this.users = new Users(this._client);
6606
+ this.groups = new Groups$1(this._client);
6607
+ this.roles = new Roles$5(this._client);
6608
+ this.certificates = new Certificates$1(this._client);
6609
+ this.projects = new Projects(this._client);
6610
+ }
6611
+ }
6612
+ Organization.AuditLogs = AuditLogs;
6613
+ Organization.AdminAPIKeys = AdminAPIKeys;
6614
+ Organization.Usage = Usage;
6615
+ Organization.Invites = Invites;
6616
+ Organization.Users = Users;
6617
+ Organization.Groups = Groups$1;
6618
+ Organization.Roles = Roles$5;
6619
+ Organization.Certificates = Certificates$1;
6620
+ Organization.Projects = Projects;
6621
+
6622
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6623
+ class Admin extends APIResource {
6624
+ constructor() {
6625
+ super(...arguments);
6626
+ this.organization = new Organization(this._client);
4922
6627
  }
4923
6628
  }
4924
- Chat.Completions = Completions$1;
6629
+ Admin.Organization = Organization;
4925
6630
 
4926
6631
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4927
6632
  const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
@@ -5018,6 +6723,7 @@ class Speech extends APIResource {
5018
6723
  body,
5019
6724
  ...options,
5020
6725
  headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
6726
+ __security: { bearerAuth: true },
5021
6727
  __binaryResponse: true,
5022
6728
  });
5023
6729
  }
@@ -5034,6 +6740,7 @@ class Transcriptions extends APIResource {
5034
6740
  ...options,
5035
6741
  stream: body.stream ?? false,
5036
6742
  __metadata: { model: body.model },
6743
+ __security: { bearerAuth: true },
5037
6744
  }, this._client));
5038
6745
  }
5039
6746
  }
@@ -5044,7 +6751,7 @@ class Transcriptions extends APIResource {
5044
6751
  */
5045
6752
  class Translations extends APIResource {
5046
6753
  create(body, options) {
5047
- return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
6754
+ return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } }, this._client));
5048
6755
  }
5049
6756
  }
5050
6757
 
@@ -5070,19 +6777,23 @@ class Batches extends APIResource {
5070
6777
  * Creates and executes a batch from an uploaded file of requests
5071
6778
  */
5072
6779
  create(body, options) {
5073
- return this._client.post('/batches', { body, ...options });
6780
+ return this._client.post('/batches', { body, ...options, __security: { bearerAuth: true } });
5074
6781
  }
5075
6782
  /**
5076
6783
  * Retrieves a batch.
5077
6784
  */
5078
6785
  retrieve(batchID, options) {
5079
- return this._client.get(path `/batches/${batchID}`, options);
6786
+ return this._client.get(path `/batches/${batchID}`, { ...options, __security: { bearerAuth: true } });
5080
6787
  }
5081
6788
  /**
5082
6789
  * List your organization's batches.
5083
6790
  */
5084
6791
  list(query = {}, options) {
5085
- return this._client.getAPIList('/batches', (CursorPage), { query, ...options });
6792
+ return this._client.getAPIList('/batches', (CursorPage), {
6793
+ query,
6794
+ ...options,
6795
+ __security: { bearerAuth: true },
6796
+ });
5086
6797
  }
5087
6798
  /**
5088
6799
  * Cancels an in-progress batch. The batch will be in status `cancelling` for up to
@@ -5090,7 +6801,10 @@ class Batches extends APIResource {
5090
6801
  * (if any) available in the output file.
5091
6802
  */
5092
6803
  cancel(batchID, options) {
5093
- return this._client.post(path `/batches/${batchID}/cancel`, options);
6804
+ return this._client.post(path `/batches/${batchID}/cancel`, {
6805
+ ...options,
6806
+ __security: { bearerAuth: true },
6807
+ });
5094
6808
  }
5095
6809
  }
5096
6810
 
@@ -5109,6 +6823,7 @@ class Assistants extends APIResource {
5109
6823
  body,
5110
6824
  ...options,
5111
6825
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6826
+ __security: { bearerAuth: true },
5112
6827
  });
5113
6828
  }
5114
6829
  /**
@@ -5120,6 +6835,7 @@ class Assistants extends APIResource {
5120
6835
  return this._client.get(path `/assistants/${assistantID}`, {
5121
6836
  ...options,
5122
6837
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6838
+ __security: { bearerAuth: true },
5123
6839
  });
5124
6840
  }
5125
6841
  /**
@@ -5132,6 +6848,7 @@ class Assistants extends APIResource {
5132
6848
  body,
5133
6849
  ...options,
5134
6850
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6851
+ __security: { bearerAuth: true },
5135
6852
  });
5136
6853
  }
5137
6854
  /**
@@ -5144,6 +6861,7 @@ class Assistants extends APIResource {
5144
6861
  query,
5145
6862
  ...options,
5146
6863
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6864
+ __security: { bearerAuth: true },
5147
6865
  });
5148
6866
  }
5149
6867
  /**
@@ -5155,6 +6873,7 @@ class Assistants extends APIResource {
5155
6873
  return this._client.delete(path `/assistants/${assistantID}`, {
5156
6874
  ...options,
5157
6875
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6876
+ __security: { bearerAuth: true },
5158
6877
  });
5159
6878
  }
5160
6879
  }
@@ -5181,6 +6900,7 @@ let Sessions$1 = class Sessions extends APIResource {
5181
6900
  body,
5182
6901
  ...options,
5183
6902
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6903
+ __security: { bearerAuth: true },
5184
6904
  });
5185
6905
  }
5186
6906
  };
@@ -5207,6 +6927,7 @@ class TranscriptionSessions extends APIResource {
5207
6927
  body,
5208
6928
  ...options,
5209
6929
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6930
+ __security: { bearerAuth: true },
5210
6931
  });
5211
6932
  }
5212
6933
  }
@@ -5244,6 +6965,7 @@ class Sessions extends APIResource {
5244
6965
  body,
5245
6966
  ...options,
5246
6967
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
6968
+ __security: { bearerAuth: true },
5247
6969
  });
5248
6970
  }
5249
6971
  /**
@@ -5261,6 +6983,7 @@ class Sessions extends APIResource {
5261
6983
  return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
5262
6984
  ...options,
5263
6985
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
6986
+ __security: { bearerAuth: true },
5264
6987
  });
5265
6988
  }
5266
6989
  }
@@ -5280,6 +7003,7 @@ let Threads$1 = class Threads extends APIResource {
5280
7003
  return this._client.get(path `/chatkit/threads/${threadID}`, {
5281
7004
  ...options,
5282
7005
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
7006
+ __security: { bearerAuth: true },
5283
7007
  });
5284
7008
  }
5285
7009
  /**
@@ -5298,6 +7022,7 @@ let Threads$1 = class Threads extends APIResource {
5298
7022
  query,
5299
7023
  ...options,
5300
7024
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
7025
+ __security: { bearerAuth: true },
5301
7026
  });
5302
7027
  }
5303
7028
  /**
@@ -5314,6 +7039,7 @@ let Threads$1 = class Threads extends APIResource {
5314
7039
  return this._client.delete(path `/chatkit/threads/${threadID}`, {
5315
7040
  ...options,
5316
7041
  headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
7042
+ __security: { bearerAuth: true },
5317
7043
  });
5318
7044
  }
5319
7045
  /**
@@ -5330,7 +7056,12 @@ let Threads$1 = class Threads extends APIResource {
5330
7056
  * ```
5331
7057
  */
5332
7058
  listItems(threadID, query = {}, options) {
5333
- return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), { query, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) });
7059
+ return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), {
7060
+ query,
7061
+ ...options,
7062
+ headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
7063
+ __security: { bearerAuth: true },
7064
+ });
5334
7065
  }
5335
7066
  };
5336
7067
 
@@ -5362,6 +7093,7 @@ class Messages extends APIResource {
5362
7093
  body,
5363
7094
  ...options,
5364
7095
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7096
+ __security: { bearerAuth: true },
5365
7097
  });
5366
7098
  }
5367
7099
  /**
@@ -5374,6 +7106,7 @@ class Messages extends APIResource {
5374
7106
  return this._client.get(path `/threads/${thread_id}/messages/${messageID}`, {
5375
7107
  ...options,
5376
7108
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7109
+ __security: { bearerAuth: true },
5377
7110
  });
5378
7111
  }
5379
7112
  /**
@@ -5387,6 +7120,7 @@ class Messages extends APIResource {
5387
7120
  body,
5388
7121
  ...options,
5389
7122
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7123
+ __security: { bearerAuth: true },
5390
7124
  });
5391
7125
  }
5392
7126
  /**
@@ -5399,6 +7133,7 @@ class Messages extends APIResource {
5399
7133
  query,
5400
7134
  ...options,
5401
7135
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7136
+ __security: { bearerAuth: true },
5402
7137
  });
5403
7138
  }
5404
7139
  /**
@@ -5411,6 +7146,7 @@ class Messages extends APIResource {
5411
7146
  return this._client.delete(path `/threads/${thread_id}/messages/${messageID}`, {
5412
7147
  ...options,
5413
7148
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7149
+ __security: { bearerAuth: true },
5414
7150
  });
5415
7151
  }
5416
7152
  }
@@ -5433,6 +7169,7 @@ class Steps extends APIResource {
5433
7169
  query,
5434
7170
  ...options,
5435
7171
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7172
+ __security: { bearerAuth: true },
5436
7173
  });
5437
7174
  }
5438
7175
  /**
@@ -5446,6 +7183,7 @@ class Steps extends APIResource {
5446
7183
  query,
5447
7184
  ...options,
5448
7185
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7186
+ __security: { bearerAuth: true },
5449
7187
  });
5450
7188
  }
5451
7189
  }
@@ -6049,6 +7787,7 @@ let Runs$1 = class Runs extends APIResource {
6049
7787
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6050
7788
  stream: params.stream ?? false,
6051
7789
  __synthesizeEventData: true,
7790
+ __security: { bearerAuth: true },
6052
7791
  });
6053
7792
  }
6054
7793
  /**
@@ -6061,6 +7800,7 @@ let Runs$1 = class Runs extends APIResource {
6061
7800
  return this._client.get(path `/threads/${thread_id}/runs/${runID}`, {
6062
7801
  ...options,
6063
7802
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7803
+ __security: { bearerAuth: true },
6064
7804
  });
6065
7805
  }
6066
7806
  /**
@@ -6074,6 +7814,7 @@ let Runs$1 = class Runs extends APIResource {
6074
7814
  body,
6075
7815
  ...options,
6076
7816
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7817
+ __security: { bearerAuth: true },
6077
7818
  });
6078
7819
  }
6079
7820
  /**
@@ -6086,6 +7827,7 @@ let Runs$1 = class Runs extends APIResource {
6086
7827
  query,
6087
7828
  ...options,
6088
7829
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7830
+ __security: { bearerAuth: true },
6089
7831
  });
6090
7832
  }
6091
7833
  /**
@@ -6098,6 +7840,7 @@ let Runs$1 = class Runs extends APIResource {
6098
7840
  return this._client.post(path `/threads/${thread_id}/runs/${runID}/cancel`, {
6099
7841
  ...options,
6100
7842
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7843
+ __security: { bearerAuth: true },
6101
7844
  });
6102
7845
  }
6103
7846
  /**
@@ -6180,6 +7923,7 @@ let Runs$1 = class Runs extends APIResource {
6180
7923
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6181
7924
  stream: params.stream ?? false,
6182
7925
  __synthesizeEventData: true,
7926
+ __security: { bearerAuth: true },
6183
7927
  });
6184
7928
  }
6185
7929
  /**
@@ -6224,6 +7968,7 @@ class Threads extends APIResource {
6224
7968
  body,
6225
7969
  ...options,
6226
7970
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7971
+ __security: { bearerAuth: true },
6227
7972
  });
6228
7973
  }
6229
7974
  /**
@@ -6235,6 +7980,7 @@ class Threads extends APIResource {
6235
7980
  return this._client.get(path `/threads/${threadID}`, {
6236
7981
  ...options,
6237
7982
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7983
+ __security: { bearerAuth: true },
6238
7984
  });
6239
7985
  }
6240
7986
  /**
@@ -6247,6 +7993,7 @@ class Threads extends APIResource {
6247
7993
  body,
6248
7994
  ...options,
6249
7995
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
7996
+ __security: { bearerAuth: true },
6250
7997
  });
6251
7998
  }
6252
7999
  /**
@@ -6258,6 +8005,7 @@ class Threads extends APIResource {
6258
8005
  return this._client.delete(path `/threads/${threadID}`, {
6259
8006
  ...options,
6260
8007
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
8008
+ __security: { bearerAuth: true },
6261
8009
  });
6262
8010
  }
6263
8011
  createAndRun(body, options) {
@@ -6267,6 +8015,7 @@ class Threads extends APIResource {
6267
8015
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
6268
8016
  stream: body.stream ?? false,
6269
8017
  __synthesizeEventData: true,
8018
+ __security: { bearerAuth: true },
6270
8019
  });
6271
8020
  }
6272
8021
  /**
@@ -6309,7 +8058,12 @@ Beta.Threads = Threads;
6309
8058
  */
6310
8059
  class Completions extends APIResource {
6311
8060
  create(body, options) {
6312
- return this._client.post('/completions', { body, ...options, stream: body.stream ?? false });
8061
+ return this._client.post('/completions', {
8062
+ body,
8063
+ ...options,
8064
+ stream: body.stream ?? false,
8065
+ __security: { bearerAuth: true },
8066
+ });
6313
8067
  }
6314
8068
  }
6315
8069
 
@@ -6323,6 +8077,7 @@ let Content$2 = class Content extends APIResource {
6323
8077
  return this._client.get(path `/containers/${container_id}/files/${fileID}/content`, {
6324
8078
  ...options,
6325
8079
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8080
+ __security: { bearerAuth: true },
6326
8081
  __binaryResponse: true,
6327
8082
  });
6328
8083
  }
@@ -6341,14 +8096,17 @@ let Files$2 = class Files extends APIResource {
6341
8096
  * a JSON request with a file ID.
6342
8097
  */
6343
8098
  create(containerID, body, options) {
6344
- return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
8099
+ return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6345
8100
  }
6346
8101
  /**
6347
8102
  * Retrieve Container File
6348
8103
  */
6349
8104
  retrieve(fileID, params, options) {
6350
8105
  const { container_id } = params;
6351
- return this._client.get(path `/containers/${container_id}/files/${fileID}`, options);
8106
+ return this._client.get(path `/containers/${container_id}/files/${fileID}`, {
8107
+ ...options,
8108
+ __security: { bearerAuth: true },
8109
+ });
6352
8110
  }
6353
8111
  /**
6354
8112
  * List Container files
@@ -6357,6 +8115,7 @@ let Files$2 = class Files extends APIResource {
6357
8115
  return this._client.getAPIList(path `/containers/${containerID}/files`, (CursorPage), {
6358
8116
  query,
6359
8117
  ...options,
8118
+ __security: { bearerAuth: true },
6360
8119
  });
6361
8120
  }
6362
8121
  /**
@@ -6367,6 +8126,7 @@ let Files$2 = class Files extends APIResource {
6367
8126
  return this._client.delete(path `/containers/${container_id}/files/${fileID}`, {
6368
8127
  ...options,
6369
8128
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8129
+ __security: { bearerAuth: true },
6370
8130
  });
6371
8131
  }
6372
8132
  };
@@ -6382,19 +8142,26 @@ class Containers extends APIResource {
6382
8142
  * Create Container
6383
8143
  */
6384
8144
  create(body, options) {
6385
- return this._client.post('/containers', { body, ...options });
8145
+ return this._client.post('/containers', { body, ...options, __security: { bearerAuth: true } });
6386
8146
  }
6387
8147
  /**
6388
8148
  * Retrieve Container
6389
8149
  */
6390
8150
  retrieve(containerID, options) {
6391
- return this._client.get(path `/containers/${containerID}`, options);
8151
+ return this._client.get(path `/containers/${containerID}`, {
8152
+ ...options,
8153
+ __security: { bearerAuth: true },
8154
+ });
6392
8155
  }
6393
8156
  /**
6394
8157
  * List Containers
6395
8158
  */
6396
8159
  list(query = {}, options) {
6397
- return this._client.getAPIList('/containers', (CursorPage), { query, ...options });
8160
+ return this._client.getAPIList('/containers', (CursorPage), {
8161
+ query,
8162
+ ...options,
8163
+ __security: { bearerAuth: true },
8164
+ });
6398
8165
  }
6399
8166
  /**
6400
8167
  * Delete Container
@@ -6403,6 +8170,7 @@ class Containers extends APIResource {
6403
8170
  return this._client.delete(path `/containers/${containerID}`, {
6404
8171
  ...options,
6405
8172
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8173
+ __security: { bearerAuth: true },
6406
8174
  });
6407
8175
  }
6408
8176
  }
@@ -6422,6 +8190,7 @@ class Items extends APIResource {
6422
8190
  query: { include },
6423
8191
  body,
6424
8192
  ...options,
8193
+ __security: { bearerAuth: true },
6425
8194
  });
6426
8195
  }
6427
8196
  /**
@@ -6429,20 +8198,27 @@ class Items extends APIResource {
6429
8198
  */
6430
8199
  retrieve(itemID, params, options) {
6431
8200
  const { conversation_id, ...query } = params;
6432
- return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, { query, ...options });
8201
+ return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, {
8202
+ query,
8203
+ ...options,
8204
+ __security: { bearerAuth: true },
8205
+ });
6433
8206
  }
6434
8207
  /**
6435
8208
  * List all items for a conversation with the given ID.
6436
8209
  */
6437
8210
  list(conversationID, query = {}, options) {
6438
- return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options });
8211
+ return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options, __security: { bearerAuth: true } });
6439
8212
  }
6440
8213
  /**
6441
8214
  * Delete an item from a conversation with the given IDs.
6442
8215
  */
6443
8216
  delete(itemID, params, options) {
6444
8217
  const { conversation_id } = params;
6445
- return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, options);
8218
+ return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, {
8219
+ ...options,
8220
+ __security: { bearerAuth: true },
8221
+ });
6446
8222
  }
6447
8223
  }
6448
8224
 
@@ -6459,25 +8235,35 @@ class Conversations extends APIResource {
6459
8235
  * Create a conversation.
6460
8236
  */
6461
8237
  create(body = {}, options) {
6462
- return this._client.post('/conversations', { body, ...options });
8238
+ return this._client.post('/conversations', { body, ...options, __security: { bearerAuth: true } });
6463
8239
  }
6464
8240
  /**
6465
8241
  * Get a conversation
6466
8242
  */
6467
8243
  retrieve(conversationID, options) {
6468
- return this._client.get(path `/conversations/${conversationID}`, options);
8244
+ return this._client.get(path `/conversations/${conversationID}`, {
8245
+ ...options,
8246
+ __security: { bearerAuth: true },
8247
+ });
6469
8248
  }
6470
8249
  /**
6471
8250
  * Update a conversation
6472
8251
  */
6473
8252
  update(conversationID, body, options) {
6474
- return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
8253
+ return this._client.post(path `/conversations/${conversationID}`, {
8254
+ body,
8255
+ ...options,
8256
+ __security: { bearerAuth: true },
8257
+ });
6475
8258
  }
6476
8259
  /**
6477
8260
  * Delete a conversation. Items in the conversation will not be deleted.
6478
8261
  */
6479
8262
  delete(conversationID, options) {
6480
- return this._client.delete(path `/conversations/${conversationID}`, options);
8263
+ return this._client.delete(path `/conversations/${conversationID}`, {
8264
+ ...options,
8265
+ __security: { bearerAuth: true },
8266
+ });
6481
8267
  }
6482
8268
  }
6483
8269
  Conversations.Items = Items;
@@ -6513,6 +8299,7 @@ class Embeddings extends APIResource {
6513
8299
  encoding_format: encoding_format,
6514
8300
  },
6515
8301
  ...options,
8302
+ __security: { bearerAuth: true },
6516
8303
  });
6517
8304
  // if the user specified an encoding_format, return the response as-is
6518
8305
  if (hasUserProvidedEncodingFormat) {
@@ -6545,14 +8332,17 @@ class OutputItems extends APIResource {
6545
8332
  */
6546
8333
  retrieve(outputItemID, params, options) {
6547
8334
  const { eval_id, run_id } = params;
6548
- return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, options);
8335
+ return this._client.get(path `/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, {
8336
+ ...options,
8337
+ __security: { bearerAuth: true },
8338
+ });
6549
8339
  }
6550
8340
  /**
6551
8341
  * Get a list of output items for an evaluation run.
6552
8342
  */
6553
8343
  list(runID, params, options) {
6554
8344
  const { eval_id, ...query } = params;
6555
- return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options });
8345
+ return this._client.getAPIList(path `/evals/${eval_id}/runs/${runID}/output_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
6556
8346
  }
6557
8347
  }
6558
8348
 
@@ -6571,14 +8361,21 @@ class Runs extends APIResource {
6571
8361
  * schema specified in the config of the evaluation.
6572
8362
  */
6573
8363
  create(evalID, body, options) {
6574
- return this._client.post(path `/evals/${evalID}/runs`, { body, ...options });
8364
+ return this._client.post(path `/evals/${evalID}/runs`, {
8365
+ body,
8366
+ ...options,
8367
+ __security: { bearerAuth: true },
8368
+ });
6575
8369
  }
6576
8370
  /**
6577
8371
  * Get an evaluation run by ID.
6578
8372
  */
6579
8373
  retrieve(runID, params, options) {
6580
8374
  const { eval_id } = params;
6581
- return this._client.get(path `/evals/${eval_id}/runs/${runID}`, options);
8375
+ return this._client.get(path `/evals/${eval_id}/runs/${runID}`, {
8376
+ ...options,
8377
+ __security: { bearerAuth: true },
8378
+ });
6582
8379
  }
6583
8380
  /**
6584
8381
  * Get a list of runs for an evaluation.
@@ -6587,6 +8384,7 @@ class Runs extends APIResource {
6587
8384
  return this._client.getAPIList(path `/evals/${evalID}/runs`, (CursorPage), {
6588
8385
  query,
6589
8386
  ...options,
8387
+ __security: { bearerAuth: true },
6590
8388
  });
6591
8389
  }
6592
8390
  /**
@@ -6594,14 +8392,20 @@ class Runs extends APIResource {
6594
8392
  */
6595
8393
  delete(runID, params, options) {
6596
8394
  const { eval_id } = params;
6597
- return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, options);
8395
+ return this._client.delete(path `/evals/${eval_id}/runs/${runID}`, {
8396
+ ...options,
8397
+ __security: { bearerAuth: true },
8398
+ });
6598
8399
  }
6599
8400
  /**
6600
8401
  * Cancel an ongoing evaluation run.
6601
8402
  */
6602
8403
  cancel(runID, params, options) {
6603
8404
  const { eval_id } = params;
6604
- return this._client.post(path `/evals/${eval_id}/runs/${runID}`, options);
8405
+ return this._client.post(path `/evals/${eval_id}/runs/${runID}`, {
8406
+ ...options,
8407
+ __security: { bearerAuth: true },
8408
+ });
6605
8409
  }
6606
8410
  }
6607
8411
  Runs.OutputItems = OutputItems;
@@ -6624,31 +8428,35 @@ class Evals extends APIResource {
6624
8428
  * the [Evals guide](https://platform.openai.com/docs/guides/evals).
6625
8429
  */
6626
8430
  create(body, options) {
6627
- return this._client.post('/evals', { body, ...options });
8431
+ return this._client.post('/evals', { body, ...options, __security: { bearerAuth: true } });
6628
8432
  }
6629
8433
  /**
6630
8434
  * Get an evaluation by ID.
6631
8435
  */
6632
8436
  retrieve(evalID, options) {
6633
- return this._client.get(path `/evals/${evalID}`, options);
8437
+ return this._client.get(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
6634
8438
  }
6635
8439
  /**
6636
8440
  * Update certain properties of an evaluation.
6637
8441
  */
6638
8442
  update(evalID, body, options) {
6639
- return this._client.post(path `/evals/${evalID}`, { body, ...options });
8443
+ return this._client.post(path `/evals/${evalID}`, { body, ...options, __security: { bearerAuth: true } });
6640
8444
  }
6641
8445
  /**
6642
8446
  * List evaluations for a project.
6643
8447
  */
6644
8448
  list(query = {}, options) {
6645
- return this._client.getAPIList('/evals', (CursorPage), { query, ...options });
8449
+ return this._client.getAPIList('/evals', (CursorPage), {
8450
+ query,
8451
+ ...options,
8452
+ __security: { bearerAuth: true },
8453
+ });
6646
8454
  }
6647
8455
  /**
6648
8456
  * Delete an evaluation.
6649
8457
  */
6650
8458
  delete(evalID, options) {
6651
- return this._client.delete(path `/evals/${evalID}`, options);
8459
+ return this._client.delete(path `/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
6652
8460
  }
6653
8461
  }
6654
8462
  Evals.Runs = Runs;
@@ -6661,7 +8469,8 @@ let Files$1 = class Files extends APIResource {
6661
8469
  /**
6662
8470
  * Upload a file that can be used across various endpoints. Individual files can be
6663
8471
  * up to 512 MB, and each project can store up to 2.5 TB of files in total. There
6664
- * is no organization-wide storage limit.
8472
+ * is no organization-wide storage limit. Uploads to this endpoint are rate-limited
8473
+ * to 1,000 requests per minute per authenticated user.
6665
8474
  *
6666
8475
  * - The Assistants API supports files up to 2 million tokens and of specific file
6667
8476
  * types. See the
@@ -6676,30 +8485,40 @@ let Files$1 = class Files extends APIResource {
6676
8485
  * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
6677
8486
  * also has a specific required
6678
8487
  * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
8488
+ * - For Retrieval or `file_search` ingestion, upload files here first. If you need
8489
+ * to attach multiple uploaded files to the same vector store, use
8490
+ * [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch)
8491
+ * instead of attaching them one by one. Vector store attachment has separate
8492
+ * limits from file upload, including 2,000 attached files per minute per
8493
+ * organization.
6679
8494
  *
6680
8495
  * Please [contact us](https://help.openai.com/) if you need to increase these
6681
8496
  * storage limits.
6682
8497
  */
6683
8498
  create(body, options) {
6684
- return this._client.post('/files', multipartFormRequestOptions({ body, ...options }, this._client));
8499
+ return this._client.post('/files', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6685
8500
  }
6686
8501
  /**
6687
8502
  * Returns information about a specific file.
6688
8503
  */
6689
8504
  retrieve(fileID, options) {
6690
- return this._client.get(path `/files/${fileID}`, options);
8505
+ return this._client.get(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
6691
8506
  }
6692
8507
  /**
6693
8508
  * Returns a list of files.
6694
8509
  */
6695
8510
  list(query = {}, options) {
6696
- return this._client.getAPIList('/files', (CursorPage), { query, ...options });
8511
+ return this._client.getAPIList('/files', (CursorPage), {
8512
+ query,
8513
+ ...options,
8514
+ __security: { bearerAuth: true },
8515
+ });
6697
8516
  }
6698
8517
  /**
6699
8518
  * Delete a file and remove it from all vector stores.
6700
8519
  */
6701
8520
  delete(fileID, options) {
6702
- return this._client.delete(path `/files/${fileID}`, options);
8521
+ return this._client.delete(path `/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
6703
8522
  }
6704
8523
  /**
6705
8524
  * Returns the contents of the specified file.
@@ -6708,6 +8527,7 @@ let Files$1 = class Files extends APIResource {
6708
8527
  return this._client.get(path `/files/${fileID}/content`, {
6709
8528
  ...options,
6710
8529
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
8530
+ __security: { bearerAuth: true },
6711
8531
  __binaryResponse: true,
6712
8532
  });
6713
8533
  }
@@ -6758,7 +8578,11 @@ let Graders$1 = class Graders extends APIResource {
6758
8578
  * ```
6759
8579
  */
6760
8580
  run(body, options) {
6761
- return this._client.post('/fine_tuning/alpha/graders/run', { body, ...options });
8581
+ return this._client.post('/fine_tuning/alpha/graders/run', {
8582
+ body,
8583
+ ...options,
8584
+ __security: { bearerAuth: true },
8585
+ });
6762
8586
  }
6763
8587
  /**
6764
8588
  * Validate a grader.
@@ -6778,7 +8602,11 @@ let Graders$1 = class Graders extends APIResource {
6778
8602
  * ```
6779
8603
  */
6780
8604
  validate(body, options) {
6781
- return this._client.post('/fine_tuning/alpha/graders/validate', { body, ...options });
8605
+ return this._client.post('/fine_tuning/alpha/graders/validate', {
8606
+ body,
8607
+ ...options,
8608
+ __security: { bearerAuth: true },
8609
+ });
6782
8610
  }
6783
8611
  };
6784
8612
 
@@ -6814,7 +8642,7 @@ class Permissions extends APIResource {
6814
8642
  * ```
6815
8643
  */
6816
8644
  create(fineTunedModelCheckpoint, body, options) {
6817
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options });
8645
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (Page), { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } });
6818
8646
  }
6819
8647
  /**
6820
8648
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -6828,6 +8656,7 @@ class Permissions extends APIResource {
6828
8656
  return this._client.get(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
6829
8657
  query,
6830
8658
  ...options,
8659
+ __security: { adminAPIKeyAuth: true },
6831
8660
  });
6832
8661
  }
6833
8662
  /**
@@ -6847,7 +8676,7 @@ class Permissions extends APIResource {
6847
8676
  * ```
6848
8677
  */
6849
8678
  list(fineTunedModelCheckpoint, query = {}, options) {
6850
- return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options });
8679
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
6851
8680
  }
6852
8681
  /**
6853
8682
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
@@ -6869,7 +8698,7 @@ class Permissions extends APIResource {
6869
8698
  */
6870
8699
  delete(permissionID, params, options) {
6871
8700
  const { fine_tuned_model_checkpoint } = params;
6872
- return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, options);
8701
+ return this._client.delete(path `/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, { ...options, __security: { adminAPIKeyAuth: true } });
6873
8702
  }
6874
8703
  }
6875
8704
 
@@ -6901,7 +8730,7 @@ class Checkpoints extends APIResource {
6901
8730
  * ```
6902
8731
  */
6903
8732
  list(fineTuningJobID, query = {}, options) {
6904
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options });
8733
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
6905
8734
  }
6906
8735
  }
6907
8736
 
@@ -6932,7 +8761,7 @@ class Jobs extends APIResource {
6932
8761
  * ```
6933
8762
  */
6934
8763
  create(body, options) {
6935
- return this._client.post('/fine_tuning/jobs', { body, ...options });
8764
+ return this._client.post('/fine_tuning/jobs', { body, ...options, __security: { bearerAuth: true } });
6936
8765
  }
6937
8766
  /**
6938
8767
  * Get info about a fine-tuning job.
@@ -6947,7 +8776,10 @@ class Jobs extends APIResource {
6947
8776
  * ```
6948
8777
  */
6949
8778
  retrieve(fineTuningJobID, options) {
6950
- return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, options);
8779
+ return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, {
8780
+ ...options,
8781
+ __security: { bearerAuth: true },
8782
+ });
6951
8783
  }
6952
8784
  /**
6953
8785
  * List your organization's fine-tuning jobs
@@ -6961,7 +8793,11 @@ class Jobs extends APIResource {
6961
8793
  * ```
6962
8794
  */
6963
8795
  list(query = {}, options) {
6964
- return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), { query, ...options });
8796
+ return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), {
8797
+ query,
8798
+ ...options,
8799
+ __security: { bearerAuth: true },
8800
+ });
6965
8801
  }
6966
8802
  /**
6967
8803
  * Immediately cancel a fine-tune job.
@@ -6974,7 +8810,10 @@ class Jobs extends APIResource {
6974
8810
  * ```
6975
8811
  */
6976
8812
  cancel(fineTuningJobID, options) {
6977
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, options);
8813
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, {
8814
+ ...options,
8815
+ __security: { bearerAuth: true },
8816
+ });
6978
8817
  }
6979
8818
  /**
6980
8819
  * Get status updates for a fine-tuning job.
@@ -6990,7 +8829,7 @@ class Jobs extends APIResource {
6990
8829
  * ```
6991
8830
  */
6992
8831
  listEvents(fineTuningJobID, query = {}, options) {
6993
- return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options });
8832
+ return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
6994
8833
  }
6995
8834
  /**
6996
8835
  * Pause a fine-tune job.
@@ -7003,7 +8842,10 @@ class Jobs extends APIResource {
7003
8842
  * ```
7004
8843
  */
7005
8844
  pause(fineTuningJobID, options) {
7006
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, options);
8845
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, {
8846
+ ...options,
8847
+ __security: { bearerAuth: true },
8848
+ });
7007
8849
  }
7008
8850
  /**
7009
8851
  * Resume a fine-tune job.
@@ -7016,7 +8858,10 @@ class Jobs extends APIResource {
7016
8858
  * ```
7017
8859
  */
7018
8860
  resume(fineTuningJobID, options) {
7019
- return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, options);
8861
+ return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, {
8862
+ ...options,
8863
+ __security: { bearerAuth: true },
8864
+ });
7020
8865
  }
7021
8866
  }
7022
8867
  Jobs.Checkpoints = Checkpoints;
@@ -7065,13 +8910,18 @@ class Images extends APIResource {
7065
8910
  * ```
7066
8911
  */
7067
8912
  createVariation(body, options) {
7068
- return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options }, this._client));
8913
+ return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7069
8914
  }
7070
8915
  edit(body, options) {
7071
- return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false }, this._client));
8916
+ return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false, __security: { bearerAuth: true } }, this._client));
7072
8917
  }
7073
8918
  generate(body, options) {
7074
- return this._client.post('/images/generations', { body, ...options, stream: body.stream ?? false });
8919
+ return this._client.post('/images/generations', {
8920
+ body,
8921
+ ...options,
8922
+ stream: body.stream ?? false,
8923
+ __security: { bearerAuth: true },
8924
+ });
7075
8925
  }
7076
8926
  }
7077
8927
 
@@ -7085,21 +8935,21 @@ class Models extends APIResource {
7085
8935
  * the owner and permissioning.
7086
8936
  */
7087
8937
  retrieve(model, options) {
7088
- return this._client.get(path `/models/${model}`, options);
8938
+ return this._client.get(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
7089
8939
  }
7090
8940
  /**
7091
8941
  * Lists the currently available models, and provides basic information about each
7092
8942
  * one such as the owner and availability.
7093
8943
  */
7094
8944
  list(options) {
7095
- return this._client.getAPIList('/models', (Page), options);
8945
+ return this._client.getAPIList('/models', (Page), { ...options, __security: { bearerAuth: true } });
7096
8946
  }
7097
8947
  /**
7098
8948
  * Delete a fine-tuned model. You must have the Owner role in your organization to
7099
8949
  * delete a model.
7100
8950
  */
7101
8951
  delete(model, options) {
7102
- return this._client.delete(path `/models/${model}`, options);
8952
+ return this._client.delete(path `/models/${model}`, { ...options, __security: { bearerAuth: true } });
7103
8953
  }
7104
8954
  }
7105
8955
 
@@ -7113,7 +8963,7 @@ class Moderations extends APIResource {
7113
8963
  * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
7114
8964
  */
7115
8965
  create(body, options) {
7116
- return this._client.post('/moderations', { body, ...options });
8966
+ return this._client.post('/moderations', { body, ...options, __security: { bearerAuth: true } });
7117
8967
  }
7118
8968
  }
7119
8969
 
@@ -7135,6 +8985,7 @@ class Calls extends APIResource {
7135
8985
  body,
7136
8986
  ...options,
7137
8987
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
8988
+ __security: { bearerAuth: true },
7138
8989
  });
7139
8990
  }
7140
8991
  /**
@@ -7149,6 +9000,7 @@ class Calls extends APIResource {
7149
9000
  return this._client.post(path `/realtime/calls/${callID}/hangup`, {
7150
9001
  ...options,
7151
9002
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
9003
+ __security: { bearerAuth: true },
7152
9004
  });
7153
9005
  }
7154
9006
  /**
@@ -7166,6 +9018,7 @@ class Calls extends APIResource {
7166
9018
  body,
7167
9019
  ...options,
7168
9020
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
9021
+ __security: { bearerAuth: true },
7169
9022
  });
7170
9023
  }
7171
9024
  /**
@@ -7181,6 +9034,7 @@ class Calls extends APIResource {
7181
9034
  body,
7182
9035
  ...options,
7183
9036
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
9037
+ __security: { bearerAuth: true },
7184
9038
  });
7185
9039
  }
7186
9040
  }
@@ -7211,7 +9065,11 @@ class ClientSecrets extends APIResource {
7211
9065
  * ```
7212
9066
  */
7213
9067
  create(body, options) {
7214
- return this._client.post('/realtime/client_secrets', { body, ...options });
9068
+ return this._client.post('/realtime/client_secrets', {
9069
+ body,
9070
+ ...options,
9071
+ __security: { bearerAuth: true },
9072
+ });
7215
9073
  }
7216
9074
  }
7217
9075
 
@@ -7622,7 +9480,7 @@ class InputItems extends APIResource {
7622
9480
  * ```
7623
9481
  */
7624
9482
  list(responseID, query = {}, options) {
7625
- return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options });
9483
+ return this._client.getAPIList(path `/responses/${responseID}/input_items`, (CursorPage), { query, ...options, __security: { bearerAuth: true } });
7626
9484
  }
7627
9485
  }
7628
9486
 
@@ -7640,7 +9498,11 @@ class InputTokens extends APIResource {
7640
9498
  * ```
7641
9499
  */
7642
9500
  count(body = {}, options) {
7643
- return this._client.post('/responses/input_tokens', { body, ...options });
9501
+ return this._client.post('/responses/input_tokens', {
9502
+ body,
9503
+ ...options,
9504
+ __security: { bearerAuth: true },
9505
+ });
7644
9506
  }
7645
9507
  }
7646
9508
 
@@ -7652,7 +9514,12 @@ class Responses extends APIResource {
7652
9514
  this.inputTokens = new InputTokens(this._client);
7653
9515
  }
7654
9516
  create(body, options) {
7655
- return this._client.post('/responses', { body, ...options, stream: body.stream ?? false })._thenUnwrap((rsp) => {
9517
+ return this._client.post('/responses', {
9518
+ body,
9519
+ ...options,
9520
+ stream: body.stream ?? false,
9521
+ __security: { bearerAuth: true },
9522
+ })._thenUnwrap((rsp) => {
7656
9523
  if ('object' in rsp && rsp.object === 'response') {
7657
9524
  addOutputText(rsp);
7658
9525
  }
@@ -7664,6 +9531,7 @@ class Responses extends APIResource {
7664
9531
  query,
7665
9532
  ...options,
7666
9533
  stream: query?.stream ?? false,
9534
+ __security: { bearerAuth: true },
7667
9535
  })._thenUnwrap((rsp) => {
7668
9536
  if ('object' in rsp && rsp.object === 'response') {
7669
9537
  addOutputText(rsp);
@@ -7685,6 +9553,7 @@ class Responses extends APIResource {
7685
9553
  return this._client.delete(path `/responses/${responseID}`, {
7686
9554
  ...options,
7687
9555
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
9556
+ __security: { bearerAuth: true },
7688
9557
  });
7689
9558
  }
7690
9559
  parse(body, options) {
@@ -7711,7 +9580,10 @@ class Responses extends APIResource {
7711
9580
  * ```
7712
9581
  */
7713
9582
  cancel(responseID, options) {
7714
- return this._client.post(path `/responses/${responseID}/cancel`, options);
9583
+ return this._client.post(path `/responses/${responseID}/cancel`, {
9584
+ ...options,
9585
+ __security: { bearerAuth: true },
9586
+ });
7715
9587
  }
7716
9588
  /**
7717
9589
  * Compact a conversation. Returns a compacted response object.
@@ -7729,7 +9601,7 @@ class Responses extends APIResource {
7729
9601
  * ```
7730
9602
  */
7731
9603
  compact(body, options) {
7732
- return this._client.post('/responses/compact', { body, ...options });
9604
+ return this._client.post('/responses/compact', { body, ...options, __security: { bearerAuth: true } });
7733
9605
  }
7734
9606
  }
7735
9607
  Responses.InputItems = InputItems;
@@ -7744,6 +9616,7 @@ let Content$1 = class Content extends APIResource {
7744
9616
  return this._client.get(path `/skills/${skillID}/content`, {
7745
9617
  ...options,
7746
9618
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
9619
+ __security: { bearerAuth: true },
7747
9620
  __binaryResponse: true,
7748
9621
  });
7749
9622
  }
@@ -7759,6 +9632,7 @@ class Content extends APIResource {
7759
9632
  return this._client.get(path `/skills/${skill_id}/versions/${version}/content`, {
7760
9633
  ...options,
7761
9634
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
9635
+ __security: { bearerAuth: true },
7762
9636
  __binaryResponse: true,
7763
9637
  });
7764
9638
  }
@@ -7774,14 +9648,17 @@ class Versions extends APIResource {
7774
9648
  * Create a new immutable skill version.
7775
9649
  */
7776
9650
  create(skillID, body = {}, options) {
7777
- return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
9651
+ return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7778
9652
  }
7779
9653
  /**
7780
9654
  * Get a specific skill version.
7781
9655
  */
7782
9656
  retrieve(version, params, options) {
7783
9657
  const { skill_id } = params;
7784
- return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
9658
+ return this._client.get(path `/skills/${skill_id}/versions/${version}`, {
9659
+ ...options,
9660
+ __security: { bearerAuth: true },
9661
+ });
7785
9662
  }
7786
9663
  /**
7787
9664
  * List skill versions for a skill.
@@ -7790,6 +9667,7 @@ class Versions extends APIResource {
7790
9667
  return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
7791
9668
  query,
7792
9669
  ...options,
9670
+ __security: { bearerAuth: true },
7793
9671
  });
7794
9672
  }
7795
9673
  /**
@@ -7797,7 +9675,10 @@ class Versions extends APIResource {
7797
9675
  */
7798
9676
  delete(version, params, options) {
7799
9677
  const { skill_id } = params;
7800
- return this._client.delete(path `/skills/${skill_id}/versions/${version}`, options);
9678
+ return this._client.delete(path `/skills/${skill_id}/versions/${version}`, {
9679
+ ...options,
9680
+ __security: { bearerAuth: true },
9681
+ });
7801
9682
  }
7802
9683
  }
7803
9684
  Versions.Content = Content;
@@ -7813,31 +9694,39 @@ class Skills extends APIResource {
7813
9694
  * Create a new skill.
7814
9695
  */
7815
9696
  create(body = {}, options) {
7816
- return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
9697
+ return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7817
9698
  }
7818
9699
  /**
7819
9700
  * Get a skill by its ID.
7820
9701
  */
7821
9702
  retrieve(skillID, options) {
7822
- return this._client.get(path `/skills/${skillID}`, options);
9703
+ return this._client.get(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
7823
9704
  }
7824
9705
  /**
7825
9706
  * Update the default version pointer for a skill.
7826
9707
  */
7827
9708
  update(skillID, body, options) {
7828
- return this._client.post(path `/skills/${skillID}`, { body, ...options });
9709
+ return this._client.post(path `/skills/${skillID}`, {
9710
+ body,
9711
+ ...options,
9712
+ __security: { bearerAuth: true },
9713
+ });
7829
9714
  }
7830
9715
  /**
7831
9716
  * List all skills for the current project.
7832
9717
  */
7833
9718
  list(query = {}, options) {
7834
- return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
9719
+ return this._client.getAPIList('/skills', (CursorPage), {
9720
+ query,
9721
+ ...options,
9722
+ __security: { bearerAuth: true },
9723
+ });
7835
9724
  }
7836
9725
  /**
7837
9726
  * Delete a skill by its ID.
7838
9727
  */
7839
9728
  delete(skillID, options) {
7840
- return this._client.delete(path `/skills/${skillID}`, options);
9729
+ return this._client.delete(path `/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
7841
9730
  }
7842
9731
  }
7843
9732
  Skills.Content = Content$1;
@@ -7862,7 +9751,7 @@ class Parts extends APIResource {
7862
9751
  * [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
7863
9752
  */
7864
9753
  create(uploadID, body, options) {
7865
- return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options }, this._client));
9754
+ return this._client.post(path `/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
7866
9755
  }
7867
9756
  }
7868
9757
 
@@ -7899,7 +9788,7 @@ class Uploads extends APIResource {
7899
9788
  * Returns the Upload object with status `pending`.
7900
9789
  */
7901
9790
  create(body, options) {
7902
- return this._client.post('/uploads', { body, ...options });
9791
+ return this._client.post('/uploads', { body, ...options, __security: { bearerAuth: true } });
7903
9792
  }
7904
9793
  /**
7905
9794
  * Cancels the Upload. No Parts may be added after an Upload is cancelled.
@@ -7907,7 +9796,10 @@ class Uploads extends APIResource {
7907
9796
  * Returns the Upload object with status `cancelled`.
7908
9797
  */
7909
9798
  cancel(uploadID, options) {
7910
- return this._client.post(path `/uploads/${uploadID}/cancel`, options);
9799
+ return this._client.post(path `/uploads/${uploadID}/cancel`, {
9800
+ ...options,
9801
+ __security: { bearerAuth: true },
9802
+ });
7911
9803
  }
7912
9804
  /**
7913
9805
  * Completes the
@@ -7927,7 +9819,11 @@ class Uploads extends APIResource {
7927
9819
  * object.
7928
9820
  */
7929
9821
  complete(uploadID, body, options) {
7930
- return this._client.post(path `/uploads/${uploadID}/complete`, { body, ...options });
9822
+ return this._client.post(path `/uploads/${uploadID}/complete`, {
9823
+ body,
9824
+ ...options,
9825
+ __security: { bearerAuth: true },
9826
+ });
7931
9827
  }
7932
9828
  }
7933
9829
  Uploads.Parts = Parts;
@@ -7964,6 +9860,7 @@ class FileBatches extends APIResource {
7964
9860
  body,
7965
9861
  ...options,
7966
9862
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9863
+ __security: { bearerAuth: true },
7967
9864
  });
7968
9865
  }
7969
9866
  /**
@@ -7974,6 +9871,7 @@ class FileBatches extends APIResource {
7974
9871
  return this._client.get(path `/vector_stores/${vector_store_id}/file_batches/${batchID}`, {
7975
9872
  ...options,
7976
9873
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9874
+ __security: { bearerAuth: true },
7977
9875
  });
7978
9876
  }
7979
9877
  /**
@@ -7985,6 +9883,7 @@ class FileBatches extends APIResource {
7985
9883
  return this._client.post(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/cancel`, {
7986
9884
  ...options,
7987
9885
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9886
+ __security: { bearerAuth: true },
7988
9887
  });
7989
9888
  }
7990
9889
  /**
@@ -7999,7 +9898,12 @@ class FileBatches extends APIResource {
7999
9898
  */
8000
9899
  listFiles(batchID, params, options) {
8001
9900
  const { vector_store_id, ...query } = params;
8002
- 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]) });
9901
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, (CursorPage), {
9902
+ query,
9903
+ ...options,
9904
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9905
+ __security: { bearerAuth: true },
9906
+ });
8003
9907
  }
8004
9908
  /**
8005
9909
  * Wait for the given file batch to be processed.
@@ -8089,6 +9993,7 @@ class Files extends APIResource {
8089
9993
  body,
8090
9994
  ...options,
8091
9995
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
9996
+ __security: { bearerAuth: true },
8092
9997
  });
8093
9998
  }
8094
9999
  /**
@@ -8099,6 +10004,7 @@ class Files extends APIResource {
8099
10004
  return this._client.get(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
8100
10005
  ...options,
8101
10006
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10007
+ __security: { bearerAuth: true },
8102
10008
  });
8103
10009
  }
8104
10010
  /**
@@ -8110,6 +10016,7 @@ class Files extends APIResource {
8110
10016
  body,
8111
10017
  ...options,
8112
10018
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10019
+ __security: { bearerAuth: true },
8113
10020
  });
8114
10021
  }
8115
10022
  /**
@@ -8120,6 +10027,7 @@ class Files extends APIResource {
8120
10027
  query,
8121
10028
  ...options,
8122
10029
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10030
+ __security: { bearerAuth: true },
8123
10031
  });
8124
10032
  }
8125
10033
  /**
@@ -8133,6 +10041,7 @@ class Files extends APIResource {
8133
10041
  return this._client.delete(path `/vector_stores/${vector_store_id}/files/${fileID}`, {
8134
10042
  ...options,
8135
10043
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10044
+ __security: { bearerAuth: true },
8136
10045
  });
8137
10046
  }
8138
10047
  /**
@@ -8206,7 +10115,11 @@ class Files extends APIResource {
8206
10115
  */
8207
10116
  content(fileID, params, options) {
8208
10117
  const { vector_store_id } = params;
8209
- return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), { ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]) });
10118
+ return this._client.getAPIList(path `/vector_stores/${vector_store_id}/files/${fileID}/content`, (Page), {
10119
+ ...options,
10120
+ headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10121
+ __security: { bearerAuth: true },
10122
+ });
8210
10123
  }
8211
10124
  }
8212
10125
 
@@ -8225,6 +10138,7 @@ class VectorStores extends APIResource {
8225
10138
  body,
8226
10139
  ...options,
8227
10140
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10141
+ __security: { bearerAuth: true },
8228
10142
  });
8229
10143
  }
8230
10144
  /**
@@ -8234,6 +10148,7 @@ class VectorStores extends APIResource {
8234
10148
  return this._client.get(path `/vector_stores/${vectorStoreID}`, {
8235
10149
  ...options,
8236
10150
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10151
+ __security: { bearerAuth: true },
8237
10152
  });
8238
10153
  }
8239
10154
  /**
@@ -8244,6 +10159,7 @@ class VectorStores extends APIResource {
8244
10159
  body,
8245
10160
  ...options,
8246
10161
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10162
+ __security: { bearerAuth: true },
8247
10163
  });
8248
10164
  }
8249
10165
  /**
@@ -8254,6 +10170,7 @@ class VectorStores extends APIResource {
8254
10170
  query,
8255
10171
  ...options,
8256
10172
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10173
+ __security: { bearerAuth: true },
8257
10174
  });
8258
10175
  }
8259
10176
  /**
@@ -8263,6 +10180,7 @@ class VectorStores extends APIResource {
8263
10180
  return this._client.delete(path `/vector_stores/${vectorStoreID}`, {
8264
10181
  ...options,
8265
10182
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10183
+ __security: { bearerAuth: true },
8266
10184
  });
8267
10185
  }
8268
10186
  /**
@@ -8275,6 +10193,7 @@ class VectorStores extends APIResource {
8275
10193
  method: 'post',
8276
10194
  ...options,
8277
10195
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
10196
+ __security: { bearerAuth: true },
8278
10197
  });
8279
10198
  }
8280
10199
  }
@@ -8287,31 +10206,35 @@ class Videos extends APIResource {
8287
10206
  * Create a new video generation job from a prompt and optional reference assets.
8288
10207
  */
8289
10208
  create(body, options) {
8290
- return this._client.post('/videos', multipartFormRequestOptions({ body, ...options }, this._client));
10209
+ return this._client.post('/videos', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
8291
10210
  }
8292
10211
  /**
8293
10212
  * Fetch the latest metadata for a generated video.
8294
10213
  */
8295
10214
  retrieve(videoID, options) {
8296
- return this._client.get(path `/videos/${videoID}`, options);
10215
+ return this._client.get(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
8297
10216
  }
8298
10217
  /**
8299
10218
  * List recently generated videos for the current project.
8300
10219
  */
8301
10220
  list(query = {}, options) {
8302
- return this._client.getAPIList('/videos', (ConversationCursorPage), { query, ...options });
10221
+ return this._client.getAPIList('/videos', (ConversationCursorPage), {
10222
+ query,
10223
+ ...options,
10224
+ __security: { bearerAuth: true },
10225
+ });
8303
10226
  }
8304
10227
  /**
8305
10228
  * Permanently delete a completed or failed video and its stored assets.
8306
10229
  */
8307
10230
  delete(videoID, options) {
8308
- return this._client.delete(path `/videos/${videoID}`, options);
10231
+ return this._client.delete(path `/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
8309
10232
  }
8310
10233
  /**
8311
10234
  * Create a character from an uploaded video.
8312
10235
  */
8313
10236
  createCharacter(body, options) {
8314
- return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options }, this._client));
10237
+ return this._client.post('/videos/characters', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
8315
10238
  }
8316
10239
  /**
8317
10240
  * Download the generated video bytes or a derived preview asset.
@@ -8323,6 +10246,7 @@ class Videos extends APIResource {
8323
10246
  query,
8324
10247
  ...options,
8325
10248
  headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
10249
+ __security: { bearerAuth: true },
8326
10250
  __binaryResponse: true,
8327
10251
  });
8328
10252
  }
@@ -8331,25 +10255,28 @@ class Videos extends APIResource {
8331
10255
  * generated video.
8332
10256
  */
8333
10257
  edit(body, options) {
8334
- return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options }, this._client));
10258
+ return this._client.post('/videos/edits', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
8335
10259
  }
8336
10260
  /**
8337
10261
  * Create an extension of a completed video.
8338
10262
  */
8339
10263
  extend(body, options) {
8340
- return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
10264
+ return this._client.post('/videos/extensions', multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
8341
10265
  }
8342
10266
  /**
8343
10267
  * Fetch a character.
8344
10268
  */
8345
10269
  getCharacter(characterID, options) {
8346
- return this._client.get(path `/videos/characters/${characterID}`, options);
10270
+ return this._client.get(path `/videos/characters/${characterID}`, {
10271
+ ...options,
10272
+ __security: { bearerAuth: true },
10273
+ });
8347
10274
  }
8348
10275
  /**
8349
10276
  * Create a remix of a completed video using a refreshed prompt.
8350
10277
  */
8351
10278
  remix(videoID, body, options) {
8352
- return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
10279
+ return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
8353
10280
  }
8354
10281
  }
8355
10282
 
@@ -8456,7 +10383,8 @@ class OpenAI {
8456
10383
  /**
8457
10384
  * API Client for interfacing with the OpenAI API.
8458
10385
  *
8459
- * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
10386
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? null]
10387
+ * @param {string | null | undefined} [opts.adminAPIKey=process.env['OPENAI_ADMIN_KEY'] ?? null]
8460
10388
  * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
8461
10389
  * @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
8462
10390
  * @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
@@ -8469,7 +10397,7 @@ class OpenAI {
8469
10397
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
8470
10398
  * @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.
8471
10399
  */
8472
- 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 } = {}) {
10400
+ 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 } = {}) {
8473
10401
  _OpenAI_instances.add(this);
8474
10402
  _OpenAI_encoder.set(this, void 0);
8475
10403
  /**
@@ -8511,6 +10439,7 @@ class OpenAI {
8511
10439
  * Use Uploads to upload large files in multiple parts.
8512
10440
  */
8513
10441
  this.uploads = new Uploads(this);
10442
+ this.admin = new Admin(this);
8514
10443
  this.responses = new Responses(this);
8515
10444
  this.realtime = new Realtime(this);
8516
10445
  /**
@@ -8524,17 +10453,9 @@ class OpenAI {
8524
10453
  this.containers = new Containers(this);
8525
10454
  this.skills = new Skills(this);
8526
10455
  this.videos = new Videos(this);
8527
- if (workloadIdentity) {
8528
- if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
8529
- throw new OpenAIError('The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.');
8530
- }
8531
- apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
8532
- }
8533
- else if (apiKey === undefined) {
8534
- throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.');
8535
- }
8536
10456
  const options = {
8537
10457
  apiKey,
10458
+ adminAPIKey,
8538
10459
  organization,
8539
10460
  project,
8540
10461
  webhookSecret,
@@ -8542,6 +10463,12 @@ class OpenAI {
8542
10463
  ...opts,
8543
10464
  baseURL: baseURL || `https://api.openai.com/v1`,
8544
10465
  };
10466
+ if (apiKey && workloadIdentity) {
10467
+ throw new OpenAIError('The `apiKey` and `workloadIdentity` options are mutually exclusive');
10468
+ }
10469
+ if (!apiKey && !adminAPIKey && !workloadIdentity) {
10470
+ throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.');
10471
+ }
8545
10472
  if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
8546
10473
  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");
8547
10474
  }
@@ -8559,11 +10486,23 @@ class OpenAI {
8559
10486
  this.maxRetries = options.maxRetries ?? 2;
8560
10487
  this.fetch = options.fetch ?? getDefaultFetch();
8561
10488
  __classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
10489
+ const customHeadersEnv = readEnv('OPENAI_CUSTOM_HEADERS');
10490
+ if (customHeadersEnv) {
10491
+ const parsed = {};
10492
+ for (const line of customHeadersEnv.split('\n')) {
10493
+ const colon = line.indexOf(':');
10494
+ if (colon >= 0) {
10495
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
10496
+ }
10497
+ }
10498
+ options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
10499
+ }
8562
10500
  this._options = options;
8563
10501
  if (workloadIdentity) {
8564
10502
  this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
8565
10503
  }
8566
- this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
10504
+ this.apiKey = typeof apiKey === 'string' ? apiKey : null;
10505
+ this.adminAPIKey = adminAPIKey;
8567
10506
  this.organization = organization;
8568
10507
  this.project = project;
8569
10508
  this.webhookSecret = webhookSecret;
@@ -8581,7 +10520,8 @@ class OpenAI {
8581
10520
  logLevel: this.logLevel,
8582
10521
  fetch: this.fetch,
8583
10522
  fetchOptions: this.fetchOptions,
8584
- apiKey: this.apiKey,
10523
+ apiKey: this._options.apiKey,
10524
+ adminAPIKey: this.adminAPIKey,
8585
10525
  workloadIdentity: this._options.workloadIdentity,
8586
10526
  organization: this.organization,
8587
10527
  project: this.project,
@@ -8593,12 +10533,45 @@ class OpenAI {
8593
10533
  defaultQuery() {
8594
10534
  return this._options.defaultQuery;
8595
10535
  }
8596
- validateHeaders({ values, nulls }) {
8597
- return;
10536
+ validateHeaders({ values, nulls }, schemes = {
10537
+ bearerAuth: true,
10538
+ adminAPIKeyAuth: true,
10539
+ }) {
10540
+ if (values.get('authorization') || values.get('api-key')) {
10541
+ return;
10542
+ }
10543
+ if (nulls.has('authorization') || nulls.has('api-key')) {
10544
+ return;
10545
+ }
10546
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
10547
+ return;
10548
+ }
10549
+ 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');
8598
10550
  }
8599
- async authHeaders(opts) {
10551
+ async authHeaders(opts, schemes = {
10552
+ bearerAuth: true,
10553
+ adminAPIKeyAuth: true,
10554
+ }) {
10555
+ return buildHeaders([
10556
+ schemes.bearerAuth ? await this.bearerAuth(opts) : null,
10557
+ schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null,
10558
+ ]);
10559
+ }
10560
+ async bearerAuth(opts) {
10561
+ if (this._workloadIdentityAuth) {
10562
+ return buildHeaders([{ Authorization: `Bearer ${await this._workloadIdentityAuth.getToken()}` }]);
10563
+ }
10564
+ if (this.apiKey == null) {
10565
+ return undefined;
10566
+ }
8600
10567
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
8601
10568
  }
10569
+ async adminAPIKeyAuth(opts) {
10570
+ if (this.adminAPIKey == null) {
10571
+ return undefined;
10572
+ }
10573
+ return buildHeaders([{ Authorization: `Bearer ${this.adminAPIKey}` }]);
10574
+ }
8602
10575
  stringifyQuery(query) {
8603
10576
  return stringifyQuery(query);
8604
10577
  }
@@ -8651,7 +10624,10 @@ class OpenAI {
8651
10624
  * Used as a callback for mutating the given `FinalRequestOptions` object.
8652
10625
  */
8653
10626
  async prepareOptions(options) {
8654
- await this._callApiKey();
10627
+ const security = options.__security ?? { bearerAuth: true };
10628
+ if (security.bearerAuth) {
10629
+ await this._callApiKey();
10630
+ }
8655
10631
  }
8656
10632
  /**
8657
10633
  * Used as a callback for mutating the given `RequestInit` object.
@@ -8708,8 +10684,9 @@ class OpenAI {
8708
10684
  if (options.signal?.aborted) {
8709
10685
  throw new APIUserAbortError();
8710
10686
  }
10687
+ const security = options.__security ?? { bearerAuth: true };
8711
10688
  const controller = new AbortController();
8712
- const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
10689
+ const response = await this.fetchWithAuth(url, req, timeout, controller, security).catch(castToError);
8713
10690
  const headersTime = Date.now();
8714
10691
  if (response instanceof globalThis.Error) {
8715
10692
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -8755,6 +10732,7 @@ class OpenAI {
8755
10732
  if (!response.ok) {
8756
10733
  if (response.status === 401 &&
8757
10734
  this._workloadIdentityAuth &&
10735
+ security.bearerAuth &&
8758
10736
  !options.__metadata?.['hasStreamingBody'] &&
8759
10737
  !options.__metadata?.['workloadIdentityTokenRefreshed']) {
8760
10738
  await CancelReadableStream(response.body);
@@ -8817,8 +10795,11 @@ class OpenAI {
8817
10795
  const request = this.makeRequest(options, null, undefined);
8818
10796
  return new PagePromise(this, request, Page);
8819
10797
  }
8820
- async fetchWithAuth(url, init, timeout, controller) {
8821
- if (this._workloadIdentityAuth) {
10798
+ async fetchWithAuth(url, init, timeout, controller, schemes = {
10799
+ bearerAuth: true,
10800
+ adminAPIKeyAuth: true,
10801
+ }) {
10802
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
8822
10803
  const headers = init.headers;
8823
10804
  const authHeader = headers.get('Authorization');
8824
10805
  if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
@@ -8963,12 +10944,12 @@ class OpenAI {
8963
10944
  'OpenAI-Organization': this.organization,
8964
10945
  'OpenAI-Project': this.project,
8965
10946
  },
8966
- await this.authHeaders(options),
10947
+ await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
8967
10948
  this._options.defaultHeaders,
8968
10949
  bodyHeaders,
8969
10950
  options.headers,
8970
10951
  ]);
8971
- this.validateHeaders(headers);
10952
+ this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
8972
10953
  return headers.values;
8973
10954
  }
8974
10955
  _makeAbort(controller) {
@@ -9065,6 +11046,7 @@ OpenAI.Webhooks = Webhooks;
9065
11046
  OpenAI.Beta = Beta;
9066
11047
  OpenAI.Batches = Batches;
9067
11048
  OpenAI.Uploads = Uploads;
11049
+ OpenAI.Admin = Admin;
9068
11050
  OpenAI.Responses = Responses;
9069
11051
  OpenAI.Realtime = Realtime;
9070
11052
  OpenAI.Conversations = Conversations;
@@ -11624,7 +13606,6 @@ function zodTextFormat(zodObject, name, props) {
11624
13606
  }, (content) => zodObject.parse(JSON.parse(content)));
11625
13607
  }
11626
13608
 
11627
- // llm-openai-config.ts
11628
13609
  const DEFAULT_MODEL = 'gpt-5-mini';
11629
13610
  const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11630
13611
  const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
@@ -11705,25 +13686,144 @@ const deepseekModelCosts = {
11705
13686
  function shouldUseGPT5HighContextPricing(model, inputTokens) {
11706
13687
  return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
11707
13688
  }
11708
- /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
11709
- const openAiImageCosts = {
11710
- 'gpt-image-1': 0.0075, // $0.0075 per image for gpt-image-1
11711
- 'gpt-image-1.5': 0.0075, // Assumes parity pricing with gpt-image-1 until OpenAI publishes updated rates
13689
+ const DEFAULT_IMAGE_PRICING_QUALITY = 'high';
13690
+ const DEFAULT_IMAGE_PRICING_SIZE = '1024x1024';
13691
+ const PRICED_OPENAI_IMAGE_MODELS = [
13692
+ 'gpt-image-2',
13693
+ 'gpt-image-2-2026-04-21',
13694
+ 'gpt-image-1.5',
13695
+ 'gpt-image-1',
13696
+ 'gpt-image-1-mini',
13697
+ ];
13698
+ const OPENAI_IMAGE_PRICING_SIZES = ['1024x1024', '1024x1536', '1536x1024'];
13699
+ /**
13700
+ * Estimated image output costs in USD per image for common GPT Image sizes.
13701
+ * Last updated May 2026 from the OpenAI image generation guide. Text and image
13702
+ * input token costs for prompts and edit inputs are not included.
13703
+ */
13704
+ const openAiImageCostByQualityAndSize = {
13705
+ 'gpt-image-2': {
13706
+ low: {
13707
+ '1024x1024': 0.006,
13708
+ '1024x1536': 0.005,
13709
+ '1536x1024': 0.005,
13710
+ },
13711
+ medium: {
13712
+ '1024x1024': 0.053,
13713
+ '1024x1536': 0.041,
13714
+ '1536x1024': 0.041,
13715
+ },
13716
+ high: {
13717
+ '1024x1024': 0.211,
13718
+ '1024x1536': 0.165,
13719
+ '1536x1024': 0.165,
13720
+ },
13721
+ },
13722
+ 'gpt-image-2-2026-04-21': {
13723
+ low: {
13724
+ '1024x1024': 0.006,
13725
+ '1024x1536': 0.005,
13726
+ '1536x1024': 0.005,
13727
+ },
13728
+ medium: {
13729
+ '1024x1024': 0.053,
13730
+ '1024x1536': 0.041,
13731
+ '1536x1024': 0.041,
13732
+ },
13733
+ high: {
13734
+ '1024x1024': 0.211,
13735
+ '1024x1536': 0.165,
13736
+ '1536x1024': 0.165,
13737
+ },
13738
+ },
13739
+ 'gpt-image-1.5': {
13740
+ low: {
13741
+ '1024x1024': 0.009,
13742
+ '1024x1536': 0.013,
13743
+ '1536x1024': 0.013,
13744
+ },
13745
+ medium: {
13746
+ '1024x1024': 0.034,
13747
+ '1024x1536': 0.05,
13748
+ '1536x1024': 0.05,
13749
+ },
13750
+ high: {
13751
+ '1024x1024': 0.133,
13752
+ '1024x1536': 0.2,
13753
+ '1536x1024': 0.2,
13754
+ },
13755
+ },
13756
+ 'gpt-image-1': {
13757
+ low: {
13758
+ '1024x1024': 0.011,
13759
+ '1024x1536': 0.016,
13760
+ '1536x1024': 0.016,
13761
+ },
13762
+ medium: {
13763
+ '1024x1024': 0.042,
13764
+ '1024x1536': 0.063,
13765
+ '1536x1024': 0.063,
13766
+ },
13767
+ high: {
13768
+ '1024x1024': 0.167,
13769
+ '1024x1536': 0.25,
13770
+ '1536x1024': 0.25,
13771
+ },
13772
+ },
13773
+ 'gpt-image-1-mini': {
13774
+ low: {
13775
+ '1024x1024': 0.005,
13776
+ '1024x1536': 0.006,
13777
+ '1536x1024': 0.006,
13778
+ },
13779
+ medium: {
13780
+ '1024x1024': 0.011,
13781
+ '1024x1536': 0.015,
13782
+ '1536x1024': 0.015,
13783
+ },
13784
+ high: {
13785
+ '1024x1024': 0.036,
13786
+ '1024x1536': 0.052,
13787
+ '1536x1024': 0.052,
13788
+ },
13789
+ },
11712
13790
  };
13791
+ function isPricedOpenAIImageModel(model) {
13792
+ return PRICED_OPENAI_IMAGE_MODELS.includes(model);
13793
+ }
13794
+ function isOpenAIImagePricingSize(size) {
13795
+ return OPENAI_IMAGE_PRICING_SIZES.includes(size);
13796
+ }
13797
+ function resolveImagePricingQuality(quality) {
13798
+ if (quality === 'low' || quality === 'medium' || quality === 'high') {
13799
+ return quality;
13800
+ }
13801
+ return DEFAULT_IMAGE_PRICING_QUALITY;
13802
+ }
13803
+ function resolveImagePricingSize(size) {
13804
+ if (typeof size === 'string' && isOpenAIImagePricingSize(size)) {
13805
+ return size;
13806
+ }
13807
+ return DEFAULT_IMAGE_PRICING_SIZE;
13808
+ }
11713
13809
  /**
11714
13810
  * Calculates the cost of generating images using OpenAI's Images API.
11715
13811
  *
11716
13812
  * @param model The image generation model name.
11717
13813
  * @param imageCount The number of images generated.
13814
+ * @param quality The requested image quality.
13815
+ * @param size The requested image size.
11718
13816
  * @returns The cost of generating the images in USD.
11719
13817
  */
11720
- function calculateImageCost(model, imageCount) {
13818
+ function calculateImageCost(model, imageCount, quality, size) {
11721
13819
  if (typeof model !== 'string' || typeof imageCount !== 'number' || imageCount <= 0) {
11722
13820
  return 0;
11723
13821
  }
11724
- const costPerImage = openAiImageCosts[model];
11725
- if (!costPerImage)
13822
+ if (!isPricedOpenAIImageModel(model))
11726
13823
  return 0;
13824
+ const pricingQuality = resolveImagePricingQuality(quality);
13825
+ const pricingSize = resolveImagePricingSize(size);
13826
+ const costPerImage = openAiImageCostByQualityAndSize[model][pricingQuality][pricingSize];
11727
13827
  return imageCount * costPerImage;
11728
13828
  }
11729
13829
  /**
@@ -12422,7 +14522,7 @@ async function makeLLMCall(input, options = {}) {
12422
14522
  return await makeResponsesAPICall(processedInput, responsesOptions);
12423
14523
  }
12424
14524
 
12425
- const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
14525
+ const DEFAULT_IMAGE_MODEL = 'gpt-image-2';
12426
14526
  const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
12427
14527
  const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
12428
14528
  /**
@@ -12511,7 +14611,7 @@ async function makeImagesCall(prompt, options = {}) {
12511
14611
  throw new Error('No images returned from OpenAI Images API');
12512
14612
  }
12513
14613
  // Calculate cost
12514
- const cost = calculateImageCost(imageModel, count || 1);
14614
+ const cost = calculateImageCost(imageModel, count || 1, quality, size);
12515
14615
  // Return the response with enhanced usage information
12516
14616
  const enhancedResponse = {
12517
14617
  ...response,
@@ -21566,5 +23666,5 @@ const disco = {
21566
23666
  },
21567
23667
  };
21568
23668
 
21569
- export { AlpacaMarketDataAPI, AlpacaTradingAPI, OPENAI_MODELS, OPENROUTER_MODELS, disco, isOpenAIModel, isOpenRouterModel, supportsTemperature };
23669
+ export { AlpacaMarketDataAPI, AlpacaTradingAPI, OPENAI_IMAGE_MODELS, OPENAI_MODELS, OPENROUTER_MODELS, disco, isOpenAIImageModel, isOpenAIModel, isOpenRouterModel, supportsTemperature };
21570
23670
  //# sourceMappingURL=index.mjs.map