From e27228d081c6c69d688cec38d1d29148a48ba4ee Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 3 Dec 2026 05:28:13 +0000 Subject: [PATCH] ## Python SDK Changes: * `open_router.guardrail_policies.list_capacity_policies()`: **Added** * `open_router.guardrail_policies.create_capacity_policy()`: **Added** * `open_router.guardrail_policies.delete_capacity_policy()`: **Added** * `open_router.guardrail_policies.get_capacity_policy()`: **Added** * `open_router.guardrail_policies.update_capacity_policy()`: **Added** * `open_router.guardrail_policies.create_budget_policy()`: `request.move_existing_assignments` **Added** * `open_router.guardrail_policies.create_model_availability_policy()`: `request.move_existing_assignments` **Added** * `open_router.guardrail_policies.create_moderation_policy()`: `request.move_existing_assignments` **Added** --- .speakeasy/gen.lock | 398 +++- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 1612 +++++++++++---- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/components/bucketby.mdx | 22 + docs/components/capacityguardrailpolicy.mdx | 12 + .../capacityguardrailpolicydetail.mdx | 21 + ...apacityguardrailpolicydetailpolicytype.mdx | 15 + ...capacityguardrailpolicydetailreference.mdx | 22 + .../capacityguardrailpolicydetailresponse.mdx | 9 + .../capacityguardrailpolicypolicytype.mdx | 15 + .../capacityguardrailpolicyresponse.mdx | 9 + .../capacityguardrailpolicysummary.mdx | 16 + ...pacityguardrailpolicysummarypolicytype.mdx | 15 + ...changeguardrailpolicyassignmentrequest.mdx | 14 +- ...drailpolicyassignmentrequestpolicytype.mdx | 2 +- .../createbudgetguardrailpolicyrequest.mdx | 1 + .../createcapacityguardrailpolicyrequest.mdx | 18 + ...pacityguardrailpolicyrequestpolicytype.mdx | 15 + ...odelavailabilityguardrailpolicyrequest.mdx | 1 + ...createmoderationguardrailpolicyrequest.mdx | 1 + docs/components/guardrailcapacitylimit.mdx | 11 + .../components/guardrailcapacitylimitunit.mdx | 22 + .../guardrailcapacitypolicyconfig.mdx | 10 + .../listcapacityguardrailpoliciesresponse.mdx | 10 + docs/components/models.mdx | 21 + docs/components/modelsenum.mdx | 17 + .../updatecapacityguardrailpolicyrequest.mdx | 16 + .../createcapacitypolicyglobals.mdx | 11 + .../createcapacitypolicyrequest.mdx | 12 + .../deletecapacitypolicyglobals.mdx | 11 + .../deletecapacitypolicyrequest.mdx | 13 + .../getapikeypolicyassignmentpolicytype.mdx | 2 +- .../getapikeypolicyassignmentrequest.mdx | 16 +- docs/operations/getcapacitypolicyglobals.mdx | 11 + docs/operations/getcapacitypolicyrequest.mdx | 13 + .../getmemberpolicyassignmentpolicytype.mdx | 2 +- .../getmemberpolicyassignmentrequest.mdx | 16 +- .../listcapacitypoliciesglobals.mdx | 11 + .../listcapacitypoliciesrequest.mdx | 14 + .../listcapacitypoliciesresponse.mdx | 9 + .../updatecapacitypolicyglobals.mdx | 11 + .../updatecapacitypolicyrequest.mdx | 13 + docs/sdks/guardrailpolicies/README.mdx | 392 +++- docs/sdks/privateendpoints/README.mdx | 4 +- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/components/__init__.py | 110 ++ .../components/capacityguardrailpolicy.py | 34 + .../capacityguardrailpolicydetail.py | 128 ++ .../capacityguardrailpolicydetailresponse.py | 17 + .../capacityguardrailpolicyresponse.py | 17 + .../capacityguardrailpolicysummary.py | 72 + .../changeguardrailpolicyassignmentrequest.py | 6 +- .../createbudgetguardrailpolicyrequest.py | 6 + .../createcapacityguardrailpolicyrequest.py | 90 + ...modelavailabilityguardrailpolicyrequest.py | 6 + .../createmoderationguardrailpolicyrequest.py | 6 + .../components/guardrailcapacitylimit.py | 48 + .../guardrailcapacitypolicyconfig.py | 36 + .../listcapacityguardrailpoliciesresponse.py | 23 + .../updatecapacityguardrailpolicyrequest.py | 78 + src/openrouter/guardrail_policies.py | 1727 ++++++++++++++++- src/openrouter/operations/__init__.py | 76 + .../operations/createcapacitypolicy.py | 146 ++ .../operations/deletecapacitypolicy.py | 156 ++ .../operations/getapikeypolicyassignment.py | 6 +- .../operations/getcapacitypolicy.py | 156 ++ .../operations/getmemberpolicyassignment.py | 6 +- .../operations/listcapacitypolicies.py | 182 ++ .../operations/updatecapacitypolicy.py | 158 ++ src/openrouter/private_endpoints.py | 8 +- uv.lock | 2 +- 74 files changed, 5684 insertions(+), 532 deletions(-) create mode 100644 docs/components/bucketby.mdx create mode 100644 docs/components/capacityguardrailpolicy.mdx create mode 100644 docs/components/capacityguardrailpolicydetail.mdx create mode 100644 docs/components/capacityguardrailpolicydetailpolicytype.mdx create mode 100644 docs/components/capacityguardrailpolicydetailreference.mdx create mode 100644 docs/components/capacityguardrailpolicydetailresponse.mdx create mode 100644 docs/components/capacityguardrailpolicypolicytype.mdx create mode 100644 docs/components/capacityguardrailpolicyresponse.mdx create mode 100644 docs/components/capacityguardrailpolicysummary.mdx create mode 100644 docs/components/capacityguardrailpolicysummarypolicytype.mdx create mode 100644 docs/components/createcapacityguardrailpolicyrequest.mdx create mode 100644 docs/components/createcapacityguardrailpolicyrequestpolicytype.mdx create mode 100644 docs/components/guardrailcapacitylimit.mdx create mode 100644 docs/components/guardrailcapacitylimitunit.mdx create mode 100644 docs/components/guardrailcapacitypolicyconfig.mdx create mode 100644 docs/components/listcapacityguardrailpoliciesresponse.mdx create mode 100644 docs/components/models.mdx create mode 100644 docs/components/modelsenum.mdx create mode 100644 docs/components/updatecapacityguardrailpolicyrequest.mdx create mode 100644 docs/operations/createcapacitypolicyglobals.mdx create mode 100644 docs/operations/createcapacitypolicyrequest.mdx create mode 100644 docs/operations/deletecapacitypolicyglobals.mdx create mode 100644 docs/operations/deletecapacitypolicyrequest.mdx create mode 100644 docs/operations/getcapacitypolicyglobals.mdx create mode 100644 docs/operations/getcapacitypolicyrequest.mdx create mode 100644 docs/operations/listcapacitypoliciesglobals.mdx create mode 100644 docs/operations/listcapacitypoliciesrequest.mdx create mode 100644 docs/operations/listcapacitypoliciesresponse.mdx create mode 100644 docs/operations/updatecapacitypolicyglobals.mdx create mode 100644 docs/operations/updatecapacitypolicyrequest.mdx create mode 100644 src/openrouter/components/capacityguardrailpolicy.py create mode 100644 src/openrouter/components/capacityguardrailpolicydetail.py create mode 100644 src/openrouter/components/capacityguardrailpolicydetailresponse.py create mode 100644 src/openrouter/components/capacityguardrailpolicyresponse.py create mode 100644 src/openrouter/components/capacityguardrailpolicysummary.py create mode 100644 src/openrouter/components/createcapacityguardrailpolicyrequest.py create mode 100644 src/openrouter/components/guardrailcapacitylimit.py create mode 100644 src/openrouter/components/guardrailcapacitypolicyconfig.py create mode 100644 src/openrouter/components/listcapacityguardrailpoliciesresponse.py create mode 100644 src/openrouter/components/updatecapacityguardrailpolicyrequest.py create mode 100644 src/openrouter/operations/createcapacitypolicy.py create mode 100644 src/openrouter/operations/deletecapacitypolicy.py create mode 100644 src/openrouter/operations/getcapacitypolicy.py create mode 100644 src/openrouter/operations/listcapacitypolicies.py create mode 100644 src/openrouter/operations/updatecapacitypolicy.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index faa5fdb36..07a7122c5 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: c48cf606-fb42-4a45-9c23-8f0555307828 management: - docChecksum: aa20ba624ec481df58c29dc50fb2a41e + docChecksum: f25038f43a2bb37a03dea228084d93b0 docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.234 - configChecksum: 6d9ede6dcd8a5e5c7ca1a96da8338ff6 + releaseVersion: 1.3.235 + configChecksum: 08a36653100ebbea06c0befe1dd4f33f repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: ad7776e0-0883-44c0-af7d-59baa591ffad - pristine_commit_hash: 73cf1e99f5b9cbecff4cc328e37de9e01b812e2f - pristine_tree_hash: eefc5c70d547f44bbf77427dbf665233a7eb6e9c + generation_id: 728b59d5-72fe-48eb-99bc-f216625a6c99 + pristine_commit_hash: b9e112d64eade464794b205a6a85ccb67fdf7132 + pristine_tree_hash: 6980e382eb7d3761c703eb87affde9e639b55ea1 features: python: acceptHeaders: 3.0.0 @@ -1774,6 +1774,10 @@ trackedFiles: id: 3d683799f3f6 last_write_checksum: sha1:5809eec8a5a3ac96b49952f5345d606d50c0fef4 pristine_git_object: 4af2fa1e8e4e4e2c8eb2b3a0c83aa0a2efde22f4 + docs/components/bucketby.mdx: + id: f5edb4f2f5e3 + last_write_checksum: sha1:90e2cb7ab5750a1c61f15e2047960b4fc5a79534 + pristine_git_object: b5a655a71767a66313782ae46e2c834ccc1f67c9 docs/components/budgetaccountguardrailpolicy.mdx: id: f12fc1785329 last_write_checksum: sha1:4a1d120ed38f9df85ba862b69fd546c9264c98a5 @@ -1902,18 +1906,54 @@ trackedFiles: id: 34ac0e581d79 last_write_checksum: sha1:62ee9ccab6cec4572383cef654997ab4106d4676 pristine_git_object: ace8f22b972273bdee620a9981abcb0cc46d994e + docs/components/capacityguardrailpolicy.mdx: + id: 48e66403bef3 + last_write_checksum: sha1:4ad0754534f62865e53b256f0ef9cc2f63a64e29 + pristine_git_object: 0e0ac3421b9216392b4d1de5b590948ab46cd568 + docs/components/capacityguardrailpolicydetail.mdx: + id: 808bdbd3860a + last_write_checksum: sha1:536ebd586a88d3c39cf8401970be3caa3039f9a6 + pristine_git_object: 374f360227a67eefd3510cae254e5df7aa3d75d8 + docs/components/capacityguardrailpolicydetailpolicytype.mdx: + id: 14d6cc5ba772 + last_write_checksum: sha1:52ff86aebfae2a68d49c84f2c5842dcc40c1244d + pristine_git_object: eff9779251531ce82ee4d3968cde225b019297f2 + docs/components/capacityguardrailpolicydetailreference.mdx: + id: 496317ffee74 + last_write_checksum: sha1:b8402138f7ebabb71f2a7f27e01e5b87fc5c9477 + pristine_git_object: 27f84697cd2073fa83627c23c5bedcb803597c93 + docs/components/capacityguardrailpolicydetailresponse.mdx: + id: fa827636c77b + last_write_checksum: sha1:0663efd0a0b8caf0f0712f0fbf5e94670c241b96 + pristine_git_object: d105de59dc35573995e4a76c7c68ff443abb6757 + docs/components/capacityguardrailpolicypolicytype.mdx: + id: 6fb04db6b92e + last_write_checksum: sha1:431dfe92b3f747667d5600dcdd97c80ea15628c3 + pristine_git_object: 0b92714969fcdf597377b33bad8444879f4173c8 + docs/components/capacityguardrailpolicyresponse.mdx: + id: 3e27f144acab + last_write_checksum: sha1:aa387c9920ea8e9fad838ed5ea289a09d85d5bf4 + pristine_git_object: bb7630ad623cd104d57fcf3f4dae00e4e5659334 + docs/components/capacityguardrailpolicysummary.mdx: + id: c017434a1617 + last_write_checksum: sha1:d357bba76642de7a614214c235de86391b17b2ad + pristine_git_object: 4374b1e74dc29cfabef8f220e5f5a96fec4b12d8 + docs/components/capacityguardrailpolicysummarypolicytype.mdx: + id: 6f50b217ab08 + last_write_checksum: sha1:9d61ee7f3a8f3130807302b85fea7b8d27ca8357 + pristine_git_object: ebb54ef5c7d473a3dc8264737309482e4c780b88 docs/components/cascademode.mdx: id: e12579b7297c last_write_checksum: sha1:e6be79cba57b5631cfc4c5d5ece5a19a89ee5c07 pristine_git_object: f48cd9f2d8f491aa8a1f7027e44f92df2e24a30c docs/components/changeguardrailpolicyassignmentrequest.mdx: id: 35619bc1d436 - last_write_checksum: sha1:c6d8eddeafa30eb160014832ea85f9a389cf999a - pristine_git_object: d5058d1193ca1d089dcea91d7999a9f528cb2553 + last_write_checksum: sha1:3782992312685a35d4e5d23b032dab93f436ca43 + pristine_git_object: 311cc03b5f9076001fd0fccedbe56e5a04518bbe docs/components/changeguardrailpolicyassignmentrequestpolicytype.mdx: id: a42946d02f73 - last_write_checksum: sha1:2ce4a2ac9c210a76ac1df21d544d6ac992d1245e - pristine_git_object: 36dea9cb8af3b602371227ec04e4b39324ff5721 + last_write_checksum: sha1:eff11f696f947b2061505ca51c008482099aad0e + pristine_git_object: ec3da3764810af72d6a717435344f2b199ab6fdb docs/components/changeguardrailpolicyassignmentresponse.mdx: id: 6247bb0da7f3 last_write_checksum: sha1:8b01abf315c7d2ae600685862cda689c6410d8c8 @@ -2828,8 +2868,8 @@ trackedFiles: pristine_git_object: 63f7c7711d78d68cd27c258f391696266b406e52 docs/components/createbudgetguardrailpolicyrequest.mdx: id: de0b70ea9516 - last_write_checksum: sha1:e17d3cf2469850459ca87ae822308db524812c77 - pristine_git_object: c28957d766cbaa6f395805b8d961c61553d5772b + last_write_checksum: sha1:da10e5f42fe88f2be4dacebb8bdf2ef3ec39603a + pristine_git_object: 12c1786a8180b547e1778a0a04d8e24031d31c14 docs/components/createbudgetguardrailpolicyrequestpolicytype.mdx: id: 24911ea91f67 last_write_checksum: sha1:e36dfd48c97b8a20ce0b16cb542697bf489d61e5 @@ -2846,6 +2886,14 @@ trackedFiles: id: 73f247dc0e33 last_write_checksum: sha1:1dc1e5bf261b2530f231117a36ed1dace0910863 pristine_git_object: 07d71200222c22066ca9f8421c65ba883a53c75e + docs/components/createcapacityguardrailpolicyrequest.mdx: + id: 2d90d40fb6af + last_write_checksum: sha1:36cfb73b790d402cf6eff5d16464d0572ed90806 + pristine_git_object: 39b53eece946c537dc2df0a974c55a2c37462bb8 + docs/components/createcapacityguardrailpolicyrequestpolicytype.mdx: + id: 18c828e8caf2 + last_write_checksum: sha1:15864c889443f988ce08115750422bd75e13d9a5 + pristine_git_object: 0e35826a6a7b996ab920dd470c120b3b8a6dc448 docs/components/createexternaluserrequest.mdx: id: 10d107b37a9d last_write_checksum: sha1:63b57c9a55541e5ee9089220f70546c255d14f1c @@ -2860,16 +2908,16 @@ trackedFiles: pristine_git_object: 2501a2a5a0c6557094a66cb5b8f529fa5516e9e8 docs/components/createmodelavailabilityguardrailpolicyrequest.mdx: id: 4f756b818b48 - last_write_checksum: sha1:b96efef9c2f7fd7b84c88bb24dcb7e8407a8e981 - pristine_git_object: 0cb9d5f7b54afac3e1abed6ee565877babec88fb + last_write_checksum: sha1:8b65a8e54101fca4b45b1c254d6a7e39837ef8e4 + pristine_git_object: 72e186d33b745076bfb7b01fe751acd868921035 docs/components/createmodelavailabilityguardrailpolicyrequestpolicytype.mdx: id: ebf64ca3901b last_write_checksum: sha1:4ef123af623ab01b715274dcd9f129afbae76fb2 pristine_git_object: bd2d34bf9bdff620f0668862333a1afb81db98a5 docs/components/createmoderationguardrailpolicyrequest.mdx: id: ce01f7d82903 - last_write_checksum: sha1:3062f4d19ffd32d2f153e7ed857047ef00d965d4 - pristine_git_object: 3f83a4d848b5278734186def3bd7d9c8c0e1fa1c + last_write_checksum: sha1:7fe2641dac4a4d18542241f94b3237c8aeeced00 + pristine_git_object: 61f974e90c41730f42f09e9d221c59ed802d73a9 docs/components/createmoderationguardrailpolicyrequestpolicytype.mdx: id: 178698f14336 last_write_checksum: sha1:a6ced09bc3e134b5b9f6740099461a8c180edc06 @@ -4314,6 +4362,18 @@ trackedFiles: id: b9c0d87291e1 last_write_checksum: sha1:8ffe2b41db9daf3a45d10574fe102d78ae350e9e pristine_git_object: 53a7745e879e6610e80c0264617466bc06e9cf19 + docs/components/guardrailcapacitylimit.mdx: + id: 70f846cbd512 + last_write_checksum: sha1:25125786e0769400a674a43c0000db7f070bc4f8 + pristine_git_object: ee43d7b5edcbe28bd4b3bbc717cff3892c0a076e + docs/components/guardrailcapacitylimitunit.mdx: + id: 8113fe870b4e + last_write_checksum: sha1:89dac90c530fa328beca348409a0f63bcb0907c2 + pristine_git_object: 44b2dd0f5876272c0c82b2f972ce659801d7b4cd + docs/components/guardrailcapacitypolicyconfig.mdx: + id: 88523761486c + last_write_checksum: sha1:124b94a8a3189726315556007a6e02dee57fce2b + pristine_git_object: 05f33e5dc13f37426395e0a9e8c7f8d97cb1fd8c docs/components/guardraildataregion.mdx: id: d3be2a48aa20 last_write_checksum: sha1:81f1c0b515e1c1c13432cae9910ce77cb9991507 @@ -4990,6 +5050,10 @@ trackedFiles: id: be41921e1cce last_write_checksum: sha1:e135d933625d10b38e317f2695097f52d83a68ce pristine_git_object: e44710002075335f33eb63c1de9cf7f69b73f90d + docs/components/listcapacityguardrailpoliciesresponse.mdx: + id: 2b7d70f499a8 + last_write_checksum: sha1:5d7204fc0420ec3ca7d97589e2a566805f609714 + pristine_git_object: 3fd7b443d4bb054d16f1c923f589fba9065a1666 docs/components/listendpointsresponse.mdx: id: 1aeb90d09e63 last_write_checksum: sha1:e56418826927a03c674bcae841e99bdce1c6bba7 @@ -5978,6 +6042,10 @@ trackedFiles: id: 5a9393d9fc35 last_write_checksum: sha1:7acbd450ca042a47559761e9dff50c644014817b pristine_git_object: 34fbcd6a5b16ac942e515c00fa314bbb9db4d5c4 + docs/components/models.mdx: + id: 052f0dc2e3ac + last_write_checksum: sha1:e972c52f3ffea48c0b717bcec5674d7e775c409a + pristine_git_object: 75a480527deb7ae393623774c78cb39c53c886af docs/components/modelscountresponse.mdx: id: 74d50ecbad3f last_write_checksum: sha1:cc73eaa2f5a36c3e77a44dab530ea32df47f7dc2 @@ -5986,6 +6054,10 @@ trackedFiles: id: c0ff644852aa last_write_checksum: sha1:176dadedc04de9ca8a5607bc98e19e92bf6bd8a8 pristine_git_object: 52bceffe48675ef6541d938077ed1cf29951d246 + docs/components/modelsenum.mdx: + id: 557a9290cf05 + last_write_checksum: sha1:f070b51a0add95c347290d7cd24c261074a4c3ef + pristine_git_object: 7742af54717325df1b2688d638b1cc1e02ecd66c docs/components/modelslistresponse.mdx: id: 1880eae9f45e last_write_checksum: sha1:c946630ee68fbebb8cd3c72796883021f6106b4d @@ -9590,6 +9662,10 @@ trackedFiles: id: 9b4490c340b4 last_write_checksum: sha1:19167967157c0929a871d56d70d6291812a0fbe4 pristine_git_object: 97f998f8db004d2e7eec0ff5d54cb3c775e66163 + docs/components/updatecapacityguardrailpolicyrequest.mdx: + id: c0e15b48df86 + last_write_checksum: sha1:311088c6aa77486d72b802eefc577cee6ee64482 + pristine_git_object: 34058327f64bde91c25dca69407f95479c897a2b docs/components/updateexternaluserrequest.mdx: id: 3b80312f3719 last_write_checksum: sha1:2c9010b5358fd8ab666786d35133b4cc09ac9a9c @@ -10422,6 +10498,14 @@ trackedFiles: id: 091fcb472560 last_write_checksum: sha1:cda727485d33c21c140bbc060833d352cb369faa pristine_git_object: 488b8b57dcdb92e59281fe415e8015a616679970 + docs/operations/createcapacitypolicyglobals.mdx: + id: 3d531d833ba7 + last_write_checksum: sha1:6344ab159754ec5311dce1d48dab480da11f8011 + pristine_git_object: 1b61441ee55daae2d2d565797507a01d5e6b9c7c + docs/operations/createcapacitypolicyrequest.mdx: + id: 64271518d523 + last_write_checksum: sha1:4ef34a7fed7831125438acf8d2df2bcff656eb37 + pristine_git_object: 8949678782138a5bba9681118642f314bb70f636 docs/operations/createembeddingsdata.mdx: id: 1bb218f30173 last_write_checksum: sha1:d69468aca84eaf4d19f3a7ff3f9bfadeb58903e0 @@ -10702,6 +10786,14 @@ trackedFiles: id: 5f6e81896314 last_write_checksum: sha1:a9df7298f87df949d5c4d942f6149774f47d1c13 pristine_git_object: ec315ba23fe0a2132b4b813654a49fc11dfb51e1 + docs/operations/deletecapacitypolicyglobals.mdx: + id: d3db7ac60a24 + last_write_checksum: sha1:7fbf4f49fa8813c3465df92a94bf1502e49933d1 + pristine_git_object: 4de6a2f3295ef5d74b490140c4800f716bb3a6b7 + docs/operations/deletecapacitypolicyrequest.mdx: + id: 1406a145e9a0 + last_write_checksum: sha1:e8ae0e599503b84fac5b162eadb4fd42aa2c2df8 + pristine_git_object: cd90e7b1e7e812c53bf553abf9a5534a7b79e75c docs/operations/deleteexternaluserglobals.mdx: id: 21570552af46 last_write_checksum: sha1:a58cf02fcf7626771371c03afe4712add97392de @@ -10972,12 +11064,12 @@ trackedFiles: pristine_git_object: f121aa621a1f904558a33f1150b750a37a0bce23 docs/operations/getapikeypolicyassignmentpolicytype.mdx: id: 5df18d0bbbd6 - last_write_checksum: sha1:7ab2dc08e7c5bdf0187290e754086a8d9c926991 - pristine_git_object: aefef6cbce3c5817aa2d7358d9f27f52758ea1f9 + last_write_checksum: sha1:40c55d47c7776297d0b303d125a7b6b2b2e805fb + pristine_git_object: 4979477e2f46a4025dda57e0d0a34864d220220c docs/operations/getapikeypolicyassignmentrequest.mdx: id: 6c6b7de2c3e6 - last_write_checksum: sha1:27f5c082eb0dfe3a0123edc7b35d114a9d55a105 - pristine_git_object: 74e3988cdf4fff9486b8f5ac72dcf7dbc328c758 + last_write_checksum: sha1:047dea5ddc90755e72651263efd507b30c73a505 + pristine_git_object: 921be38a46f418848b63ded764740abbe58f6791 docs/operations/getapprankingscategory.mdx: id: f533cbc2f61c last_write_checksum: sha1:dddef3ed7370f63a996d8201282702598ba3823d @@ -11042,6 +11134,14 @@ trackedFiles: id: 13473d1c826b last_write_checksum: sha1:852abcfaa31a4955d59c25ea0fd5d85f08497442 pristine_git_object: 2f01f2af01e04abc5a5465c0470932266386821f + docs/operations/getcapacitypolicyglobals.mdx: + id: 681f2eae5274 + last_write_checksum: sha1:0fea1805be5f4d05251e6041cf1de0eb60384bd9 + pristine_git_object: 773d17775f72a9d10acabd9e9aff420ea8915d31 + docs/operations/getcapacitypolicyrequest.mdx: + id: 7fca258970c0 + last_write_checksum: sha1:76840cbad840e6d5b0889602ea26b2d92dfd5a34 + pristine_git_object: b8cf00fa4bccb11f847a58a2c7f780a442564654 docs/operations/getcontainerfileglobals.mdx: id: 168ff6e69a10 last_write_checksum: sha1:dcd3353d0630eda06018fb8e8748b5aa51e9182e @@ -11136,12 +11236,12 @@ trackedFiles: pristine_git_object: bbd9115cd5f46c61058f4677467de27a35fbe9de docs/operations/getmemberpolicyassignmentpolicytype.mdx: id: 78fec48fd5d2 - last_write_checksum: sha1:245e228c11bc7b6af01afe67814e7e8d38b9bb50 - pristine_git_object: 8f1249a1c51f3985c6500c61e7ad099b3e86740c + last_write_checksum: sha1:6cc4c9e72d46c0e7cd4c421bde500d7c28211d84 + pristine_git_object: ddd65e53928a73141204542b07ef48815c92068c docs/operations/getmemberpolicyassignmentrequest.mdx: id: cb85e9c92abf - last_write_checksum: sha1:1553e3441330fa4430420ba8a51a25c27b7a3a39 - pristine_git_object: 4d0d209249ae69b0259448abca5ab6322adc1c88 + last_write_checksum: sha1:dfc862eaab51f1e7b87ea0129e7d116aeb0a3b57 + pristine_git_object: 34f375d78d84eafda6d96d723d6df960d89ebe9c docs/operations/getmodelavailabilitypolicyglobals.mdx: id: f44e22466764 last_write_checksum: sha1:536f206e900238aecd1ac9b6b063df383b72091b @@ -11446,6 +11546,18 @@ trackedFiles: id: ad2f5a3c160a last_write_checksum: sha1:99b440d418cb1c93cbfe4671bfd7d94692802cd9 pristine_git_object: c11d4b3d54231b6756b63d85abd75a422f3b347c + docs/operations/listcapacitypoliciesglobals.mdx: + id: 7c059c12a537 + last_write_checksum: sha1:71b5d874dd44af6a88a5d02d9298d412eef123d1 + pristine_git_object: 3ac1059392efdddf11aefd580b17a3ed12ed442c + docs/operations/listcapacitypoliciesrequest.mdx: + id: 411474eb2729 + last_write_checksum: sha1:a8ca5c1e41b35305ad72dcc4595d706f238298c6 + pristine_git_object: 4fd2f34bfebe99dfe63746bd6668daff4f1343a7 + docs/operations/listcapacitypoliciesresponse.mdx: + id: fc71bc0d08cd + last_write_checksum: sha1:10b44e9adabda5ff7d3fa53904d2aa89bfc52e38 + pristine_git_object: 3e1028b89400fb5c1bb618d161e6d5891ddf7628 docs/operations/listcontainerfilesglobals.mdx: id: 89c4df41f2bf last_write_checksum: sha1:d6714a0c996af5623709842c989a8c277a8ddf3d @@ -12146,6 +12258,14 @@ trackedFiles: id: cef280b21ee9 last_write_checksum: sha1:657ec995c1c2d9e737603b8a5b59510ba965b12f pristine_git_object: b3dd3dfcbadbb529e4b37e75a21fb8bb4d7c0148 + docs/operations/updatecapacitypolicyglobals.mdx: + id: 4ca7b29fba52 + last_write_checksum: sha1:17fb57fca97200354b2d6eb506d590074116b145 + pristine_git_object: 5a879772bd132f2ec085e5d561076669fcb358b3 + docs/operations/updatecapacitypolicyrequest.mdx: + id: f0d4dafe321c + last_write_checksum: sha1:0d807987717854cb02b6b067d1e56262fa52d68f + pristine_git_object: 61b9cfcbd37d443b5b71810090f0be579276223c docs/operations/updateexternaluserglobals.mdx: id: e1b817957857 last_write_checksum: sha1:a2250edf2569a0cdd277017843446c38dc234cb8 @@ -12384,8 +12504,8 @@ trackedFiles: pristine_git_object: 7ec17f429d4a03eb91f993e592edd019caeeb451 docs/sdks/guardrailpolicies/README.mdx: id: 0e5ed6ce5965 - last_write_checksum: sha1:45e5052fc7960a1778e4403f0c9ac076d4ddb699 - pristine_git_object: fca09f04a84e31cf40b360e715c9175220334deb + last_write_checksum: sha1:1b84e58562930a8c90da470ca374e706a85a6aa6 + pristine_git_object: 0487a345570c6825ff5f920a6e81a3f6e8a20f8a docs/sdks/guardrails/README.mdx: id: a0cd4218b8fa last_write_checksum: sha1:d5af5863ad27cfa25e66f238d58c53422282e73a @@ -12416,8 +12536,8 @@ trackedFiles: pristine_git_object: 28c3e51a827054eb167e08eebd47ba6a3fd75f6b docs/sdks/privateendpoints/README.mdx: id: 54dee70b8cc7 - last_write_checksum: sha1:8e1c6bc572df0f70e1607ab337b0bee76c63ebb0 - pristine_git_object: 3339d338207481f2752f1dbd982d6aa64f8dabd1 + last_write_checksum: sha1:bbcf4de4e5a73ebef78861dc2721a4e1ca965d2e + pristine_git_object: a1d8564e1f4583f8c3fdc0ecb7774386f98c0f94 docs/sdks/privateproviders/README.mdx: id: 517c31195442 last_write_checksum: sha1:69cd8bc9ffad703ca458c861510c201be38f283b @@ -12472,8 +12592,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:7809c0e614e564bf08f764a22e02cc46507a9f4a - pristine_git_object: c40b713125364fa50fdf91309ffb10aab46ad607 + last_write_checksum: sha1:f6ec1eaf4638a648868304be75b4084c20e91da9 + pristine_git_object: 72dd1aad7bb8e082a43a6846269869092214e028 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -12500,8 +12620,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:ec83861ca75f26d55ed2661f879f54ebf5a76c32 - pristine_git_object: 7d7fcb4d1fa6846b8c496db0a181a09a239cda74 + last_write_checksum: sha1:6a722ecd4772c61f047b2dc43755a0c16c6c873c + pristine_git_object: 252f8c76491b13ab0bdb26d88bf29425cb7a7371 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -12548,8 +12668,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:d0d475a1ac834861dac6785e6d8fdeed1d32e196 - pristine_git_object: 7348dedb37fa6f42c3ceef7914e1f986e2362614 + last_write_checksum: sha1:82687a37fc3736db9ee6282abb24c0142f656c7f + pristine_git_object: 401fa9aba9cc9a5efaa7f5bb915ff9b103d65532 src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:08125e1d60df82793e11e8aed6e3c9fdb7512ebb @@ -13350,10 +13470,30 @@ trackedFiles: id: 368790a86f10 last_write_checksum: sha1:a167551924ee82b4b5876a0ab698a45fe8c87a95 pristine_git_object: a1cb577d9835d93914b06761e2cad3ceae2961e2 + src/openrouter/components/capacityguardrailpolicy.py: + id: a0a438eb6ff4 + last_write_checksum: sha1:b4b0e8d8d4279c350e4412fe5968214a9a03071d + pristine_git_object: 8b813687009197d28000224e30f157bf913edbbc + src/openrouter/components/capacityguardrailpolicydetail.py: + id: 18a59441758e + last_write_checksum: sha1:825fea0aeac135abd927d07520a1f209932b69b5 + pristine_git_object: d269ae08e786e917577101d3af73a6aad2f46e76 + src/openrouter/components/capacityguardrailpolicydetailresponse.py: + id: c1949bc9bbb8 + last_write_checksum: sha1:c08d401552bcbef3e9323b6bbc61060089abc59c + pristine_git_object: 6d15ac10f92791dcba1fcd2520bbcfbb381725fe + src/openrouter/components/capacityguardrailpolicyresponse.py: + id: b2dc1233d9b5 + last_write_checksum: sha1:cc948f75267274cb03ea3d642e61a8748eb836db + pristine_git_object: 6245797586a296e6c65d7467d8217ff34f8bcd3b + src/openrouter/components/capacityguardrailpolicysummary.py: + id: d1a7169c137d + last_write_checksum: sha1:d07860dbb765889088176af25e8759964ba67d60 + pristine_git_object: 9b1f2d0b07b4692d677f2d178acef2aa38d98845 src/openrouter/components/changeguardrailpolicyassignmentrequest.py: id: e74dfdf48a81 - last_write_checksum: sha1:e4b3cfaf5979165dbeca1ac89c4187e40ba2b5d0 - pristine_git_object: 7ecc46a115f59724762c33de2eed3a6bb5c6dba4 + last_write_checksum: sha1:a7a97fc3b29fe1d2edd0a531760f4485931db205 + pristine_git_object: 8d537f73912fe862f04f88450c7cbb4d7ee18e90 src/openrouter/components/changeguardrailpolicyassignmentresponse.py: id: 8ea6504bed9d last_write_checksum: sha1:5b15572ac8f586bf9a3e2c806f196edb02ded7a9 @@ -13748,8 +13888,8 @@ trackedFiles: pristine_git_object: 15b66bb18088bd61cccfa17e1cb5ef26c02abc84 src/openrouter/components/createbudgetguardrailpolicyrequest.py: id: 8fc88141b2b2 - last_write_checksum: sha1:a411f159e4a35b0adc03230975b49a59bf08dadf - pristine_git_object: 1baab50ee7abc3c8a00dbff58dfb84eaf639677b + last_write_checksum: sha1:6b78322e8dc44f0e16ee2c6e9c31cf70ac695b29 + pristine_git_object: d90a8561c4859e26eb86e39386d1651aaaf4cb59 src/openrouter/components/createbyokkeyrequest.py: id: 238e868445b4 last_write_checksum: sha1:06e736e3a4e979bc909e367133c71157cdd61e88 @@ -13758,6 +13898,10 @@ trackedFiles: id: 2b6c5e13270a last_write_checksum: sha1:a7a2a40b9ac16a975a4c5ecc8802fc0b7785691c pristine_git_object: fcfd9d646f216fdbb715cbbaefa4382d75750b79 + src/openrouter/components/createcapacityguardrailpolicyrequest.py: + id: b1885e7ca14b + last_write_checksum: sha1:9d5d180cc25c7261ab424674adeedfd8fc013da5 + pristine_git_object: c85918bd0652f52123c656ad59d11c7231a04697 src/openrouter/components/createexternaluserrequest.py: id: 34c26d8d246d last_write_checksum: sha1:5e1419d56df9bbb0003fa01bec9e19657f6ab1ae @@ -13772,12 +13916,12 @@ trackedFiles: pristine_git_object: d6c4a4dc73222668daddc2a1788d314ff30e8fe6 src/openrouter/components/createmodelavailabilityguardrailpolicyrequest.py: id: caedf451c860 - last_write_checksum: sha1:e35758408158d2acc093693fa98d61e7d3a45540 - pristine_git_object: 8a28539e0900a86d025156b4fcb95c607720e047 + last_write_checksum: sha1:ef16cceea7d271d8209ac9c76a9786e819a6146f + pristine_git_object: c309dbc8f05b033d9eebd0a612c0eff161dc6985 src/openrouter/components/createmoderationguardrailpolicyrequest.py: id: 6ceafafe2ebc - last_write_checksum: sha1:b624f706a0dd378f7437233a8b9889f1f65a70f7 - pristine_git_object: 5a1db586e1e6a97ccb298c62f116212ed852a611 + last_write_checksum: sha1:9a89f538c7294c232d92efd9f527834900965bea + pristine_git_object: 2aa88fa389ade4e6f1f7ee760dc38fbc0c2558e9 src/openrouter/components/createobservabilitydestinationrequest.py: id: 58587fb98a32 last_write_checksum: sha1:77c2f86b0f7afe33d0919d8fbb793bc6d1583dec @@ -14370,6 +14514,14 @@ trackedFiles: id: 13d0e65aeceb last_write_checksum: sha1:81e4bdaa79bfcf6738b53f0e86a03d0f39ae1780 pristine_git_object: d7904915e9f5ac069c2707f7102379dd8d06e10b + src/openrouter/components/guardrailcapacitylimit.py: + id: de5d2460313c + last_write_checksum: sha1:6a2352a7fd4deb10b1bf3fca19884664029d533f + pristine_git_object: 099d10914fbce92b58da1a15f00f8e3a2a51b768 + src/openrouter/components/guardrailcapacitypolicyconfig.py: + id: 1e512046b512 + last_write_checksum: sha1:a515693bda80584f63da346d2ecfcb16b2843147 + pristine_git_object: 4da8dfb2ddf74b6371ee67eec532083cc853a2fa src/openrouter/components/guardraildataregion.py: id: 16c31f1446b2 last_write_checksum: sha1:52b5622a7c93a30219108f033ab0e3fbb3a396f7 @@ -14614,6 +14766,10 @@ trackedFiles: id: d5f63cba5dd9 last_write_checksum: sha1:97cd54e94ba4996ebb43252ac31aa70511e0328c pristine_git_object: 3cbde84c8d3cc12e69b9788bd365dc39f9fa27b8 + src/openrouter/components/listcapacityguardrailpoliciesresponse.py: + id: 9eddc8ba0128 + last_write_checksum: sha1:f1187fe12715c439a7f6dd1ce4b594be460b7d1b + pristine_git_object: a7878f13623fdea4812ce0e89ea9803aa8feb4fa src/openrouter/components/listendpointsresponse.py: id: 7662d5774bdb last_write_checksum: sha1:8645389f8ca0cc28969d27c99c3ef6dd6a2fe3d3 @@ -16350,6 +16506,10 @@ trackedFiles: id: 31338080f7cc last_write_checksum: sha1:794d77355ae37451076a6b5754c6c8cc77063047 pristine_git_object: a3664695c9722c531f7694851da76e51c2efe4fb + src/openrouter/components/updatecapacityguardrailpolicyrequest.py: + id: ad7fa246ff8d + last_write_checksum: sha1:ee35b57e0da0030b5b8aacaf79f145b86a06debd + pristine_git_object: 423c3c4b2a1e94766e5eb8c53376e8bce2a19e1a src/openrouter/components/updateexternaluserrequest.py: id: 3ddaf4647482 last_write_checksum: sha1:2d9f0b3094152252c7c2699d84aa75ecc84ce974 @@ -16752,8 +16912,8 @@ trackedFiles: pristine_git_object: 67c135fcabfa563a3f7e2721d2618041ef8d7650 src/openrouter/guardrail_policies.py: id: 0505548eb66e - last_write_checksum: sha1:2544613139808e80185fff69bca4abd3226869a4 - pristine_git_object: 5d25f0c1dedebc98eae66eef48c63dbf5d6c5f02 + last_write_checksum: sha1:16f5f8055ac33690f85d15ada1ca2b3619c39bc7 + pristine_git_object: 724c517913837ea635fe2c33d68c00a4e371e14e src/openrouter/guardrails.py: id: 705839f34e66 last_write_checksum: sha1:69bf7403b0ab33a52b621377a3ee404f47f8983b @@ -16792,8 +16952,8 @@ trackedFiles: pristine_git_object: 039fd484b407d7ca13177a892db5939b312ee50d src/openrouter/operations/__init__.py: id: 9afcea1e7161 - last_write_checksum: sha1:bed4eec66a59879888122e7b05e14d231f884c9d - pristine_git_object: 22931c7a8c02d333b5c02a0e982a1d25a61b79a0 + last_write_checksum: sha1:7780af065ff8f0fc52018dc81bcb83553160d107 + pristine_git_object: 21c6927612a5e604142ebf48e9cdc77f250e82f4 src/openrouter/operations/activateprivateendpoint.py: id: 3b39eec5d66f last_write_checksum: sha1:9406e6b3d38c82895fd795f637702ef579cc6d36 @@ -16878,6 +17038,10 @@ trackedFiles: id: eaeefa9fe0c2 last_write_checksum: sha1:7e371b512bf4d80820881e0dc1868cb0861ae2ac pristine_git_object: d96c756e911994eaf6ef695a059f7575d69ff63c + src/openrouter/operations/createcapacitypolicy.py: + id: 9028e232d5b3 + last_write_checksum: sha1:008719425f10fc7af01b07bc80ff57f875b6c0b2 + pristine_git_object: c34b9ff0ce3f9eb993bc7b99bd3a5bbfc24296f6 src/openrouter/operations/createembeddings.py: id: fe1160a960e9 last_write_checksum: sha1:5d214462d03b94720ed4243cb0ee0b966a8e529a @@ -16982,6 +17146,10 @@ trackedFiles: id: b1b2c6b06913 last_write_checksum: sha1:90aad5198d43e289d99c7b2eb66353de7593a68b pristine_git_object: 2148ca98c6cde1506783e9c5f2f522226a27e428 + src/openrouter/operations/deletecapacitypolicy.py: + id: 316599a21bc8 + last_write_checksum: sha1:edf41d9774f65f19d61613c43eac2cf7c7c1d09e + pristine_git_object: d636f4aedf00c3dd0cb7f188812c8201fa2a0ce4 src/openrouter/operations/deleteexternaluser.py: id: 0e2de6c39fa4 last_write_checksum: sha1:c7907541db7db37772636d634903429796cf9922 @@ -17076,8 +17244,8 @@ trackedFiles: pristine_git_object: d4b717427347a5183eff59d470945a183af4607d src/openrouter/operations/getapikeypolicyassignment.py: id: ad6711113aec - last_write_checksum: sha1:18d9215c0b3894dd1af2fd99e331b9854daad40b - pristine_git_object: b4e7379c156acc0e04c84a38180d9b8467f43653 + last_write_checksum: sha1:01d1605805b874db8de6fee274ba412b7a9faf5e + pristine_git_object: a256ffb16acb0a68c5de0098b17888d5ad39867b src/openrouter/operations/getapprankings.py: id: 5ffd23dafcc1 last_write_checksum: sha1:ab86de57d9c8502a130a61f4405f3ca40c2ff5dc @@ -17102,6 +17270,10 @@ trackedFiles: id: d141452bd88a last_write_checksum: sha1:d6d391b230d90f51945144e63e9c53772650bd7b pristine_git_object: 6021faa4de45bfaf200eca955b62f4b5b3113804 + src/openrouter/operations/getcapacitypolicy.py: + id: 7e24106da91a + last_write_checksum: sha1:e241cd09097552a0ac762b02bcff654b1dd5105d + pristine_git_object: 98ab5f3709d17f1c86e022eb15526aaf92e3050a src/openrouter/operations/getcontainerfile.py: id: 7b8249f30861 last_write_checksum: sha1:d0993761976ab52e86456926d0823e7a9585af5a @@ -17136,8 +17308,8 @@ trackedFiles: pristine_git_object: 25127de14ec0e01f24d9d54523eda65316a8bd3f src/openrouter/operations/getmemberpolicyassignment.py: id: d2e2fd55dd30 - last_write_checksum: sha1:b706e4bba9ac879ae043d488dd5e83f095bf752f - pristine_git_object: babf428c57a2435e388cc104cab671616218b03f + last_write_checksum: sha1:109328270cc3d7f1a4bf2943e20d080a841f1343 + pristine_git_object: 87d40abdc22166cf03b0eea131b090c988ef5c96 src/openrouter/operations/getmodel.py: id: 90c926cd726f last_write_checksum: sha1:3ba2f12410841c49e329821b8eaec5f87d5882c1 @@ -17250,6 +17422,10 @@ trackedFiles: id: b6dd42b3e05f last_write_checksum: sha1:5b606099ff376da8a4fd7df988952a90722a9afc pristine_git_object: 3600afdfc2542a3d084abaa6e8d56f155c3f776b + src/openrouter/operations/listcapacitypolicies.py: + id: ff7e675a1b45 + last_write_checksum: sha1:2dfb44d7a5f5d1a27cecf445a64e35511466e173 + pristine_git_object: 580725312119585d9a6c065524db326e8aee05b2 src/openrouter/operations/listcontainerfiles.py: id: 7a30b9291c76 last_write_checksum: sha1:937c9fb30fd651d28793340285b3389518b26d96 @@ -17466,6 +17642,10 @@ trackedFiles: id: 486f4ea60120 last_write_checksum: sha1:a170382e38c66128bddbe8ea18c034d1350910da pristine_git_object: cf8b4ee9febb198afe12c27d03c72902eaa8baf0 + src/openrouter/operations/updatecapacitypolicy.py: + id: b84b6fea7f33 + last_write_checksum: sha1:0c535fe0c0c5c8b85fe030d75121cce460204d89 + pristine_git_object: e940ef3ca0b8a76b36d9eee813e0fdeeb6cc7350 src/openrouter/operations/updateexternaluser.py: id: 270d32c666fe last_write_checksum: sha1:483493cef9d48056eec2cb48774aacfdeaedad14 @@ -17536,8 +17716,8 @@ trackedFiles: pristine_git_object: 936058d4adcb7ce049c186bd93a938d7891e1b33 src/openrouter/private_endpoints.py: id: fdbce8846ed0 - last_write_checksum: sha1:211afe95c4b8e737cbb21aa90dff11da6c19791e - pristine_git_object: b5d5df05023b750805222076a4147ebf1e7b5539 + last_write_checksum: sha1:0ad55d4b0bef25a353596e08c70b8e4127f31be2 + pristine_git_object: 6661a4158330cd3ad63c538b1bbe19613a95ca0c src/openrouter/private_providers.py: id: d2b888527155 last_write_checksum: sha1:73483e415ea971a08d9d76b2ed55dc164ae3953a @@ -23031,11 +23211,115 @@ 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: | ## Python SDK Changes: - * `open_router.guardrail_policies.list_scim_group_policy_assignments()`: **Added** - * `open_router.guardrail_policies.get_scim_group_policy_assignment()`: **Added** - * `open_router.guardrail_policies.update_scim_group_policy_assignment()`: **Added** - * `open_router.guardrail_policies.delete_scim_group_policy_opt_out()`: **Added** - * `open_router.guardrail_policies.list_scim_group_policy_opt_outs()`: **Added** + * `open_router.guardrail_policies.list_capacity_policies()`: **Added** + * `open_router.guardrail_policies.create_capacity_policy()`: **Added** + * `open_router.guardrail_policies.delete_capacity_policy()`: **Added** + * `open_router.guardrail_policies.get_capacity_policy()`: **Added** + * `open_router.guardrail_policies.update_capacity_policy()`: **Added** + * `open_router.guardrail_policies.create_budget_policy()`: `request.move_existing_assignments` **Added** + * `open_router.guardrail_policies.create_model_availability_policy()`: `request.move_existing_assignments` **Added** + * `open_router.guardrail_policies.create_moderation_policy()`: `request.move_existing_assignments` **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index b6456a599..788c8f3ba 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.234 + version: 1.3.235 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index c77dca590..15e6dc5b8 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -7768,6 +7768,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: @@ -7784,7 +7964,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' @@ -10731,6 +10911,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' @@ -10894,6 +11077,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: @@ -11240,6 +11490,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' @@ -11303,6 +11556,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' @@ -16624,6 +16880,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: @@ -19195,6 +19526,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: @@ -39442,6 +39788,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: @@ -51736,36 +52141,670 @@ paths: schema: $ref: '#/components/schemas/InternalServerResponse' description: 'Internal Server Error - Unexpected server error' - summary: 'Delete a workspace-wide policy' + 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' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /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: + - in: 'path' + name: 'mapping_id' + required: true + schema: + format: 'uuid' + type: 'string' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ScimGroupPolicyAssignmentResponse' + description: 'Policy assignment for the 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: '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: @@ -51826,49 +52865,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: @@ -51876,8 +52906,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: @@ -51918,6 +52948,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: @@ -51928,36 +52968,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: @@ -52018,28 +53048,38 @@ 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' + nullable: false + - 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' @@ -52049,27 +53089,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: @@ -52120,36 +53146,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: @@ -52210,25 +53237,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: @@ -52289,22 +53335,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: @@ -52312,8 +53366,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: @@ -52354,16 +53408,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: @@ -52374,215 +53418,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: @@ -52643,17 +53508,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' @@ -52675,12 +53541,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' @@ -52689,8 +53555,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: @@ -52741,10 +53607,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' @@ -52757,21 +53623,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: @@ -52832,18 +53698,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' @@ -52854,12 +53720,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' @@ -52869,7 +53735,7 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteGuardrailPolicyResponse' - description: 'budget policy deleted' + description: 'capacity policy deleted' '400': content: application/json: @@ -52930,13 +53796,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' @@ -52947,12 +53813,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' @@ -52961,8 +53827,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: @@ -53013,13 +53879,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' @@ -53034,15 +53900,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: @@ -53103,10 +53969,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" @@ -59820,7 +60686,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.' @@ -60617,7 +61483,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 216167230..a80331c3e 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.803.2 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:2a127dbf4ae3f98225ab580e0e1d8af2dd08ee19886e1b577db5efc54b47caca - sourceBlobDigest: sha256:28244438bfe9cce279f0c869625a6d06f59c5889302295ed55dabaa85b75cf8c + sourceRevisionDigest: sha256:27980a2a560cd7d7ff31ac770e0896a5e2199558f5595e90f749e172ca2a7f24 + sourceBlobDigest: sha256:59a70cb8e30bc137782ec2896df25d087380763dce232be639bb0b8355670b62 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:2a127dbf4ae3f98225ab580e0e1d8af2dd08ee19886e1b577db5efc54b47caca - sourceBlobDigest: sha256:28244438bfe9cce279f0c869625a6d06f59c5889302295ed55dabaa85b75cf8c + sourceRevisionDigest: sha256:27980a2a560cd7d7ff31ac770e0896a5e2199558f5595e90f749e172ca2a7f24 + sourceBlobDigest: sha256:59a70cb8e30bc137782ec2896df25d087380763dce232be639bb0b8355670b62 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:98ca949c625855362450336fe93267d9ed4b17c4d33627f2e4e53e13b40ad21b + codeSamplesRevisionDigest: sha256:7a7fa831b9ebc6f5036fe681a5a842f506d8da85f64ee9bd0bbe956a4823c634 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index c0a591a86..4e5d7bb59 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5109,4 +5109,14 @@ Based on: ### Generated - [python v1.3.234] . ### Releases -- [PyPI v1.3.234] https://pypi.org/project/openrouter/1.3.234 - . \ No newline at end of file +- [PyPI v1.3.234] https://pypi.org/project/openrouter/1.3.234 - . + +## 2026-12-03 05:25:29 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.235] . +### Releases +- [PyPI v1.3.235] https://pypi.org/project/openrouter/1.3.235 - . \ No newline at end of file diff --git a/docs/components/bucketby.mdx b/docs/components/bucketby.mdx new file mode 100644 index 000000000..b5a655a71 --- /dev/null +++ b/docs/components/bucketby.mdx @@ -0,0 +1,22 @@ +--- +title: "BucketBy" +--- + +## Example Usage + +```python +from openrouter.components import BucketBy + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: BucketBy = "workspace" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"workspace"` +- `"member"` +- `"api_key"` +- `"model"` diff --git a/docs/components/capacityguardrailpolicy.mdx b/docs/components/capacityguardrailpolicy.mdx new file mode 100644 index 000000000..0e0ac3421 --- /dev/null +++ b/docs/components/capacityguardrailpolicy.mdx @@ -0,0 +1,12 @@ +--- +title: "CapacityGuardrailPolicy" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `config` | [components.GuardrailCapacityPolicyConfig](../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `policy_type` | [components.CapacityGuardrailPolicyPolicyType](../components/capacityguardrailpolicypolicytype.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/components/capacityguardrailpolicydetail.mdx b/docs/components/capacityguardrailpolicydetail.mdx new file mode 100644 index 000000000..374f36022 --- /dev/null +++ b/docs/components/capacityguardrailpolicydetail.mdx @@ -0,0 +1,21 @@ +--- +title: "CapacityGuardrailPolicyDetail" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `api_key_hashes` | List[*str*] | ✔️ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [components.GuardrailCapacityPolicyConfig](../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `is_workspace_default` | *Optional[bool]* | ➖ | N/A | | +| `member_ids` | List[*str*] | ✔️ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `opted_out_api_key_hashes` | List[*str*] | ✔️ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `opted_out_member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `overridden_api_key_hashes` | List[*str*] | ✔️ | API keys that have a different policy of this type assigned directly | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `overridden_member_ids` | List[*str*] | ➖ | Members that have a different policy of this type assigned directly | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `policy_type` | [components.CapacityGuardrailPolicyDetailPolicyType](../components/capacityguardrailpolicydetailpolicytype.mdx) | ✔️ | N/A | | +| `reference` | [OptionalNullable[components.CapacityGuardrailPolicyDetailReference]](../components/capacityguardrailpolicydetailreference.mdx) | ➖ | `legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null` | | +| `updated_at` | *Nullable[str]* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/components/capacityguardrailpolicydetailpolicytype.mdx b/docs/components/capacityguardrailpolicydetailpolicytype.mdx new file mode 100644 index 000000000..eff977925 --- /dev/null +++ b/docs/components/capacityguardrailpolicydetailpolicytype.mdx @@ -0,0 +1,15 @@ +--- +title: "CapacityGuardrailPolicyDetailPolicyType" +--- + +## Example Usage + +```python +from openrouter.components import CapacityGuardrailPolicyDetailPolicyType +value: CapacityGuardrailPolicyDetailPolicyType = "rate_limit" +``` + + +## Values + +- `"rate_limit"` diff --git a/docs/components/capacityguardrailpolicydetailreference.mdx b/docs/components/capacityguardrailpolicydetailreference.mdx new file mode 100644 index 000000000..27f84697c --- /dev/null +++ b/docs/components/capacityguardrailpolicydetailreference.mdx @@ -0,0 +1,22 @@ +--- +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 + +```python +from openrouter.components import CapacityGuardrailPolicyDetailReference + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: CapacityGuardrailPolicyDetailReference = "legacy_mapping" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"legacy_mapping"` +- `"account_default"` diff --git a/docs/components/capacityguardrailpolicydetailresponse.mdx b/docs/components/capacityguardrailpolicydetailresponse.mdx new file mode 100644 index 000000000..d105de59d --- /dev/null +++ b/docs/components/capacityguardrailpolicydetailresponse.mdx @@ -0,0 +1,9 @@ +--- +title: "CapacityGuardrailPolicyDetailResponse" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `data` | [components.CapacityGuardrailPolicyDetail](../components/capacityguardrailpolicydetail.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/components/capacityguardrailpolicypolicytype.mdx b/docs/components/capacityguardrailpolicypolicytype.mdx new file mode 100644 index 000000000..0b9271496 --- /dev/null +++ b/docs/components/capacityguardrailpolicypolicytype.mdx @@ -0,0 +1,15 @@ +--- +title: "CapacityGuardrailPolicyPolicyType" +--- + +## Example Usage + +```python +from openrouter.components import CapacityGuardrailPolicyPolicyType +value: CapacityGuardrailPolicyPolicyType = "rate_limit" +``` + + +## Values + +- `"rate_limit"` diff --git a/docs/components/capacityguardrailpolicyresponse.mdx b/docs/components/capacityguardrailpolicyresponse.mdx new file mode 100644 index 000000000..bb7630ad6 --- /dev/null +++ b/docs/components/capacityguardrailpolicyresponse.mdx @@ -0,0 +1,9 @@ +--- +title: "CapacityGuardrailPolicyResponse" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `data` | [components.CapacityGuardrailPolicy](../components/capacityguardrailpolicy.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/components/capacityguardrailpolicysummary.mdx b/docs/components/capacityguardrailpolicysummary.mdx new file mode 100644 index 000000000..4374b1e74 --- /dev/null +++ b/docs/components/capacityguardrailpolicysummary.mdx @@ -0,0 +1,16 @@ +--- +title: "CapacityGuardrailPolicySummary" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `api_key_count` | *int* | ✔️ | N/A | | +| `config` | [components.GuardrailCapacityPolicyConfig](../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `is_workspace_default` | *Optional[bool]* | ➖ | N/A | | +| `member_count` | *int* | ✔️ | N/A | | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `policy_type` | [components.CapacityGuardrailPolicySummaryPolicyType](../components/capacityguardrailpolicysummarypolicytype.mdx) | ✔️ | N/A | | +| `updated_at` | *Nullable[str]* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/components/capacityguardrailpolicysummarypolicytype.mdx b/docs/components/capacityguardrailpolicysummarypolicytype.mdx new file mode 100644 index 000000000..ebb54ef5c --- /dev/null +++ b/docs/components/capacityguardrailpolicysummarypolicytype.mdx @@ -0,0 +1,15 @@ +--- +title: "CapacityGuardrailPolicySummaryPolicyType" +--- + +## Example Usage + +```python +from openrouter.components import CapacityGuardrailPolicySummaryPolicyType +value: CapacityGuardrailPolicySummaryPolicyType = "rate_limit" +``` + + +## Values + +- `"rate_limit"` diff --git a/docs/components/changeguardrailpolicyassignmentrequest.mdx b/docs/components/changeguardrailpolicyassignmentrequest.mdx index d5058d119..311cc03b5 100644 --- a/docs/components/changeguardrailpolicyassignmentrequest.mdx +++ b/docs/components/changeguardrailpolicyassignmentrequest.mdx @@ -4,10 +4,10 @@ title: "ChangeGuardrailPolicyAssignmentRequest" ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | -| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | -| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | -| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../components/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `workspace_id` | *Optional[str]* | ➖ | 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` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | +| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | +| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../components/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 | +| `workspace_id` | *Optional[str]* | ➖ | 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/components/changeguardrailpolicyassignmentrequestpolicytype.mdx b/docs/components/changeguardrailpolicyassignmentrequestpolicytype.mdx index 36dea9cb8..ec3da3764 100644 --- a/docs/components/changeguardrailpolicyassignmentrequestpolicytype.mdx +++ b/docs/components/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/components/createbudgetguardrailpolicyrequest.mdx b/docs/components/createbudgetguardrailpolicyrequest.mdx index c28957d76..12c1786a8 100644 --- a/docs/components/createbudgetguardrailpolicyrequest.mdx +++ b/docs/components/createbudgetguardrailpolicyrequest.mdx @@ -10,6 +10,7 @@ title: "CreateBudgetGuardrailPolicyRequest" | `config` | [components.GuardrailBudgetPolicyAuthoringConfig](../components/guardrailbudgetpolicyauthoringconfig.mdx) | ✔️ | N/A | \{
"include_byok_in_budgets": false,
"limit_usd": 200,
"reset_interval": "monthly"
} | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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` | *str* | ✔️ | Policy name | Engineering monthly budget | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/components/createcapacityguardrailpolicyrequest.mdx b/docs/components/createcapacityguardrailpolicyrequest.mdx new file mode 100644 index 000000000..39b53eece --- /dev/null +++ b/docs/components/createcapacityguardrailpolicyrequest.mdx @@ -0,0 +1,18 @@ +--- +title: "CreateCapacityGuardrailPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [components.GuardrailCapacityPolicyConfig](../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | +| `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `policy_type` | [components.CreateCapacityGuardrailPolicyRequestPolicyType](../components/createcapacityguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | | +| `workspace_id` | *str* | ✔️ | 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/components/createcapacityguardrailpolicyrequestpolicytype.mdx b/docs/components/createcapacityguardrailpolicyrequestpolicytype.mdx new file mode 100644 index 000000000..0e35826a6 --- /dev/null +++ b/docs/components/createcapacityguardrailpolicyrequestpolicytype.mdx @@ -0,0 +1,15 @@ +--- +title: "CreateCapacityGuardrailPolicyRequestPolicyType" +--- + +## Example Usage + +```python +from openrouter.components import CreateCapacityGuardrailPolicyRequestPolicyType +value: CreateCapacityGuardrailPolicyRequestPolicyType = "rate_limit" +``` + + +## Values + +- `"rate_limit"` diff --git a/docs/components/createmodelavailabilityguardrailpolicyrequest.mdx b/docs/components/createmodelavailabilityguardrailpolicyrequest.mdx index 0cb9d5f7b..72e186d33 100644 --- a/docs/components/createmodelavailabilityguardrailpolicyrequest.mdx +++ b/docs/components/createmodelavailabilityguardrailpolicyrequest.mdx @@ -10,6 +10,7 @@ title: "CreateModelAvailabilityGuardrailPolicyRequest" | `config` | [components.GuardrailModelAvailabilityPolicyAuthoringConfig](../components/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
} | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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` | *str* | ✔️ | Policy name | Engineering monthly budget | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/components/createmoderationguardrailpolicyrequest.mdx b/docs/components/createmoderationguardrailpolicyrequest.mdx index 3f83a4d84..61f974e90 100644 --- a/docs/components/createmoderationguardrailpolicyrequest.mdx +++ b/docs/components/createmoderationguardrailpolicyrequest.mdx @@ -10,6 +10,7 @@ title: "CreateModerationGuardrailPolicyRequest" | `config` | [components.GuardrailModerationPolicyConfig](../components/guardrailmoderationpolicyconfig.mdx) | ✔️ | N/A | \{
"content_filter_builtins": [
\{
"action": "block",
"slug": "secrets"
}
]
} | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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` | *str* | ✔️ | Policy name | Engineering monthly budget | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | diff --git a/docs/components/guardrailcapacitylimit.mdx b/docs/components/guardrailcapacitylimit.mdx new file mode 100644 index 000000000..ee43d7b5e --- /dev/null +++ b/docs/components/guardrailcapacitylimit.mdx @@ -0,0 +1,11 @@ +--- +title: "GuardrailCapacityLimit" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `limit` | *int* | ✔️ | Bucket capacity and per-minute refill rate. | 100000 | +| `models` | [components.Models](../components/models.mdx) | ✔️ | Either `"all"` to cover every model or a non-empty list of exact model slugs. | all | +| `unit` | [components.GuardrailCapacityLimitUnit](../components/guardrailcapacitylimitunit.mdx) | ✔️ | Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). | tokens | \ No newline at end of file diff --git a/docs/components/guardrailcapacitylimitunit.mdx b/docs/components/guardrailcapacitylimitunit.mdx new file mode 100644 index 000000000..44b2dd0f5 --- /dev/null +++ b/docs/components/guardrailcapacitylimitunit.mdx @@ -0,0 +1,22 @@ +--- +title: "GuardrailCapacityLimitUnit" +--- + +Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`). + +## Example Usage + +```python +from openrouter.components import GuardrailCapacityLimitUnit + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: GuardrailCapacityLimitUnit = "tokens" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"tokens"` +- `"requests"` diff --git a/docs/components/guardrailcapacitypolicyconfig.mdx b/docs/components/guardrailcapacitypolicyconfig.mdx new file mode 100644 index 000000000..05f33e5dc --- /dev/null +++ b/docs/components/guardrailcapacitypolicyconfig.mdx @@ -0,0 +1,10 @@ +--- +title: "GuardrailCapacityPolicyConfig" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `bucket_by` | List[[components.BucketBy](../components/bucketby.mdx)] | ✔️ | Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`. | [
"member",
"model"
] | +| `limits` | List[[components.GuardrailCapacityLimit](../components/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/components/listcapacityguardrailpoliciesresponse.mdx b/docs/components/listcapacityguardrailpoliciesresponse.mdx new file mode 100644 index 000000000..3fd7b443d --- /dev/null +++ b/docs/components/listcapacityguardrailpoliciesresponse.mdx @@ -0,0 +1,10 @@ +--- +title: "ListCapacityGuardrailPoliciesResponse" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `data` | List[[components.CapacityGuardrailPolicySummary](../components/capacityguardrailpolicysummary.mdx)] | ✔️ | N/A | | +| `total_count` | *int* | ✔️ | Total number of policies | 1 | \ No newline at end of file diff --git a/docs/components/models.mdx b/docs/components/models.mdx new file mode 100644 index 000000000..75a480527 --- /dev/null +++ b/docs/components/models.mdx @@ -0,0 +1,21 @@ +--- +title: "Models" +--- + +Either `"all"` to cover every model or a non-empty list of exact model slugs. + + +## Supported Types + +### `components.ModelsEnum` + +```python +value: components.ModelsEnum = /* values here */ +``` + +### `List[str]` + +```python +value: List[str] = /* values here */ +``` + diff --git a/docs/components/modelsenum.mdx b/docs/components/modelsenum.mdx new file mode 100644 index 000000000..7742af547 --- /dev/null +++ b/docs/components/modelsenum.mdx @@ -0,0 +1,17 @@ +--- +title: "ModelsEnum" +--- + +Apply this limit to every model. + +## Example Usage + +```python +from openrouter.components import ModelsEnum +value: ModelsEnum = "all" +``` + + +## Values + +- `"all"` diff --git a/docs/components/updatecapacityguardrailpolicyrequest.mdx b/docs/components/updatecapacityguardrailpolicyrequest.mdx new file mode 100644 index 000000000..34058327f --- /dev/null +++ b/docs/components/updatecapacityguardrailpolicyrequest.mdx @@ -0,0 +1,16 @@ +--- +title: "UpdateCapacityGuardrailPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | +| `api_key_hashes` | List[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `config` | [components.GuardrailCapacityPolicyConfig](../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `is_workspace_default` | *Optional[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | | +| `member_ids` | List[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `opted_out_api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `opted_out_member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `workspace_id` | *str* | ✔️ | 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/operations/createcapacitypolicyglobals.mdx b/docs/operations/createcapacitypolicyglobals.mdx new file mode 100644 index 000000000..1b61441ee --- /dev/null +++ b/docs/operations/createcapacitypolicyglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "CreateCapacityPolicyGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | 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/operations/createcapacitypolicyrequest.mdx b/docs/operations/createcapacitypolicyrequest.mdx new file mode 100644 index 000000000..894967878 --- /dev/null +++ b/docs/operations/createcapacitypolicyrequest.mdx @@ -0,0 +1,12 @@ +--- +title: "CreateCapacityPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| +| `create_capacity_guardrail_policy_request` | [components.CreateCapacityGuardrailPolicyRequest](../components/createcapacityguardrailpolicyrequest.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/operations/deletecapacitypolicyglobals.mdx b/docs/operations/deletecapacitypolicyglobals.mdx new file mode 100644 index 000000000..4de6a2f32 --- /dev/null +++ b/docs/operations/deletecapacitypolicyglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "DeleteCapacityPolicyGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | 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/operations/deletecapacitypolicyrequest.mdx b/docs/operations/deletecapacitypolicyrequest.mdx new file mode 100644 index 000000000..cd90e7b1e --- /dev/null +++ b/docs/operations/deletecapacitypolicyrequest.mdx @@ -0,0 +1,13 @@ +--- +title: "DeleteCapacityPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspace_id` | *str* | ✔️ | 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/operations/getapikeypolicyassignmentpolicytype.mdx b/docs/operations/getapikeypolicyassignmentpolicytype.mdx index aefef6cbc..4979477e2 100644 --- a/docs/operations/getapikeypolicyassignmentpolicytype.mdx +++ b/docs/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/operations/getapikeypolicyassignmentrequest.mdx b/docs/operations/getapikeypolicyassignmentrequest.mdx index 74e3988cd..921be38a4 100644 --- a/docs/operations/getapikeypolicyassignmentrequest.mdx +++ b/docs/operations/getapikeypolicyassignmentrequest.mdx @@ -4,11 +4,11 @@ title: "GetAPIKeyPolicyAssignmentRequest" ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `policy_type` | [operations.GetAPIKeyPolicyAssignmentPolicyType](../operations/getapikeypolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `policy_type` | [operations.GetAPIKeyPolicyAssignmentPolicyType](../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/operations/getcapacitypolicyglobals.mdx b/docs/operations/getcapacitypolicyglobals.mdx new file mode 100644 index 000000000..773d17775 --- /dev/null +++ b/docs/operations/getcapacitypolicyglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "GetCapacityPolicyGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | 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/operations/getcapacitypolicyrequest.mdx b/docs/operations/getcapacitypolicyrequest.mdx new file mode 100644 index 000000000..b8cf00fa4 --- /dev/null +++ b/docs/operations/getcapacitypolicyrequest.mdx @@ -0,0 +1,13 @@ +--- +title: "GetCapacityPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspace_id` | *str* | ✔️ | 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/operations/getmemberpolicyassignmentpolicytype.mdx b/docs/operations/getmemberpolicyassignmentpolicytype.mdx index 8f1249a1c..ddd65e539 100644 --- a/docs/operations/getmemberpolicyassignmentpolicytype.mdx +++ b/docs/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/operations/getmemberpolicyassignmentrequest.mdx b/docs/operations/getmemberpolicyassignmentrequest.mdx index 4d0d20924..34f375d78 100644 --- a/docs/operations/getmemberpolicyassignmentrequest.mdx +++ b/docs/operations/getmemberpolicyassignmentrequest.mdx @@ -4,11 +4,11 @@ title: "GetMemberPolicyAssignmentRequest" ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `policy_type` | [operations.GetMemberPolicyAssignmentPolicyType](../operations/getmemberpolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `policy_type` | [operations.GetMemberPolicyAssignmentPolicyType](../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/operations/listcapacitypoliciesglobals.mdx b/docs/operations/listcapacitypoliciesglobals.mdx new file mode 100644 index 000000000..3ac105939 --- /dev/null +++ b/docs/operations/listcapacitypoliciesglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "ListCapacityPoliciesGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | 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/operations/listcapacitypoliciesrequest.mdx b/docs/operations/listcapacitypoliciesrequest.mdx new file mode 100644 index 000000000..4fd2f34bf --- /dev/null +++ b/docs/operations/listcapacitypoliciesrequest.mdx @@ -0,0 +1,14 @@ +--- +title: "ListCapacityPoliciesRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *Optional[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 | +| `workspace_id` | *str* | ✔️ | 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/operations/listcapacitypoliciesresponse.mdx b/docs/operations/listcapacitypoliciesresponse.mdx new file mode 100644 index 000000000..3e1028b89 --- /dev/null +++ b/docs/operations/listcapacitypoliciesresponse.mdx @@ -0,0 +1,9 @@ +--- +title: "ListCapacityPoliciesResponse" +--- + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| `result` | [components.ListCapacityGuardrailPoliciesResponse](../components/listcapacityguardrailpoliciesresponse.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/operations/updatecapacitypolicyglobals.mdx b/docs/operations/updatecapacitypolicyglobals.mdx new file mode 100644 index 000000000..5a879772b --- /dev/null +++ b/docs/operations/updatecapacitypolicyglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "UpdateCapacityPolicyGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | 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/operations/updatecapacitypolicyrequest.mdx b/docs/operations/updatecapacitypolicyrequest.mdx new file mode 100644 index 000000000..61b9cfcbd --- /dev/null +++ b/docs/operations/updatecapacitypolicyrequest.mdx @@ -0,0 +1,13 @@ +--- +title: "UpdateCapacityPolicyRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `update_capacity_guardrail_policy_request` | [components.UpdateCapacityGuardrailPolicyRequest](../components/updatecapacityguardrailpolicyrequest.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/sdks/guardrailpolicies/README.mdx b/docs/sdks/guardrailpolicies/README.mdx index fca09f04a..0487a3455 100644 --- a/docs/sdks/guardrailpolicies/README.mdx +++ b/docs/sdks/guardrailpolicies/README.mdx @@ -27,6 +27,11 @@ Guardrail Policies endpoints * [delete_budget_policy](#delete_budget_policy) - Delete a budget policy * [get_budget_policy](#get_budget_policy) - Get a budget policy * [update_budget_policy](#update_budget_policy) - Update a budget policy +* [list_capacity_policies](#list_capacity_policies) - List capacity policies +* [create_capacity_policy](#create_capacity_policy) - Create a capacity policy +* [delete_capacity_policy](#delete_capacity_policy) - Delete a capacity policy +* [get_capacity_policy](#get_capacity_policy) - Get a capacity policy +* [update_capacity_policy](#update_capacity_policy) - Update a capacity policy * [list_model_availability_policies](#list_model_availability_policies) - List model availability policies * [create_model_availability_policy](#create_model_availability_policy) - Create a model availability policy * [delete_model_availability_policy](#delete_model_availability_policy) - Delete a model availability policy @@ -288,15 +293,15 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | -| `policy_type` | [operations.GetAPIKeyPolicyAssignmentPolicyType](../../operations/getapikeypolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | +| `policy_type` | [operations.GetAPIKeyPolicyAssignmentPolicyType](../../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 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -346,18 +351,18 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | -| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | -| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | -| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | -| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 | +| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | +| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | +| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/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 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -402,15 +407,15 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | -| `policy_type` | [operations.GetMemberPolicyAssignmentPolicyType](../../operations/getmemberpolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | +| `policy_type` | [operations.GetMemberPolicyAssignmentPolicyType](../../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 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -460,18 +465,18 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | -| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | -| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | -| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | -| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for | budget | -| `http_referer` | *Optional[str]* | ➖ | 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.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | 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 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `member_id` | *str* | ✔️ | Organization member user ID | user_2abcDEFghiJKLmnoPQRstu | +| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true | +| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | | +| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/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 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | 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 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -845,6 +850,7 @@ with OpenRouter( | `api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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`. | | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | | `workspace_id` | *Optional[str]* | ➖ | 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 | @@ -1032,6 +1038,306 @@ with OpenRouter( | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | +## list_capacity_policies + +List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.guardrail_policies.list_capacity_policies(workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11") + + while res is not None: + # Handle items + + res = res.next() + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *Optional[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[operations.ListCapacityPoliciesResponse](../../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 | \*/\* | + +## create_capacity_policy + +Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.guardrail_policies.create_capacity_policy(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") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `config` | [components.GuardrailCapacityPolicyConfig](../../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `policy_type` | [components.CreateCapacityGuardrailPolicyRequestPolicyType](../../components/createcapacityguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | | +| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | +| `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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`. | | +| `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.CapacityGuardrailPolicyResponse](../../components/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 | \*/\* | + +## delete_capacity_policy + +Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + +### Example Usage + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.guardrail_policies.delete_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.DeleteGuardrailPolicyResponse](../../components/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 | \*/\* | + +## get_capacity_policy + +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 + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.guardrail_policies.get_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.CapacityGuardrailPolicyDetailResponse](../../components/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 | \*/\* | + +## update_capacity_policy + +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 + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.guardrail_policies.update_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", config={ + "bucket_by": [ + "member", + "model", + ], + "limits": [ + { + "limit": 100000, + "models": "all", + "unit": "tokens", + }, + ], + }, name="Engineering monthly budget", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 | +| `config` | [components.GuardrailCapacityPolicyConfig](../../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{
"bucket_by": [
"member",
"model"
],
"limits": [
\{
"limit": 100000,
"models": "all",
"unit": "tokens"
}
]
} | +| `name` | *str* | ✔️ | Policy name | Engineering monthly budget | +| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `http_referer` | *Optional[str]* | ➖ | 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.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `api_key_hashes` | List[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `is_workspace_default` | *Optional[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | | +| `member_ids` | List[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `opted_out_api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | +| `opted_out_member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.CapacityGuardrailPolicyResponse](../../components/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 | \*/\* | + ## list_model_availability_policies List the model availability policies in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required. @@ -1124,6 +1430,7 @@ with OpenRouter( | `api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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`. | | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | | `workspace_id` | *Optional[str]* | ➖ | 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 | @@ -1399,6 +1706,7 @@ with OpenRouter( | `api_key_hashes` | List[*str*] | ➖ | API key hashes | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `is_workspace_default` | *Optional[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | | | `member_ids` | List[*str*] | ➖ | Organization member user IDs | [
"user_2abcDEFghiJKLmnoPQRstu"
] | +| `move_existing_assignments` | *Optional[bool]* | ➖ | 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`. | | | `opted_out_api_key_hashes` | List[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | [
"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
] | | `opted_out_member_ids` | List[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | [
"user_2abcDEFghiJKLmnoPQRstu"
] | | `workspace_id` | *Optional[str]* | ➖ | 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 | diff --git a/docs/sdks/privateendpoints/README.mdx b/docs/sdks/privateendpoints/README.mdx index 3339d3382..a1d8564e1 100644 --- a/docs/sdks/privateendpoints/README.mdx +++ b/docs/sdks/privateendpoints/README.mdx @@ -69,7 +69,7 @@ with OpenRouter( ## 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 @@ -466,7 +466,7 @@ with OpenRouter( ## 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/pyproject.toml b/pyproject.toml index c40b71312..72dd1aad7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.234" +version = "1.3.235" description = "Official Python Client SDK for OpenRouter." authors = [{ name = "OpenRouter" },] readme = "README-PYPI.md" diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 7d7fcb4d1..252f8c764 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.3.234" +__version__: str = "1.3.235" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.234 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.235 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index 7348dedb3..401fa9aba 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -1098,6 +1098,30 @@ CapabilityDescriptorTypedDict, UnknownCapabilityDescriptor, ) + from .capacityguardrailpolicy import ( + CapacityGuardrailPolicy, + CapacityGuardrailPolicyPolicyType, + CapacityGuardrailPolicyTypedDict, + ) + from .capacityguardrailpolicydetail import ( + CapacityGuardrailPolicyDetail, + CapacityGuardrailPolicyDetailPolicyType, + CapacityGuardrailPolicyDetailReference, + CapacityGuardrailPolicyDetailTypedDict, + ) + from .capacityguardrailpolicydetailresponse import ( + CapacityGuardrailPolicyDetailResponse, + CapacityGuardrailPolicyDetailResponseTypedDict, + ) + from .capacityguardrailpolicyresponse import ( + CapacityGuardrailPolicyResponse, + CapacityGuardrailPolicyResponseTypedDict, + ) + from .capacityguardrailpolicysummary import ( + CapacityGuardrailPolicySummary, + CapacityGuardrailPolicySummaryPolicyType, + CapacityGuardrailPolicySummaryTypedDict, + ) from .changeguardrailpolicyassignmentrequest import ( ChangeGuardrailPolicyAssignmentRequest, ChangeGuardrailPolicyAssignmentRequestPolicyType, @@ -1613,6 +1637,11 @@ CreateBYOKKeyResponse, CreateBYOKKeyResponseTypedDict, ) + from .createcapacityguardrailpolicyrequest import ( + CreateCapacityGuardrailPolicyRequest, + CreateCapacityGuardrailPolicyRequestPolicyType, + CreateCapacityGuardrailPolicyRequestTypedDict, + ) from .createexternaluserrequest import ( CreateExternalUserRequest, CreateExternalUserRequestTypedDict, @@ -2447,6 +2476,19 @@ GuardrailBudgetPolicyConfig, GuardrailBudgetPolicyConfigTypedDict, ) + from .guardrailcapacitylimit import ( + GuardrailCapacityLimit, + GuardrailCapacityLimitTypedDict, + GuardrailCapacityLimitUnit, + Models, + ModelsEnum, + ModelsTypedDict, + ) + from .guardrailcapacitypolicyconfig import ( + BucketBy, + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, + ) from .guardraildataregion import GuardrailDataRegion from .guardrailinterval import GuardrailInterval from .guardrailmodelavailabilitypolicyauthoringconfig import ( @@ -2779,6 +2821,10 @@ ListBYOKKeysResponse, ListBYOKKeysResponseTypedDict, ) + from .listcapacityguardrailpoliciesresponse import ( + ListCapacityGuardrailPoliciesResponse, + ListCapacityGuardrailPoliciesResponseTypedDict, + ) from .listendpointsresponse import ( Architecture, ArchitectureTypedDict, @@ -5166,6 +5212,10 @@ UpdateBYOKKeyResponse, UpdateBYOKKeyResponseTypedDict, ) + from .updatecapacityguardrailpolicyrequest import ( + UpdateCapacityGuardrailPolicyRequest, + UpdateCapacityGuardrailPolicyRequestTypedDict, + ) from .updateexternaluserrequest import ( UpdateExternalUserRequest, UpdateExternalUserRequestTypedDict, @@ -6139,6 +6189,7 @@ "BooleanCapabilityTypedDict", "Box", "BoxTypedDict", + "BucketBy", "BudgetAccountGuardrailPolicy", "BudgetAccountGuardrailPolicyPolicyType", "BudgetAccountGuardrailPolicyRequest", @@ -6188,6 +6239,20 @@ "By", "CapabilityDescriptor", "CapabilityDescriptorTypedDict", + "CapacityGuardrailPolicy", + "CapacityGuardrailPolicyDetail", + "CapacityGuardrailPolicyDetailPolicyType", + "CapacityGuardrailPolicyDetailReference", + "CapacityGuardrailPolicyDetailResponse", + "CapacityGuardrailPolicyDetailResponseTypedDict", + "CapacityGuardrailPolicyDetailTypedDict", + "CapacityGuardrailPolicyPolicyType", + "CapacityGuardrailPolicyResponse", + "CapacityGuardrailPolicyResponseTypedDict", + "CapacityGuardrailPolicySummary", + "CapacityGuardrailPolicySummaryPolicyType", + "CapacityGuardrailPolicySummaryTypedDict", + "CapacityGuardrailPolicyTypedDict", "CascadeMode", "ChangeGuardrailPolicyAssignmentRequest", "ChangeGuardrailPolicyAssignmentRequestPolicyType", @@ -6575,6 +6640,9 @@ "CreateBudgetGuardrailPolicyRequest", "CreateBudgetGuardrailPolicyRequestPolicyType", "CreateBudgetGuardrailPolicyRequestTypedDict", + "CreateCapacityGuardrailPolicyRequest", + "CreateCapacityGuardrailPolicyRequestPolicyType", + "CreateCapacityGuardrailPolicyRequestTypedDict", "CreateExternalUserRequest", "CreateExternalUserRequestTypedDict", "CreateGuardrailRequest", @@ -7177,6 +7245,11 @@ "GuardrailBudgetPolicyAuthoringConfigTypedDict", "GuardrailBudgetPolicyConfig", "GuardrailBudgetPolicyConfigTypedDict", + "GuardrailCapacityLimit", + "GuardrailCapacityLimitTypedDict", + "GuardrailCapacityLimitUnit", + "GuardrailCapacityPolicyConfig", + "GuardrailCapacityPolicyConfigTypedDict", "GuardrailDataRegion", "GuardrailInterval", "GuardrailModelAvailabilityPolicyAuthoringConfig", @@ -7439,6 +7512,8 @@ "ListBYOKKeysResponseTypedDict", "ListBudgetGuardrailPoliciesResponse", "ListBudgetGuardrailPoliciesResponseTypedDict", + "ListCapacityGuardrailPoliciesResponse", + "ListCapacityGuardrailPoliciesResponseTypedDict", "ListEndpointsResponse", "ListEndpointsResponseTypedDict", "ListExternalUsersResponse", @@ -7843,14 +7918,17 @@ "ModelResponse", "ModelResponseTypedDict", "ModelTypedDict", + "Models", "ModelsCountResponse", "ModelsCountResponseData", "ModelsCountResponseDataTypedDict", "ModelsCountResponseTypedDict", + "ModelsEnum", "ModelsListResponse", "ModelsListResponseLinks", "ModelsListResponseLinksTypedDict", "ModelsListResponseTypedDict", + "ModelsTypedDict", "Moderation", "ModerationAccountGuardrailPolicy", "ModerationAccountGuardrailPolicyPolicyType", @@ -9292,6 +9370,8 @@ "UpdateBYOKKeyResponseTypedDict", "UpdateBudgetGuardrailPolicyRequest", "UpdateBudgetGuardrailPolicyRequestTypedDict", + "UpdateCapacityGuardrailPolicyRequest", + "UpdateCapacityGuardrailPolicyRequestTypedDict", "UpdateExternalUserRequest", "UpdateExternalUserRequestTypedDict", "UpdateGuardrailRequest", @@ -10261,6 +10341,20 @@ "CapabilityDescriptor": ".capabilitydescriptor", "CapabilityDescriptorTypedDict": ".capabilitydescriptor", "UnknownCapabilityDescriptor": ".capabilitydescriptor", + "CapacityGuardrailPolicy": ".capacityguardrailpolicy", + "CapacityGuardrailPolicyPolicyType": ".capacityguardrailpolicy", + "CapacityGuardrailPolicyTypedDict": ".capacityguardrailpolicy", + "CapacityGuardrailPolicyDetail": ".capacityguardrailpolicydetail", + "CapacityGuardrailPolicyDetailPolicyType": ".capacityguardrailpolicydetail", + "CapacityGuardrailPolicyDetailReference": ".capacityguardrailpolicydetail", + "CapacityGuardrailPolicyDetailTypedDict": ".capacityguardrailpolicydetail", + "CapacityGuardrailPolicyDetailResponse": ".capacityguardrailpolicydetailresponse", + "CapacityGuardrailPolicyDetailResponseTypedDict": ".capacityguardrailpolicydetailresponse", + "CapacityGuardrailPolicyResponse": ".capacityguardrailpolicyresponse", + "CapacityGuardrailPolicyResponseTypedDict": ".capacityguardrailpolicyresponse", + "CapacityGuardrailPolicySummary": ".capacityguardrailpolicysummary", + "CapacityGuardrailPolicySummaryPolicyType": ".capacityguardrailpolicysummary", + "CapacityGuardrailPolicySummaryTypedDict": ".capacityguardrailpolicysummary", "ChangeGuardrailPolicyAssignmentRequest": ".changeguardrailpolicyassignmentrequest", "ChangeGuardrailPolicyAssignmentRequestPolicyType": ".changeguardrailpolicyassignmentrequest", "ChangeGuardrailPolicyAssignmentRequestTypedDict": ".changeguardrailpolicyassignmentrequest", @@ -10622,6 +10716,9 @@ "CreateBYOKKeyRequestTypedDict": ".createbyokkeyrequest", "CreateBYOKKeyResponse": ".createbyokkeyresponse", "CreateBYOKKeyResponseTypedDict": ".createbyokkeyresponse", + "CreateCapacityGuardrailPolicyRequest": ".createcapacityguardrailpolicyrequest", + "CreateCapacityGuardrailPolicyRequestPolicyType": ".createcapacityguardrailpolicyrequest", + "CreateCapacityGuardrailPolicyRequestTypedDict": ".createcapacityguardrailpolicyrequest", "CreateExternalUserRequest": ".createexternaluserrequest", "CreateExternalUserRequestTypedDict": ".createexternaluserrequest", "CreateGuardrailRequest": ".createguardrailrequest", @@ -11226,6 +11323,15 @@ "GuardrailBudgetPolicyAuthoringConfigTypedDict": ".guardrailbudgetpolicyauthoringconfig", "GuardrailBudgetPolicyConfig": ".guardrailbudgetpolicyconfig", "GuardrailBudgetPolicyConfigTypedDict": ".guardrailbudgetpolicyconfig", + "GuardrailCapacityLimit": ".guardrailcapacitylimit", + "GuardrailCapacityLimitTypedDict": ".guardrailcapacitylimit", + "GuardrailCapacityLimitUnit": ".guardrailcapacitylimit", + "Models": ".guardrailcapacitylimit", + "ModelsEnum": ".guardrailcapacitylimit", + "ModelsTypedDict": ".guardrailcapacitylimit", + "BucketBy": ".guardrailcapacitypolicyconfig", + "GuardrailCapacityPolicyConfig": ".guardrailcapacitypolicyconfig", + "GuardrailCapacityPolicyConfigTypedDict": ".guardrailcapacitypolicyconfig", "GuardrailDataRegion": ".guardraildataregion", "GuardrailInterval": ".guardrailinterval", "GuardrailModelAvailabilityPolicyAuthoringConfig": ".guardrailmodelavailabilitypolicyauthoringconfig", @@ -11476,6 +11582,8 @@ "ListBudgetGuardrailPoliciesResponseTypedDict": ".listbudgetguardrailpoliciesresponse", "ListBYOKKeysResponse": ".listbyokkeysresponse", "ListBYOKKeysResponseTypedDict": ".listbyokkeysresponse", + "ListCapacityGuardrailPoliciesResponse": ".listcapacityguardrailpoliciesresponse", + "ListCapacityGuardrailPoliciesResponseTypedDict": ".listcapacityguardrailpoliciesresponse", "Architecture": ".listendpointsresponse", "ArchitectureTypedDict": ".listendpointsresponse", "ListEndpointsResponse": ".listendpointsresponse", @@ -13285,6 +13393,8 @@ "UpdateBYOKKeyRequestTypedDict": ".updatebyokkeyrequest", "UpdateBYOKKeyResponse": ".updatebyokkeyresponse", "UpdateBYOKKeyResponseTypedDict": ".updatebyokkeyresponse", + "UpdateCapacityGuardrailPolicyRequest": ".updatecapacityguardrailpolicyrequest", + "UpdateCapacityGuardrailPolicyRequestTypedDict": ".updatecapacityguardrailpolicyrequest", "UpdateExternalUserRequest": ".updateexternaluserrequest", "UpdateExternalUserRequestTypedDict": ".updateexternaluserrequest", "UpdateGuardrailRequest": ".updateguardrailrequest", diff --git a/src/openrouter/components/capacityguardrailpolicy.py b/src/openrouter/components/capacityguardrailpolicy.py new file mode 100644 index 000000000..8b8136870 --- /dev/null +++ b/src/openrouter/components/capacityguardrailpolicy.py @@ -0,0 +1,34 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitypolicyconfig import ( + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, +) +from openrouter.types import BaseModel +from typing import Literal +from typing_extensions import TypedDict + + +CapacityGuardrailPolicyPolicyType = Literal["rate_limit",] + + +class CapacityGuardrailPolicyTypedDict(TypedDict): + config: GuardrailCapacityPolicyConfigTypedDict + id: str + r"""Policy ID""" + name: str + r"""Policy name""" + policy_type: CapacityGuardrailPolicyPolicyType + + +class CapacityGuardrailPolicy(BaseModel): + config: GuardrailCapacityPolicyConfig + + id: str + r"""Policy ID""" + + name: str + r"""Policy name""" + + policy_type: CapacityGuardrailPolicyPolicyType diff --git a/src/openrouter/components/capacityguardrailpolicydetail.py b/src/openrouter/components/capacityguardrailpolicydetail.py new file mode 100644 index 000000000..d269ae08e --- /dev/null +++ b/src/openrouter/components/capacityguardrailpolicydetail.py @@ -0,0 +1,128 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitypolicyconfig import ( + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, +) +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET_SENTINEL, + UnrecognizedStr, +) +from pydantic import model_serializer +from typing import List, Literal, Optional, Union +from typing_extensions import NotRequired, TypedDict + + +CapacityGuardrailPolicyDetailPolicyType = Literal["rate_limit",] + + +CapacityGuardrailPolicyDetailReference = Union[ + Literal[ + "legacy_mapping", + "account_default", + ], + UnrecognizedStr, +] +r"""`legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null`""" + + +class CapacityGuardrailPolicyDetailTypedDict(TypedDict): + api_key_hashes: List[str] + r"""API key hashes""" + config: GuardrailCapacityPolicyConfigTypedDict + id: str + r"""Policy ID""" + member_ids: List[str] + r"""Organization member user IDs""" + name: str + r"""Policy name""" + opted_out_api_key_hashes: List[str] + r"""API key hashes""" + overridden_api_key_hashes: List[str] + r"""API keys that have a different policy of this type assigned directly""" + policy_type: CapacityGuardrailPolicyDetailPolicyType + updated_at: Nullable[str] + is_workspace_default: NotRequired[bool] + opted_out_member_ids: NotRequired[List[str]] + r"""Organization member user IDs""" + overridden_member_ids: NotRequired[List[str]] + r"""Members that have a different policy of this type assigned directly""" + reference: NotRequired[Nullable[CapacityGuardrailPolicyDetailReference]] + r"""`legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null`""" + + +class CapacityGuardrailPolicyDetail(BaseModel): + api_key_hashes: List[str] + r"""API key hashes""" + + config: GuardrailCapacityPolicyConfig + + id: str + r"""Policy ID""" + + member_ids: List[str] + r"""Organization member user IDs""" + + name: str + r"""Policy name""" + + opted_out_api_key_hashes: List[str] + r"""API key hashes""" + + overridden_api_key_hashes: List[str] + r"""API keys that have a different policy of this type assigned directly""" + + policy_type: CapacityGuardrailPolicyDetailPolicyType + + updated_at: Nullable[str] + + is_workspace_default: Optional[bool] = None + + opted_out_member_ids: Optional[List[str]] = None + r"""Organization member user IDs""" + + overridden_member_ids: Optional[List[str]] = None + r"""Members that have a different policy of this type assigned directly""" + + reference: OptionalNullable[CapacityGuardrailPolicyDetailReference] = None + r"""`legacy_mapping` when the policy is synced from a v1 guardrail, `account_default` when it is an account-wide default, otherwise `null`""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "is_workspace_default", + "opted_out_member_ids", + "overridden_member_ids", + "reference", + ] + ) + nullable_fields = set(["reference", "updated_at"]) + null_default_fields = set(["reference"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and ( + self.__pydantic_fields_set__.intersection({n}) + or k in null_default_fields + ) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + + return m diff --git a/src/openrouter/components/capacityguardrailpolicydetailresponse.py b/src/openrouter/components/capacityguardrailpolicydetailresponse.py new file mode 100644 index 000000000..6d15ac10f --- /dev/null +++ b/src/openrouter/components/capacityguardrailpolicydetailresponse.py @@ -0,0 +1,17 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .capacityguardrailpolicydetail import ( + CapacityGuardrailPolicyDetail, + CapacityGuardrailPolicyDetailTypedDict, +) +from openrouter.types import BaseModel +from typing_extensions import TypedDict + + +class CapacityGuardrailPolicyDetailResponseTypedDict(TypedDict): + data: CapacityGuardrailPolicyDetailTypedDict + + +class CapacityGuardrailPolicyDetailResponse(BaseModel): + data: CapacityGuardrailPolicyDetail diff --git a/src/openrouter/components/capacityguardrailpolicyresponse.py b/src/openrouter/components/capacityguardrailpolicyresponse.py new file mode 100644 index 000000000..624579758 --- /dev/null +++ b/src/openrouter/components/capacityguardrailpolicyresponse.py @@ -0,0 +1,17 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .capacityguardrailpolicy import ( + CapacityGuardrailPolicy, + CapacityGuardrailPolicyTypedDict, +) +from openrouter.types import BaseModel +from typing_extensions import TypedDict + + +class CapacityGuardrailPolicyResponseTypedDict(TypedDict): + data: CapacityGuardrailPolicyTypedDict + + +class CapacityGuardrailPolicyResponse(BaseModel): + data: CapacityGuardrailPolicy diff --git a/src/openrouter/components/capacityguardrailpolicysummary.py b/src/openrouter/components/capacityguardrailpolicysummary.py new file mode 100644 index 000000000..9b1f2d0b0 --- /dev/null +++ b/src/openrouter/components/capacityguardrailpolicysummary.py @@ -0,0 +1,72 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitypolicyconfig import ( + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, +) +from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL +from pydantic import model_serializer +from typing import Literal, Optional +from typing_extensions import NotRequired, TypedDict + + +CapacityGuardrailPolicySummaryPolicyType = Literal["rate_limit",] + + +class CapacityGuardrailPolicySummaryTypedDict(TypedDict): + api_key_count: int + config: GuardrailCapacityPolicyConfigTypedDict + id: str + r"""Policy ID""" + member_count: int + name: str + r"""Policy name""" + policy_type: CapacityGuardrailPolicySummaryPolicyType + updated_at: Nullable[str] + is_workspace_default: NotRequired[bool] + + +class CapacityGuardrailPolicySummary(BaseModel): + api_key_count: int + + config: GuardrailCapacityPolicyConfig + + id: str + r"""Policy ID""" + + member_count: int + + name: str + r"""Policy name""" + + policy_type: CapacityGuardrailPolicySummaryPolicyType + + updated_at: Nullable[str] + + is_workspace_default: Optional[bool] = None + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["is_workspace_default"]) + nullable_fields = set(["updated_at"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + + return m diff --git a/src/openrouter/components/changeguardrailpolicyassignmentrequest.py b/src/openrouter/components/changeguardrailpolicyassignmentrequest.py index 7ecc46a11..8d537f739 100644 --- a/src/openrouter/components/changeguardrailpolicyassignmentrequest.py +++ b/src/openrouter/components/changeguardrailpolicyassignmentrequest.py @@ -20,7 +20,7 @@ ], UnrecognizedStr, ] -r"""Policy type the assignment is read or changed for""" +r"""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`.""" class ChangeGuardrailPolicyAssignmentRequestTypedDict(TypedDict): @@ -30,7 +30,7 @@ class ChangeGuardrailPolicyAssignmentRequestTypedDict(TypedDict): policy_id: str r"""Policy ID""" policy_type: ChangeGuardrailPolicyAssignmentRequestPolicyType - r"""Policy type the assignment is read or changed for""" + r"""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`.""" workspace_id: NotRequired[str] r"""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.""" @@ -45,7 +45,7 @@ class ChangeGuardrailPolicyAssignmentRequest(BaseModel): r"""Policy ID""" policy_type: ChangeGuardrailPolicyAssignmentRequestPolicyType - r"""Policy type the assignment is read or changed for""" + r"""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`.""" workspace_id: Optional[str] = None r"""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.""" diff --git a/src/openrouter/components/createbudgetguardrailpolicyrequest.py b/src/openrouter/components/createbudgetguardrailpolicyrequest.py index 1baab50ee..d90a8561c 100644 --- a/src/openrouter/components/createbudgetguardrailpolicyrequest.py +++ b/src/openrouter/components/createbudgetguardrailpolicyrequest.py @@ -25,6 +25,8 @@ class CreateBudgetGuardrailPolicyRequestTypedDict(TypedDict): r"""Make this the workspace default for its policy type. Defaults to `false`.""" member_ids: NotRequired[List[str]] r"""Organization member user IDs""" + move_existing_assignments: NotRequired[bool] + r"""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`.""" opted_out_api_key_hashes: NotRequired[List[str]] r"""API keys that should not inherit the policy when it is the workspace default""" opted_out_member_ids: NotRequired[List[str]] @@ -50,6 +52,9 @@ class CreateBudgetGuardrailPolicyRequest(BaseModel): member_ids: Optional[List[str]] = None r"""Organization member user IDs""" + move_existing_assignments: Optional[bool] = None + r"""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`.""" + opted_out_api_key_hashes: Optional[List[str]] = None r"""API keys that should not inherit the policy when it is the workspace default""" @@ -66,6 +71,7 @@ def serialize_model(self, handler): "api_key_hashes", "is_workspace_default", "member_ids", + "move_existing_assignments", "opted_out_api_key_hashes", "opted_out_member_ids", "workspace_id", diff --git a/src/openrouter/components/createcapacityguardrailpolicyrequest.py b/src/openrouter/components/createcapacityguardrailpolicyrequest.py new file mode 100644 index 000000000..c85918bd0 --- /dev/null +++ b/src/openrouter/components/createcapacityguardrailpolicyrequest.py @@ -0,0 +1,90 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitypolicyconfig import ( + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, +) +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import List, Literal, Optional +from typing_extensions import NotRequired, TypedDict + + +CreateCapacityGuardrailPolicyRequestPolicyType = Literal["rate_limit",] + + +class CreateCapacityGuardrailPolicyRequestTypedDict(TypedDict): + config: GuardrailCapacityPolicyConfigTypedDict + name: str + r"""Policy name""" + policy_type: CreateCapacityGuardrailPolicyRequestPolicyType + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + api_key_hashes: NotRequired[List[str]] + r"""API key hashes""" + is_workspace_default: NotRequired[bool] + r"""Make this the workspace default for its policy type. Defaults to `false`.""" + member_ids: NotRequired[List[str]] + r"""Organization member user IDs""" + move_existing_assignments: NotRequired[bool] + r"""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`.""" + opted_out_api_key_hashes: NotRequired[List[str]] + r"""API keys that should not inherit the policy when it is the workspace default""" + opted_out_member_ids: NotRequired[List[str]] + r"""Members that should not inherit the policy when it is the workspace default""" + + +class CreateCapacityGuardrailPolicyRequest(BaseModel): + config: GuardrailCapacityPolicyConfig + + name: str + r"""Policy name""" + + policy_type: CreateCapacityGuardrailPolicyRequestPolicyType + + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + + api_key_hashes: Optional[List[str]] = None + r"""API key hashes""" + + is_workspace_default: Optional[bool] = None + r"""Make this the workspace default for its policy type. Defaults to `false`.""" + + member_ids: Optional[List[str]] = None + r"""Organization member user IDs""" + + move_existing_assignments: Optional[bool] = None + r"""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`.""" + + opted_out_api_key_hashes: Optional[List[str]] = None + r"""API keys that should not inherit the policy when it is the workspace default""" + + opted_out_member_ids: Optional[List[str]] = None + r"""Members that should not inherit the policy when it is the workspace default""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "api_key_hashes", + "is_workspace_default", + "member_ids", + "move_existing_assignments", + "opted_out_api_key_hashes", + "opted_out_member_ids", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/components/createmodelavailabilityguardrailpolicyrequest.py b/src/openrouter/components/createmodelavailabilityguardrailpolicyrequest.py index 8a28539e0..c309dbc8f 100644 --- a/src/openrouter/components/createmodelavailabilityguardrailpolicyrequest.py +++ b/src/openrouter/components/createmodelavailabilityguardrailpolicyrequest.py @@ -25,6 +25,8 @@ class CreateModelAvailabilityGuardrailPolicyRequestTypedDict(TypedDict): r"""Make this the workspace default for its policy type. Defaults to `false`.""" member_ids: NotRequired[List[str]] r"""Organization member user IDs""" + move_existing_assignments: NotRequired[bool] + r"""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`.""" opted_out_api_key_hashes: NotRequired[List[str]] r"""API keys that should not inherit the policy when it is the workspace default""" opted_out_member_ids: NotRequired[List[str]] @@ -50,6 +52,9 @@ class CreateModelAvailabilityGuardrailPolicyRequest(BaseModel): member_ids: Optional[List[str]] = None r"""Organization member user IDs""" + move_existing_assignments: Optional[bool] = None + r"""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`.""" + opted_out_api_key_hashes: Optional[List[str]] = None r"""API keys that should not inherit the policy when it is the workspace default""" @@ -66,6 +71,7 @@ def serialize_model(self, handler): "api_key_hashes", "is_workspace_default", "member_ids", + "move_existing_assignments", "opted_out_api_key_hashes", "opted_out_member_ids", "workspace_id", diff --git a/src/openrouter/components/createmoderationguardrailpolicyrequest.py b/src/openrouter/components/createmoderationguardrailpolicyrequest.py index 5a1db586e..2aa88fa38 100644 --- a/src/openrouter/components/createmoderationguardrailpolicyrequest.py +++ b/src/openrouter/components/createmoderationguardrailpolicyrequest.py @@ -25,6 +25,8 @@ class CreateModerationGuardrailPolicyRequestTypedDict(TypedDict): r"""Make this the workspace default for its policy type. Defaults to `false`.""" member_ids: NotRequired[List[str]] r"""Organization member user IDs""" + move_existing_assignments: NotRequired[bool] + r"""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`.""" opted_out_api_key_hashes: NotRequired[List[str]] r"""API keys that should not inherit the policy when it is the workspace default""" opted_out_member_ids: NotRequired[List[str]] @@ -50,6 +52,9 @@ class CreateModerationGuardrailPolicyRequest(BaseModel): member_ids: Optional[List[str]] = None r"""Organization member user IDs""" + move_existing_assignments: Optional[bool] = None + r"""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`.""" + opted_out_api_key_hashes: Optional[List[str]] = None r"""API keys that should not inherit the policy when it is the workspace default""" @@ -66,6 +71,7 @@ def serialize_model(self, handler): "api_key_hashes", "is_workspace_default", "member_ids", + "move_existing_assignments", "opted_out_api_key_hashes", "opted_out_member_ids", "workspace_id", diff --git a/src/openrouter/components/guardrailcapacitylimit.py b/src/openrouter/components/guardrailcapacitylimit.py new file mode 100644 index 000000000..099d10914 --- /dev/null +++ b/src/openrouter/components/guardrailcapacitylimit.py @@ -0,0 +1,48 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UnrecognizedStr +from typing import List, Literal, Union +from typing_extensions import TypeAliasType, TypedDict + + +ModelsEnum = Literal["all",] +r"""Apply this limit to every model.""" + + +ModelsTypedDict = TypeAliasType("ModelsTypedDict", Union[ModelsEnum, List[str]]) +r"""Either `\"all\"` to cover every model or a non-empty list of exact model slugs.""" + + +Models = TypeAliasType("Models", Union[ModelsEnum, List[str]]) +r"""Either `\"all\"` to cover every model or a non-empty list of exact model slugs.""" + + +GuardrailCapacityLimitUnit = Union[ + Literal[ + "tokens", + "requests", + ], + UnrecognizedStr, +] +r"""Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`).""" + + +class GuardrailCapacityLimitTypedDict(TypedDict): + limit: int + r"""Bucket capacity and per-minute refill rate.""" + models: ModelsTypedDict + r"""Either `\"all\"` to cover every model or a non-empty list of exact model slugs.""" + unit: GuardrailCapacityLimitUnit + r"""Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`).""" + + +class GuardrailCapacityLimit(BaseModel): + limit: int + r"""Bucket capacity and per-minute refill rate.""" + + models: Models + r"""Either `\"all\"` to cover every model or a non-empty list of exact model slugs.""" + + unit: GuardrailCapacityLimitUnit + r"""Rate-limit unit: per-minute tokens (`tokens`) or requests (`requests`).""" diff --git a/src/openrouter/components/guardrailcapacitypolicyconfig.py b/src/openrouter/components/guardrailcapacitypolicyconfig.py new file mode 100644 index 000000000..4da8dfb2d --- /dev/null +++ b/src/openrouter/components/guardrailcapacitypolicyconfig.py @@ -0,0 +1,36 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitylimit import ( + GuardrailCapacityLimit, + GuardrailCapacityLimitTypedDict, +) +from openrouter.types import BaseModel, UnrecognizedStr +from typing import List, Literal, Union +from typing_extensions import TypedDict + + +BucketBy = Union[ + Literal[ + "workspace", + "member", + "api_key", + "model", + ], + UnrecognizedStr, +] + + +class GuardrailCapacityPolicyConfigTypedDict(TypedDict): + bucket_by: List[BucketBy] + r"""Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`.""" + limits: List[GuardrailCapacityLimitTypedDict] + r"""One or more per-minute token or request limits (up to 200 entries and 200 listed models total).""" + + +class GuardrailCapacityPolicyConfig(BaseModel): + bucket_by: List[BucketBy] + r"""Distinct dimensions defining each rate-limit bucket. Must include `member` or `api_key` and end with `model`.""" + + limits: List[GuardrailCapacityLimit] + r"""One or more per-minute token or request limits (up to 200 entries and 200 listed models total).""" diff --git a/src/openrouter/components/listcapacityguardrailpoliciesresponse.py b/src/openrouter/components/listcapacityguardrailpoliciesresponse.py new file mode 100644 index 000000000..a7878f136 --- /dev/null +++ b/src/openrouter/components/listcapacityguardrailpoliciesresponse.py @@ -0,0 +1,23 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .capacityguardrailpolicysummary import ( + CapacityGuardrailPolicySummary, + CapacityGuardrailPolicySummaryTypedDict, +) +from openrouter.types import BaseModel +from typing import List +from typing_extensions import TypedDict + + +class ListCapacityGuardrailPoliciesResponseTypedDict(TypedDict): + data: List[CapacityGuardrailPolicySummaryTypedDict] + total_count: int + r"""Total number of policies""" + + +class ListCapacityGuardrailPoliciesResponse(BaseModel): + data: List[CapacityGuardrailPolicySummary] + + total_count: int + r"""Total number of policies""" diff --git a/src/openrouter/components/updatecapacityguardrailpolicyrequest.py b/src/openrouter/components/updatecapacityguardrailpolicyrequest.py new file mode 100644 index 000000000..423c3c4b2 --- /dev/null +++ b/src/openrouter/components/updatecapacityguardrailpolicyrequest.py @@ -0,0 +1,78 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .guardrailcapacitypolicyconfig import ( + GuardrailCapacityPolicyConfig, + GuardrailCapacityPolicyConfigTypedDict, +) +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class UpdateCapacityGuardrailPolicyRequestTypedDict(TypedDict): + config: GuardrailCapacityPolicyConfigTypedDict + name: str + r"""Policy name""" + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + api_key_hashes: NotRequired[List[str]] + r"""Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments.""" + is_workspace_default: NotRequired[bool] + r"""Omit to keep the stored default status; `false` unsets the policy as the workspace default.""" + member_ids: NotRequired[List[str]] + r"""Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments.""" + opted_out_api_key_hashes: NotRequired[List[str]] + r"""API key hashes""" + opted_out_member_ids: NotRequired[List[str]] + r"""Organization member user IDs""" + + +class UpdateCapacityGuardrailPolicyRequest(BaseModel): + config: GuardrailCapacityPolicyConfig + + name: str + r"""Policy name""" + + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + + api_key_hashes: Optional[List[str]] = None + r"""Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments.""" + + is_workspace_default: Optional[bool] = None + r"""Omit to keep the stored default status; `false` unsets the policy as the workspace default.""" + + member_ids: Optional[List[str]] = None + r"""Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments.""" + + opted_out_api_key_hashes: Optional[List[str]] = None + r"""API key hashes""" + + opted_out_member_ids: Optional[List[str]] = None + r"""Organization member user IDs""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "api_key_hashes", + "is_workspace_default", + "member_ids", + "opted_out_api_key_hashes", + "opted_out_member_ids", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/guardrail_policies.py b/src/openrouter/guardrail_policies.py index 5d25f0c1d..724c51791 100644 --- a/src/openrouter/guardrail_policies.py +++ b/src/openrouter/guardrail_policies.py @@ -1309,7 +1309,7 @@ def get_api_key_policy_assignment( 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. :param hash: API key hash - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -1455,7 +1455,7 @@ async def get_api_key_policy_assignment_async( 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. :param hash: API key hash - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -1610,7 +1610,7 @@ def change_api_key_policy_assignment( :param assigned: `true` assigns the policy to the subject, `false` removes it :param expected_assignment: :param policy_id: Policy ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -1784,7 +1784,7 @@ async def change_api_key_policy_assignment_async( :param assigned: `true` assigns the policy to the subject, `false` removes it :param expected_assignment: :param policy_id: Policy ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -1949,7 +1949,7 @@ def get_member_policy_assignment( 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. :param member_id: Organization member user ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -2095,7 +2095,7 @@ async def get_member_policy_assignment_async( 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. :param member_id: Organization member user ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -2250,7 +2250,7 @@ def change_member_policy_assignment( :param assigned: `true` assigns the policy to the subject, `false` removes it :param expected_assignment: :param policy_id: Policy ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -2424,7 +2424,7 @@ async def change_member_policy_assignment_async( :param assigned: `true` assigns the policy to the subject, `false` removes it :param expected_assignment: :param policy_id: Policy ID - :param policy_type: Policy type the assignment is read or changed for + :param policy_type: 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`. :param http_referer: 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. @@ -4440,6 +4440,7 @@ def create_budget_policy( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -4465,6 +4466,7 @@ def create_budget_policy( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -4494,6 +4496,7 @@ def create_budget_policy( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] @@ -4627,6 +4630,7 @@ async def create_budget_policy_async( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -4652,6 +4656,7 @@ async def create_budget_policy_async( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -4681,6 +4686,7 @@ async def create_budget_policy_async( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] @@ -5755,6 +5761,1699 @@ async def update_budget_policy_async( raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + def list_capacity_policies( + self, + *, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + offset: Optional[int] = None, + limit: Optional[int] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> Optional[operations.ListCapacityPoliciesResponse]: + r"""List capacity policies + + List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned + :param limit: Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.ListCapacityPoliciesRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + offset=offset, + limit=limit, + workspace_id=workspace_id, + ) + + req = self._build_request( + method="GET", + path="/guardrails/policies/capacity", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.ListCapacityPoliciesGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="listCapacityPolicies", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + def next_func() -> Optional[operations.ListCapacityPoliciesResponse]: + body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]]) + + offset = request.offset if isinstance(request.offset, int) else 0 + + if not http_res.text: + return None + results = JSONPath("$.data").parse(body) + if len(results) == 0 or len(results[0]) == 0: + return None + limit_ = request.limit if isinstance(request.limit, int) else 0 + if len(results[0]) < limit_: + return None + next_offset = offset + len(results[0]) + + return self.list_capacity_policies( + workspace_id=workspace_id, + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + offset=next_offset, + limit=limit, + retries=retries, + server_url=server_url, + timeout_ms=timeout_ms, + http_headers=http_headers, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return operations.ListCapacityPoliciesResponse( + result=unmarshal_json_response( + components.ListCapacityGuardrailPoliciesResponse, http_res + ), + next=next_func, + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def list_capacity_policies_async( + self, + *, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + offset: Optional[int] = None, + limit: Optional[int] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> Optional[operations.ListCapacityPoliciesResponse]: + r"""List capacity policies + + List the capacity policies in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned + :param limit: Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.ListCapacityPoliciesRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + offset=offset, + limit=limit, + workspace_id=workspace_id, + ) + + req = self._build_request_async( + method="GET", + path="/guardrails/policies/capacity", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.ListCapacityPoliciesGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="listCapacityPolicies", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + def next_func() -> Awaitable[Optional[operations.ListCapacityPoliciesResponse]]: + body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]]) + + async def empty_result(): + return None + + offset = request.offset if isinstance(request.offset, int) else 0 + + if not http_res.text: + return empty_result() + results = JSONPath("$.data").parse(body) + if len(results) == 0 or len(results[0]) == 0: + return empty_result() + limit_ = request.limit if isinstance(request.limit, int) else 0 + if len(results[0]) < limit_: + return empty_result() + next_offset = offset + len(results[0]) + + return self.list_capacity_policies_async( + workspace_id=workspace_id, + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + offset=next_offset, + limit=limit, + retries=retries, + server_url=server_url, + timeout_ms=timeout_ms, + http_headers=http_headers, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return operations.ListCapacityPoliciesResponse( + result=unmarshal_json_response( + components.ListCapacityGuardrailPoliciesResponse, http_res + ), + next=next_func, + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + def create_capacity_policy( + self, + *, + config: Union[ + components.GuardrailCapacityPolicyConfig, + components.GuardrailCapacityPolicyConfigTypedDict, + ], + name: str, + policy_type: components.CreateCapacityGuardrailPolicyRequestPolicyType, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + api_key_hashes: Optional[Iterable[str]] = None, + is_workspace_default: Optional[bool] = None, + member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, + opted_out_api_key_hashes: Optional[Iterable[str]] = None, + opted_out_member_ids: Optional[Iterable[str]] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyResponse: + r"""Create a capacity policy + + Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param config: + :param name: Policy name + :param policy_type: + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param api_key_hashes: API key hashes + :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. + :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. + :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default + :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.CreateCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + create_capacity_guardrail_policy_request=components.CreateCapacityGuardrailPolicyRequest( + api_key_hashes=utils.unmarshal(api_key_hashes, Optional[List[str]]), + config=utils.get_pydantic_model( + config, components.GuardrailCapacityPolicyConfig + ), + is_workspace_default=is_workspace_default, + member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, + name=name, + opted_out_api_key_hashes=utils.unmarshal( + opted_out_api_key_hashes, Optional[List[str]] + ), + opted_out_member_ids=utils.unmarshal( + opted_out_member_ids, Optional[List[str]] + ), + policy_type=policy_type, + workspace_id=workspace_id, + ), + ) + + req = self._build_request( + method="POST", + path="/guardrails/policies/capacity", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.CreateCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.create_capacity_guardrail_policy_request, + False, + False, + "json", + components.CreateCapacityGuardrailPolicyRequest, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="createCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "201", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def create_capacity_policy_async( + self, + *, + config: Union[ + components.GuardrailCapacityPolicyConfig, + components.GuardrailCapacityPolicyConfigTypedDict, + ], + name: str, + policy_type: components.CreateCapacityGuardrailPolicyRequestPolicyType, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + api_key_hashes: Optional[Iterable[str]] = None, + is_workspace_default: Optional[bool] = None, + member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, + opted_out_api_key_hashes: Optional[Iterable[str]] = None, + opted_out_member_ids: Optional[Iterable[str]] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyResponse: + r"""Create a capacity policy + + Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param config: + :param name: Policy name + :param policy_type: + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param api_key_hashes: API key hashes + :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. + :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. + :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default + :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.CreateCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + create_capacity_guardrail_policy_request=components.CreateCapacityGuardrailPolicyRequest( + api_key_hashes=utils.unmarshal(api_key_hashes, Optional[List[str]]), + config=utils.get_pydantic_model( + config, components.GuardrailCapacityPolicyConfig + ), + is_workspace_default=is_workspace_default, + member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, + name=name, + opted_out_api_key_hashes=utils.unmarshal( + opted_out_api_key_hashes, Optional[List[str]] + ), + opted_out_member_ids=utils.unmarshal( + opted_out_member_ids, Optional[List[str]] + ), + policy_type=policy_type, + workspace_id=workspace_id, + ), + ) + + req = self._build_request_async( + method="POST", + path="/guardrails/policies/capacity", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.CreateCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.create_capacity_guardrail_policy_request, + False, + False, + "json", + components.CreateCapacityGuardrailPolicyRequest, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="createCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "201", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + def delete_capacity_policy( + self, + *, + id: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.DeleteGuardrailPolicyResponse: + r"""Delete a capacity policy + + Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param id: Policy ID + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.DeleteCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + workspace_id=workspace_id, + ) + + req = self._build_request( + method="DELETE", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.DeleteCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="deleteCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.DeleteGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def delete_capacity_policy_async( + self, + *, + id: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.DeleteGuardrailPolicyResponse: + r"""Delete a capacity policy + + Delete a capacity policy. Enterprise private beta feature. [Management key](/docs/guides/overview/auth/management-api-keys) required. + + :param id: Policy ID + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.DeleteCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + workspace_id=workspace_id, + ) + + req = self._build_request_async( + method="DELETE", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.DeleteCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="deleteCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.DeleteGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + def get_capacity_policy( + self, + *, + id: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyDetailResponse: + r"""Get a capacity policy + + 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. + + :param id: Policy ID + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.GetCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + workspace_id=workspace_id, + ) + + req = self._build_request( + method="GET", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.GetCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="getCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyDetailResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def get_capacity_policy_async( + self, + *, + id: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyDetailResponse: + r"""Get a capacity policy + + 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. + + :param id: Policy ID + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.GetCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + workspace_id=workspace_id, + ) + + req = self._build_request_async( + method="GET", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.GetCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="getCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyDetailResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + def update_capacity_policy( + self, + *, + id: str, + config: Union[ + components.GuardrailCapacityPolicyConfig, + components.GuardrailCapacityPolicyConfigTypedDict, + ], + name: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + api_key_hashes: Optional[Iterable[str]] = None, + is_workspace_default: Optional[bool] = None, + member_ids: Optional[Iterable[str]] = None, + opted_out_api_key_hashes: Optional[Iterable[str]] = None, + opted_out_member_ids: Optional[Iterable[str]] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyResponse: + r"""Update a capacity policy + + 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. + + :param id: Policy ID + :param config: + :param name: Policy name + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param api_key_hashes: Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. + :param is_workspace_default: Omit to keep the stored default status; `false` unsets the policy as the workspace default. + :param member_ids: Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. + :param opted_out_api_key_hashes: API key hashes + :param opted_out_member_ids: Organization member user IDs + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.UpdateCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + update_capacity_guardrail_policy_request=components.UpdateCapacityGuardrailPolicyRequest( + api_key_hashes=utils.unmarshal(api_key_hashes, Optional[List[str]]), + config=utils.get_pydantic_model( + config, components.GuardrailCapacityPolicyConfig + ), + is_workspace_default=is_workspace_default, + member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + name=name, + opted_out_api_key_hashes=utils.unmarshal( + opted_out_api_key_hashes, Optional[List[str]] + ), + opted_out_member_ids=utils.unmarshal( + opted_out_member_ids, Optional[List[str]] + ), + workspace_id=workspace_id, + ), + ) + + req = self._build_request( + method="PUT", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.UpdateCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.update_capacity_guardrail_policy_request, + False, + False, + "json", + components.UpdateCapacityGuardrailPolicyRequest, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="updateCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def update_capacity_policy_async( + self, + *, + id: str, + config: Union[ + components.GuardrailCapacityPolicyConfig, + components.GuardrailCapacityPolicyConfigTypedDict, + ], + name: str, + workspace_id: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + api_key_hashes: Optional[Iterable[str]] = None, + is_workspace_default: Optional[bool] = None, + member_ids: Optional[Iterable[str]] = None, + opted_out_api_key_hashes: Optional[Iterable[str]] = None, + opted_out_member_ids: Optional[Iterable[str]] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CapacityGuardrailPolicyResponse: + r"""Update a capacity policy + + 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. + + :param id: Policy ID + :param config: + :param name: Policy name + :param workspace_id: Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. + :param http_referer: 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. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param api_key_hashes: Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. + :param is_workspace_default: Omit to keep the stored default status; `false` unsets the policy as the workspace default. + :param member_ids: Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. + :param opted_out_api_key_hashes: API key hashes + :param opted_out_member_ids: Organization member user IDs + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.UpdateCapacityPolicyRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + id=id, + update_capacity_guardrail_policy_request=components.UpdateCapacityGuardrailPolicyRequest( + api_key_hashes=utils.unmarshal(api_key_hashes, Optional[List[str]]), + config=utils.get_pydantic_model( + config, components.GuardrailCapacityPolicyConfig + ), + is_workspace_default=is_workspace_default, + member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + name=name, + opted_out_api_key_hashes=utils.unmarshal( + opted_out_api_key_hashes, Optional[List[str]] + ), + opted_out_member_ids=utils.unmarshal( + opted_out_member_ids, Optional[List[str]] + ), + workspace_id=workspace_id, + ), + ) + + req = self._build_request_async( + method="PUT", + path="/guardrails/policies/capacity/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.UpdateCapacityPolicyGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.update_capacity_guardrail_policy_request, + False, + False, + "json", + components.UpdateCapacityGuardrailPolicyRequest, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="updateCapacityPolicy", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Guardrail Policies"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.CapacityGuardrailPolicyResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + def list_model_availability_policies( self, *, @@ -6129,6 +7828,7 @@ def create_model_availability_policy( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -6154,6 +7854,7 @@ def create_model_availability_policy( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -6183,6 +7884,7 @@ def create_model_availability_policy( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] @@ -6316,6 +8018,7 @@ async def create_model_availability_policy_async( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -6341,6 +8044,7 @@ async def create_model_availability_policy_async( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -6370,6 +8074,7 @@ async def create_model_availability_policy_async( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] @@ -7818,6 +9523,7 @@ def create_moderation_policy( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -7843,6 +9549,7 @@ def create_moderation_policy( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -7872,6 +9579,7 @@ def create_moderation_policy( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] @@ -8005,6 +9713,7 @@ async def create_moderation_policy_async( api_key_hashes: Optional[Iterable[str]] = None, is_workspace_default: Optional[bool] = None, member_ids: Optional[Iterable[str]] = None, + move_existing_assignments: Optional[bool] = None, opted_out_api_key_hashes: Optional[Iterable[str]] = None, opted_out_member_ids: Optional[Iterable[str]] = None, workspace_id: Optional[str] = None, @@ -8030,6 +9739,7 @@ async def create_moderation_policy_async( :param api_key_hashes: API key hashes :param is_workspace_default: Make this the workspace default for its policy type. Defaults to `false`. :param member_ids: Organization member user IDs + :param move_existing_assignments: 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`. :param opted_out_api_key_hashes: API keys that should not inherit the policy when it is the workspace default :param opted_out_member_ids: Members that should not inherit the policy when it is the workspace default :param workspace_id: 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. @@ -8059,6 +9769,7 @@ async def create_moderation_policy_async( ), is_workspace_default=is_workspace_default, member_ids=utils.unmarshal(member_ids, Optional[List[str]]), + move_existing_assignments=move_existing_assignments, name=name, opted_out_api_key_hashes=utils.unmarshal( opted_out_api_key_hashes, Optional[List[str]] diff --git a/src/openrouter/operations/__init__.py b/src/openrouter/operations/__init__.py index 22931c7a8..21c692761 100644 --- a/src/openrouter/operations/__init__.py +++ b/src/openrouter/operations/__init__.py @@ -147,6 +147,12 @@ CreateBYOKKeyRequest, CreateBYOKKeyRequestTypedDict, ) + from .createcapacitypolicy import ( + CreateCapacityPolicyGlobals, + CreateCapacityPolicyGlobalsTypedDict, + CreateCapacityPolicyRequest, + CreateCapacityPolicyRequestTypedDict, + ) from .createembeddings import ( Content, ContentImageURL, @@ -367,6 +373,12 @@ DeleteBYOKKeyRequest, DeleteBYOKKeyRequestTypedDict, ) + from .deletecapacitypolicy import ( + DeleteCapacityPolicyGlobals, + DeleteCapacityPolicyGlobalsTypedDict, + DeleteCapacityPolicyRequest, + DeleteCapacityPolicyRequestTypedDict, + ) from .deleteexternaluser import ( DeleteExternalUserGlobals, DeleteExternalUserGlobalsTypedDict, @@ -588,6 +600,12 @@ GetBYOKKeyRequest, GetBYOKKeyRequestTypedDict, ) + from .getcapacitypolicy import ( + GetCapacityPolicyGlobals, + GetCapacityPolicyGlobalsTypedDict, + GetCapacityPolicyRequest, + GetCapacityPolicyRequestTypedDict, + ) from .getcontainerfile import ( GetContainerFileGlobals, GetContainerFileGlobalsTypedDict, @@ -866,6 +884,14 @@ ListBYOKKeysResponseTypedDict, Provider, ) + from .listcapacitypolicies import ( + ListCapacityPoliciesGlobals, + ListCapacityPoliciesGlobalsTypedDict, + ListCapacityPoliciesRequest, + ListCapacityPoliciesRequestTypedDict, + ListCapacityPoliciesResponse, + ListCapacityPoliciesResponseTypedDict, + ) from .listcontainerfiles import ( ListContainerFilesGlobals, ListContainerFilesGlobalsTypedDict, @@ -1280,6 +1306,12 @@ UpdateBYOKKeyRequest, UpdateBYOKKeyRequestTypedDict, ) + from .updatecapacitypolicy import ( + UpdateCapacityPolicyGlobals, + UpdateCapacityPolicyGlobalsTypedDict, + UpdateCapacityPolicyRequest, + UpdateCapacityPolicyRequestTypedDict, + ) from .updateexternaluser import ( UpdateExternalUserGlobals, UpdateExternalUserGlobalsTypedDict, @@ -1500,6 +1532,10 @@ "CreateBudgetPolicyGlobalsTypedDict", "CreateBudgetPolicyRequest", "CreateBudgetPolicyRequestTypedDict", + "CreateCapacityPolicyGlobals", + "CreateCapacityPolicyGlobalsTypedDict", + "CreateCapacityPolicyRequest", + "CreateCapacityPolicyRequestTypedDict", "CreateEmbeddingsData", "CreateEmbeddingsDataTypedDict", "CreateEmbeddingsGlobals", @@ -1638,6 +1674,10 @@ "DeleteBudgetPolicyGlobalsTypedDict", "DeleteBudgetPolicyRequest", "DeleteBudgetPolicyRequestTypedDict", + "DeleteCapacityPolicyGlobals", + "DeleteCapacityPolicyGlobalsTypedDict", + "DeleteCapacityPolicyRequest", + "DeleteCapacityPolicyRequestTypedDict", "DeleteExternalUserGlobals", "DeleteExternalUserGlobalsTypedDict", "DeleteExternalUserRequest", @@ -1798,6 +1838,10 @@ "GetBudgetPolicyGlobalsTypedDict", "GetBudgetPolicyRequest", "GetBudgetPolicyRequestTypedDict", + "GetCapacityPolicyGlobals", + "GetCapacityPolicyGlobalsTypedDict", + "GetCapacityPolicyRequest", + "GetCapacityPolicyRequestTypedDict", "GetContainerFileGlobals", "GetContainerFileGlobalsTypedDict", "GetContainerFileRequest", @@ -1992,6 +2036,12 @@ "ListBudgetPoliciesRequestTypedDict", "ListBudgetPoliciesResponse", "ListBudgetPoliciesResponseTypedDict", + "ListCapacityPoliciesGlobals", + "ListCapacityPoliciesGlobalsTypedDict", + "ListCapacityPoliciesRequest", + "ListCapacityPoliciesRequestTypedDict", + "ListCapacityPoliciesResponse", + "ListCapacityPoliciesResponseTypedDict", "ListContainerFilesGlobals", "ListContainerFilesGlobalsTypedDict", "ListContainerFilesRequest", @@ -2323,6 +2373,10 @@ "UpdateBudgetPolicyGlobalsTypedDict", "UpdateBudgetPolicyRequest", "UpdateBudgetPolicyRequestTypedDict", + "UpdateCapacityPolicyGlobals", + "UpdateCapacityPolicyGlobalsTypedDict", + "UpdateCapacityPolicyRequest", + "UpdateCapacityPolicyRequestTypedDict", "UpdateExternalUserGlobals", "UpdateExternalUserGlobalsTypedDict", "UpdateExternalUserRequest", @@ -2504,6 +2558,10 @@ "CreateBYOKKeyGlobalsTypedDict": ".createbyokkey", "CreateBYOKKeyRequest": ".createbyokkey", "CreateBYOKKeyRequestTypedDict": ".createbyokkey", + "CreateCapacityPolicyGlobals": ".createcapacitypolicy", + "CreateCapacityPolicyGlobalsTypedDict": ".createcapacitypolicy", + "CreateCapacityPolicyRequest": ".createcapacitypolicy", + "CreateCapacityPolicyRequestTypedDict": ".createcapacitypolicy", "Content": ".createembeddings", "ContentImageURL": ".createembeddings", "ContentImageURLTypedDict": ".createembeddings", @@ -2672,6 +2730,10 @@ "DeleteBYOKKeyGlobalsTypedDict": ".deletebyokkey", "DeleteBYOKKeyRequest": ".deletebyokkey", "DeleteBYOKKeyRequestTypedDict": ".deletebyokkey", + "DeleteCapacityPolicyGlobals": ".deletecapacitypolicy", + "DeleteCapacityPolicyGlobalsTypedDict": ".deletecapacitypolicy", + "DeleteCapacityPolicyRequest": ".deletecapacitypolicy", + "DeleteCapacityPolicyRequestTypedDict": ".deletecapacitypolicy", "DeleteExternalUserGlobals": ".deleteexternaluser", "DeleteExternalUserGlobalsTypedDict": ".deleteexternaluser", "DeleteExternalUserRequest": ".deleteexternaluser", @@ -2833,6 +2895,10 @@ "GetBYOKKeyGlobalsTypedDict": ".getbyokkey", "GetBYOKKeyRequest": ".getbyokkey", "GetBYOKKeyRequestTypedDict": ".getbyokkey", + "GetCapacityPolicyGlobals": ".getcapacitypolicy", + "GetCapacityPolicyGlobalsTypedDict": ".getcapacitypolicy", + "GetCapacityPolicyRequest": ".getcapacitypolicy", + "GetCapacityPolicyRequestTypedDict": ".getcapacitypolicy", "GetContainerFileGlobals": ".getcontainerfile", "GetContainerFileGlobalsTypedDict": ".getcontainerfile", "GetContainerFileRequest": ".getcontainerfile", @@ -3037,6 +3103,12 @@ "ListBYOKKeysResponse": ".listbyokkeys", "ListBYOKKeysResponseTypedDict": ".listbyokkeys", "Provider": ".listbyokkeys", + "ListCapacityPoliciesGlobals": ".listcapacitypolicies", + "ListCapacityPoliciesGlobalsTypedDict": ".listcapacitypolicies", + "ListCapacityPoliciesRequest": ".listcapacitypolicies", + "ListCapacityPoliciesRequestTypedDict": ".listcapacitypolicies", + "ListCapacityPoliciesResponse": ".listcapacitypolicies", + "ListCapacityPoliciesResponseTypedDict": ".listcapacitypolicies", "ListContainerFilesGlobals": ".listcontainerfiles", "ListContainerFilesGlobalsTypedDict": ".listcontainerfiles", "ListContainerFilesRequest": ".listcontainerfiles", @@ -3343,6 +3415,10 @@ "UpdateBYOKKeyGlobalsTypedDict": ".updatebyokkey", "UpdateBYOKKeyRequest": ".updatebyokkey", "UpdateBYOKKeyRequestTypedDict": ".updatebyokkey", + "UpdateCapacityPolicyGlobals": ".updatecapacitypolicy", + "UpdateCapacityPolicyGlobalsTypedDict": ".updatecapacitypolicy", + "UpdateCapacityPolicyRequest": ".updatecapacitypolicy", + "UpdateCapacityPolicyRequestTypedDict": ".updatecapacitypolicy", "UpdateExternalUserGlobals": ".updateexternaluser", "UpdateExternalUserGlobalsTypedDict": ".updateexternaluser", "UpdateExternalUserRequest": ".updateexternaluser", diff --git a/src/openrouter/operations/createcapacitypolicy.py b/src/openrouter/operations/createcapacitypolicy.py new file mode 100644 index 000000000..c34b9ff0c --- /dev/null +++ b/src/openrouter/operations/createcapacitypolicy.py @@ -0,0 +1,146 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.components import ( + createcapacityguardrailpolicyrequest as components_createcapacityguardrailpolicyrequest, +) +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import FieldMetadata, HeaderMetadata, RequestMetadata +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class CreateCapacityPolicyGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class CreateCapacityPolicyGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class CreateCapacityPolicyRequestTypedDict(TypedDict): + create_capacity_guardrail_policy_request: components_createcapacityguardrailpolicyrequest.CreateCapacityGuardrailPolicyRequestTypedDict + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class CreateCapacityPolicyRequest(BaseModel): + create_capacity_guardrail_policy_request: Annotated[ + components_createcapacityguardrailpolicyrequest.CreateCapacityGuardrailPolicyRequest, + FieldMetadata(request=RequestMetadata(media_type="application/json")), + ] + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/operations/deletecapacitypolicy.py b/src/openrouter/operations/deletecapacitypolicy.py new file mode 100644 index 000000000..d636f4aed --- /dev/null +++ b/src/openrouter/operations/deletecapacitypolicy.py @@ -0,0 +1,156 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class DeleteCapacityPolicyGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class DeleteCapacityPolicyGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class DeleteCapacityPolicyRequestTypedDict(TypedDict): + id: str + r"""Policy ID""" + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class DeleteCapacityPolicyRequest(BaseModel): + id: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""Policy ID""" + + workspace_id: Annotated[ + str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True)) + ] + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/operations/getapikeypolicyassignment.py b/src/openrouter/operations/getapikeypolicyassignment.py index b4e7379c1..a256ffb16 100644 --- a/src/openrouter/operations/getapikeypolicyassignment.py +++ b/src/openrouter/operations/getapikeypolicyassignment.py @@ -87,14 +87,14 @@ def serialize_model(self, handler): ], UnrecognizedStr, ] -r"""Policy type the assignment is read or changed for""" +r"""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`.""" class GetAPIKeyPolicyAssignmentRequestTypedDict(TypedDict): hash: str r"""API key hash""" policy_type: GetAPIKeyPolicyAssignmentPolicyType - r"""Policy type the assignment is read or changed for""" + r"""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`.""" http_referer: NotRequired[str] r"""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. @@ -122,7 +122,7 @@ class GetAPIKeyPolicyAssignmentRequest(BaseModel): GetAPIKeyPolicyAssignmentPolicyType, FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] - r"""Policy type the assignment is read or changed for""" + r"""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`.""" http_referer: Annotated[ Optional[str], diff --git a/src/openrouter/operations/getcapacitypolicy.py b/src/openrouter/operations/getcapacitypolicy.py new file mode 100644 index 000000000..98ab5f370 --- /dev/null +++ b/src/openrouter/operations/getcapacitypolicy.py @@ -0,0 +1,156 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class GetCapacityPolicyGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class GetCapacityPolicyGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class GetCapacityPolicyRequestTypedDict(TypedDict): + id: str + r"""Policy ID""" + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class GetCapacityPolicyRequest(BaseModel): + id: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""Policy ID""" + + workspace_id: Annotated[ + str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True)) + ] + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/operations/getmemberpolicyassignment.py b/src/openrouter/operations/getmemberpolicyassignment.py index babf428c5..87d40abdc 100644 --- a/src/openrouter/operations/getmemberpolicyassignment.py +++ b/src/openrouter/operations/getmemberpolicyassignment.py @@ -87,14 +87,14 @@ def serialize_model(self, handler): ], UnrecognizedStr, ] -r"""Policy type the assignment is read or changed for""" +r"""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`.""" class GetMemberPolicyAssignmentRequestTypedDict(TypedDict): member_id: str r"""Organization member user ID""" policy_type: GetMemberPolicyAssignmentPolicyType - r"""Policy type the assignment is read or changed for""" + r"""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`.""" http_referer: NotRequired[str] r"""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. @@ -122,7 +122,7 @@ class GetMemberPolicyAssignmentRequest(BaseModel): GetMemberPolicyAssignmentPolicyType, FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] - r"""Policy type the assignment is read or changed for""" + r"""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`.""" http_referer: Annotated[ Optional[str], diff --git a/src/openrouter/operations/listcapacitypolicies.py b/src/openrouter/operations/listcapacitypolicies.py new file mode 100644 index 000000000..580725312 --- /dev/null +++ b/src/openrouter/operations/listcapacitypolicies.py @@ -0,0 +1,182 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.components import ( + listcapacityguardrailpoliciesresponse as components_listcapacityguardrailpoliciesresponse, +) +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import FieldMetadata, HeaderMetadata, QueryParamMetadata +import pydantic +from pydantic import model_serializer +from typing import Awaitable, Callable, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict + + +class ListCapacityPoliciesGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class ListCapacityPoliciesGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class ListCapacityPoliciesRequestTypedDict(TypedDict): + workspace_id: str + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + offset: NotRequired[int] + r"""Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned""" + limit: NotRequired[int] + r"""Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned""" + + +class ListCapacityPoliciesRequest(BaseModel): + workspace_id: Annotated[ + str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True)) + ] + r"""Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key.""" + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + offset: Annotated[ + Optional[int], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned""" + + limit: Annotated[ + Optional[int], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "HTTP-Referer", + "X-OpenRouter-Title", + "X-OpenRouter-Categories", + "offset", + "limit", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class ListCapacityPoliciesResponseTypedDict(TypedDict): + result: components_listcapacityguardrailpoliciesresponse.ListCapacityGuardrailPoliciesResponseTypedDict + + +class ListCapacityPoliciesResponse(BaseModel): + next: Union[ + Callable[[], Optional[ListCapacityPoliciesResponse]], + Callable[[], Awaitable[Optional[ListCapacityPoliciesResponse]]], + ] + + result: components_listcapacityguardrailpoliciesresponse.ListCapacityGuardrailPoliciesResponse diff --git a/src/openrouter/operations/updatecapacitypolicy.py b/src/openrouter/operations/updatecapacitypolicy.py new file mode 100644 index 000000000..e940ef3ca --- /dev/null +++ b/src/openrouter/operations/updatecapacitypolicy.py @@ -0,0 +1,158 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.components import ( + updatecapacityguardrailpolicyrequest as components_updatecapacityguardrailpolicyrequest, +) +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + RequestMetadata, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class UpdateCapacityPolicyGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class UpdateCapacityPolicyGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class UpdateCapacityPolicyRequestTypedDict(TypedDict): + id: str + r"""Policy ID""" + update_capacity_guardrail_policy_request: components_updatecapacityguardrailpolicyrequest.UpdateCapacityGuardrailPolicyRequestTypedDict + http_referer: NotRequired[str] + r"""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. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class UpdateCapacityPolicyRequest(BaseModel): + id: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""Policy ID""" + + update_capacity_guardrail_policy_request: Annotated[ + components_updatecapacityguardrailpolicyrequest.UpdateCapacityGuardrailPolicyRequest, + FieldMetadata(request=RequestMetadata(media_type="application/json")), + ] + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""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. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/private_endpoints.py b/src/openrouter/private_endpoints.py index b5d5df050..6661a4158 100644 --- a/src/openrouter/private_endpoints.py +++ b/src/openrouter/private_endpoints.py @@ -319,7 +319,7 @@ def create( ) -> components.ManagedPrivateEndpointResponse: r"""Create a private endpoint - 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. :param model_permaslug: Permanent slug of the model this endpoint serves. :param provider_slug: Slug of the upstream provider. @@ -540,7 +540,7 @@ async def create_async( ) -> components.ManagedPrivateEndpointResponse: r"""Create a private endpoint - 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. :param model_permaslug: Permanent slug of the model this endpoint serves. :param provider_slug: Slug of the upstream provider. @@ -2713,7 +2713,7 @@ def validate( ) -> components.PrivateEndpointValidationResponse: r"""Validate a draft private endpoint - 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. :param id: Stable identifier of the private endpoint. :param workspace_id: Workspace whose BYOK credential is used for the live validation call. The workspace must belong to your account. @@ -2885,7 +2885,7 @@ async def validate_async( ) -> components.PrivateEndpointValidationResponse: r"""Validate a draft private endpoint - 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. :param id: Stable identifier of the private endpoint. :param workspace_id: Workspace whose BYOK credential is used for the live validation call. The workspace must belong to your account. diff --git a/uv.lock b/uv.lock index e4aa0166a..f2f3e6845 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.234" +version = "1.3.235" source = { editable = "." } dependencies = [ { name = "httpcore" },