diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 16c903ece..ab55ecdd8 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: "" id: "" management: - docChecksum: 4f788aa6e5dc1ba741d875efae921dd0 + docChecksum: 7355ca8d820d1af33337c0cd907c51e3 docVersion: 1.0.0 speakeasyVersion: 1.808.1 generationVersion: 2.960.8 - releaseVersion: 1.5.167 - configChecksum: 7368315b9109499da3cb67c43ec385a8 + releaseVersion: 1.5.168 + configChecksum: 3888ae92124fa56020ca40bfa0016cc1 repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true @@ -1864,6 +1864,7 @@ trackedFiles: docs/models/box.mdx: id: 60189ae274d6 pristine_git_object: 55fa409925b0e7e3d4b2450df703c101f67a3d0d + docs/models/bucketby.mdx: {} docs/models/budgetaccountguardrailpolicy.mdx: id: 298ff31bc409 pristine_git_object: 85cd4adb90e4471fbeb6035f4700a5ecb9c3dfd6 @@ -2039,6 +2040,15 @@ trackedFiles: docs/models/capabilitydescriptor.mdx: id: 9300b066dc6b pristine_git_object: 9caa6e69bb99158cb99c2c3f49dc562bc9a55617 + docs/models/capacityguardrailpolicy.mdx: {} + docs/models/capacityguardrailpolicydetail.mdx: {} + docs/models/capacityguardrailpolicydetailpolicytype.mdx: {} + docs/models/capacityguardrailpolicydetailreference.mdx: {} + docs/models/capacityguardrailpolicydetailresponse.mdx: {} + docs/models/capacityguardrailpolicypolicytype.mdx: {} + docs/models/capacityguardrailpolicyresponse.mdx: {} + docs/models/capacityguardrailpolicysummary.mdx: {} + docs/models/capacityguardrailpolicysummarypolicytype.mdx: {} docs/models/cascademode.mdx: id: 25f8cafe9058 pristine_git_object: df9dc488c82508addcacbddc4883e0f544d155d6 @@ -3504,6 +3514,8 @@ trackedFiles: docs/models/createbyokkeyresponse.mdx: id: 8548d8738625 pristine_git_object: 5ebb548b4dc421bf35e55cb76d3efa2d58af69d7 + docs/models/createcapacityguardrailpolicyrequest.mdx: {} + docs/models/createcapacityguardrailpolicyrequestpolicytype.mdx: {} docs/models/createexternaluserrequest.mdx: id: 56b13a9e4f18 pristine_git_object: 95696766cf0d9fa3b7b0c0b497457a24e2004d91 @@ -5144,6 +5156,9 @@ trackedFiles: docs/models/guardrailbudgetpolicyconfig.mdx: id: 24366aa6d86d pristine_git_object: 186835a3aa3f19ae5f41e772545555ecdb47e4a6 + docs/models/guardrailcapacitylimit.mdx: {} + docs/models/guardrailcapacitylimitunit.mdx: {} + docs/models/guardrailcapacitypolicyconfig.mdx: {} docs/models/guardraildataregion.mdx: id: 3cac5d56218f pristine_git_object: 4d893b87c579a77f076856e1751b78fba195fa3f @@ -6100,6 +6115,7 @@ trackedFiles: docs/models/listbyokkeysresponse.mdx: id: 3e4531beaf95 pristine_git_object: 56c04219d3ace77780ab1962f5c91ff116377399 + docs/models/listcapacityguardrailpoliciesresponse.mdx: {} docs/models/listendpointsresponse.mdx: id: 67f685fdc519 pristine_git_object: 80ac049e255d02178810d3a362d37a4170bf00a7 @@ -6912,6 +6928,7 @@ trackedFiles: docs/models/modelresponse.mdx: id: b41c751b5708 pristine_git_object: ceca43a5e0d19729f5320b7b47e2dec9f1420af4 + docs/models/models.mdx: {} docs/models/modelscountresponse.mdx: id: 9ce251dc48fa pristine_git_object: c7bd6b349663b873261d53e4cbd632ad114bb1de @@ -6923,6 +6940,7 @@ trackedFiles: docs/models/modelscountresponsedata.mdx: id: 35e5d2aa9065 pristine_git_object: d7dff46eef5200f916f309d3dbb9ec88287b2ff3 + docs/models/modelsenum.mdx: {} docs/models/modelslistresponse.mdx: id: e4fca550ce24 pristine_git_object: 2a14e36bfe5ee3c0e09a04f3b055bbede5dcee51 @@ -7996,6 +8014,8 @@ trackedFiles: docs/models/operations/createbyokkeyrequest.mdx: id: 316288b88ec0 pristine_git_object: 34f0a3cd9330f97b2520ac54b011c0a26457a7f9 + docs/models/operations/createcapacitypolicyglobals.mdx: {} + docs/models/operations/createcapacitypolicyrequest.mdx: {} docs/models/operations/createembeddingsdata.mdx: id: 4603e7c2f657 pristine_git_object: 5278f3c7abf4df51bed5f540df8ec18a98b8d61a @@ -8342,6 +8362,8 @@ trackedFiles: docs/models/operations/deletebyokkeyrequest.mdx: id: 93e1a6557e28 pristine_git_object: bafc9e5c3e4f62b0f0a89c40b3bf3da5c6a72eb6 + docs/models/operations/deletecapacitypolicyglobals.mdx: {} + docs/models/operations/deletecapacitypolicyrequest.mdx: {} docs/models/operations/deleteexternaluserglobals.mdx: id: 833b789dcc62 pristine_git_object: 396b66171f5930d9be5b1bc1100c4a4dd7831f42 @@ -8761,6 +8783,8 @@ trackedFiles: docs/models/operations/getbyokkeyrequest.mdx: id: 9c447e3ec71d pristine_git_object: 2191dc6223bb6b7a2c3017df7f5ecb203753eb06 + docs/models/operations/getcapacitypolicyglobals.mdx: {} + docs/models/operations/getcapacitypolicyrequest.mdx: {} docs/models/operations/getcontainerfileglobals.mdx: id: 3a47255ef558 pristine_git_object: 3f8d84c999f2289634674c34b89f14f7155aa4b0 @@ -9182,6 +9206,9 @@ trackedFiles: docs/models/operations/listbyokkeysresponse.mdx: id: 23158c88a16c pristine_git_object: f04309122b3000cdc6469669c58722c30de2fbd8 + docs/models/operations/listcapacitypoliciesglobals.mdx: {} + docs/models/operations/listcapacitypoliciesrequest.mdx: {} + docs/models/operations/listcapacitypoliciesresponse.mdx: {} docs/models/operations/listcontainerfilesglobals.mdx: id: b92d7b513ebf pristine_git_object: 56541561d7b0b4d6312ca6fa2456d877591fa755 @@ -9960,6 +9987,8 @@ trackedFiles: docs/models/operations/updatebyokkeyrequest.mdx: id: 6dd63623997d pristine_git_object: ad4d572f3510a505d39f6f2bac2f07501f40e2ad + docs/models/operations/updatecapacitypolicyglobals.mdx: {} + docs/models/operations/updatecapacitypolicyrequest.mdx: {} docs/models/operations/updateexternaluserglobals.mdx: id: d1fae9cfe0ab pristine_git_object: adc796e4c12329a1b16ba32c72987a0b71627038 @@ -13572,6 +13601,7 @@ trackedFiles: docs/models/updatebyokkeyresponse.mdx: id: 3ad646ddc662 pristine_git_object: aeaeda620c3b61782b802fdd3bac843f71f32425 + docs/models/updatecapacityguardrailpolicyrequest.mdx: {} docs/models/updateexternaluserrequest.mdx: id: 1ad256fed067 pristine_git_object: 05ae49ce32b10736190f923d3ede3e0bc7ff7570 @@ -14545,6 +14575,7 @@ trackedFiles: src/funcs/guardrailPoliciesCreateBudgetPolicy.ts: id: a79f5af4c5c2 pristine_git_object: a73df413e828d8a43bbc63f2e9a675518a979fc3 + src/funcs/guardrailPoliciesCreateCapacityPolicy.ts: {} src/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.ts: id: 2b979a2c959f pristine_git_object: 00d405f42b1f479491e6b0d83021b5bdcd754676 @@ -14557,6 +14588,7 @@ trackedFiles: src/funcs/guardrailPoliciesDeleteBudgetPolicy.ts: id: d1f10f2a06c4 pristine_git_object: fa7cec93f9b684da20443431e245bf10cd378a15 + src/funcs/guardrailPoliciesDeleteCapacityPolicy.ts: {} src/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.ts: id: 1e732901786e pristine_git_object: 7d21116a1c116c56b343b604b21ee6d326dd82e7 @@ -14570,6 +14602,7 @@ trackedFiles: src/funcs/guardrailPoliciesGetBudgetPolicy.ts: id: 4c260766198d pristine_git_object: fe37cdc7b6332932c5949099840d546c4b18ff30 + src/funcs/guardrailPoliciesGetCapacityPolicy.ts: {} src/funcs/guardrailPoliciesGetMemberPolicyAssignment.ts: id: 3ed3be5b3d94 pristine_git_object: cd8d1b187cc0db0ea598c8a8b2cbcc0ef9b2545a @@ -14586,6 +14619,7 @@ trackedFiles: src/funcs/guardrailPoliciesListBudgetPolicies.ts: id: 0dcf7b8d8c03 pristine_git_object: 3ec4e4c94f9178bfece85d03a90930d98e9d6582 + src/funcs/guardrailPoliciesListCapacityPolicies.ts: {} src/funcs/guardrailPoliciesListModelAvailabilityPolicies.ts: id: 9b475003fe34 pristine_git_object: 524949acba02229f590bf83754c9f330a652f286 @@ -14600,6 +14634,7 @@ trackedFiles: src/funcs/guardrailPoliciesUpdateBudgetPolicy.ts: id: 04a2340f871e pristine_git_object: 21babad90ee5a2eeb741e2085676d84263eed300 + src/funcs/guardrailPoliciesUpdateCapacityPolicy.ts: {} src/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.ts: id: b441ba2c4612 pristine_git_object: fa0d3076c6dddfbb823524430c6429c82022d881 @@ -15562,6 +15597,11 @@ trackedFiles: src/models/capabilitydescriptor.ts: id: 867d654ac8ab pristine_git_object: 610154ca320e7a61495ca159dfddc205355ad68e + src/models/capacityguardrailpolicy.ts: {} + src/models/capacityguardrailpolicydetail.ts: {} + src/models/capacityguardrailpolicydetailresponse.ts: {} + src/models/capacityguardrailpolicyresponse.ts: {} + src/models/capacityguardrailpolicysummary.ts: {} src/models/changeguardrailpolicyassignmentrequest.ts: id: 4b85db36d2ce pristine_git_object: e9df0c38ee28f047f866414570a09bac9e496a2f @@ -15860,6 +15900,7 @@ trackedFiles: src/models/createbyokkeyresponse.ts: id: 93fb8363303b pristine_git_object: db7f7476736a5d486bcbfe50c06b5c80c6e2883e + src/models/createcapacityguardrailpolicyrequest.ts: {} src/models/createexternaluserrequest.ts: id: dabbf073ef0b pristine_git_object: ff23af8082b911c16d061e83c3ff26202e52de6b @@ -16397,6 +16438,8 @@ trackedFiles: src/models/guardrailbudgetpolicyconfig.ts: id: a7c9ca00225f pristine_git_object: b04f3df95563c88ba8f8c962e5e9e94694c4aa17 + src/models/guardrailcapacitylimit.ts: {} + src/models/guardrailcapacitypolicyconfig.ts: {} src/models/guardraildataregion.ts: id: 5e2e4801b177 pristine_git_object: 55553bde303e154cc4bd311a5515ae437b824a64 @@ -16583,6 +16626,7 @@ trackedFiles: src/models/listbyokkeysresponse.ts: id: 58b401d42307 pristine_git_object: c7d5a689bff9507370850473760b9d9e8ac4e3bf + src/models/listcapacityguardrailpoliciesresponse.ts: {} src/models/listendpointsresponse.ts: id: 5178e92a44ba pristine_git_object: 71cf52aa220abd1f2e4de769b679815bc1c1ee7d @@ -17045,6 +17089,7 @@ trackedFiles: src/models/operations/createbyokkey.ts: id: 1725e1bba8d8 pristine_git_object: 536c37a011550df4f81508b09ac6790233bf92c6 + src/models/operations/createcapacitypolicy.ts: {} src/models/operations/createembeddings.ts: id: 7c210337fdff pristine_git_object: 5828a573a05d7616dbf99139eb3f2384c5f7e837 @@ -17121,6 +17166,7 @@ trackedFiles: src/models/operations/deletebyokkey.ts: id: 948bcb0fbfc1 pristine_git_object: 2bd54f48f0c362b36d41cccf37e6366629b7e39e + src/models/operations/deletecapacitypolicy.ts: {} src/models/operations/deleteexternaluser.ts: id: a152c674057b pristine_git_object: f074f9d3ac031b3af905aeab7c7e1a387efc304e @@ -17205,6 +17251,7 @@ trackedFiles: src/models/operations/getbyokkey.ts: id: 883c19bd90fb pristine_git_object: aa4ea52ed70e6c58a92930f9a6d9724603fa65a1 + src/models/operations/getcapacitypolicy.ts: {} src/models/operations/getcontainerfile.ts: id: 2fb4120bb6ff pristine_git_object: 6b728bfd12fa8d2d55a58e8d85097aea7923299b @@ -17313,6 +17360,7 @@ trackedFiles: src/models/operations/listbyokkeys.ts: id: 953de50b8d0e pristine_git_object: e27003be602bd31c1f802ee9ed98193585a51044 + src/models/operations/listcapacitypolicies.ts: {} src/models/operations/listcontainerfiles.ts: id: 833ac1772f55 pristine_git_object: cd8b9ec3151136cd984fb48af161ca264099bb15 @@ -17463,6 +17511,7 @@ trackedFiles: src/models/operations/updatebyokkey.ts: id: e302ae3fa539 pristine_git_object: e0cc22e58b768818ff68f4273c1323513115a1a4 + src/models/operations/updatecapacitypolicy.ts: {} src/models/operations/updateexternaluser.ts: id: 89e743bb6fb7 pristine_git_object: 7a41351217e3138e790b857027a4b9d8e62540b3 @@ -18335,6 +18384,7 @@ trackedFiles: src/models/updatebyokkeyresponse.ts: id: 016842b2461b pristine_git_object: c14691083fe55e6bc7f5b5204fadbcafcf3c726b + src/models/updatecapacityguardrailpolicyrequest.ts: {} src/models/updateexternaluserrequest.ts: id: 61f141e8739a pristine_git_object: 555bb0924165ad829d977424a215b9f890252f7f @@ -24062,11 +24112,106 @@ examples: application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + listCapacityPolicies: + speakeasy-default-list-capacity-policies: + parameters: + query: + workspace_id: "0df9e665-d932-5740-b2c7-b52af166bc11" + responses: + "200": + application/json: {"data": [], "total_count": 1} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + createCapacityPolicy: + speakeasy-default-create-capacity-policy: + requestBody: + application/json: {"config": {"bucket_by": ["member", "model"], "limits": [{"limit": 100000, "models": "all", "unit": "tokens"}]}, "name": "Engineering monthly budget", "policy_type": "rate_limit", "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"} + responses: + "201": + application/json: {"data": {"config": {"bucket_by": ["member", "model"], "limits": [{"limit": 100000, "models": "all", "unit": "tokens"}]}, "id": "550e8400-e29b-41d4-a716-446655440000", "name": "Engineering monthly budget", "policy_type": "rate_limit"}} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + deleteCapacityPolicy: + speakeasy-default-delete-capacity-policy: + parameters: + path: + id: "550e8400-e29b-41d4-a716-446655440000" + query: + workspace_id: "0df9e665-d932-5740-b2c7-b52af166bc11" + responses: + "200": + application/json: {"data": true} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + getCapacityPolicy: + speakeasy-default-get-capacity-policy: + parameters: + path: + id: "550e8400-e29b-41d4-a716-446655440000" + query: + workspace_id: "0df9e665-d932-5740-b2c7-b52af166bc11" + responses: + "200": + application/json: {"data": {"api_key_hashes": ["c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"], "config": {"bucket_by": ["member", "model"], "limits": [{"limit": 100000, "models": "all", "unit": "tokens"}]}, "id": "550e8400-e29b-41d4-a716-446655440000", "member_ids": ["user_2abcDEFghiJKLmnoPQRstu"], "name": "Engineering monthly budget", "opted_out_api_key_hashes": ["c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"], "overridden_api_key_hashes": ["c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"], "policy_type": "rate_limit", "reference": null, "updated_at": "1735660473092"}} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + updateCapacityPolicy: + speakeasy-default-update-capacity-policy: + parameters: + path: + id: "550e8400-e29b-41d4-a716-446655440000" + requestBody: + application/json: {"config": {"bucket_by": ["member", "model"], "limits": [{"limit": 100000, "models": "all", "unit": "tokens"}]}, "name": "Engineering monthly budget", "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"} + responses: + "200": + application/json: {"data": {"config": {"bucket_by": ["member", "model"], "limits": [{"limit": 100000, "models": "all", "unit": "tokens"}]}, "id": "550e8400-e29b-41d4-a716-446655440000", "name": "Engineering monthly budget", "policy_type": "rate_limit"}} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: | - ## Typescript SDK Changes: - * `openrouter.guardrailPolicies.listScimGroupPolicyAssignments()`: **Added** - * `openrouter.guardrailPolicies.getScimGroupPolicyAssignment()`: **Added** - * `openrouter.guardrailPolicies.updateScimGroupPolicyAssignment()`: **Added** - * `openrouter.guardrailPolicies.deleteScimGroupPolicyOptOut()`: **Added** - * `openrouter.guardrailPolicies.listScimGroupPolicyOptOuts()`: **Added** +releaseNotes: "## Typescript SDK Changes:\n* `openrouter.guardrailPolicies.listCapacityPolicies()`: **Added**\n* `openrouter.guardrailPolicies.createCapacityPolicy()`: **Added**\n* `openrouter.guardrailPolicies.deleteCapacityPolicy()`: **Added**\n* `openrouter.guardrailPolicies.getCapacityPolicy()`: **Added**\n* `openrouter.guardrailPolicies.updateCapacityPolicy()`: **Added**\n* `openrouter.guardrailPolicies.createBudgetPolicy()`: \n * `request.createBudgetGuardrailPolicyRequest.moveExistingAssignments` **Added**\n* `openrouter.guardrailPolicies.createModelAvailabilityPolicy()`: \n * `request.createModelAvailabilityGuardrailPolicyRequest.moveExistingAssignments` **Added**\n* `openrouter.guardrailPolicies.createModerationPolicy()`: \n * `request.createModerationGuardrailPolicyRequest.moveExistingAssignments` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 32767c8a7..a46c8c56f 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -38,7 +38,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.5.167 + version: 1.5.168 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 89590e886..e8d32a63d 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -7779,6 +7779,186 @@ components: - $ref: '#/components/schemas/EnumCapability' - $ref: '#/components/schemas/RangeCapability' - $ref: '#/components/schemas/BooleanCapability' + CapacityGuardrailPolicy: + properties: + config: + $ref: '#/components/schemas/GuardrailCapacityPolicyConfig' + id: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + name: + description: 'Policy name' + example: 'Engineering monthly budget' + maxLength: 255 + minLength: 1 + type: 'string' + policy_type: + enum: + - 'rate_limit' + type: 'string' + required: + - 'id' + - 'name' + - 'policy_type' + - 'config' + type: 'object' + CapacityGuardrailPolicyDetail: + properties: + api_key_hashes: + description: 'API key hashes' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + config: + $ref: '#/components/schemas/GuardrailCapacityPolicyConfig' + id: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + is_workspace_default: + type: 'boolean' + member_ids: + description: 'Organization member user IDs' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + name: + description: 'Policy name' + example: 'Engineering monthly budget' + maxLength: 255 + minLength: 1 + type: 'string' + opted_out_api_key_hashes: + description: 'API key hashes' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + opted_out_member_ids: + description: 'Organization member user IDs' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + overridden_api_key_hashes: + description: 'API keys that have a different policy of this type assigned directly' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + overridden_member_ids: + description: 'Members that have a different policy of this type assigned directly' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + policy_type: + enum: + - 'rate_limit' + type: 'string' + reference: + default: null + description: '`legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null`' + enum: + - 'legacy_mapping' + - 'account_default' + - null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow + updated_at: + type: + - 'string' + - 'null' + required: + - 'id' + - 'name' + - 'policy_type' + - 'config' + - 'updated_at' + - 'member_ids' + - 'api_key_hashes' + - 'opted_out_api_key_hashes' + - 'overridden_api_key_hashes' + type: 'object' + CapacityGuardrailPolicyDetailResponse: + properties: + data: + $ref: '#/components/schemas/CapacityGuardrailPolicyDetail' + required: + - 'data' + type: 'object' + CapacityGuardrailPolicyResponse: + properties: + data: + $ref: '#/components/schemas/CapacityGuardrailPolicy' + required: + - 'data' + type: 'object' + CapacityGuardrailPolicySummary: + properties: + api_key_count: + minimum: 0 + type: 'integer' + config: + $ref: '#/components/schemas/GuardrailCapacityPolicyConfig' + id: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + is_workspace_default: + type: 'boolean' + member_count: + minimum: 0 + type: 'integer' + name: + description: 'Policy name' + example: 'Engineering monthly budget' + maxLength: 255 + minLength: 1 + type: 'string' + policy_type: + enum: + - 'rate_limit' + type: 'string' + updated_at: + type: + - 'string' + - 'null' + required: + - 'id' + - 'name' + - 'policy_type' + - 'config' + - 'updated_at' + - 'member_count' + - 'api_key_count' + type: 'object' ChangeGuardrailPolicyAssignmentRequest: properties: assigned: @@ -7795,7 +7975,7 @@ components: format: 'uuid' type: 'string' policy_type: - description: 'Policy type the assignment is read or changed for' + description: 'Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`.' enum: - 'budget' - 'model_availability' @@ -10742,6 +10922,9 @@ components: minLength: 1 type: 'string' type: 'array' + move_existing_assignments: + description: 'When creating a new workspace default, also move the replaced default policy''s explicit member and API key assignments onto this policy. Defaults to `false`.' + type: 'boolean' name: description: 'Policy name' example: 'Engineering monthly budget' @@ -10905,6 +11088,73 @@ components: required: - 'data' type: 'object' + CreateCapacityGuardrailPolicyRequest: + properties: + api_key_hashes: + description: 'API key hashes' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + config: + $ref: '#/components/schemas/GuardrailCapacityPolicyConfig' + is_workspace_default: + description: 'Make this the workspace default for its policy type. Defaults to `false`.' + type: 'boolean' + member_ids: + description: 'Organization member user IDs' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + move_existing_assignments: + description: 'When creating a new workspace default, also move the replaced default policy''s explicit member and API key assignments onto this policy. Defaults to `false`.' + type: 'boolean' + name: + description: 'Policy name' + example: 'Engineering monthly budget' + maxLength: 255 + minLength: 1 + type: 'string' + opted_out_api_key_hashes: + description: 'API keys that should not inherit the policy when it is the workspace default' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + opted_out_member_ids: + description: 'Members that should not inherit the policy when it is the workspace default' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + policy_type: + enum: + - 'rate_limit' + type: 'string' + workspace_id: + description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' + format: 'uuid' + type: 'string' + required: + - 'name' + - 'policy_type' + - 'config' + - 'workspace_id' + type: 'object' CreateCreditPurchaseRequest: properties: credit_amount_usd: @@ -11251,6 +11501,9 @@ components: minLength: 1 type: 'string' type: 'array' + move_existing_assignments: + description: 'When creating a new workspace default, also move the replaced default policy''s explicit member and API key assignments onto this policy. Defaults to `false`.' + type: 'boolean' name: description: 'Policy name' example: 'Engineering monthly budget' @@ -11314,6 +11567,9 @@ components: minLength: 1 type: 'string' type: 'array' + move_existing_assignments: + description: 'When creating a new workspace default, also move the replaced default policy''s explicit member and API key assignments onto this policy. Defaults to `false`.' + type: 'boolean' name: description: 'Policy name' example: 'Engineering monthly budget' @@ -16640,6 +16896,81 @@ components: reset_interval: $ref: '#/components/schemas/GuardrailInterval' type: 'object' + GuardrailCapacityLimit: + additionalProperties: false + properties: + limit: + description: 'Bucket capacity and per-minute refill rate.' + example: 100000 + minimum: 1 + type: 'integer' + models: + anyOf: + - description: 'Apply this limit to every model.' + enum: + - 'all' + type: 'string' + - description: 'Exact model slugs covered by this limit (wildcards are not supported).' + example: + - 'openai/gpt-4o' + items: + maxLength: 255 + minLength: 1 + type: 'string' + minItems: 1 + type: 'array' + description: 'Either `"all"` to cover every model or a non-empty list of exact model slugs.' + example: 'all' + unit: + description: 'Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`).' + enum: + - 'tokens' + - 'requests' + example: 'tokens' + type: 'string' + x-speakeasy-unknown-values: allow + required: + - 'unit' + - 'limit' + - 'models' + type: 'object' + GuardrailCapacityPolicyConfig: + additionalProperties: false + example: + bucket_by: + - 'member' + - 'model' + limits: + - limit: 100000 + models: 'all' + unit: 'tokens' + properties: + bucket_by: + description: 'Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`.' + example: + - 'member' + - 'model' + items: + enum: + - 'workspace' + - 'member' + - 'api_key' + - 'model' + type: 'string' + x-speakeasy-unknown-values: allow + minItems: 1 + type: 'array' + limits: + description: 'One or more per-minute token or request limits (up to 200 entries and 200 listed models total).' + items: + $ref: '#/components/schemas/GuardrailCapacityLimit' + maxItems: 200 + minItems: 1 + type: 'array' + required: + - 'bucket_by' + - 'limits' + type: 'object' GuardrailDataRegion: description: 'An OpenRouter data region: `global` (https://openrouter.ai), `europe` (https://eu.openrouter.ai), or `us` (https://us.openrouter.ai)' enum: @@ -19211,6 +19542,21 @@ components: - 'data' - 'total_count' type: 'object' + ListCapacityGuardrailPoliciesResponse: + properties: + data: + items: + $ref: '#/components/schemas/CapacityGuardrailPolicySummary' + type: 'array' + total_count: + description: 'Total number of policies' + example: 1 + minimum: 0 + type: 'integer' + required: + - 'data' + - 'total_count' + type: 'object' ListEndpointsResponse: description: 'List of available endpoints for a model' example: @@ -39460,6 +39806,65 @@ components: required: - 'data' type: 'object' + UpdateCapacityGuardrailPolicyRequest: + properties: + api_key_hashes: + description: 'Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments.' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + config: + $ref: '#/components/schemas/GuardrailCapacityPolicyConfig' + is_workspace_default: + description: 'Omit to keep the stored default status; `false` unsets the policy as the workspace default.' + type: 'boolean' + member_ids: + description: 'Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments.' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + name: + description: 'Policy name' + example: 'Engineering monthly budget' + maxLength: 255 + minLength: 1 + type: 'string' + opted_out_api_key_hashes: + description: 'API key hashes' + example: + - 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + opted_out_member_ids: + description: 'Organization member user IDs' + example: + - 'user_2abcDEFghiJKLmnoPQRstu' + items: + maxLength: 255 + minLength: 1 + type: 'string' + type: 'array' + workspace_id: + description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' + format: 'uuid' + type: 'string' + required: + - 'name' + - 'config' + - 'workspace_id' + type: 'object' UpdateExternalUserRequest: additionalProperties: false example: @@ -51654,26 +52059,664 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Create a workspace-wide policy' + summary: 'Create a workspace-wide policy' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'createAccountPolicy' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /guardrails/policies/account/{id}: + delete: + description: 'Delete a workspace-wide policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'deleteAccountPolicy' + parameters: + - description: 'Policy ID' + in: 'path' + name: 'id' + required: true + schema: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteGuardrailPolicyResponse' + description: 'Workspace-wide policy deleted' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Delete a workspace-wide policy' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'deleteAccountPolicy' + put: + description: 'Replace a workspace-wide policy and its workspace coverage. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'updateAccountPolicy' + parameters: + - description: 'Policy ID' + in: 'path' + name: 'id' + required: true + schema: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AccountGuardrailPolicyRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AccountGuardrailPolicyResponse' + description: 'Workspace-wide policy updated' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Update a workspace-wide policy' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'updateAccountPolicy' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /guardrails/policies/assignments/api-keys/{hash}: + get: + description: 'Get the policies of one type that apply to an API key in a workspace. Requires a management key with write access. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'getApiKeyPolicyAssignment' + parameters: + - description: 'API key hash' + in: 'path' + name: 'hash' + required: true + schema: + description: 'API key hash' + example: 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + minLength: 1 + type: 'string' + - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' + format: 'uuid' + type: 'string' + - description: 'Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`.' + in: 'query' + name: 'policy_type' + required: true + schema: + description: 'Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`.' + enum: + - 'budget' + - 'model_availability' + - 'moderation' + - 'rate_limit' + example: 'budget' + type: 'string' + x-speakeasy-unknown-values: allow + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GuardrailPolicyAssignmentResponse' + description: 'Assignment state' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Get an API key policy assignment' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'getApiKeyPolicyAssignment' + put: + description: 'Assign or unassign one policy for an API key. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'changeApiKeyPolicyAssignment' + parameters: + - description: 'API key hash' + in: 'path' + name: 'hash' + required: true + schema: + description: 'API key hash' + example: 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' + minLength: 1 + type: 'string' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentResponse' + description: 'Assignment changed' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Change an API key policy assignment' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'changeApiKeyPolicyAssignment' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /guardrails/policies/assignments/members/{member_id}: + get: + description: 'Get the policies of one type that apply to a member in a workspace. Requires a management key with write access. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'getMemberPolicyAssignment' + parameters: + - description: 'Organization member user ID' + in: 'path' + name: 'member_id' + required: true + schema: + description: 'Organization member user ID' + example: 'user_2abcDEFghiJKLmnoPQRstu' + minLength: 1 + type: 'string' + - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' + format: 'uuid' + type: 'string' + - description: 'Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`.' + in: 'query' + name: 'policy_type' + required: true + schema: + description: 'Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`.' + enum: + - 'budget' + - 'model_availability' + - 'moderation' + - 'rate_limit' + example: 'budget' + type: 'string' + x-speakeasy-unknown-values: allow + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GuardrailPolicyAssignmentResponse' + description: 'Assignment state' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Get a member policy assignment' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'getMemberPolicyAssignment' + put: + description: 'Assign or unassign one policy for a member. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'changeMemberPolicyAssignment' + parameters: + - description: 'Organization member user ID' + in: 'path' + name: 'member_id' + required: true + schema: + description: 'Organization member user ID' + example: 'user_2abcDEFghiJKLmnoPQRstu' + minLength: 1 + type: 'string' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentResponse' + description: 'Assignment changed' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'Change a member policy assignment' + tags: + - 'Guardrail Policies' + x-speakeasy-name-override: 'changeMemberPolicyAssignment' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /guardrails/policies/assignments/scim-groups: + get: + description: 'List the guardrail policies attached to each SCIM group mapping in the organization. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'listScimGroupPolicyAssignments' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListScimGroupPolicyAssignmentsResponse' + description: 'Policy assignments for every SCIM group mapping' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + summary: 'List SCIM group policy assignments' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'createAccountPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/account/{id}: - delete: - description: 'Delete a workspace-wide policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'deleteAccountPolicy' + /guardrails/policies/assignments/scim-groups/{mapping_id}: + get: + description: 'Get the guardrail policies attached to one SCIM group mapping. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'getScimGroupPolicyAssignment' parameters: - - description: 'Policy ID' - in: 'path' - name: 'id' + - in: 'path' + name: 'mapping_id' required: true schema: - description: 'Policy ID' - example: '550e8400-e29b-41d4-a716-446655440000' format: 'uuid' type: 'string' responses: @@ -51681,8 +52724,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/DeleteGuardrailPolicyResponse' - description: 'Workspace-wide policy deleted' + $ref: '#/components/schemas/ScimGroupPolicyAssignmentResponse' + description: 'Policy assignment for the SCIM group mapping' '400': content: application/json: @@ -51743,36 +52786,32 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Delete a workspace-wide policy' + summary: 'Get a SCIM group policy assignment' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'deleteAccountPolicy' - put: - description: 'Replace a workspace-wide policy and its workspace coverage. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'updateAccountPolicy' + patch: + description: 'Attach or remove guardrail policies on one SCIM group mapping, then update its members'' policies. Every type in the request is applied, or none is. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'updateScimGroupPolicyAssignment' parameters: - - description: 'Policy ID' - in: 'path' - name: 'id' + - in: 'path' + name: 'mapping_id' required: true schema: - description: 'Policy ID' - example: '550e8400-e29b-41d4-a716-446655440000' format: 'uuid' type: 'string' requestBody: content: application/json: schema: - $ref: '#/components/schemas/AccountGuardrailPolicyRequest' + $ref: '#/components/schemas/UpdateScimGroupPolicyAssignmentRequest' required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/AccountGuardrailPolicyResponse' - description: 'Workspace-wide policy updated' + $ref: '#/components/schemas/ScimGroupPolicyAssignmentResponse' + description: 'Updated policy assignment' '400': content: application/json: @@ -51833,49 +52872,40 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Update a workspace-wide policy' + summary: 'Update a SCIM group policy assignment' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'updateAccountPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/assignments/api-keys/{hash}: - get: - description: 'Get the policies of one type that apply to an API key in a workspace. Requires a management key with write access. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'getApiKeyPolicyAssignment' + /guardrails/policies/assignments/scim-groups/{mapping_id}/opt-outs: + delete: + description: 'Remove a member''s opt-out for one policy type, so the member receives their groups'' policy again right away. The member must be in the mapping''s group and the mapping must set a policy of that type. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'deleteScimGroupPolicyOptOut' parameters: - - description: 'API key hash' - in: 'path' - name: 'hash' + - in: 'path' + name: 'mapping_id' required: true schema: - description: 'API key hash' - example: 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' - minLength: 1 + format: 'uuid' type: 'string' - - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' - in: 'query' - name: 'workspace_id' - required: false + - in: 'query' + name: 'user_id' + required: true schema: - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' - example: '0df9e665-d932-5740-b2c7-b52af166bc11' - format: 'uuid' + maxLength: 255 + minLength: 1 type: 'string' - - description: 'Policy type the assignment is read or changed for' - in: 'query' + - in: 'query' name: 'policy_type' required: true schema: - description: 'Policy type the assignment is read or changed for' enum: - 'budget' - 'model_availability' - 'moderation' - 'rate_limit' - example: 'budget' type: 'string' x-speakeasy-unknown-values: allow responses: @@ -51883,8 +52913,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/GuardrailPolicyAssignmentResponse' - description: 'Assignment state' + $ref: '#/components/schemas/DeleteScimGroupOptOutResponse' + description: 'Opt-out removed' '400': content: application/json: @@ -51925,6 +52955,16 @@ paths: schema: $ref: '#/components/schemas/NotFoundResponse' description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' '500': content: application/json: @@ -51935,36 +52975,26 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Get an API key policy assignment' + summary: 'Restore a member to a SCIM group policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'getApiKeyPolicyAssignment' - put: - description: 'Assign or unassign one policy for an API key. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'changeApiKeyPolicyAssignment' + get: + description: 'List the group''s members who opted out of a guardrail policy this mapping sets, per policy type. Opted-out members keep their own assignment (or none) instead of the group policy. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'listScimGroupPolicyOptOuts' parameters: - - description: 'API key hash' - in: 'path' - name: 'hash' + - in: 'path' + name: 'mapping_id' required: true schema: - description: 'API key hash' - example: 'c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93' - minLength: 1 + format: 'uuid' type: 'string' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentRequest' - required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentResponse' - description: 'Assignment changed' + $ref: '#/components/schemas/ListScimGroupOptOutsResponse' + description: 'Opt-outs from the group policies' '400': content: application/json: @@ -52025,28 +53055,37 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Change an API key policy assignment' + summary: 'List opt-outs from a SCIM group policy assignment' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'changeApiKeyPolicyAssignment' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/assignments/members/{member_id}: + /guardrails/policies/budget: get: - description: 'Get the policies of one type that apply to a member in a workspace. Requires a management key with write access. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'getMemberPolicyAssignment' + description: 'List the budget policies in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'listBudgetPolicies' parameters: - - description: 'Organization member user ID' - in: 'path' - name: 'member_id' - required: true + - description: 'Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned' + in: 'query' + name: 'offset' + required: false schema: - description: 'Organization member user ID' - example: 'user_2abcDEFghiJKLmnoPQRstu' - minLength: 1 - type: 'string' + description: 'Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned' + example: 0 + minimum: 0 + type: 'integer' + - description: 'Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned' + in: 'query' + name: 'limit' + required: false + schema: + description: 'Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned' + example: 50 + maximum: 100 + minimum: 1 + type: 'integer' - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' in: 'query' name: 'workspace_id' @@ -52056,27 +53095,13 @@ paths: example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' - - description: 'Policy type the assignment is read or changed for' - in: 'query' - name: 'policy_type' - required: true - schema: - description: 'Policy type the assignment is read or changed for' - enum: - - 'budget' - - 'model_availability' - - 'moderation' - - 'rate_limit' - example: 'budget' - type: 'string' - x-speakeasy-unknown-values: allow responses: '200': content: application/json: schema: - $ref: '#/components/schemas/GuardrailPolicyAssignmentResponse' - description: 'Assignment state' + $ref: '#/components/schemas/ListBudgetGuardrailPoliciesResponse' + description: 'List of budget policies' '400': content: application/json: @@ -52127,36 +53152,37 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Get a member policy assignment' + summary: 'List budget policies' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'getMemberPolicyAssignment' - put: - description: 'Assign or unassign one policy for a member. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'changeMemberPolicyAssignment' - parameters: - - description: 'Organization member user ID' - in: 'path' - name: 'member_id' - required: true - schema: - description: 'Organization member user ID' - example: 'user_2abcDEFghiJKLmnoPQRstu' - minLength: 1 - type: 'string' + x-speakeasy-name-override: 'listBudgetPolicies' + x-speakeasy-pagination: + inputs: + - in: 'parameters' + name: 'offset' + type: 'offset' + - in: 'parameters' + name: 'limit' + type: 'limit' + outputs: + results: '$.data' + type: 'offsetLimit' + post: + description: 'Create a budget policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'createBudgetPolicy' requestBody: content: application/json: schema: - $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentRequest' + $ref: '#/components/schemas/CreateBudgetGuardrailPolicyRequest' required: true responses: - '200': + '201': content: application/json: schema: - $ref: '#/components/schemas/ChangeGuardrailPolicyAssignmentResponse' - description: 'Assignment changed' + $ref: '#/components/schemas/BudgetGuardrailPolicyResponse' + description: 'budget policy created' '400': content: application/json: @@ -52217,25 +53243,44 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Change a member policy assignment' + summary: 'Create a budget policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'changeMemberPolicyAssignment' + x-speakeasy-name-override: 'createBudgetPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/assignments/scim-groups: - get: - description: 'List the guardrail policies attached to each SCIM group mapping in the organization. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'listScimGroupPolicyAssignments' + /guardrails/policies/budget/{id}: + delete: + description: 'Delete a budget policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'deleteBudgetPolicy' + parameters: + - description: 'Policy ID' + in: 'path' + name: 'id' + required: true + schema: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' + format: 'uuid' + type: 'string' responses: '200': content: application/json: schema: - $ref: '#/components/schemas/ListScimGroupPolicyAssignmentsResponse' - description: 'Policy assignments for every SCIM group mapping' + $ref: '#/components/schemas/DeleteGuardrailPolicyResponse' + description: 'budget policy deleted' '400': content: application/json: @@ -52296,22 +53341,30 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'List SCIM group policy assignments' + summary: 'Delete a budget policy' tags: - 'Guardrail Policies' - parameters: - - $ref: "#/components/parameters/AppIdentifier" - - $ref: "#/components/parameters/AppDisplayName" - - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/assignments/scim-groups/{mapping_id}: + x-speakeasy-name-override: 'deleteBudgetPolicy' get: - description: 'Get the guardrail policies attached to one SCIM group mapping. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'getScimGroupPolicyAssignment' + description: 'Get a budget policy with its member and API key assignments. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'getBudgetPolicy' parameters: - - in: 'path' - name: 'mapping_id' + - description: 'Policy ID' + in: 'path' + name: 'id' required: true schema: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' + format: 'uuid' + type: 'string' + - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' responses: @@ -52319,8 +53372,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ScimGroupPolicyAssignmentResponse' - description: 'Policy assignment for the SCIM group mapping' + $ref: '#/components/schemas/BudgetGuardrailPolicyDetailResponse' + description: 'budget policy details' '400': content: application/json: @@ -52361,16 +53414,6 @@ paths: schema: $ref: '#/components/schemas/NotFoundResponse' description: 'Not Found - Resource does not exist' - '409': - content: - application/json: - example: - error: - code: 409 - message: 'Resource conflict. Please try again later.' - schema: - $ref: '#/components/schemas/ConflictResponse' - description: 'Conflict - Resource conflict or concurrent modification' '500': content: application/json: @@ -52381,215 +53424,36 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Get a SCIM group policy assignment' + summary: 'Get a budget policy' tags: - 'Guardrail Policies' - patch: - description: 'Attach or remove guardrail policies on one SCIM group mapping, then update its members'' policies. Every type in the request is applied, or none is. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'updateScimGroupPolicyAssignment' + x-speakeasy-name-override: 'getBudgetPolicy' + put: + description: 'Replace a budget policy''s name and config, and optionally its assignments. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'updateBudgetPolicy' parameters: - - in: 'path' - name: 'mapping_id' + - description: 'Policy ID' + in: 'path' + name: 'id' required: true schema: + description: 'Policy ID' + example: '550e8400-e29b-41d4-a716-446655440000' format: 'uuid' type: 'string' requestBody: content: application/json: schema: - $ref: '#/components/schemas/UpdateScimGroupPolicyAssignmentRequest' + $ref: '#/components/schemas/UpdateBudgetGuardrailPolicyRequest' required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/ScimGroupPolicyAssignmentResponse' - description: 'Updated policy assignment' - '400': - content: - application/json: - example: - error: - code: 400 - message: 'Invalid request parameters' - schema: - $ref: '#/components/schemas/BadRequestResponse' - description: 'Bad Request - Invalid request parameters or malformed input' - '401': - content: - application/json: - example: - error: - code: 401 - message: 'Missing Authentication header' - schema: - $ref: '#/components/schemas/UnauthorizedResponse' - description: 'Unauthorized - Authentication required or invalid credentials' - '403': - content: - application/json: - example: - error: - code: 403 - message: 'Only management keys can perform this operation' - schema: - $ref: '#/components/schemas/ForbiddenResponse' - description: 'Forbidden - Authentication successful but insufficient permissions' - '404': - content: - application/json: - example: - error: - code: 404 - message: 'Resource not found' - schema: - $ref: '#/components/schemas/NotFoundResponse' - description: 'Not Found - Resource does not exist' - '409': - content: - application/json: - example: - error: - code: 409 - message: 'Resource conflict. Please try again later.' - schema: - $ref: '#/components/schemas/ConflictResponse' - description: 'Conflict - Resource conflict or concurrent modification' - '500': - content: - application/json: - example: - error: - code: 500 - message: 'Internal Server Error' - schema: - $ref: '#/components/schemas/InternalServerResponse' - description: 'Internal Server Error - Unexpected server error' - summary: 'Update a SCIM group policy assignment' - tags: - - 'Guardrail Policies' - parameters: - - $ref: "#/components/parameters/AppIdentifier" - - $ref: "#/components/parameters/AppDisplayName" - - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/assignments/scim-groups/{mapping_id}/opt-outs: - delete: - description: 'Remove a member''s opt-out for one policy type, so the member receives their groups'' policy again right away. The member must be in the mapping''s group and the mapping must set a policy of that type. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'deleteScimGroupPolicyOptOut' - parameters: - - in: 'path' - name: 'mapping_id' - required: true - schema: - format: 'uuid' - type: 'string' - - in: 'query' - name: 'user_id' - required: true - schema: - maxLength: 255 - minLength: 1 - type: 'string' - - in: 'query' - name: 'policy_type' - required: true - schema: - enum: - - 'budget' - - 'model_availability' - - 'moderation' - - 'rate_limit' - type: 'string' - x-speakeasy-unknown-values: allow - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/DeleteScimGroupOptOutResponse' - description: 'Opt-out removed' - '400': - content: - application/json: - example: - error: - code: 400 - message: 'Invalid request parameters' - schema: - $ref: '#/components/schemas/BadRequestResponse' - description: 'Bad Request - Invalid request parameters or malformed input' - '401': - content: - application/json: - example: - error: - code: 401 - message: 'Missing Authentication header' - schema: - $ref: '#/components/schemas/UnauthorizedResponse' - description: 'Unauthorized - Authentication required or invalid credentials' - '403': - content: - application/json: - example: - error: - code: 403 - message: 'Only management keys can perform this operation' - schema: - $ref: '#/components/schemas/ForbiddenResponse' - description: 'Forbidden - Authentication successful but insufficient permissions' - '404': - content: - application/json: - example: - error: - code: 404 - message: 'Resource not found' - schema: - $ref: '#/components/schemas/NotFoundResponse' - description: 'Not Found - Resource does not exist' - '409': - content: - application/json: - example: - error: - code: 409 - message: 'Resource conflict. Please try again later.' - schema: - $ref: '#/components/schemas/ConflictResponse' - description: 'Conflict - Resource conflict or concurrent modification' - '500': - content: - application/json: - example: - error: - code: 500 - message: 'Internal Server Error' - schema: - $ref: '#/components/schemas/InternalServerResponse' - description: 'Internal Server Error - Unexpected server error' - summary: 'Restore a member to a SCIM group policy' - tags: - - 'Guardrail Policies' - get: - description: 'List the group''s members who opted out of a guardrail policy this mapping sets, per policy type. Opted-out members keep their own assignment (or none) instead of the group policy. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'listScimGroupPolicyOptOuts' - parameters: - - in: 'path' - name: 'mapping_id' - required: true - schema: - format: 'uuid' - type: 'string' - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/ListScimGroupOptOutsResponse' - description: 'Opt-outs from the group policies' + $ref: '#/components/schemas/BudgetGuardrailPolicyResponse' + description: 'budget policy updated' '400': content: application/json: @@ -52650,17 +53514,18 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'List opt-outs from a SCIM group policy assignment' + summary: 'Update a budget policy' tags: - 'Guardrail Policies' + x-speakeasy-name-override: 'updateBudgetPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/budget: + /guardrails/policies/capacity: get: - description: 'List the budget policies in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'listBudgetPolicies' + description: 'List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'listCapacityPolicies' parameters: - description: 'Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned' in: 'query' @@ -52681,12 +53546,12 @@ paths: maximum: 100 minimum: 1 type: 'integer' - - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + - description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' in: 'query' name: 'workspace_id' - required: false + required: true schema: - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' @@ -52695,8 +53560,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ListBudgetGuardrailPoliciesResponse' - description: 'List of budget policies' + $ref: '#/components/schemas/ListCapacityGuardrailPoliciesResponse' + description: 'List of capacity policies' '400': content: application/json: @@ -52747,10 +53612,10 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'List budget policies' + summary: 'List capacity policies' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'listBudgetPolicies' + x-speakeasy-name-override: 'listCapacityPolicies' x-speakeasy-pagination: inputs: - in: 'parameters' @@ -52763,21 +53628,21 @@ paths: results: '$.data' type: 'offsetLimit' post: - description: 'Create a budget policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'createBudgetPolicy' + description: 'Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'createCapacityPolicy' requestBody: content: application/json: schema: - $ref: '#/components/schemas/CreateBudgetGuardrailPolicyRequest' + $ref: '#/components/schemas/CreateCapacityGuardrailPolicyRequest' required: true responses: '201': content: application/json: schema: - $ref: '#/components/schemas/BudgetGuardrailPolicyResponse' - description: 'budget policy created' + $ref: '#/components/schemas/CapacityGuardrailPolicyResponse' + description: 'capacity policy created' '400': content: application/json: @@ -52838,18 +53703,18 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Create a budget policy' + summary: 'Create a capacity policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'createBudgetPolicy' + x-speakeasy-name-override: 'createCapacityPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" - /guardrails/policies/budget/{id}: + /guardrails/policies/capacity/{id}: delete: - description: 'Delete a budget policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'deleteBudgetPolicy' + description: 'Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'deleteCapacityPolicy' parameters: - description: 'Policy ID' in: 'path' @@ -52860,12 +53725,12 @@ paths: example: '550e8400-e29b-41d4-a716-446655440000' format: 'uuid' type: 'string' - - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + - description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' in: 'query' name: 'workspace_id' - required: false + required: true schema: - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' @@ -52875,7 +53740,7 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteGuardrailPolicyResponse' - description: 'budget policy deleted' + description: 'capacity policy deleted' '400': content: application/json: @@ -52936,13 +53801,13 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Delete a budget policy' + summary: 'Delete a capacity policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'deleteBudgetPolicy' + x-speakeasy-name-override: 'deleteCapacityPolicy' get: - description: 'Get a budget policy with its member and API key assignments. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'getBudgetPolicy' + description: 'Get a capacity policy with its member and API key assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'getCapacityPolicy' parameters: - description: 'Policy ID' in: 'path' @@ -52953,12 +53818,12 @@ paths: example: '550e8400-e29b-41d4-a716-446655440000' format: 'uuid' type: 'string' - - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + - description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' in: 'query' name: 'workspace_id' - required: false + required: true schema: - description: 'Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.' + description: 'Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' @@ -52967,8 +53832,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BudgetGuardrailPolicyDetailResponse' - description: 'budget policy details' + $ref: '#/components/schemas/CapacityGuardrailPolicyDetailResponse' + description: 'capacity policy details' '400': content: application/json: @@ -53019,13 +53884,13 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Get a budget policy' + summary: 'Get a capacity policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'getBudgetPolicy' + x-speakeasy-name-override: 'getCapacityPolicy' put: - description: 'Replace a budget policy''s name and config, and optionally its assignments. [Management key](/docs/guides/overview/auth/management-api-keys) required.' - operationId: 'updateBudgetPolicy' + description: 'Replace a capacity policy''s name and config, and optionally its assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + operationId: 'updateCapacityPolicy' parameters: - description: 'Policy ID' in: 'path' @@ -53040,15 +53905,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UpdateBudgetGuardrailPolicyRequest' + $ref: '#/components/schemas/UpdateCapacityGuardrailPolicyRequest' required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/BudgetGuardrailPolicyResponse' - description: 'budget policy updated' + $ref: '#/components/schemas/CapacityGuardrailPolicyResponse' + description: 'capacity policy updated' '400': content: application/json: @@ -53109,10 +53974,10 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Update a budget policy' + summary: 'Update a capacity policy' tags: - 'Guardrail Policies' - x-speakeasy-name-override: 'updateBudgetPolicy' + x-speakeasy-name-override: 'updateCapacityPolicy' parameters: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" @@ -59817,7 +60682,7 @@ paths: - 'Private Endpoints' x-speakeasy-name-override: 'list' post: - description: 'Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:create` can only create drafts; passing `activate` requires a full organization Read/write management key and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + description: 'Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:write` can create drafts; passing `activate` also requires `byok:write` (or a full organization Read/write management key) and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required.' operationId: 'createPrivateEndpoint' parameters: - description: 'Retry-safe create: a repeated create with the same key from the same organization returns the endpoint the first request created instead of creating another. The endpoint is returned as it is now. Reusing a key with a different request body (model, provider, base URL, upstream model ID, declared ZDR or region, pricing, or declared parameters) is rejected with 422 `idempotency_key_reused`. Declared parameters are compared as a set, so a retry that reorders or repeats a name replays the endpoint. `activate` and `settings` are not compared, and later edits to the endpoint do not affect the comparison. `settings` is still validated before the replay, so a retry with invalid settings returns 400 `settings_invalid` instead of the endpoint.' @@ -60614,7 +61479,7 @@ paths: - $ref: "#/components/parameters/AppCategories" /private-endpoints/{id}/validate: post: - description: 'Send a live test request to the draft endpoint using the given workspace''s BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. [Management key](/docs/guides/overview/auth/management-api-keys) required.' + description: 'Send a live test request to the draft endpoint using the given workspace''s BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. Custom management keys require both `private_endpoints:write` and `byok:write`. [Management key](/docs/guides/overview/auth/management-api-keys) required.' operationId: 'validatePrivateEndpoint' parameters: - description: 'Stable identifier of the private endpoint.' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index e857ed8d6..03ac56677 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.808.1 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:187aeb9fa4a3c9d5e30dedeadc5c27fae677044f950962d9bf696f25a09bf4f7 - sourceBlobDigest: sha256:e4b0e09accf6992e6852d2ec668af40cb4cab64cc2844b8553c82d68b8346613 + sourceRevisionDigest: sha256:97fca279a68115c19830682fe65c12baf1df5121034a5cfaa10085ece0186f74 + sourceBlobDigest: sha256:4300f7570b772fd9c001ba0e00fb319d47f59393d0f23f5e6a2ee3275713225e tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:187aeb9fa4a3c9d5e30dedeadc5c27fae677044f950962d9bf696f25a09bf4f7 - sourceBlobDigest: sha256:e4b0e09accf6992e6852d2ec668af40cb4cab64cc2844b8553c82d68b8346613 + sourceRevisionDigest: sha256:97fca279a68115c19830682fe65c12baf1df5121034a5cfaa10085ece0186f74 + sourceBlobDigest: sha256:4300f7570b772fd9c001ba0e00fb319d47f59393d0f23f5e6a2ee3275713225e codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:c84e13612c6c82eeae8a20d8fb29c3882c98638978a7af7802c81c5b8af5485b + codeSamplesRevisionDigest: sha256:2d1d670e873f92c814e07023105149114c1f8b98cb50eb51fa569ec1acbe902d workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.808.1 diff --git a/RELEASES.md b/RELEASES.md index 680e87eb2..114b31797 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6046,4 +6046,14 @@ Based on: ### Generated - [typescript v1.5.167] . ### Releases -- [NPM v1.5.167] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.167 - . \ No newline at end of file +- [NPM v1.5.167] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.167 - . + +## 2026-12-03 05:25:25 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.808.1 (2.960.8) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.5.168] . +### Releases +- [NPM v1.5.168] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.168 - . \ No newline at end of file diff --git a/docs/models/bucketby.mdx b/docs/models/bucketby.mdx new file mode 100644 index 000000000..520fd4e13 --- /dev/null +++ b/docs/models/bucketby.mdx @@ -0,0 +1,19 @@ +--- +title: "BucketBy" +--- + +## Example Usage + +```typescript +import { BucketBy } from "@openrouter/sdk/models"; + +let value: BucketBy = "api_key"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"workspace" | "member" | "api_key" | "model" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicy.mdx b/docs/models/capacityguardrailpolicy.mdx new file mode 100644 index 000000000..fba986769 --- /dev/null +++ b/docs/models/capacityguardrailpolicy.mdx @@ -0,0 +1,37 @@ +--- +title: "CapacityGuardrailPolicy" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicy } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicy = { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + id: "550e8400-e29b-41d4-a716-446655440000", + name: "Engineering monthly budget", + policyType: "rate_limit", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `config` | [models.GuardrailCapacityPolicyConfig](../models/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `name` | *string* | ✔️ | Policy name | Engineering monthly budget | +| `policyType` | [models.CapacityGuardrailPolicyPolicyType](../models/capacityguardrailpolicypolicytype.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicydetail.mdx b/docs/models/capacityguardrailpolicydetail.mdx new file mode 100644 index 000000000..03b934a0a --- /dev/null +++ b/docs/models/capacityguardrailpolicydetail.mdx @@ -0,0 +1,59 @@ +--- +title: "CapacityGuardrailPolicyDetail" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyDetail } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyDetail = { + apiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + id: "550e8400-e29b-41d4-a716-446655440000", + memberIds: [ + "user_2abcDEFghiJKLmnoPQRstu", + ], + name: "Engineering monthly budget", + optedOutApiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + overriddenApiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + policyType: "rate_limit", + updatedAt: "1735681367137", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `apiKeyHashes` | *string*[] | ✔️ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [models.GuardrailCapacityPolicyConfig](../models/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `isWorkspaceDefault` | *boolean* | ➖ | N/A | | +| `memberIds` | *string*[] | ✔️ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `name` | *string* | ✔️ | Policy name | Engineering monthly budget | +| `optedOutApiKeyHashes` | *string*[] | ✔️ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `optedOutMemberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `overriddenApiKeyHashes` | *string*[] | ✔️ | API keys that have a different policy of this type assigned directly | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `overriddenMemberIds` | *string*[] | ➖ | Members that have a different policy of this type assigned directly | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `policyType` | [models.CapacityGuardrailPolicyDetailPolicyType](../models/capacityguardrailpolicydetailpolicytype.mdx) | ✔️ | N/A | | +| `reference` | [models.CapacityGuardrailPolicyDetailReference](../models/capacityguardrailpolicydetailreference.mdx) | ➖ | `legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` | | +| `updatedAt` | *string* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicydetailpolicytype.mdx b/docs/models/capacityguardrailpolicydetailpolicytype.mdx new file mode 100644 index 000000000..54fc5bb0c --- /dev/null +++ b/docs/models/capacityguardrailpolicydetailpolicytype.mdx @@ -0,0 +1,17 @@ +--- +title: "CapacityGuardrailPolicyDetailPolicyType" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyDetailPolicyType } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyDetailPolicyType = "rate_limit"; +``` + +## Values + +```typescript +"rate_limit" +``` \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicydetailreference.mdx b/docs/models/capacityguardrailpolicydetailreference.mdx new file mode 100644 index 000000000..e4e0d1893 --- /dev/null +++ b/docs/models/capacityguardrailpolicydetailreference.mdx @@ -0,0 +1,21 @@ +--- +title: "CapacityGuardrailPolicyDetailReference" +--- + +`legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyDetailReference } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyDetailReference = "account_default"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"legacy_mapping" | "account_default" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicydetailresponse.mdx b/docs/models/capacityguardrailpolicydetailresponse.mdx new file mode 100644 index 000000000..84aee4195 --- /dev/null +++ b/docs/models/capacityguardrailpolicydetailresponse.mdx @@ -0,0 +1,49 @@ +--- +title: "CapacityGuardrailPolicyDetailResponse" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyDetailResponse } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyDetailResponse = { + data: { + apiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + id: "550e8400-e29b-41d4-a716-446655440000", + memberIds: [ + "user_2abcDEFghiJKLmnoPQRstu", + ], + name: "Engineering monthly budget", + optedOutApiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + overriddenApiKeyHashes: [ + "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", + ], + policyType: "rate_limit", + updatedAt: "1735616624553", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `data` | [models.CapacityGuardrailPolicyDetail](../models/capacityguardrailpolicydetail.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicypolicytype.mdx b/docs/models/capacityguardrailpolicypolicytype.mdx new file mode 100644 index 000000000..a364540ab --- /dev/null +++ b/docs/models/capacityguardrailpolicypolicytype.mdx @@ -0,0 +1,17 @@ +--- +title: "CapacityGuardrailPolicyPolicyType" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyPolicyType } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyPolicyType = "rate_limit"; +``` + +## Values + +```typescript +"rate_limit" +``` \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicyresponse.mdx b/docs/models/capacityguardrailpolicyresponse.mdx new file mode 100644 index 000000000..6f96f5dfb --- /dev/null +++ b/docs/models/capacityguardrailpolicyresponse.mdx @@ -0,0 +1,36 @@ +--- +title: "CapacityGuardrailPolicyResponse" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicyResponse } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicyResponse = { + data: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + id: "550e8400-e29b-41d4-a716-446655440000", + name: "Engineering monthly budget", + policyType: "rate_limit", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `data` | [models.CapacityGuardrailPolicy](../models/capacityguardrailpolicy.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicysummary.mdx b/docs/models/capacityguardrailpolicysummary.mdx new file mode 100644 index 000000000..e4e0499c7 --- /dev/null +++ b/docs/models/capacityguardrailpolicysummary.mdx @@ -0,0 +1,44 @@ +--- +title: "CapacityGuardrailPolicySummary" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicySummary } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicySummary = { + apiKeyCount: 742017, + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + id: "550e8400-e29b-41d4-a716-446655440000", + memberCount: 690283, + name: "Engineering monthly budget", + policyType: "rate_limit", + updatedAt: "1735605279112", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `apiKeyCount` | *number* | ✔️ | N/A | | +| `config` | [models.GuardrailCapacityPolicyConfig](../models/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `isWorkspaceDefault` | *boolean* | ➖ | N/A | | +| `memberCount` | *number* | ✔️ | N/A | | +| `name` | *string* | ✔️ | Policy name | Engineering monthly budget | +| `policyType` | [models.CapacityGuardrailPolicySummaryPolicyType](../models/capacityguardrailpolicysummarypolicytype.mdx) | ✔️ | N/A | | +| `updatedAt` | *string* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/capacityguardrailpolicysummarypolicytype.mdx b/docs/models/capacityguardrailpolicysummarypolicytype.mdx new file mode 100644 index 000000000..f1051a73d --- /dev/null +++ b/docs/models/capacityguardrailpolicysummarypolicytype.mdx @@ -0,0 +1,17 @@ +--- +title: "CapacityGuardrailPolicySummaryPolicyType" +--- + +## Example Usage + +```typescript +import { CapacityGuardrailPolicySummaryPolicyType } from "@openrouter/sdk/models"; + +let value: CapacityGuardrailPolicySummaryPolicyType = "rate_limit"; +``` + +## Values + +```typescript +"rate_limit" +``` \ No newline at end of file diff --git a/docs/models/changeguardrailpolicyassignmentrequest.mdx b/docs/models/changeguardrailpolicyassignmentrequest.mdx index ee2d1c846..b0e72ceb3 100644 --- a/docs/models/changeguardrailpolicyassignmentrequest.mdx +++ b/docs/models/changeguardrailpolicyassignmentrequest.mdx @@ -23,10 +23,10 @@ let value: ChangeGuardrailPolicyAssignmentRequest = { ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `assigned` | *boolean* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | -| `expectedAssignment` | [models.GuardrailPolicyAssignmentState](../models/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | -| `policyId` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | -| `policyType` | [models.ChangeGuardrailPolicyAssignmentRequestPolicyType](../models/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `assigned` | *boolean* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | +| `expectedAssignment` | [models.GuardrailPolicyAssignmentState](../models/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | +| `policyId` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `policyType` | [models.ChangeGuardrailPolicyAssignmentRequestPolicyType](../models/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget | +| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/models/changeguardrailpolicyassignmentrequestpolicytype.mdx b/docs/models/changeguardrailpolicyassignmentrequestpolicytype.mdx index 038ce8e6f..54c37b035 100644 --- a/docs/models/changeguardrailpolicyassignmentrequestpolicytype.mdx +++ b/docs/models/changeguardrailpolicyassignmentrequestpolicytype.mdx @@ -2,7 +2,7 @@ title: "ChangeGuardrailPolicyAssignmentRequestPolicyType" --- -Policy type the assignment is read or changed for +Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. ## Example Usage diff --git a/docs/models/createbudgetguardrailpolicyrequest.mdx b/docs/models/createbudgetguardrailpolicyrequest.mdx index f7aba542a..20e84e0e8 100644 --- a/docs/models/createbudgetguardrailpolicyrequest.mdx +++ b/docs/models/createbudgetguardrailpolicyrequest.mdx @@ -26,6 +26,7 @@ let value: CreateBudgetGuardrailPolicyRequest = { | `config` | [models.GuardrailBudgetPolicyAuthoringConfig](../models/guardrailbudgetpolicyauthoringconfig.mdx) | ✔️ | N/A | \{
"include_byok_in_budgets": false,
"limit_usd": 200,
"reset_interval": "monthly"
} | | `isWorkspaceDefault` | *boolean* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `memberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `moveExistingAssignments` | *boolean* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | | | `name` | *string* | ✔️ | Policy name | Engineering monthly budget | | `optedOutApiKeyHashes` | *string*[] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `optedOutMemberIds` | *string*[] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/models/createcapacityguardrailpolicyrequest.mdx b/docs/models/createcapacityguardrailpolicyrequest.mdx new file mode 100644 index 000000000..56b3f6532 --- /dev/null +++ b/docs/models/createcapacityguardrailpolicyrequest.mdx @@ -0,0 +1,43 @@ +--- +title: "CreateCapacityGuardrailPolicyRequest" +--- + +## Example Usage + +```typescript +import { CreateCapacityGuardrailPolicyRequest } from "@openrouter/sdk/models"; + +let value: CreateCapacityGuardrailPolicyRequest = { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + policyType: "rate_limit", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apiKeyHashes` | *string*[] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [models.GuardrailCapacityPolicyConfig](../models/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `isWorkspaceDefault` | *boolean* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | +| `memberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `moveExistingAssignments` | *boolean* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | | +| `name` | *string* | ✔️ | Policy name | Engineering monthly budget | +| `optedOutApiKeyHashes` | *string*[] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `optedOutMemberIds` | *string*[] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `policyType` | [models.CreateCapacityGuardrailPolicyRequestPolicyType](../models/createcapacityguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | | +| `workspaceId` | *string* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/models/createcapacityguardrailpolicyrequestpolicytype.mdx b/docs/models/createcapacityguardrailpolicyrequestpolicytype.mdx new file mode 100644 index 000000000..15ffd23df --- /dev/null +++ b/docs/models/createcapacityguardrailpolicyrequestpolicytype.mdx @@ -0,0 +1,17 @@ +--- +title: "CreateCapacityGuardrailPolicyRequestPolicyType" +--- + +## Example Usage + +```typescript +import { CreateCapacityGuardrailPolicyRequestPolicyType } from "@openrouter/sdk/models"; + +let value: CreateCapacityGuardrailPolicyRequestPolicyType = "rate_limit"; +``` + +## Values + +```typescript +"rate_limit" +``` \ No newline at end of file diff --git a/docs/models/createmodelavailabilityguardrailpolicyrequest.mdx b/docs/models/createmodelavailabilityguardrailpolicyrequest.mdx index 7dbe4497e..769558412 100644 --- a/docs/models/createmodelavailabilityguardrailpolicyrequest.mdx +++ b/docs/models/createmodelavailabilityguardrailpolicyrequest.mdx @@ -22,6 +22,7 @@ let value: CreateModelAvailabilityGuardrailPolicyRequest = { | `config` | [models.GuardrailModelAvailabilityPolicyAuthoringConfig](../models/guardrailmodelavailabilitypolicyauthoringconfig.mdx) | ✔️ | N/A | \{
"allowed_models": [
"openai/gpt-4o",
"anthropic/claude-sonnet-4"
],
"allowed_providers": [
"openai",
"anthropic"
],
"enforce_zdr_anthropic": true,
"enforce_zdr_openai": true
} | | `isWorkspaceDefault` | *boolean* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `memberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `moveExistingAssignments` | *boolean* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | | | `name` | *string* | ✔️ | Policy name | Engineering monthly budget | | `optedOutApiKeyHashes` | *string*[] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `optedOutMemberIds` | *string*[] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/models/createmoderationguardrailpolicyrequest.mdx b/docs/models/createmoderationguardrailpolicyrequest.mdx index 84862f78b..e0d897496 100644 --- a/docs/models/createmoderationguardrailpolicyrequest.mdx +++ b/docs/models/createmoderationguardrailpolicyrequest.mdx @@ -22,6 +22,7 @@ let value: CreateModerationGuardrailPolicyRequest = { | `config` | [models.GuardrailModerationPolicyConfig](../models/guardrailmoderationpolicyconfig.mdx) | ✔️ | N/A | \{
"content_filter_builtins": [
\{
"action": "block",
"slug": "secrets"
}
]
} | | `isWorkspaceDefault` | *boolean* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `memberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `moveExistingAssignments` | *boolean* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | | | `name` | *string* | ✔️ | Policy name | Engineering monthly budget | | `optedOutApiKeyHashes` | *string*[] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `optedOutMemberIds` | *string*[] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/models/guardrailcapacitylimit.mdx b/docs/models/guardrailcapacitylimit.mdx new file mode 100644 index 000000000..66bbc7160 --- /dev/null +++ b/docs/models/guardrailcapacitylimit.mdx @@ -0,0 +1,23 @@ +--- +title: "GuardrailCapacityLimit" +--- + +## Example Usage + +```typescript +import { GuardrailCapacityLimit } from "@openrouter/sdk/models"; + +let value: GuardrailCapacityLimit = { + limit: 100000, + models: "all", + unit: "tokens", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `limit` | *number* | ✔️ | Bucket capacity and per-minute refill rate. | 100000 | +| `models` | *models.Models* | ✔️ | Either `"all"` to cover every model or a non-empty list of exact model slugs. | all | +| `unit` | [models.GuardrailCapacityLimitUnit](../models/guardrailcapacitylimitunit.mdx) | ✔️ | Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). | tokens | \ No newline at end of file diff --git a/docs/models/guardrailcapacitylimitunit.mdx b/docs/models/guardrailcapacitylimitunit.mdx new file mode 100644 index 000000000..cd6a0f5e9 --- /dev/null +++ b/docs/models/guardrailcapacitylimitunit.mdx @@ -0,0 +1,21 @@ +--- +title: "GuardrailCapacityLimitUnit" +--- + +Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). + +## Example Usage + +```typescript +import { GuardrailCapacityLimitUnit } from "@openrouter/sdk/models"; + +let value: GuardrailCapacityLimitUnit = "tokens"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"tokens" | "requests" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/guardrailcapacitypolicyconfig.mdx b/docs/models/guardrailcapacitypolicyconfig.mdx new file mode 100644 index 000000000..ca2aa698a --- /dev/null +++ b/docs/models/guardrailcapacitypolicyconfig.mdx @@ -0,0 +1,30 @@ +--- +title: "GuardrailCapacityPolicyConfig" +--- + +## Example Usage + +```typescript +import { GuardrailCapacityPolicyConfig } from "@openrouter/sdk/models"; + +let value: GuardrailCapacityPolicyConfig = { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `bucketBy` | [models.BucketBy](../models/bucketby.mdx)[] | ✔️ | Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`. | [
"member",
"model"
] | +| `limits` | [models.GuardrailCapacityLimit](../models/guardrailcapacitylimit.mdx)[] | ✔️ | One or more per-minute token or request limits (up to 200 entries and 200 listed models total). | | \ No newline at end of file diff --git a/docs/models/listcapacityguardrailpoliciesresponse.mdx b/docs/models/listcapacityguardrailpoliciesresponse.mdx new file mode 100644 index 000000000..1ead81a85 --- /dev/null +++ b/docs/models/listcapacityguardrailpoliciesresponse.mdx @@ -0,0 +1,21 @@ +--- +title: "ListCapacityGuardrailPoliciesResponse" +--- + +## Example Usage + +```typescript +import { ListCapacityGuardrailPoliciesResponse } from "@openrouter/sdk/models"; + +let value: ListCapacityGuardrailPoliciesResponse = { + data: [], + totalCount: 1, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `data` | [models.CapacityGuardrailPolicySummary](../models/capacityguardrailpolicysummary.mdx)[] | ✔️ | N/A | | +| `totalCount` | *number* | ✔️ | Total number of policies | 1 | \ No newline at end of file diff --git a/docs/models/models.mdx b/docs/models/models.mdx new file mode 100644 index 000000000..30a6068bd --- /dev/null +++ b/docs/models/models.mdx @@ -0,0 +1,23 @@ +--- +title: "Models" +--- + +Either `"all"` to cover every model or a non-empty list of exact model slugs. + + +## Supported Types + +### `models.ModelsEnum` + +```typescript +const value: models.ModelsEnum = "all"; +``` + +### `string[]` + +```typescript +const value: string[] = [ + "openai/gpt-4o", +]; +``` + diff --git a/docs/models/modelsenum.mdx b/docs/models/modelsenum.mdx new file mode 100644 index 000000000..ec6b00047 --- /dev/null +++ b/docs/models/modelsenum.mdx @@ -0,0 +1,19 @@ +--- +title: "ModelsEnum" +--- + +Apply this limit to every model. + +## Example Usage + +```typescript +import { ModelsEnum } from "@openrouter/sdk/models"; + +let value: ModelsEnum = "all"; +``` + +## Values + +```typescript +"all" +``` \ No newline at end of file diff --git a/docs/models/operations/createcapacitypolicyglobals.mdx b/docs/models/operations/createcapacitypolicyglobals.mdx new file mode 100644 index 000000000..a274ed689 --- /dev/null +++ b/docs/models/operations/createcapacitypolicyglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "CreateCapacityPolicyGlobals" +--- + +## Example Usage + +```typescript +import { CreateCapacityPolicyGlobals } from "@openrouter/sdk/models/operations"; + +let value: CreateCapacityPolicyGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/createcapacitypolicyrequest.mdx b/docs/models/operations/createcapacitypolicyrequest.mdx new file mode 100644 index 000000000..f9abb9cd4 --- /dev/null +++ b/docs/models/operations/createcapacitypolicyrequest.mdx @@ -0,0 +1,39 @@ +--- +title: "CreateCapacityPolicyRequest" +--- + +## Example Usage + +```typescript +import { CreateCapacityPolicyRequest } from "@openrouter/sdk/models/operations"; + +let value: CreateCapacityPolicyRequest = { + createCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + policyType: "rate_limit", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| +| `createCapacityGuardrailPolicyRequest` | [models.CreateCapacityGuardrailPolicyRequest](../../models/createcapacityguardrailpolicyrequest.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/operations/deletecapacitypolicyglobals.mdx b/docs/models/operations/deletecapacitypolicyglobals.mdx new file mode 100644 index 000000000..e67e384d9 --- /dev/null +++ b/docs/models/operations/deletecapacitypolicyglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "DeleteCapacityPolicyGlobals" +--- + +## Example Usage + +```typescript +import { DeleteCapacityPolicyGlobals } from "@openrouter/sdk/models/operations"; + +let value: DeleteCapacityPolicyGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/deletecapacitypolicyrequest.mdx b/docs/models/operations/deletecapacitypolicyrequest.mdx new file mode 100644 index 000000000..ae47ce33e --- /dev/null +++ b/docs/models/operations/deletecapacitypolicyrequest.mdx @@ -0,0 +1,24 @@ +--- +title: "DeleteCapacityPolicyRequest" +--- + +## Example Usage + +```typescript +import { DeleteCapacityPolicyRequest } from "@openrouter/sdk/models/operations"; + +let value: DeleteCapacityPolicyRequest = { + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspaceId` | *string* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/models/operations/getapikeypolicyassignmentpolicytype.mdx b/docs/models/operations/getapikeypolicyassignmentpolicytype.mdx index dc103afca..ba7495f11 100644 --- a/docs/models/operations/getapikeypolicyassignmentpolicytype.mdx +++ b/docs/models/operations/getapikeypolicyassignmentpolicytype.mdx @@ -2,7 +2,7 @@ title: "GetApiKeyPolicyAssignmentPolicyType" --- -Policy type the assignment is read or changed for +Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. ## Example Usage diff --git a/docs/models/operations/getapikeypolicyassignmentrequest.mdx b/docs/models/operations/getapikeypolicyassignmentrequest.mdx index 665dfb392..28570e807 100644 --- a/docs/models/operations/getapikeypolicyassignmentrequest.mdx +++ b/docs/models/operations/getapikeypolicyassignmentrequest.mdx @@ -15,11 +15,11 @@ let value: GetApiKeyPolicyAssignmentRequest = { ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `hash` | *string* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | -| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | -| `policyType` | [operations.GetApiKeyPolicyAssignmentPolicyType](../../models/operations/getapikeypolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `hash` | *string* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | +| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `policyType` | [operations.GetApiKeyPolicyAssignmentPolicyType](../../models/operations/getapikeypolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget | \ No newline at end of file diff --git a/docs/models/operations/getcapacitypolicyglobals.mdx b/docs/models/operations/getcapacitypolicyglobals.mdx new file mode 100644 index 000000000..1a1c6c69a --- /dev/null +++ b/docs/models/operations/getcapacitypolicyglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "GetCapacityPolicyGlobals" +--- + +## Example Usage + +```typescript +import { GetCapacityPolicyGlobals } from "@openrouter/sdk/models/operations"; + +let value: GetCapacityPolicyGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/getcapacitypolicyrequest.mdx b/docs/models/operations/getcapacitypolicyrequest.mdx new file mode 100644 index 000000000..d46cdef9f --- /dev/null +++ b/docs/models/operations/getcapacitypolicyrequest.mdx @@ -0,0 +1,24 @@ +--- +title: "GetCapacityPolicyRequest" +--- + +## Example Usage + +```typescript +import { GetCapacityPolicyRequest } from "@openrouter/sdk/models/operations"; + +let value: GetCapacityPolicyRequest = { + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspaceId` | *string* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/models/operations/getmemberpolicyassignmentpolicytype.mdx b/docs/models/operations/getmemberpolicyassignmentpolicytype.mdx index 99b46700f..7d4f2af55 100644 --- a/docs/models/operations/getmemberpolicyassignmentpolicytype.mdx +++ b/docs/models/operations/getmemberpolicyassignmentpolicytype.mdx @@ -2,7 +2,7 @@ title: "GetMemberPolicyAssignmentPolicyType" --- -Policy type the assignment is read or changed for +Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. ## Example Usage diff --git a/docs/models/operations/getmemberpolicyassignmentrequest.mdx b/docs/models/operations/getmemberpolicyassignmentrequest.mdx index 0917c810c..e97b151f1 100644 --- a/docs/models/operations/getmemberpolicyassignmentrequest.mdx +++ b/docs/models/operations/getmemberpolicyassignmentrequest.mdx @@ -15,11 +15,11 @@ let value: GetMemberPolicyAssignmentRequest = { ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `memberId` | *string* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | -| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | -| `policyType` | [operations.GetMemberPolicyAssignmentPolicyType](../../models/operations/getmemberpolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `memberId` | *string* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | +| `workspaceId` | *string* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `policyType` | [operations.GetMemberPolicyAssignmentPolicyType](../../models/operations/getmemberpolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget | \ No newline at end of file diff --git a/docs/models/operations/listcapacitypoliciesglobals.mdx b/docs/models/operations/listcapacitypoliciesglobals.mdx new file mode 100644 index 000000000..075b27cc7 --- /dev/null +++ b/docs/models/operations/listcapacitypoliciesglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "ListCapacityPoliciesGlobals" +--- + +## Example Usage + +```typescript +import { ListCapacityPoliciesGlobals } from "@openrouter/sdk/models/operations"; + +let value: ListCapacityPoliciesGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/listcapacitypoliciesrequest.mdx b/docs/models/operations/listcapacitypoliciesrequest.mdx new file mode 100644 index 000000000..e583a7293 --- /dev/null +++ b/docs/models/operations/listcapacitypoliciesrequest.mdx @@ -0,0 +1,24 @@ +--- +title: "ListCapacityPoliciesRequest" +--- + +## Example Usage + +```typescript +import { ListCapacityPoliciesRequest } from "@openrouter/sdk/models/operations"; + +let value: ListCapacityPoliciesRequest = { + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *number* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 | +| `limit` | *number* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 | +| `workspaceId` | *string* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/models/operations/listcapacitypoliciesresponse.mdx b/docs/models/operations/listcapacitypoliciesresponse.mdx new file mode 100644 index 000000000..c1c37e86a --- /dev/null +++ b/docs/models/operations/listcapacitypoliciesresponse.mdx @@ -0,0 +1,22 @@ +--- +title: "ListCapacityPoliciesResponse" +--- + +## Example Usage + +```typescript +import { ListCapacityPoliciesResponse } from "@openrouter/sdk/models/operations"; + +let value: ListCapacityPoliciesResponse = { + result: { + data: [], + totalCount: 1, + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `result` | [models.ListCapacityGuardrailPoliciesResponse](../../models/listcapacityguardrailpoliciesresponse.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/operations/updatecapacitypolicyglobals.mdx b/docs/models/operations/updatecapacitypolicyglobals.mdx new file mode 100644 index 000000000..e33197d18 --- /dev/null +++ b/docs/models/operations/updatecapacitypolicyglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "UpdateCapacityPolicyGlobals" +--- + +## Example Usage + +```typescript +import { UpdateCapacityPolicyGlobals } from "@openrouter/sdk/models/operations"; + +let value: UpdateCapacityPolicyGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/updatecapacitypolicyrequest.mdx b/docs/models/operations/updatecapacitypolicyrequest.mdx new file mode 100644 index 000000000..a76c4d0b7 --- /dev/null +++ b/docs/models/operations/updatecapacitypolicyrequest.mdx @@ -0,0 +1,40 @@ +--- +title: "UpdateCapacityPolicyRequest" +--- + +## Example Usage + +```typescript +import { UpdateCapacityPolicyRequest } from "@openrouter/sdk/models/operations"; + +let value: UpdateCapacityPolicyRequest = { + id: "550e8400-e29b-41d4-a716-446655440000", + updateCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *string* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `updateCapacityGuardrailPolicyRequest` | [models.UpdateCapacityGuardrailPolicyRequest](../../models/updatecapacityguardrailpolicyrequest.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/updatecapacityguardrailpolicyrequest.mdx b/docs/models/updatecapacityguardrailpolicyrequest.mdx new file mode 100644 index 000000000..cca372454 --- /dev/null +++ b/docs/models/updatecapacityguardrailpolicyrequest.mdx @@ -0,0 +1,40 @@ +--- +title: "UpdateCapacityGuardrailPolicyRequest" +--- + +## Example Usage + +```typescript +import { UpdateCapacityGuardrailPolicyRequest } from "@openrouter/sdk/models"; + +let value: UpdateCapacityGuardrailPolicyRequest = { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | +| `apiKeyHashes` | *string*[] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [models.GuardrailCapacityPolicyConfig](../models/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `isWorkspaceDefault` | *boolean* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | | +| `memberIds` | *string*[] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `name` | *string* | ✔️ | Policy name | Engineering monthly budget | +| `optedOutApiKeyHashes` | *string*[] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `optedOutMemberIds` | *string*[] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `workspaceId` | *string* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/sdks/guardrailpolicies/README.mdx b/docs/sdks/guardrailpolicies/README.mdx index 57b9ea34b..b13be795a 100644 --- a/docs/sdks/guardrailpolicies/README.mdx +++ b/docs/sdks/guardrailpolicies/README.mdx @@ -27,6 +27,11 @@ Guardrail Policies endpoints * [deleteBudgetPolicy](#deletebudgetpolicy) - Delete a budget policy * [getBudgetPolicy](#getbudgetpolicy) - Get a budget policy * [updateBudgetPolicy](#updatebudgetpolicy) - Update a budget policy +* [listCapacityPolicies](#listcapacitypolicies) - List capacity policies +* [createCapacityPolicy](#createcapacitypolicy) - Create a capacity policy +* [deleteCapacityPolicy](#deletecapacitypolicy) - Delete a capacity policy +* [getCapacityPolicy](#getcapacitypolicy) - Get a capacity policy +* [updateCapacityPolicy](#updatecapacitypolicy) - Update a capacity policy * [listModelAvailabilityPolicies](#listmodelavailabilitypolicies) - List model availability policies * [createModelAvailabilityPolicy](#createmodelavailabilitypolicy) - Create a model availability policy * [deleteModelAvailabilityPolicy](#deletemodelavailabilitypolicy) - Delete a model availability policy @@ -1673,6 +1678,500 @@ run(); | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | +## listCapacityPolicies + +List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.guardrailPolicies.listCapacityPolicies({ + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + + for await (const page of result) { + console.log(page); + } +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { guardrailPoliciesListCapacityPolicies } from "@openrouter/sdk/funcs/guardrailPoliciesListCapacityPolicies.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await guardrailPoliciesListCapacityPolicies(openRouter, { + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + if (res.ok) { + const { value: result } = res; + for await (const page of result) { + console.log(page); + } + } else { + console.log("guardrailPoliciesListCapacityPolicies failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.ListCapacityPoliciesRequest](../../models/operations/listcapacitypoliciesrequest.mdx) | ✔️ | The request object to use for the request. | +| `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.ListCapacityPoliciesResponse](../../models/operations/listcapacitypoliciesresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## createCapacityPolicy + +Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.guardrailPolicies.createCapacityPolicy({ + createCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + policyType: "rate_limit", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { guardrailPoliciesCreateCapacityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesCreateCapacityPolicy.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await guardrailPoliciesCreateCapacityPolicy(openRouter, { + createCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + policyType: "rate_limit", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("guardrailPoliciesCreateCapacityPolicy failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.CreateCapacityPolicyRequest](../../models/operations/createcapacitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | +| `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[models.CapacityGuardrailPolicyResponse](../../models/capacityguardrailpolicyresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## deleteCapacityPolicy + +Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.guardrailPolicies.deleteCapacityPolicy({ + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { guardrailPoliciesDeleteCapacityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesDeleteCapacityPolicy.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await guardrailPoliciesDeleteCapacityPolicy(openRouter, { + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("guardrailPoliciesDeleteCapacityPolicy failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.DeleteCapacityPolicyRequest](../../models/operations/deletecapacitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | +| `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[models.DeleteGuardrailPolicyResponse](../../models/deleteguardrailpolicyresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## getCapacityPolicy + +Get a capacity policy with its member and API key assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.guardrailPolicies.getCapacityPolicy({ + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { guardrailPoliciesGetCapacityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesGetCapacityPolicy.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await guardrailPoliciesGetCapacityPolicy(openRouter, { + id: "550e8400-e29b-41d4-a716-446655440000", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("guardrailPoliciesGetCapacityPolicy failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.GetCapacityPolicyRequest](../../models/operations/getcapacitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | +| `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[models.CapacityGuardrailPolicyDetailResponse](../../models/capacityguardrailpolicydetailresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## updateCapacityPolicy + +Replace a capacity policy's name and config, and optionally its assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.guardrailPolicies.updateCapacityPolicy({ + id: "550e8400-e29b-41d4-a716-446655440000", + updateCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { guardrailPoliciesUpdateCapacityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesUpdateCapacityPolicy.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await guardrailPoliciesUpdateCapacityPolicy(openRouter, { + id: "550e8400-e29b-41d4-a716-446655440000", + updateCapacityGuardrailPolicyRequest: { + config: { + bucketBy: [ + "member", + "model", + ], + limits: [ + { + limit: 100000, + models: "all", + unit: "tokens", + }, + ], + }, + name: "Engineering monthly budget", + workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", + }, + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("guardrailPoliciesUpdateCapacityPolicy failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.UpdateCapacityPolicyRequest](../../models/operations/updatecapacitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | +| `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[models.CapacityGuardrailPolicyResponse](../../models/capacityguardrailpolicyresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + ## listModelAvailabilityPolicies List the model availability policies in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required. diff --git a/docs/sdks/privateendpoints/README.mdx b/docs/sdks/privateendpoints/README.mdx index 15c06e218..ef875a36f 100644 --- a/docs/sdks/privateendpoints/README.mdx +++ b/docs/sdks/privateendpoints/README.mdx @@ -99,7 +99,7 @@ run(); ## create -Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:create` can only create drafts; passing `activate` requires a full organization Read/write management key and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. +Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:write` can create drafts; passing `activate` also requires `byok:write` (or a full organization Read/write management key) and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. ### Example Usage @@ -719,7 +719,7 @@ run(); ## validate -Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. [Management key](/docs/guides/overview/auth/management-api-keys) required. +Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. Custom management keys require both `private_endpoints:write` and `byok:write`. [Management key](/docs/guides/overview/auth/management-api-keys) required. ### Example Usage diff --git a/jsr.json b/jsr.json index 3313e6fe3..2c6ec14cb 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.5.167", + "version": "1.5.168", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 3fc76718c..b74316572 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.5.167", + "version": "1.5.168", "author": "OpenRouter", "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.", "keywords": [ @@ -73,15 +73,15 @@ "lint": "eslint --cache --max-warnings=0 src", "build": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", "prepublishOnly": "npm run build", - "test:e2e": "vitest --run --project e2e", "test:transit": "exit 0", - "test:watch": "vitest --watch --project unit", "typecheck": "tsc --noEmit", - "typecheck:transit": "exit 0", - "compile": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", "postinstall": "node scripts/check-types.js || true", "prepare": "npm run build", - "test": "vitest --run --project unit" + "test:watch": "vitest --watch --project unit", + "typecheck:transit": "exit 0", + "compile": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", + "test": "vitest --run --project unit", + "test:e2e": "vitest --run --project e2e" }, "peerDependencies": { diff --git a/src/funcs/guardrailPoliciesCreateCapacityPolicy.ts b/src/funcs/guardrailPoliciesCreateCapacityPolicy.ts new file mode 100644 index 000000000..fd85fafe0 --- /dev/null +++ b/src/funcs/guardrailPoliciesCreateCapacityPolicy.ts @@ -0,0 +1,222 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Create a capacity policy + * + * @remarks + * Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ +export function guardrailPoliciesCreateCapacityPolicy( + client: OpenRouterCore, + request: operations.CreateCapacityPolicyRequest, + options?: RequestOptions, +): APIPromise< + Result< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.CreateCapacityPolicyRequest, + options?: RequestOptions, +): Promise< + [ + Result< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => + operations.CreateCapacityPolicyRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = encodeJSON( + "body", + payload.CreateCapacityGuardrailPolicyRequest, + { explode: true }, + ); + + const path = pathToFunc("/guardrails/policies/capacity")(); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "createCapacityPolicy", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(201, models.CapacityGuardrailPolicyResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(409, errors.ConflictResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/guardrailPoliciesDeleteCapacityPolicy.ts b/src/funcs/guardrailPoliciesDeleteCapacityPolicy.ts new file mode 100644 index 000000000..e843511b0 --- /dev/null +++ b/src/funcs/guardrailPoliciesDeleteCapacityPolicy.ts @@ -0,0 +1,228 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Delete a capacity policy + * + * @remarks + * Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ +export function guardrailPoliciesDeleteCapacityPolicy( + client: OpenRouterCore, + request: operations.DeleteCapacityPolicyRequest, + options?: RequestOptions, +): APIPromise< + Result< + models.DeleteGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.DeleteCapacityPolicyRequest, + options?: RequestOptions, +): Promise< + [ + Result< + models.DeleteGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => + operations.DeleteCapacityPolicyRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/guardrails/policies/capacity/{id}")(pathParams); + + const query = encodeFormQuery({ + "workspace_id": payload.workspace_id, + }); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "deleteCapacityPolicy", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "DELETE", + baseURL: options?.serverURL, + path: path, + headers: headers, + query: query, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + models.DeleteGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, models.DeleteGuardrailPolicyResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(409, errors.ConflictResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/guardrailPoliciesGetCapacityPolicy.ts b/src/funcs/guardrailPoliciesGetCapacityPolicy.ts new file mode 100644 index 000000000..79f3175fb --- /dev/null +++ b/src/funcs/guardrailPoliciesGetCapacityPolicy.ts @@ -0,0 +1,223 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Get a capacity policy + * + * @remarks + * Get a capacity policy with its member and API key assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ +export function guardrailPoliciesGetCapacityPolicy( + client: OpenRouterCore, + request: operations.GetCapacityPolicyRequest, + options?: RequestOptions, +): APIPromise< + Result< + models.CapacityGuardrailPolicyDetailResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.GetCapacityPolicyRequest, + options?: RequestOptions, +): Promise< + [ + Result< + models.CapacityGuardrailPolicyDetailResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => operations.GetCapacityPolicyRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/guardrails/policies/capacity/{id}")(pathParams); + + const query = encodeFormQuery({ + "workspace_id": payload.workspace_id, + }); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "getCapacityPolicy", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + query: query, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + models.CapacityGuardrailPolicyDetailResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, models.CapacityGuardrailPolicyDetailResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/guardrailPoliciesListCapacityPolicies.ts b/src/funcs/guardrailPoliciesListCapacityPolicies.ts new file mode 100644 index 000000000..9996ac472 --- /dev/null +++ b/src/funcs/guardrailPoliciesListCapacityPolicies.ts @@ -0,0 +1,293 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; +import { + createPageIterator, + haltIterator, + PageIterator, + Paginator, +} from "../types/operations.js"; + +/** + * List capacity policies + * + * @remarks + * List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ +export function guardrailPoliciesListCapacityPolicies( + client: OpenRouterCore, + request: operations.ListCapacityPoliciesRequest, + options?: RequestOptions, +): APIPromise< + PageIterator< + Result< + operations.ListCapacityPoliciesResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + { offset: number } + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.ListCapacityPoliciesRequest, + options?: RequestOptions, +): Promise< + [ + PageIterator< + Result< + operations.ListCapacityPoliciesResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + { offset: number } + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => + operations.ListCapacityPoliciesRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [haltIterator(parsed), { status: "invalid" }]; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/guardrails/policies/capacity")(); + + const query = encodeFormQuery({ + "limit": payload.limit, + "offset": payload.offset, + "workspace_id": payload.workspace_id, + }); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "listCapacityPolicies", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + query: query, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [haltIterator(requestRes), { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [haltIterator(doResult), { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result, raw] = await M.match< + operations.ListCapacityPoliciesResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.ListCapacityPoliciesResponse$inboundSchema, { + key: "Result", + }), + M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [haltIterator(result), { + status: "complete", + request: req, + response, + }]; + } + + const nextFunc = ( + responseData: unknown, + ): { + next: Paginator< + Result< + operations.ListCapacityPoliciesResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > + >; + "~next"?: { offset: number }; + } => { + const offset = request?.offset ?? 0; + + if (!responseData) { + return { next: () => null }; + } + const results = (responseData as { data: unknown }).data; + if (!Array.isArray(results) || !results.length) { + return { next: () => null }; + } + const limit = request?.limit ?? 0; + if (results.length < limit) { + return { next: () => null }; + } + const nextOffset = offset + results.length; + + const nextVal = () => + guardrailPoliciesListCapacityPolicies( + client, + { + ...request, + offset: nextOffset, + }, + options, + ); + + return { next: nextVal, "~next": { offset: nextOffset } }; + }; + + const page = { ...result, ...nextFunc(raw) }; + return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, { + status: "complete", + request: req, + response, + }]; +} diff --git a/src/funcs/guardrailPoliciesUpdateCapacityPolicy.ts b/src/funcs/guardrailPoliciesUpdateCapacityPolicy.ts new file mode 100644 index 000000000..46d453d00 --- /dev/null +++ b/src/funcs/guardrailPoliciesUpdateCapacityPolicy.ts @@ -0,0 +1,228 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Update a capacity policy + * + * @remarks + * Replace a capacity policy's name and config, and optionally its assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ +export function guardrailPoliciesUpdateCapacityPolicy( + client: OpenRouterCore, + request: operations.UpdateCapacityPolicyRequest, + options?: RequestOptions, +): APIPromise< + Result< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.UpdateCapacityPolicyRequest, + options?: RequestOptions, +): Promise< + [ + Result< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => + operations.UpdateCapacityPolicyRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = encodeJSON( + "body", + payload.UpdateCapacityGuardrailPolicyRequest, + { explode: true }, + ); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/guardrails/policies/capacity/{id}")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "updateCapacityPolicy", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "PUT", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + models.CapacityGuardrailPolicyResponse, + | errors.BadRequestResponseError + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.ConflictResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, models.CapacityGuardrailPolicyResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(409, errors.ConflictResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/privateEndpointsCreate.ts b/src/funcs/privateEndpointsCreate.ts index 69962c19e..21be0aeb8 100644 --- a/src/funcs/privateEndpointsCreate.ts +++ b/src/funcs/privateEndpointsCreate.ts @@ -31,7 +31,7 @@ import { Result } from "../types/fp.js"; * Create a private endpoint * * @remarks - * Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:create` can only create drafts; passing `activate` requires a full organization Read/write management key and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:write` can create drafts; passing `activate` also requires `byok:write` (or a full organization Read/write management key) and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ export function privateEndpointsCreate( client: OpenRouterCore, diff --git a/src/funcs/privateEndpointsValidate.ts b/src/funcs/privateEndpointsValidate.ts index b044d06c5..f5cb2e1ab 100644 --- a/src/funcs/privateEndpointsValidate.ts +++ b/src/funcs/privateEndpointsValidate.ts @@ -31,7 +31,7 @@ import { Result } from "../types/fp.js"; * Validate a draft private endpoint * * @remarks - * Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. Custom management keys require both `private_endpoints:write` and `byok:write`. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ export function privateEndpointsValidate( client: OpenRouterCore, diff --git a/src/lib/config.ts b/src/lib/config.ts index c751a497d..31a1360c7 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -74,7 +74,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "1.5.167", + sdkVersion: "1.5.168", genVersion: "2.960.8", - userAgent: "speakeasy-sdk/typescript 1.5.167 2.960.8 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.5.168 2.960.8 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/capacityguardrailpolicy.ts b/src/models/capacityguardrailpolicy.ts new file mode 100644 index 000000000..44486b216 --- /dev/null +++ b/src/models/capacityguardrailpolicy.ts @@ -0,0 +1,64 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { ClosedEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfig$inboundSchema, +} from "./guardrailcapacitypolicyconfig.js"; + +export const CapacityGuardrailPolicyPolicyType = { + RateLimit: "rate_limit", +} as const; +export type CapacityGuardrailPolicyPolicyType = ClosedEnum< + typeof CapacityGuardrailPolicyPolicyType +>; + +export type CapacityGuardrailPolicy = { + config: GuardrailCapacityPolicyConfig; + /** + * Policy ID + */ + id: string; + /** + * Policy name + */ + name: string; + policyType: CapacityGuardrailPolicyPolicyType; +}; + +/** @internal */ +export const CapacityGuardrailPolicyPolicyType$inboundSchema: z.ZodEnum< + typeof CapacityGuardrailPolicyPolicyType +> = z.enum(CapacityGuardrailPolicyPolicyType); + +/** @internal */ +export const CapacityGuardrailPolicy$inboundSchema: z.ZodType< + CapacityGuardrailPolicy, + unknown +> = z.object({ + config: GuardrailCapacityPolicyConfig$inboundSchema, + id: z.string(), + name: z.string(), + policy_type: CapacityGuardrailPolicyPolicyType$inboundSchema, +}).transform((v) => { + return remap$(v, { + "policy_type": "policyType", + }); +}); + +export function capacityGuardrailPolicyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CapacityGuardrailPolicy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CapacityGuardrailPolicy' from JSON`, + ); +} diff --git a/src/models/capacityguardrailpolicydetail.ts b/src/models/capacityguardrailpolicydetail.ts new file mode 100644 index 000000000..51bf38862 --- /dev/null +++ b/src/models/capacityguardrailpolicydetail.ts @@ -0,0 +1,133 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { ClosedEnum, OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfig$inboundSchema, +} from "./guardrailcapacitypolicyconfig.js"; + +export const CapacityGuardrailPolicyDetailPolicyType = { + RateLimit: "rate_limit", +} as const; +export type CapacityGuardrailPolicyDetailPolicyType = ClosedEnum< + typeof CapacityGuardrailPolicyDetailPolicyType +>; + +/** + * `legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` + */ +export const CapacityGuardrailPolicyDetailReference = { + LegacyMapping: "legacy_mapping", + AccountDefault: "account_default", +} as const; +/** + * `legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` + */ +export type CapacityGuardrailPolicyDetailReference = OpenEnum< + typeof CapacityGuardrailPolicyDetailReference +>; + +export type CapacityGuardrailPolicyDetail = { + /** + * API key hashes + */ + apiKeyHashes: Array; + config: GuardrailCapacityPolicyConfig; + /** + * Policy ID + */ + id: string; + isWorkspaceDefault?: boolean | undefined; + /** + * Organization member user IDs + */ + memberIds: Array; + /** + * Policy name + */ + name: string; + /** + * API key hashes + */ + optedOutApiKeyHashes: Array; + /** + * Organization member user IDs + */ + optedOutMemberIds?: Array | undefined; + /** + * API keys that have a different policy of this type assigned directly + */ + overriddenApiKeyHashes: Array; + /** + * Members that have a different policy of this type assigned directly + */ + overriddenMemberIds?: Array | undefined; + policyType: CapacityGuardrailPolicyDetailPolicyType; + /** + * `legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` + */ + reference: CapacityGuardrailPolicyDetailReference | null; + updatedAt: string | null; +}; + +/** @internal */ +export const CapacityGuardrailPolicyDetailPolicyType$inboundSchema: z.ZodEnum< + typeof CapacityGuardrailPolicyDetailPolicyType +> = z.enum(CapacityGuardrailPolicyDetailPolicyType); + +/** @internal */ +export const CapacityGuardrailPolicyDetailReference$inboundSchema: z.ZodType< + CapacityGuardrailPolicyDetailReference, + unknown +> = openEnums.inboundSchema(CapacityGuardrailPolicyDetailReference); + +/** @internal */ +export const CapacityGuardrailPolicyDetail$inboundSchema: z.ZodType< + CapacityGuardrailPolicyDetail, + unknown +> = z.object({ + api_key_hashes: z.array(z.string()), + config: GuardrailCapacityPolicyConfig$inboundSchema, + id: z.string(), + is_workspace_default: z.boolean().optional(), + member_ids: z.array(z.string()), + name: z.string(), + opted_out_api_key_hashes: z.array(z.string()), + opted_out_member_ids: z.array(z.string()).optional(), + overridden_api_key_hashes: z.array(z.string()), + overridden_member_ids: z.array(z.string()).optional(), + policy_type: CapacityGuardrailPolicyDetailPolicyType$inboundSchema, + reference: z.nullable(CapacityGuardrailPolicyDetailReference$inboundSchema) + .default(null), + updated_at: z.nullable(z.string()), +}).transform((v) => { + return remap$(v, { + "api_key_hashes": "apiKeyHashes", + "is_workspace_default": "isWorkspaceDefault", + "member_ids": "memberIds", + "opted_out_api_key_hashes": "optedOutApiKeyHashes", + "opted_out_member_ids": "optedOutMemberIds", + "overridden_api_key_hashes": "overriddenApiKeyHashes", + "overridden_member_ids": "overriddenMemberIds", + "policy_type": "policyType", + "updated_at": "updatedAt", + }); +}); + +export function capacityGuardrailPolicyDetailFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CapacityGuardrailPolicyDetail$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CapacityGuardrailPolicyDetail' from JSON`, + ); +} diff --git a/src/models/capacityguardrailpolicydetailresponse.ts b/src/models/capacityguardrailpolicydetailresponse.ts new file mode 100644 index 000000000..f12fdca70 --- /dev/null +++ b/src/models/capacityguardrailpolicydetailresponse.ts @@ -0,0 +1,35 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { + CapacityGuardrailPolicyDetail, + CapacityGuardrailPolicyDetail$inboundSchema, +} from "./capacityguardrailpolicydetail.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type CapacityGuardrailPolicyDetailResponse = { + data: CapacityGuardrailPolicyDetail; +}; + +/** @internal */ +export const CapacityGuardrailPolicyDetailResponse$inboundSchema: z.ZodType< + CapacityGuardrailPolicyDetailResponse, + unknown +> = z.object({ + data: CapacityGuardrailPolicyDetail$inboundSchema, +}); + +export function capacityGuardrailPolicyDetailResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CapacityGuardrailPolicyDetailResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CapacityGuardrailPolicyDetailResponse' from JSON`, + ); +} diff --git a/src/models/capacityguardrailpolicyresponse.ts b/src/models/capacityguardrailpolicyresponse.ts new file mode 100644 index 000000000..62456fadb --- /dev/null +++ b/src/models/capacityguardrailpolicyresponse.ts @@ -0,0 +1,34 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { + CapacityGuardrailPolicy, + CapacityGuardrailPolicy$inboundSchema, +} from "./capacityguardrailpolicy.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type CapacityGuardrailPolicyResponse = { + data: CapacityGuardrailPolicy; +}; + +/** @internal */ +export const CapacityGuardrailPolicyResponse$inboundSchema: z.ZodType< + CapacityGuardrailPolicyResponse, + unknown +> = z.object({ + data: CapacityGuardrailPolicy$inboundSchema, +}); + +export function capacityGuardrailPolicyResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CapacityGuardrailPolicyResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CapacityGuardrailPolicyResponse' from JSON`, + ); +} diff --git a/src/models/capacityguardrailpolicysummary.ts b/src/models/capacityguardrailpolicysummary.ts new file mode 100644 index 000000000..2ee7884c8 --- /dev/null +++ b/src/models/capacityguardrailpolicysummary.ts @@ -0,0 +1,76 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { ClosedEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfig$inboundSchema, +} from "./guardrailcapacitypolicyconfig.js"; + +export const CapacityGuardrailPolicySummaryPolicyType = { + RateLimit: "rate_limit", +} as const; +export type CapacityGuardrailPolicySummaryPolicyType = ClosedEnum< + typeof CapacityGuardrailPolicySummaryPolicyType +>; + +export type CapacityGuardrailPolicySummary = { + apiKeyCount: number; + config: GuardrailCapacityPolicyConfig; + /** + * Policy ID + */ + id: string; + isWorkspaceDefault?: boolean | undefined; + memberCount: number; + /** + * Policy name + */ + name: string; + policyType: CapacityGuardrailPolicySummaryPolicyType; + updatedAt: string | null; +}; + +/** @internal */ +export const CapacityGuardrailPolicySummaryPolicyType$inboundSchema: z.ZodEnum< + typeof CapacityGuardrailPolicySummaryPolicyType +> = z.enum(CapacityGuardrailPolicySummaryPolicyType); + +/** @internal */ +export const CapacityGuardrailPolicySummary$inboundSchema: z.ZodType< + CapacityGuardrailPolicySummary, + unknown +> = z.object({ + api_key_count: z.int(), + config: GuardrailCapacityPolicyConfig$inboundSchema, + id: z.string(), + is_workspace_default: z.boolean().optional(), + member_count: z.int(), + name: z.string(), + policy_type: CapacityGuardrailPolicySummaryPolicyType$inboundSchema, + updated_at: z.nullable(z.string()), +}).transform((v) => { + return remap$(v, { + "api_key_count": "apiKeyCount", + "is_workspace_default": "isWorkspaceDefault", + "member_count": "memberCount", + "policy_type": "policyType", + "updated_at": "updatedAt", + }); +}); + +export function capacityGuardrailPolicySummaryFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CapacityGuardrailPolicySummary$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CapacityGuardrailPolicySummary' from JSON`, + ); +} diff --git a/src/models/changeguardrailpolicyassignmentrequest.ts b/src/models/changeguardrailpolicyassignmentrequest.ts index a5cf692f3..d5febf280 100644 --- a/src/models/changeguardrailpolicyassignmentrequest.ts +++ b/src/models/changeguardrailpolicyassignmentrequest.ts @@ -13,7 +13,7 @@ import { } from "./guardrailpolicyassignmentstate.js"; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export const ChangeGuardrailPolicyAssignmentRequestPolicyType = { Budget: "budget", @@ -22,7 +22,7 @@ export const ChangeGuardrailPolicyAssignmentRequestPolicyType = { RateLimit: "rate_limit", } as const; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export type ChangeGuardrailPolicyAssignmentRequestPolicyType = OpenEnum< typeof ChangeGuardrailPolicyAssignmentRequestPolicyType @@ -39,7 +39,7 @@ export type ChangeGuardrailPolicyAssignmentRequest = { */ policyId: string; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ policyType: ChangeGuardrailPolicyAssignmentRequestPolicyType; /** diff --git a/src/models/createbudgetguardrailpolicyrequest.ts b/src/models/createbudgetguardrailpolicyrequest.ts index 4850afec3..ea316eced 100644 --- a/src/models/createbudgetguardrailpolicyrequest.ts +++ b/src/models/createbudgetguardrailpolicyrequest.ts @@ -32,6 +32,10 @@ export type CreateBudgetGuardrailPolicyRequest = { * Organization member user IDs */ memberIds?: Array | undefined; + /** + * When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. + */ + moveExistingAssignments?: boolean | undefined; /** * Policy name */ @@ -63,6 +67,7 @@ export type CreateBudgetGuardrailPolicyRequest$Outbound = { config: GuardrailBudgetPolicyAuthoringConfig$Outbound; is_workspace_default?: boolean | undefined; member_ids?: Array | undefined; + move_existing_assignments?: boolean | undefined; name: string; opted_out_api_key_hashes?: Array | undefined; opted_out_member_ids?: Array | undefined; @@ -79,6 +84,7 @@ export const CreateBudgetGuardrailPolicyRequest$outboundSchema: z.ZodType< config: GuardrailBudgetPolicyAuthoringConfig$outboundSchema, isWorkspaceDefault: z.boolean().optional(), memberIds: z.array(z.string()).optional(), + moveExistingAssignments: z.boolean().optional(), name: z.string(), optedOutApiKeyHashes: z.array(z.string()).optional(), optedOutMemberIds: z.array(z.string()).optional(), @@ -89,6 +95,7 @@ export const CreateBudgetGuardrailPolicyRequest$outboundSchema: z.ZodType< apiKeyHashes: "api_key_hashes", isWorkspaceDefault: "is_workspace_default", memberIds: "member_ids", + moveExistingAssignments: "move_existing_assignments", optedOutApiKeyHashes: "opted_out_api_key_hashes", optedOutMemberIds: "opted_out_member_ids", policyType: "policy_type", diff --git a/src/models/createcapacityguardrailpolicyrequest.ts b/src/models/createcapacityguardrailpolicyrequest.ts new file mode 100644 index 000000000..2dddfdcee --- /dev/null +++ b/src/models/createcapacityguardrailpolicyrequest.ts @@ -0,0 +1,114 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { ClosedEnum } from "../types/enums.js"; +import { + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfig$Outbound, + GuardrailCapacityPolicyConfig$outboundSchema, +} from "./guardrailcapacitypolicyconfig.js"; + +export const CreateCapacityGuardrailPolicyRequestPolicyType = { + RateLimit: "rate_limit", +} as const; +export type CreateCapacityGuardrailPolicyRequestPolicyType = ClosedEnum< + typeof CreateCapacityGuardrailPolicyRequestPolicyType +>; + +export type CreateCapacityGuardrailPolicyRequest = { + /** + * API key hashes + */ + apiKeyHashes?: Array | undefined; + config: GuardrailCapacityPolicyConfig; + /** + * Make this the workspace default for its policy type. Defaults to `false`. + */ + isWorkspaceDefault?: boolean | undefined; + /** + * Organization member user IDs + */ + memberIds?: Array | undefined; + /** + * When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. + */ + moveExistingAssignments?: boolean | undefined; + /** + * Policy name + */ + name: string; + /** + * API keys that should not inherit the policy when it is the workspace default + */ + optedOutApiKeyHashes?: Array | undefined; + /** + * Members that should not inherit the policy when it is the workspace default + */ + optedOutMemberIds?: Array | undefined; + policyType: CreateCapacityGuardrailPolicyRequestPolicyType; + /** + * Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + */ + workspaceId: string; +}; + +/** @internal */ +export const CreateCapacityGuardrailPolicyRequestPolicyType$outboundSchema: + z.ZodEnum = z.enum( + CreateCapacityGuardrailPolicyRequestPolicyType, + ); + +/** @internal */ +export type CreateCapacityGuardrailPolicyRequest$Outbound = { + api_key_hashes?: Array | undefined; + config: GuardrailCapacityPolicyConfig$Outbound; + is_workspace_default?: boolean | undefined; + member_ids?: Array | undefined; + move_existing_assignments?: boolean | undefined; + name: string; + opted_out_api_key_hashes?: Array | undefined; + opted_out_member_ids?: Array | undefined; + policy_type: string; + workspace_id: string; +}; + +/** @internal */ +export const CreateCapacityGuardrailPolicyRequest$outboundSchema: z.ZodType< + CreateCapacityGuardrailPolicyRequest$Outbound, + CreateCapacityGuardrailPolicyRequest +> = z.object({ + apiKeyHashes: z.array(z.string()).optional(), + config: GuardrailCapacityPolicyConfig$outboundSchema, + isWorkspaceDefault: z.boolean().optional(), + memberIds: z.array(z.string()).optional(), + moveExistingAssignments: z.boolean().optional(), + name: z.string(), + optedOutApiKeyHashes: z.array(z.string()).optional(), + optedOutMemberIds: z.array(z.string()).optional(), + policyType: CreateCapacityGuardrailPolicyRequestPolicyType$outboundSchema, + workspaceId: z.string(), +}).transform((v) => { + return remap$(v, { + apiKeyHashes: "api_key_hashes", + isWorkspaceDefault: "is_workspace_default", + memberIds: "member_ids", + moveExistingAssignments: "move_existing_assignments", + optedOutApiKeyHashes: "opted_out_api_key_hashes", + optedOutMemberIds: "opted_out_member_ids", + policyType: "policy_type", + workspaceId: "workspace_id", + }); +}); + +export function createCapacityGuardrailPolicyRequestToJSON( + createCapacityGuardrailPolicyRequest: CreateCapacityGuardrailPolicyRequest, +): string { + return JSON.stringify( + CreateCapacityGuardrailPolicyRequest$outboundSchema.parse( + createCapacityGuardrailPolicyRequest, + ), + ); +} diff --git a/src/models/createmodelavailabilityguardrailpolicyrequest.ts b/src/models/createmodelavailabilityguardrailpolicyrequest.ts index b19b80f88..64db0f9f0 100644 --- a/src/models/createmodelavailabilityguardrailpolicyrequest.ts +++ b/src/models/createmodelavailabilityguardrailpolicyrequest.ts @@ -31,6 +31,10 @@ export type CreateModelAvailabilityGuardrailPolicyRequest = { * Organization member user IDs */ memberIds?: Array | undefined; + /** + * When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. + */ + moveExistingAssignments?: boolean | undefined; /** * Policy name */ @@ -61,6 +65,7 @@ export type CreateModelAvailabilityGuardrailPolicyRequest$Outbound = { config: GuardrailModelAvailabilityPolicyAuthoringConfig$Outbound; is_workspace_default?: boolean | undefined; member_ids?: Array | undefined; + move_existing_assignments?: boolean | undefined; name: string; opted_out_api_key_hashes?: Array | undefined; opted_out_member_ids?: Array | undefined; @@ -78,6 +83,7 @@ export const CreateModelAvailabilityGuardrailPolicyRequest$outboundSchema: config: GuardrailModelAvailabilityPolicyAuthoringConfig$outboundSchema, isWorkspaceDefault: z.boolean().optional(), memberIds: z.array(z.string()).optional(), + moveExistingAssignments: z.boolean().optional(), name: z.string(), optedOutApiKeyHashes: z.array(z.string()).optional(), optedOutMemberIds: z.array(z.string()).optional(), @@ -89,6 +95,7 @@ export const CreateModelAvailabilityGuardrailPolicyRequest$outboundSchema: apiKeyHashes: "api_key_hashes", isWorkspaceDefault: "is_workspace_default", memberIds: "member_ids", + moveExistingAssignments: "move_existing_assignments", optedOutApiKeyHashes: "opted_out_api_key_hashes", optedOutMemberIds: "opted_out_member_ids", policyType: "policy_type", diff --git a/src/models/createmoderationguardrailpolicyrequest.ts b/src/models/createmoderationguardrailpolicyrequest.ts index 683c2da17..4ebe68550 100644 --- a/src/models/createmoderationguardrailpolicyrequest.ts +++ b/src/models/createmoderationguardrailpolicyrequest.ts @@ -32,6 +32,10 @@ export type CreateModerationGuardrailPolicyRequest = { * Organization member user IDs */ memberIds?: Array | undefined; + /** + * When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. + */ + moveExistingAssignments?: boolean | undefined; /** * Policy name */ @@ -63,6 +67,7 @@ export type CreateModerationGuardrailPolicyRequest$Outbound = { config: GuardrailModerationPolicyConfig$Outbound; is_workspace_default?: boolean | undefined; member_ids?: Array | undefined; + move_existing_assignments?: boolean | undefined; name: string; opted_out_api_key_hashes?: Array | undefined; opted_out_member_ids?: Array | undefined; @@ -79,6 +84,7 @@ export const CreateModerationGuardrailPolicyRequest$outboundSchema: z.ZodType< config: GuardrailModerationPolicyConfig$outboundSchema, isWorkspaceDefault: z.boolean().optional(), memberIds: z.array(z.string()).optional(), + moveExistingAssignments: z.boolean().optional(), name: z.string(), optedOutApiKeyHashes: z.array(z.string()).optional(), optedOutMemberIds: z.array(z.string()).optional(), @@ -89,6 +95,7 @@ export const CreateModerationGuardrailPolicyRequest$outboundSchema: z.ZodType< apiKeyHashes: "api_key_hashes", isWorkspaceDefault: "is_workspace_default", memberIds: "member_ids", + moveExistingAssignments: "move_existing_assignments", optedOutApiKeyHashes: "opted_out_api_key_hashes", optedOutMemberIds: "opted_out_member_ids", policyType: "policy_type", diff --git a/src/models/guardrailcapacitylimit.ts b/src/models/guardrailcapacitylimit.ts new file mode 100644 index 000000000..91500e7e3 --- /dev/null +++ b/src/models/guardrailcapacitylimit.ts @@ -0,0 +1,142 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { ClosedEnum, OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +/** + * Apply this limit to every model. + */ +export const ModelsEnum = { + All: "all", +} as const; +/** + * Apply this limit to every model. + */ +export type ModelsEnum = ClosedEnum; + +/** + * Either `"all"` to cover every model or a non-empty list of exact model slugs. + */ +export type Models = ModelsEnum | Array; + +/** + * Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). + */ +export const GuardrailCapacityLimitUnit = { + Tokens: "tokens", + Requests: "requests", +} as const; +/** + * Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). + */ +export type GuardrailCapacityLimitUnit = OpenEnum< + typeof GuardrailCapacityLimitUnit +>; + +export type GuardrailCapacityLimit = { + /** + * Bucket capacity and per-minute refill rate. + */ + limit: number; + /** + * Either `"all"` to cover every model or a non-empty list of exact model slugs. + */ + models: ModelsEnum | Array; + /** + * Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). + */ + unit: GuardrailCapacityLimitUnit; +}; + +/** @internal */ +export const ModelsEnum$inboundSchema: z.ZodEnum = z.enum( + ModelsEnum, +); +/** @internal */ +export const ModelsEnum$outboundSchema: z.ZodEnum = + ModelsEnum$inboundSchema; + +/** @internal */ +export const Models$inboundSchema: z.ZodType = z.union([ + ModelsEnum$inboundSchema, + z.array(z.string()), +]); +/** @internal */ +export type Models$Outbound = string | Array; + +/** @internal */ +export const Models$outboundSchema: z.ZodType = z + .union([ModelsEnum$outboundSchema, z.array(z.string())]); + +export function modelsToJSON(models: Models): string { + return JSON.stringify(Models$outboundSchema.parse(models)); +} +export function modelsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Models$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Models' from JSON`, + ); +} + +/** @internal */ +export const GuardrailCapacityLimitUnit$inboundSchema: z.ZodType< + GuardrailCapacityLimitUnit, + unknown +> = openEnums.inboundSchema(GuardrailCapacityLimitUnit); +/** @internal */ +export const GuardrailCapacityLimitUnit$outboundSchema: z.ZodType< + string, + GuardrailCapacityLimitUnit +> = openEnums.outboundSchema(GuardrailCapacityLimitUnit); + +/** @internal */ +export const GuardrailCapacityLimit$inboundSchema: z.ZodType< + GuardrailCapacityLimit, + unknown +> = z.object({ + limit: z.int(), + models: z.union([ModelsEnum$inboundSchema, z.array(z.string())]), + unit: GuardrailCapacityLimitUnit$inboundSchema, +}); +/** @internal */ +export type GuardrailCapacityLimit$Outbound = { + limit: number; + models: string | Array; + unit: string; +}; + +/** @internal */ +export const GuardrailCapacityLimit$outboundSchema: z.ZodType< + GuardrailCapacityLimit$Outbound, + GuardrailCapacityLimit +> = z.object({ + limit: z.int(), + models: z.union([ModelsEnum$outboundSchema, z.array(z.string())]), + unit: GuardrailCapacityLimitUnit$outboundSchema, +}); + +export function guardrailCapacityLimitToJSON( + guardrailCapacityLimit: GuardrailCapacityLimit, +): string { + return JSON.stringify( + GuardrailCapacityLimit$outboundSchema.parse(guardrailCapacityLimit), + ); +} +export function guardrailCapacityLimitFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GuardrailCapacityLimit$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GuardrailCapacityLimit' from JSON`, + ); +} diff --git a/src/models/guardrailcapacitypolicyconfig.ts b/src/models/guardrailcapacitypolicyconfig.ts new file mode 100644 index 000000000..c8ad5fe2c --- /dev/null +++ b/src/models/guardrailcapacitypolicyconfig.ts @@ -0,0 +1,93 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + GuardrailCapacityLimit, + GuardrailCapacityLimit$inboundSchema, + GuardrailCapacityLimit$Outbound, + GuardrailCapacityLimit$outboundSchema, +} from "./guardrailcapacitylimit.js"; + +export const BucketBy = { + Workspace: "workspace", + Member: "member", + ApiKey: "api_key", + Model: "model", +} as const; +export type BucketBy = OpenEnum; + +export type GuardrailCapacityPolicyConfig = { + /** + * Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`. + */ + bucketBy: Array; + /** + * One or more per-minute token or request limits (up to 200 entries and 200 listed models total). + */ + limits: Array; +}; + +/** @internal */ +export const BucketBy$inboundSchema: z.ZodType = openEnums + .inboundSchema(BucketBy); +/** @internal */ +export const BucketBy$outboundSchema: z.ZodType = openEnums + .outboundSchema(BucketBy); + +/** @internal */ +export const GuardrailCapacityPolicyConfig$inboundSchema: z.ZodType< + GuardrailCapacityPolicyConfig, + unknown +> = z.object({ + bucket_by: z.array(BucketBy$inboundSchema), + limits: z.array(GuardrailCapacityLimit$inboundSchema), +}).transform((v) => { + return remap$(v, { + "bucket_by": "bucketBy", + }); +}); +/** @internal */ +export type GuardrailCapacityPolicyConfig$Outbound = { + bucket_by: Array; + limits: Array; +}; + +/** @internal */ +export const GuardrailCapacityPolicyConfig$outboundSchema: z.ZodType< + GuardrailCapacityPolicyConfig$Outbound, + GuardrailCapacityPolicyConfig +> = z.object({ + bucketBy: z.array(BucketBy$outboundSchema), + limits: z.array(GuardrailCapacityLimit$outboundSchema), +}).transform((v) => { + return remap$(v, { + bucketBy: "bucket_by", + }); +}); + +export function guardrailCapacityPolicyConfigToJSON( + guardrailCapacityPolicyConfig: GuardrailCapacityPolicyConfig, +): string { + return JSON.stringify( + GuardrailCapacityPolicyConfig$outboundSchema.parse( + guardrailCapacityPolicyConfig, + ), + ); +} +export function guardrailCapacityPolicyConfigFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GuardrailCapacityPolicyConfig$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GuardrailCapacityPolicyConfig' from JSON`, + ); +} diff --git a/src/models/index.ts b/src/models/index.ts index 29a4e7067..9a8230a38 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -202,6 +202,11 @@ export * from "./bulkunassignmembersresponse.js"; export * from "./byokkey.js"; export * from "./byokproviderslug.js"; export * from "./capabilitydescriptor.js"; +export * from "./capacityguardrailpolicy.js"; +export * from "./capacityguardrailpolicydetail.js"; +export * from "./capacityguardrailpolicydetailresponse.js"; +export * from "./capacityguardrailpolicyresponse.js"; +export * from "./capacityguardrailpolicysummary.js"; export * from "./changeguardrailpolicyassignmentrequest.js"; export * from "./changeguardrailpolicyassignmentresponse.js"; export * from "./chatannotation.js"; @@ -304,6 +309,7 @@ export * from "./costdetails.js"; export * from "./createbudgetguardrailpolicyrequest.js"; export * from "./createbyokkeyrequest.js"; export * from "./createbyokkeyresponse.js"; +export * from "./createcapacityguardrailpolicyrequest.js"; export * from "./createexternaluserrequest.js"; export * from "./createguardrailrequest.js"; export * from "./createguardrailresponse.js"; @@ -457,6 +463,8 @@ export * from "./goneresponseerrordata.js"; export * from "./guardrail.js"; export * from "./guardrailbudgetpolicyauthoringconfig.js"; export * from "./guardrailbudgetpolicyconfig.js"; +export * from "./guardrailcapacitylimit.js"; +export * from "./guardrailcapacitypolicyconfig.js"; export * from "./guardraildataregion.js"; export * from "./guardrailinterval.js"; export * from "./guardrailmodelavailabilitypolicyauthoringconfig.js"; @@ -518,6 +526,7 @@ export * from "./legacywebsearchservertool.js"; export * from "./listaccountguardrailpoliciesresponse.js"; export * from "./listbudgetguardrailpoliciesresponse.js"; export * from "./listbyokkeysresponse.js"; +export * from "./listcapacityguardrailpoliciesresponse.js"; export * from "./listendpointsresponse.js"; export * from "./listexternalusersresponse.js"; export * from "./listguardrailsresponse.js"; @@ -952,6 +961,7 @@ export * from "./unprocessableentityresponseerrordata.js"; export * from "./updatebudgetguardrailpolicyrequest.js"; export * from "./updatebyokkeyrequest.js"; export * from "./updatebyokkeyresponse.js"; +export * from "./updatecapacityguardrailpolicyrequest.js"; export * from "./updateexternaluserrequest.js"; export * from "./updateguardrailrequest.js"; export * from "./updateguardrailresponse.js"; diff --git a/src/models/listcapacityguardrailpoliciesresponse.ts b/src/models/listcapacityguardrailpoliciesresponse.ts new file mode 100644 index 000000000..20e58ed11 --- /dev/null +++ b/src/models/listcapacityguardrailpoliciesresponse.ts @@ -0,0 +1,45 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { + CapacityGuardrailPolicySummary, + CapacityGuardrailPolicySummary$inboundSchema, +} from "./capacityguardrailpolicysummary.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type ListCapacityGuardrailPoliciesResponse = { + data: Array; + /** + * Total number of policies + */ + totalCount: number; +}; + +/** @internal */ +export const ListCapacityGuardrailPoliciesResponse$inboundSchema: z.ZodType< + ListCapacityGuardrailPoliciesResponse, + unknown +> = z.object({ + data: z.array(CapacityGuardrailPolicySummary$inboundSchema), + total_count: z.int(), +}).transform((v) => { + return remap$(v, { + "total_count": "totalCount", + }); +}); + +export function listCapacityGuardrailPoliciesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListCapacityGuardrailPoliciesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListCapacityGuardrailPoliciesResponse' from JSON`, + ); +} diff --git a/src/models/operations/createcapacitypolicy.ts b/src/models/operations/createcapacitypolicy.ts new file mode 100644 index 000000000..1c1aa088c --- /dev/null +++ b/src/models/operations/createcapacitypolicy.ts @@ -0,0 +1,90 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as models from "../index.js"; + +export type CreateCapacityPolicyGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type CreateCapacityPolicyRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + createCapacityGuardrailPolicyRequest: + models.CreateCapacityGuardrailPolicyRequest; +}; + +/** @internal */ +export type CreateCapacityPolicyRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + CreateCapacityGuardrailPolicyRequest: + models.CreateCapacityGuardrailPolicyRequest$Outbound; +}; + +/** @internal */ +export const CreateCapacityPolicyRequest$outboundSchema: z.ZodType< + CreateCapacityPolicyRequest$Outbound, + CreateCapacityPolicyRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + createCapacityGuardrailPolicyRequest: + models.CreateCapacityGuardrailPolicyRequest$outboundSchema, +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + createCapacityGuardrailPolicyRequest: + "CreateCapacityGuardrailPolicyRequest", + }); +}); + +export function createCapacityPolicyRequestToJSON( + createCapacityPolicyRequest: CreateCapacityPolicyRequest, +): string { + return JSON.stringify( + CreateCapacityPolicyRequest$outboundSchema.parse( + createCapacityPolicyRequest, + ), + ); +} diff --git a/src/models/operations/deletecapacitypolicy.ts b/src/models/operations/deletecapacitypolicy.ts new file mode 100644 index 000000000..2569da240 --- /dev/null +++ b/src/models/operations/deletecapacitypolicy.ts @@ -0,0 +1,94 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; + +export type DeleteCapacityPolicyGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type DeleteCapacityPolicyRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Policy ID + */ + id: string; + /** + * Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + */ + workspaceId: string; +}; + +/** @internal */ +export type DeleteCapacityPolicyRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + id: string; + workspace_id: string; +}; + +/** @internal */ +export const DeleteCapacityPolicyRequest$outboundSchema: z.ZodType< + DeleteCapacityPolicyRequest$Outbound, + DeleteCapacityPolicyRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + id: z.string(), + workspaceId: z.string(), +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + workspaceId: "workspace_id", + }); +}); + +export function deleteCapacityPolicyRequestToJSON( + deleteCapacityPolicyRequest: DeleteCapacityPolicyRequest, +): string { + return JSON.stringify( + DeleteCapacityPolicyRequest$outboundSchema.parse( + deleteCapacityPolicyRequest, + ), + ); +} diff --git a/src/models/operations/getapikeypolicyassignment.ts b/src/models/operations/getapikeypolicyassignment.ts index 7cc2beba6..2ca0fe14b 100644 --- a/src/models/operations/getapikeypolicyassignment.ts +++ b/src/models/operations/getapikeypolicyassignment.ts @@ -30,7 +30,7 @@ export type GetApiKeyPolicyAssignmentGlobals = { }; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export const GetApiKeyPolicyAssignmentPolicyType = { Budget: "budget", @@ -39,7 +39,7 @@ export const GetApiKeyPolicyAssignmentPolicyType = { RateLimit: "rate_limit", } as const; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export type GetApiKeyPolicyAssignmentPolicyType = OpenEnum< typeof GetApiKeyPolicyAssignmentPolicyType @@ -74,7 +74,7 @@ export type GetApiKeyPolicyAssignmentRequest = { */ workspaceId?: string | undefined; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ policyType: GetApiKeyPolicyAssignmentPolicyType; }; diff --git a/src/models/operations/getcapacitypolicy.ts b/src/models/operations/getcapacitypolicy.ts new file mode 100644 index 000000000..35d6523ba --- /dev/null +++ b/src/models/operations/getcapacitypolicy.ts @@ -0,0 +1,92 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; + +export type GetCapacityPolicyGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type GetCapacityPolicyRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Policy ID + */ + id: string; + /** + * Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + */ + workspaceId: string; +}; + +/** @internal */ +export type GetCapacityPolicyRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + id: string; + workspace_id: string; +}; + +/** @internal */ +export const GetCapacityPolicyRequest$outboundSchema: z.ZodType< + GetCapacityPolicyRequest$Outbound, + GetCapacityPolicyRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + id: z.string(), + workspaceId: z.string(), +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + workspaceId: "workspace_id", + }); +}); + +export function getCapacityPolicyRequestToJSON( + getCapacityPolicyRequest: GetCapacityPolicyRequest, +): string { + return JSON.stringify( + GetCapacityPolicyRequest$outboundSchema.parse(getCapacityPolicyRequest), + ); +} diff --git a/src/models/operations/getmemberpolicyassignment.ts b/src/models/operations/getmemberpolicyassignment.ts index 3ecfc3c2d..f7d32f8e7 100644 --- a/src/models/operations/getmemberpolicyassignment.ts +++ b/src/models/operations/getmemberpolicyassignment.ts @@ -30,7 +30,7 @@ export type GetMemberPolicyAssignmentGlobals = { }; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export const GetMemberPolicyAssignmentPolicyType = { Budget: "budget", @@ -39,7 +39,7 @@ export const GetMemberPolicyAssignmentPolicyType = { RateLimit: "rate_limit", } as const; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ export type GetMemberPolicyAssignmentPolicyType = OpenEnum< typeof GetMemberPolicyAssignmentPolicyType @@ -74,7 +74,7 @@ export type GetMemberPolicyAssignmentRequest = { */ workspaceId?: string | undefined; /** - * Policy type the assignment is read or changed for + * Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. */ policyType: GetMemberPolicyAssignmentPolicyType; }; diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index 47c2726fa..92d024efe 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -23,6 +23,7 @@ export * from "./createauthkeyscode.js"; export * from "./createbatches.js"; export * from "./createbudgetpolicy.js"; export * from "./createbyokkey.js"; +export * from "./createcapacitypolicy.js"; export * from "./createembeddings.js"; export * from "./createexternaluser.js"; export * from "./createguardrail.js"; @@ -49,6 +50,7 @@ export * from "./deleteaccountpolicy.js"; export * from "./deletebatch.js"; export * from "./deletebudgetpolicy.js"; export * from "./deletebyokkey.js"; +export * from "./deletecapacitypolicy.js"; export * from "./deleteexternaluser.js"; export * from "./deletefile.js"; export * from "./deleteguardrail.js"; @@ -79,6 +81,7 @@ export * from "./getbatchresults.js"; export * from "./getbenchmarks.js"; export * from "./getbudgetpolicy.js"; export * from "./getbyokkey.js"; +export * from "./getcapacitypolicy.js"; export * from "./getcontainerfile.js"; export * from "./getcredits.js"; export * from "./getcurrentkey.js"; @@ -116,6 +119,7 @@ export * from "./listaccountpolicies.js"; export * from "./listbatches.js"; export * from "./listbudgetpolicies.js"; export * from "./listbyokkeys.js"; +export * from "./listcapacitypolicies.js"; export * from "./listcontainerfiles.js"; export * from "./listembeddingsmodels.js"; export * from "./listendpoints.js"; @@ -170,6 +174,7 @@ export * from "./submitgenerationfeedback.js"; export * from "./updateaccountpolicy.js"; export * from "./updatebudgetpolicy.js"; export * from "./updatebyokkey.js"; +export * from "./updatecapacitypolicy.js"; export * from "./updateexternaluser.js"; export * from "./updateguardrail.js"; export * from "./updatekeys.js"; diff --git a/src/models/operations/listcapacitypolicies.ts b/src/models/operations/listcapacitypolicies.ts new file mode 100644 index 000000000..26b3f4b1a --- /dev/null +++ b/src/models/operations/listcapacitypolicies.ts @@ -0,0 +1,130 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import * as models from "../index.js"; + +export type ListCapacityPoliciesGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type ListCapacityPoliciesRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned + */ + offset?: number | undefined; + /** + * Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned + */ + limit?: number | undefined; + /** + * Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + */ + workspaceId: string; +}; + +export type ListCapacityPoliciesResponse = { + result: models.ListCapacityGuardrailPoliciesResponse; +}; + +/** @internal */ +export type ListCapacityPoliciesRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + offset?: number | undefined; + limit?: number | undefined; + workspace_id: string; +}; + +/** @internal */ +export const ListCapacityPoliciesRequest$outboundSchema: z.ZodType< + ListCapacityPoliciesRequest$Outbound, + ListCapacityPoliciesRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + offset: z.int().optional(), + limit: z.int().optional(), + workspaceId: z.string(), +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + workspaceId: "workspace_id", + }); +}); + +export function listCapacityPoliciesRequestToJSON( + listCapacityPoliciesRequest: ListCapacityPoliciesRequest, +): string { + return JSON.stringify( + ListCapacityPoliciesRequest$outboundSchema.parse( + listCapacityPoliciesRequest, + ), + ); +} + +/** @internal */ +export const ListCapacityPoliciesResponse$inboundSchema: z.ZodType< + ListCapacityPoliciesResponse, + unknown +> = z.object({ + Result: models.ListCapacityGuardrailPoliciesResponse$inboundSchema, +}).transform((v) => { + return remap$(v, { + "Result": "result", + }); +}); + +export function listCapacityPoliciesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListCapacityPoliciesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListCapacityPoliciesResponse' from JSON`, + ); +} diff --git a/src/models/operations/updatecapacitypolicy.ts b/src/models/operations/updatecapacitypolicy.ts new file mode 100644 index 000000000..b9757f14d --- /dev/null +++ b/src/models/operations/updatecapacitypolicy.ts @@ -0,0 +1,96 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as models from "../index.js"; + +export type UpdateCapacityPolicyGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type UpdateCapacityPolicyRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Policy ID + */ + id: string; + updateCapacityGuardrailPolicyRequest: + models.UpdateCapacityGuardrailPolicyRequest; +}; + +/** @internal */ +export type UpdateCapacityPolicyRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + id: string; + UpdateCapacityGuardrailPolicyRequest: + models.UpdateCapacityGuardrailPolicyRequest$Outbound; +}; + +/** @internal */ +export const UpdateCapacityPolicyRequest$outboundSchema: z.ZodType< + UpdateCapacityPolicyRequest$Outbound, + UpdateCapacityPolicyRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + id: z.string(), + updateCapacityGuardrailPolicyRequest: + models.UpdateCapacityGuardrailPolicyRequest$outboundSchema, +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + updateCapacityGuardrailPolicyRequest: + "UpdateCapacityGuardrailPolicyRequest", + }); +}); + +export function updateCapacityPolicyRequestToJSON( + updateCapacityPolicyRequest: UpdateCapacityPolicyRequest, +): string { + return JSON.stringify( + UpdateCapacityPolicyRequest$outboundSchema.parse( + updateCapacityPolicyRequest, + ), + ); +} diff --git a/src/models/updatecapacityguardrailpolicyrequest.ts b/src/models/updatecapacityguardrailpolicyrequest.ts new file mode 100644 index 000000000..3de214e61 --- /dev/null +++ b/src/models/updatecapacityguardrailpolicyrequest.ts @@ -0,0 +1,89 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfig$Outbound, + GuardrailCapacityPolicyConfig$outboundSchema, +} from "./guardrailcapacitypolicyconfig.js"; + +export type UpdateCapacityGuardrailPolicyRequest = { + /** + * Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. + */ + apiKeyHashes?: Array | undefined; + config: GuardrailCapacityPolicyConfig; + /** + * Omit to keep the stored default status; `false` unsets the policy as the workspace default. + */ + isWorkspaceDefault?: boolean | undefined; + /** + * Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. + */ + memberIds?: Array | undefined; + /** + * Policy name + */ + name: string; + /** + * API key hashes + */ + optedOutApiKeyHashes?: Array | undefined; + /** + * Organization member user IDs + */ + optedOutMemberIds?: Array | undefined; + /** + * Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + */ + workspaceId: string; +}; + +/** @internal */ +export type UpdateCapacityGuardrailPolicyRequest$Outbound = { + api_key_hashes?: Array | undefined; + config: GuardrailCapacityPolicyConfig$Outbound; + is_workspace_default?: boolean | undefined; + member_ids?: Array | undefined; + name: string; + opted_out_api_key_hashes?: Array | undefined; + opted_out_member_ids?: Array | undefined; + workspace_id: string; +}; + +/** @internal */ +export const UpdateCapacityGuardrailPolicyRequest$outboundSchema: z.ZodType< + UpdateCapacityGuardrailPolicyRequest$Outbound, + UpdateCapacityGuardrailPolicyRequest +> = z.object({ + apiKeyHashes: z.array(z.string()).optional(), + config: GuardrailCapacityPolicyConfig$outboundSchema, + isWorkspaceDefault: z.boolean().optional(), + memberIds: z.array(z.string()).optional(), + name: z.string(), + optedOutApiKeyHashes: z.array(z.string()).optional(), + optedOutMemberIds: z.array(z.string()).optional(), + workspaceId: z.string(), +}).transform((v) => { + return remap$(v, { + apiKeyHashes: "api_key_hashes", + isWorkspaceDefault: "is_workspace_default", + memberIds: "member_ids", + optedOutApiKeyHashes: "opted_out_api_key_hashes", + optedOutMemberIds: "opted_out_member_ids", + workspaceId: "workspace_id", + }); +}); + +export function updateCapacityGuardrailPolicyRequestToJSON( + updateCapacityGuardrailPolicyRequest: UpdateCapacityGuardrailPolicyRequest, +): string { + return JSON.stringify( + UpdateCapacityGuardrailPolicyRequest$outboundSchema.parse( + updateCapacityGuardrailPolicyRequest, + ), + ); +} diff --git a/src/sdk/guardrailpolicies.ts b/src/sdk/guardrailpolicies.ts index 1852ba25f..4332cf252 100644 --- a/src/sdk/guardrailpolicies.ts +++ b/src/sdk/guardrailpolicies.ts @@ -6,27 +6,32 @@ import { guardrailPoliciesChangeApiKeyPolicyAssignment } from "../funcs/guardrai import { guardrailPoliciesChangeMemberPolicyAssignment } from "../funcs/guardrailPoliciesChangeMemberPolicyAssignment.js"; import { guardrailPoliciesCreateAccountPolicy } from "../funcs/guardrailPoliciesCreateAccountPolicy.js"; import { guardrailPoliciesCreateBudgetPolicy } from "../funcs/guardrailPoliciesCreateBudgetPolicy.js"; +import { guardrailPoliciesCreateCapacityPolicy } from "../funcs/guardrailPoliciesCreateCapacityPolicy.js"; import { guardrailPoliciesCreateModelAvailabilityPolicy } from "../funcs/guardrailPoliciesCreateModelAvailabilityPolicy.js"; import { guardrailPoliciesCreateModerationPolicy } from "../funcs/guardrailPoliciesCreateModerationPolicy.js"; import { guardrailPoliciesDeleteAccountPolicy } from "../funcs/guardrailPoliciesDeleteAccountPolicy.js"; import { guardrailPoliciesDeleteBudgetPolicy } from "../funcs/guardrailPoliciesDeleteBudgetPolicy.js"; +import { guardrailPoliciesDeleteCapacityPolicy } from "../funcs/guardrailPoliciesDeleteCapacityPolicy.js"; import { guardrailPoliciesDeleteModelAvailabilityPolicy } from "../funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.js"; import { guardrailPoliciesDeleteModerationPolicy } from "../funcs/guardrailPoliciesDeleteModerationPolicy.js"; import { guardrailPoliciesDeleteScimGroupPolicyOptOut } from "../funcs/guardrailPoliciesDeleteScimGroupPolicyOptOut.js"; import { guardrailPoliciesGetApiKeyPolicyAssignment } from "../funcs/guardrailPoliciesGetApiKeyPolicyAssignment.js"; import { guardrailPoliciesGetBudgetPolicy } from "../funcs/guardrailPoliciesGetBudgetPolicy.js"; +import { guardrailPoliciesGetCapacityPolicy } from "../funcs/guardrailPoliciesGetCapacityPolicy.js"; import { guardrailPoliciesGetMemberPolicyAssignment } from "../funcs/guardrailPoliciesGetMemberPolicyAssignment.js"; import { guardrailPoliciesGetModelAvailabilityPolicy } from "../funcs/guardrailPoliciesGetModelAvailabilityPolicy.js"; import { guardrailPoliciesGetModerationPolicy } from "../funcs/guardrailPoliciesGetModerationPolicy.js"; import { guardrailPoliciesGetScimGroupPolicyAssignment } from "../funcs/guardrailPoliciesGetScimGroupPolicyAssignment.js"; import { guardrailPoliciesListAccountPolicies } from "../funcs/guardrailPoliciesListAccountPolicies.js"; import { guardrailPoliciesListBudgetPolicies } from "../funcs/guardrailPoliciesListBudgetPolicies.js"; +import { guardrailPoliciesListCapacityPolicies } from "../funcs/guardrailPoliciesListCapacityPolicies.js"; import { guardrailPoliciesListModelAvailabilityPolicies } from "../funcs/guardrailPoliciesListModelAvailabilityPolicies.js"; import { guardrailPoliciesListModerationPolicies } from "../funcs/guardrailPoliciesListModerationPolicies.js"; import { guardrailPoliciesListScimGroupPolicyAssignments } from "../funcs/guardrailPoliciesListScimGroupPolicyAssignments.js"; import { guardrailPoliciesListScimGroupPolicyOptOuts } from "../funcs/guardrailPoliciesListScimGroupPolicyOptOuts.js"; import { guardrailPoliciesUpdateAccountPolicy } from "../funcs/guardrailPoliciesUpdateAccountPolicy.js"; import { guardrailPoliciesUpdateBudgetPolicy } from "../funcs/guardrailPoliciesUpdateBudgetPolicy.js"; +import { guardrailPoliciesUpdateCapacityPolicy } from "../funcs/guardrailPoliciesUpdateCapacityPolicy.js"; import { guardrailPoliciesUpdateModelAvailabilityPolicy } from "../funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.js"; import { guardrailPoliciesUpdateModerationPolicy } from "../funcs/guardrailPoliciesUpdateModerationPolicy.js"; import { guardrailPoliciesUpdateScimGroupPolicyAssignment } from "../funcs/guardrailPoliciesUpdateScimGroupPolicyAssignment.js"; @@ -347,6 +352,93 @@ export class GuardrailPolicies extends ClientSDK { )); } + /** + * List capacity policies + * + * @remarks + * List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + async listCapacityPolicies( + request: operations.ListCapacityPoliciesRequest, + options?: RequestOptions, + ): Promise< + PageIterator + > { + return unwrapResultIterator(guardrailPoliciesListCapacityPolicies( + this, + request, + options, + )); + } + + /** + * Create a capacity policy + * + * @remarks + * Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + async createCapacityPolicy( + request: operations.CreateCapacityPolicyRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(guardrailPoliciesCreateCapacityPolicy( + this, + request, + options, + )); + } + + /** + * Delete a capacity policy + * + * @remarks + * Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + async deleteCapacityPolicy( + request: operations.DeleteCapacityPolicyRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(guardrailPoliciesDeleteCapacityPolicy( + this, + request, + options, + )); + } + + /** + * Get a capacity policy + * + * @remarks + * Get a capacity policy with its member and API key assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + async getCapacityPolicy( + request: operations.GetCapacityPolicyRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(guardrailPoliciesGetCapacityPolicy( + this, + request, + options, + )); + } + + /** + * Update a capacity policy + * + * @remarks + * Replace a capacity policy's name and config, and optionally its assignments. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + async updateCapacityPolicy( + request: operations.UpdateCapacityPolicyRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(guardrailPoliciesUpdateCapacityPolicy( + this, + request, + options, + )); + } + /** * List model availability policies * diff --git a/src/sdk/privateendpoints.ts b/src/sdk/privateendpoints.ts index 5e2e3b8bb..13c0d60e4 100644 --- a/src/sdk/privateendpoints.ts +++ b/src/sdk/privateendpoints.ts @@ -38,7 +38,7 @@ export class PrivateEndpoints extends ClientSDK { * Create a private endpoint * * @remarks - * Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:create` can only create drafts; passing `activate` requires a full organization Read/write management key and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Create a private endpoint as a draft. Drafts are not routable: validate one with `POST /private-endpoints/{id}/validate`, then activate it with `POST /private-endpoints/{id}/activate`. Pass `activate` to do all three in one call; if validation fails the draft is kept and returned with the failed checks. Custom management keys with `private_endpoints:write` can create drafts; passing `activate` also requires `byok:write` (or a full organization Read/write management key) and otherwise returns 403. Send an `Idempotency-Key` header to make retries safe: a repeated key with the same request returns the endpoint the first request created; reusing it with different fields returns 422 `idempotency_key_reused`. Returns 400 `parameters_invalid` when `tool_choice` is declared without `tools`. The response does not echo `declared_parameters` or `tested_parameters`; read them with `GET /private-endpoints/{id}`. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ async create( request: operations.CreatePrivateEndpointRequest, @@ -157,7 +157,7 @@ export class PrivateEndpoints extends ClientSDK { * Validate a draft private endpoint * * @remarks - * Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider. A passing validation is required before activation. Failed checks return 200 with `passed: false`. Custom management keys require both `private_endpoints:write` and `byok:write`. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ async validate( request: operations.ValidatePrivateEndpointRequest,