From 32d7f01c8914d49c0a2dc77a9c02c2e9d09659c7 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 4 Dec 2026 23:52:52 +0000 Subject: [PATCH] ## Python SDK Changes: * `open_router.analytics.query_analytics()`: `request.api_key_tag_key` **Added** * `open_router.api_keys.list()`: * `request.tag` **Added** * `response.data[].tags` **Added** * `open_router.api_keys.create()`: * `request.tags` **Added** * `response.data.tags` **Added** * `open_router.api_keys.get()`: `response.data.tags` **Added** * `open_router.api_keys.update()`: * `request.tags` **Added** * `response.data.tags` **Added** --- .speakeasy/gen.lock | 132 ++++++++------- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 156 ++++++++++++++++++ .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/operations/createkeysdata.mdx | 1 + docs/operations/createkeysrequestbody.mdx | 21 +-- docs/operations/createkeystagrequest.mdx | 10 ++ docs/operations/createkeystagresponse.mdx | 10 ++ docs/operations/getkeydata.mdx | 1 + docs/operations/getkeytag.mdx | 10 ++ docs/operations/listdata.mdx | 1 + docs/operations/listrequest.mdx | 1 + docs/operations/listtag.mdx | 10 ++ docs/operations/queryanalyticsrequestbody.mdx | 25 +-- docs/operations/updatekeysdata.mdx | 1 + docs/operations/updatekeysrequestbody.mdx | 1 + docs/operations/updatekeystagrequest.mdx | 10 ++ docs/operations/updatekeystagresponse.mdx | 10 ++ docs/sdks/analytics/README.mdx | 33 ++-- docs/sdks/apikeys/README.mdx | 30 ++-- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/analytics.py | 6 + src/openrouter/api_keys.py | 44 ++++- src/openrouter/operations/__init__.py | 36 ++++ src/openrouter/operations/createkeys.py | 78 ++++++++- src/openrouter/operations/getkey.py | 36 +++- src/openrouter/operations/list.py | 43 +++++ src/openrouter/operations/queryanalytics.py | 6 + src/openrouter/operations/updatekeys.py | 78 ++++++++- uv.lock | 2 +- 32 files changed, 698 insertions(+), 124 deletions(-) create mode 100644 docs/operations/createkeystagrequest.mdx create mode 100644 docs/operations/createkeystagresponse.mdx create mode 100644 docs/operations/getkeytag.mdx create mode 100644 docs/operations/listtag.mdx create mode 100644 docs/operations/updatekeystagrequest.mdx create mode 100644 docs/operations/updatekeystagresponse.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index afa69f6fc..7c32b1342 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: 67ee7f2bb1ab5067b2102f459b8f23b2 + docChecksum: 44e816121f7386c21e0c62d08d159a7f docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.247 - configChecksum: d770a14449806169f3e4493a91092c77 + releaseVersion: 1.3.248 + configChecksum: 3b85946ca2851499a18603a125e13ee7 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 88b22f06-3368-4ad9-b495-b74c52e23c98 - pristine_commit_hash: d98558be9ca98e0a0ac811c12dc980692157877f - pristine_tree_hash: 94180302778ea7be1e1ff1513378c1df4ddb3921 + generation_id: 2dce75bd-d14c-435f-9fb6-d0b6378f1073 + pristine_commit_hash: 1ed625264b0ece58a2e21c7aea790df8b1678689 + pristine_tree_hash: c928982858c19ce36478eb05df4806864c5511c2 features: python: acceptHeaders: 3.0.0 @@ -10636,8 +10636,8 @@ trackedFiles: pristine_git_object: 77636052b24b9c8973895543fc9bacebe8459844 docs/operations/createkeysdata.mdx: id: bf8133a06827 - last_write_checksum: sha1:294cc38986802a3b3bc44aacd59491b793a034cf - pristine_git_object: 35d57f21b25c9583aa9c2c2a5990c4019da48d57 + last_write_checksum: sha1:3a6865fe0fd5fed0bc3d7e7dd88e1832f4c91b51 + pristine_git_object: 5ffab101143a6ec931ebd15ad2bbb50b1c7c1d64 docs/operations/createkeysglobals.mdx: id: ebcc738c53da last_write_checksum: sha1:1406d22fde760dc61b74a87cfc1803ad8b34fefd @@ -10652,12 +10652,20 @@ trackedFiles: pristine_git_object: 62eedd2321693acb84070b67518bcf8746e71d25 docs/operations/createkeysrequestbody.mdx: id: 77bb49febf62 - last_write_checksum: sha1:e91ddae31c666733c93c489524f2afbe5c59bea2 - pristine_git_object: cbcf07729178f7e5fa9b4a1c0d8206cfcb3d4fd2 + last_write_checksum: sha1:94cfc49b707801d04fb8561bd90546462681cbe0 + pristine_git_object: d86808ae86493bb9eb48e55fe821cc5bc1196efb docs/operations/createkeysresponse.mdx: id: 08e825fab080 last_write_checksum: sha1:ad171dae3c841d8f21b63a8266c79f22b2d5310c pristine_git_object: f3f11ab333c352305e6b30e417ad2ee7966fb061 + docs/operations/createkeystagrequest.mdx: + id: 09e140aa11da + last_write_checksum: sha1:3752078bc11155b2d55189d51482322ce1f5a606 + pristine_git_object: 92c2ebc14647c3aa88fad2bb813fe098d2af09b8 + docs/operations/createkeystagresponse.mdx: + id: a6b0f7bce57d + last_write_checksum: sha1:e9d9f2ccc810ececb7411bf6c0bf408b1850d71b + pristine_git_object: 49084ac6e1261399cc86b8d0bef778eb8a8a046d docs/operations/createmodelavailabilitypolicyglobals.mdx: id: c33abd60f8a4 last_write_checksum: sha1:de5a9222b8875f9c206f5d29c9c5001d1e5105a4 @@ -11288,8 +11296,8 @@ trackedFiles: pristine_git_object: 2b3ebb518e3369ce403a00708a4d6cbd1dbcea03 docs/operations/getkeydata.mdx: id: 6e826a999e6b - last_write_checksum: sha1:df6135d59bf7656f2e08c84a17928bdb829ae153 - pristine_git_object: 4c8d4969a2ffd8eef09e4cd948b294c408a9f0e0 + last_write_checksum: sha1:1fc464020671f3fc6bcd07dc067538563883cea7 + pristine_git_object: aa91babc230e4d06ee8812204e18a8610ddffcfc docs/operations/getkeyglobals.mdx: id: e0e92d532c82 last_write_checksum: sha1:ca9cdd5ea3986d387b0d44dfd3ecb3120f67a3b8 @@ -11302,6 +11310,10 @@ trackedFiles: id: dd773bd25661 last_write_checksum: sha1:bbfeaf2fc813f60f1ca490b8d09679c10e64ffaf pristine_git_object: 4f5f35a2b8fda85919b260f54de213b6702423ec + docs/operations/getkeytag.mdx: + id: ab3d6a2e5b4f + last_write_checksum: sha1:0d8181d2fab174b529f8430edcdab0d4b288d9bc + pristine_git_object: 64622a142a8c7d616df284973776ccd9f10fcefd docs/operations/getmemberpolicyassignmentglobals.mdx: id: c9b1b164b494 last_write_checksum: sha1:ef6a3b80781308ca0805f5a9517a7937f47386f2 @@ -11640,8 +11652,8 @@ trackedFiles: pristine_git_object: 0be55b6db3088f83f153451eef4e9ff8f445faba docs/operations/listdata.mdx: id: 949d8d9f5ac7 - last_write_checksum: sha1:42b0ebf9a1508cff6213ec48e8051f91b93c125d - pristine_git_object: 97881f159c34693459d28551bbdeac554cf85ff1 + last_write_checksum: sha1:b9bfcbf7cc2e4ab01b0355e79c9ebf51c009adec + pristine_git_object: d15cf0b7f4cfa7a69687f58188d5f85aaef616ee docs/operations/listembeddingsmodelsglobals.mdx: id: b9243861091c last_write_checksum: sha1:22116c5aa7c3f69f05dfb82d98dbd66e53bfd229 @@ -11976,8 +11988,8 @@ trackedFiles: pristine_git_object: df35dcd1bd18f96a586f213c620bbb73197093bf docs/operations/listrequest.mdx: id: 2652e61cd671 - last_write_checksum: sha1:f1ea9b33d6f13334132b5884c82034c9629413f6 - pristine_git_object: 07e9fc86753b564074075a0781dc3acddf03f9ed + last_write_checksum: sha1:0df8427fee6e37350c016769d72402389b3ae1d8 + pristine_git_object: 9833e32eec9f45422fd0e1ab49b5f3a26c934a8a docs/operations/listrerankmodelsglobals.mdx: id: e667ce591912 last_write_checksum: sha1:fc694c61d0bb57cab54a8f04cead1eb740eff6ff @@ -12054,6 +12066,10 @@ trackedFiles: id: 6b0267d50573 last_write_checksum: sha1:3f955fab123e059aed1144343d01e7872f92d860 pristine_git_object: 491e743d69a97bda7428069521f6bfb001d94b6a + docs/operations/listtag.mdx: + id: 66a22206e915 + last_write_checksum: sha1:d407965a8f7f2d97e337ab16fcb474da7587096e + pristine_git_object: 7a78454e986a8f2e654dabec3030ab702f47f33b docs/operations/listtoolsglobals.mdx: id: a03447166c23 last_write_checksum: sha1:77ccb3b0c9aa914fb39c3cd0bb7f4f4b45e59c1e @@ -12200,8 +12216,8 @@ trackedFiles: pristine_git_object: 5111d4142ba2b4e1113f98b47e00d53e77176dd7 docs/operations/queryanalyticsrequestbody.mdx: id: 1b8d33b6ac1b - last_write_checksum: sha1:05657894920bc680a58bc99693c0c1509c431d9b - pristine_git_object: 09d27e7e5cc92be736a3db295a77c417e9b7b682 + last_write_checksum: sha1:e4d9d1afb56ecb2dfd799162413ed7d74e529f7f + pristine_git_object: 798482f5c72e89b5b59fd7f6df9fb3702324db00 docs/operations/queryanalyticsresponse.mdx: id: 26c4b637ce33 last_write_checksum: sha1:df7654f3f2086a50e9f8b56aeb1ba1a54d8c89ef @@ -12356,8 +12372,8 @@ trackedFiles: pristine_git_object: e6d6ae202c4f7a0898897e67eda2fbaa812feef3 docs/operations/updatekeysdata.mdx: id: d398ba596e27 - last_write_checksum: sha1:ab7d11648fc53881b85d9e61f83d192caa451fa4 - pristine_git_object: 8166a750fc861a56a6827b796f6aed6f3b3993a8 + last_write_checksum: sha1:1e02979245da6054e52432d42ebc2758d4e47a58 + pristine_git_object: be6562a8398679f933b2954d6b8b0ba956e73aa2 docs/operations/updatekeysglobals.mdx: id: b28932f180bb last_write_checksum: sha1:287f5ea4fe6dd4824668760663b5ad5eae5e5291 @@ -12372,12 +12388,20 @@ trackedFiles: pristine_git_object: daf63d2d520fa5e00d343cd921e825245e828200 docs/operations/updatekeysrequestbody.mdx: id: dc55066cca3d - last_write_checksum: sha1:500a77b74559aa1d95cff0db67bcfb3149b1ceab - pristine_git_object: 97d7f017e1f476664edd7210ad40ab94cbdecd0b + last_write_checksum: sha1:48bdcce470b456710e33742e57c0a9b48407ffa8 + pristine_git_object: 2dc03917b42753d9c914c4ce44ad03acc2696231 docs/operations/updatekeysresponse.mdx: id: a97d51fea627 last_write_checksum: sha1:44631562c5f1edb827ac0f66d9b2b6974bcab417 pristine_git_object: b644f9bd39777883f9d80ae02a7b4f5398d2338f + docs/operations/updatekeystagrequest.mdx: + id: 4e95860150e3 + last_write_checksum: sha1:7d10a67286ed185a01380de6db6c24ed4b3909b9 + pristine_git_object: 48b0ac966e750be1a82445c65965a5ed5a8b05ca + docs/operations/updatekeystagresponse.mdx: + id: fd0ba91bf245 + last_write_checksum: sha1:53d49b38409e663ae703a3d459c7986586a4751f + pristine_git_object: 6b246ae272a94d922faa4d793f31b933eda8ac60 docs/operations/updatemodelavailabilitypolicyglobals.mdx: id: d5fcd05c75fe last_write_checksum: sha1:af82a2a32ff586c5415bfd4b9a4304ff47d949cd @@ -12504,12 +12528,12 @@ trackedFiles: pristine_git_object: f265978fdb338b412232349476bf1e874833c9f8 docs/sdks/analytics/README.mdx: id: 281aa5320be1 - last_write_checksum: sha1:eac16cb8441e91ae294bbc4c247bfbd80994be8f - pristine_git_object: 6e2f6a9572701eb308dce4cc5ee70c9be044676a + last_write_checksum: sha1:d1658b6666643f190f25b89820134ce4c91a385a + pristine_git_object: 6f54827421d52d6e2395dbe911b24cdb41dac7e9 docs/sdks/apikeys/README.mdx: id: 27fcaae1c346 - last_write_checksum: sha1:3bcc34ec3517f4fbe3eadb65c9ad64a1c55072cb - pristine_git_object: e1c261779c6ccbc2b6cf70738af9bf5b5a9925aa + last_write_checksum: sha1:e1c65bda1cd3fdb42328e4c2de835d0feeb58c43 + pristine_git_object: d4304854d226e88da980c5c4743bc592289d8143 docs/sdks/batch/README.mdx: id: e367aa4f4295 last_write_checksum: sha1:1a1160bdde124e4f3f4d8c4c14448ab3df7f2c77 @@ -12664,8 +12688,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:2c94c3e454f7cf9ff020b6df516dd716f76d50a2 - pristine_git_object: 5525dafe27561ec980a1fbf7846a1918a52edf17 + last_write_checksum: sha1:fd7fe0384911d4eb15199a8261b1db34b4a20af0 + pristine_git_object: 13352aa96fb0d98ff097db96d3d810ebab7b7e08 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -12692,20 +12716,20 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:a2028804657a6d0e3137fe5b25e867782cb630db - pristine_git_object: f68041cee1dd76aaf390da6d91be436023914369 + last_write_checksum: sha1:a69a3e89c74fdf99e249c8784bf55b4ac1be3ac9 + pristine_git_object: 1f21bad301f60965eb2c4828b5298e417eb7c43f src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 pristine_git_object: f512ec0a9dab3feb43c9add635c0a926b7728b2d src/openrouter/analytics.py: id: cb406b5aaabb - last_write_checksum: sha1:0818c3268af317b08a265d0eced9ada614041586 - pristine_git_object: 976e0eb3dd65195d3815078c7db78d2ba03ba2da + last_write_checksum: sha1:0e5c2d755f542442becd3b21c25e31f8690e07ac + pristine_git_object: c8c167da45fec957c76b0a1242b21e8434012b55 src/openrouter/api_keys.py: id: 876fac88fff6 - last_write_checksum: sha1:6b3da9db7e95a73f3cf2abaf4dda5cf711681434 - pristine_git_object: dca0e9844405262a28aa5994a136436c6a1d945a + last_write_checksum: sha1:e340320de33d3173d05aa10bf589ba65233a4191 + pristine_git_object: 08188ee95cebfb093228f2e5e83a8c5a618eddfb src/openrouter/basesdk.py: id: c5733c5a1e12 last_write_checksum: sha1:65769ff2cb5473f85b364c6213a0ddc8c68644ea @@ -17040,8 +17064,8 @@ trackedFiles: pristine_git_object: 039fd484b407d7ca13177a892db5939b312ee50d src/openrouter/operations/__init__.py: id: 9afcea1e7161 - last_write_checksum: sha1:7780af065ff8f0fc52018dc81bcb83553160d107 - pristine_git_object: 21c6927612a5e604142ebf48e9cdc77f250e82f4 + last_write_checksum: sha1:b6ea61b22f3f873d11d819236ce08bb5eee7b356 + pristine_git_object: 53d4d30e23405fa179f6aec3983bca0e24fb8a69 src/openrouter/operations/activateprivateendpoint.py: id: 3b39eec5d66f last_write_checksum: sha1:9406e6b3d38c82895fd795f637702ef579cc6d36 @@ -17148,8 +17172,8 @@ trackedFiles: pristine_git_object: 8216a656ec1412a034878e257bd9de9e94fa8da1 src/openrouter/operations/createkeys.py: id: 64ad31fdaa6c - last_write_checksum: sha1:4e6081b726929446f5edef60bf004d59a402959b - pristine_git_object: 90eeb1bda3f838d8ec2f71df622a0857195f5c62 + last_write_checksum: sha1:4370ffe2aeda35cc0be713c50869c6edf81f7f84 + pristine_git_object: dd410c70b6023cfd12e68e2f66b4b84b2af67b13 src/openrouter/operations/createmodelavailabilitypolicy.py: id: e37901457787 last_write_checksum: sha1:2f023f2efe62eefdbf440cc1e220dd762868bdd6 @@ -17392,8 +17416,8 @@ trackedFiles: pristine_git_object: 3d69c1678d900400234631c4ace61a9f8354efc2 src/openrouter/operations/getkey.py: id: d9769da90865 - last_write_checksum: sha1:8a3f6fc7a11713e3abfcc35c61e5f130bb671daa - pristine_git_object: 25127de14ec0e01f24d9d54523eda65316a8bd3f + last_write_checksum: sha1:2972ada288f49036dd3681f08a994139a253d8e4 + pristine_git_object: 482383b0921633030e05651850aff672de5e36bd src/openrouter/operations/getmemberpolicyassignment.py: id: d2e2fd55dd30 last_write_checksum: sha1:109328270cc3d7f1a4bf2943e20d080a841f1343 @@ -17492,8 +17516,8 @@ trackedFiles: pristine_git_object: 0365c6edd5a01c4086dfcf75d326fb48a67ad9d6 src/openrouter/operations/list.py: id: 3ced31e3804e - last_write_checksum: sha1:b45463528bb90d001ce5190bd5515cb39a82cc2b - pristine_git_object: 0b10172e2947dd223be94056d9c2e50ca9947a49 + last_write_checksum: sha1:ba7e2fbcc812b3c0958d5265d8634f64ee27d3a9 + pristine_git_object: 30fdc9b8b24f0767588770f303f8c405bb557b79 src/openrouter/operations/listaccountpolicies.py: id: 43e7588167c6 last_write_checksum: sha1:b45f72d17215528a2ae562e37ca99826ecea706b @@ -17696,8 +17720,8 @@ trackedFiles: pristine_git_object: 6ab264885a9454b195955adba4b65e01f2abf223 src/openrouter/operations/queryanalytics.py: id: d76c63ff66f6 - last_write_checksum: sha1:7902d3cac3a3efda6358b9d55f633c2820f6c0be - pristine_git_object: ffee192330d5854fb37564c66bf370bb37c8a243 + last_write_checksum: sha1:dfac785a484737359e5fdca7cebe0790c326cc77 + pristine_git_object: f2621a861a9de7ebc1d7ff595ff72b6d285683da src/openrouter/operations/restorepreset.py: id: 60fe5377a465 last_write_checksum: sha1:7d400992c42990fcc106f00c868d647962dabc9f @@ -17744,8 +17768,8 @@ trackedFiles: pristine_git_object: 3787f0ce396fca69bdd7bce99d8054fec4dd23d6 src/openrouter/operations/updatekeys.py: id: 56fb213253a8 - last_write_checksum: sha1:443a3b9075995ba8775808b9fd1caa896fc6da40 - pristine_git_object: c6747043df66ec5f55bce7aab569993d7b632d4d + last_write_checksum: sha1:2c8f6222873370bcf9ee05c54301840ff9cf2a0e + pristine_git_object: 808efa3ba70fad42684f5d92cc4db2f966174220 src/openrouter/operations/updatemodelavailabilitypolicy.py: id: d1b2f4316f03 last_write_checksum: sha1:c778c8d1210644d625357a6782307d772fcbaa46 @@ -18277,7 +18301,7 @@ examples: speakeasy-default-list: responses: "200": - application/json: {"data": [{"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": false, "label": "Production API Key", "last_used_at": "2026-09-15T15:45:00Z", "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "name": "My Production Key", "updated_at": "2025-08-24T15:45:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}]} + application/json: {"data": [{"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": false, "label": "Production API Key", "last_used_at": "2026-09-15T15:45:00Z", "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "name": "My Production Key", "tags": [{"key": "team", "value": "billing"}, {"key": "beta", "value": null}], "updated_at": "2025-08-24T15:45:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}]} "401": application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} "429": @@ -18296,7 +18320,7 @@ examples: application/json: {"name": "My New API Key"} responses: "201": - application/json: {"data": {"byok_usage": 0, "byok_usage_daily": 0, "byok_usage_monthly": 0, "byok_usage_weekly": 0, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": true, "label": "My New API Key", "last_used_at": null, "limit": 50, "limit_remaining": 50, "limit_reset": "monthly", "name": "My New API Key", "updated_at": null, "usage": 0, "usage_daily": 0, "usage_monthly": 0, "usage_weekly": 0, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}, "key": "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"} + application/json: {"data": {"byok_usage": 0, "byok_usage_daily": 0, "byok_usage_monthly": 0, "byok_usage_weekly": 0, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": true, "label": "My New API Key", "last_used_at": null, "limit": 50, "limit_remaining": 50, "limit_reset": "monthly", "name": "My New API Key", "tags": [{"key": "team", "value": "billing"}, {"key": "beta", "value": null}], "updated_at": null, "usage": 0, "usage_daily": 0, "usage_monthly": 0, "usage_weekly": 0, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}, "key": "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"} "400": application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} "401": @@ -18316,7 +18340,7 @@ examples: application/json: {} responses: "200": - application/json: {"data": {"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": true, "label": "Updated API Key Name", "last_used_at": "2026-09-15T15:45:00Z", "limit": 75, "limit_remaining": 32.12, "limit_reset": "daily", "name": "Updated API Key Name", "updated_at": "2025-08-24T16:00:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}} + application/json: {"data": {"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": true, "label": "Updated API Key Name", "last_used_at": "2026-09-15T15:45:00Z", "limit": 75, "limit_remaining": 32.12, "limit_reset": "daily", "name": "Updated API Key Name", "tags": [{"key": "team", "value": "billing"}, {"key": "beta", "value": null}], "updated_at": "2025-08-24T16:00:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}} "400": application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} "401": @@ -18374,7 +18398,7 @@ examples: hash: "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943" responses: "200": - application/json: {"data": {"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": false, "label": "Production API Key", "last_used_at": "2026-09-15T15:45:00Z", "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "name": "My Production Key", "updated_at": "2025-08-24T15:45:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}} + application/json: {"data": {"byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_monthly": 17.38, "byok_usage_weekly": 17.38, "created_at": "2025-08-24T10:30:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "disabled": false, "external_user": null, "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943", "include_byok_in_limit": false, "label": "Production API Key", "last_used_at": "2026-09-15T15:45:00Z", "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "name": "My Production Key", "tags": [{"key": "team", "value": "billing"}, {"key": "beta", "value": null}], "updated_at": "2025-08-24T15:45:00Z", "usage": 25.5, "usage_daily": 25.5, "usage_monthly": 25.5, "usage_weekly": 25.5, "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"}} "401": application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} "404": @@ -23403,10 +23427,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: | - ## Python SDK Changes: - * `open_router.tts.create_speech()`: `request.separate_tracks` **Added** - * `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** - * `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** - * `open_router.images.list_models()`: `response.data[].supported_parameters.Map.union(range)` **Changed** - * `open_router.images.list_model_endpoints()`: `response.endpoints[].supported_parameters.Map.union(range)` **Changed** +releaseNotes: "## Python SDK Changes:\n* `open_router.analytics.query_analytics()`: `request.api_key_tag_key` **Added**\n* `open_router.api_keys.list()`: \n * `request.tag` **Added**\n * `response.data[].tags` **Added**\n* `open_router.api_keys.create()`: \n * `request.tags` **Added**\n * `response.data.tags` **Added**\n* `open_router.api_keys.get()`: `response.data.tags` **Added**\n* `open_router.api_keys.update()`: \n * `request.tags` **Added**\n * `response.data.tags` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 397d706da..e4033d99c 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.247 + version: 1.3.248 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index d767fccef..6bcd7b4b8 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -43686,6 +43686,12 @@ paths: start: '2025-01-01T00:00:00Z' schema: properties: + api_key_tag_key: + description: 'Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each.' + example: 'team' + maxLength: 32 + minLength: 1 + type: 'string' classifier_dimensions: description: 'Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace.' properties: @@ -56182,6 +56188,14 @@ paths: example: '0df9e665-d932-5740-b2c7-b52af166bc11' format: 'uuid' type: 'string' + - description: 'Only return API keys with this tag: `team` matches the tag key with any value, `team:billing` that exact value (case-insensitive).' + in: 'query' + name: 'tag' + required: false + schema: + description: 'Only return API keys with this tag: `team` matches the tag key with any value, `team:billing` that exact value (case-insensitive).' + example: 'team:billing' + type: 'string' - description: 'Only return API keys created by this user ID (the `creator_user_id` on each key). Requires a management key that can view key creators.' in: 'query' name: 'creator_user_id' @@ -56365,6 +56379,30 @@ paths: description: 'Name of the API key' example: 'My Production Key' type: 'string' + tags: + description: 'Custom key-value tags attached to this API key.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + value: null + items: + properties: + key: + description: 'Tag key, as it was entered.' + example: 'team' + type: 'string' + value: + description: 'Tag value, as it was entered, or null when the tag is just a key.' + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + - 'value' + type: 'object' + type: 'array' updated_at: description: 'ISO 8601 timestamp of when the API key was last updated' example: '2025-08-24T15:45:00Z' @@ -56418,6 +56456,7 @@ paths: - 'external_user' - 'creator_user_id' - 'workspace_id' + - 'tags' type: 'object' type: 'array' required: @@ -56579,6 +56618,27 @@ paths: maxLength: 256 minLength: 1 type: 'string' + tags: + description: 'Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain '':''. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + items: + properties: + key: + example: 'team' + type: 'string' + value: + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + type: 'object' + maxItems: 5 + type: 'array' workspace_id: description: 'The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key''s own workspace for a workspace-scoped one, which cannot create keys elsewhere.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' @@ -56763,6 +56823,30 @@ paths: description: 'Name of the API key' example: 'My Production Key' type: 'string' + tags: + description: 'Custom key-value tags attached to this API key.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + value: null + items: + properties: + key: + description: 'Tag key, as it was entered.' + example: 'team' + type: 'string' + value: + description: 'Tag value, as it was entered, or null when the tag is just a key.' + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + - 'value' + type: 'object' + type: 'array' updated_at: description: 'ISO 8601 timestamp of when the API key was last updated' example: '2025-08-24T15:45:00Z' @@ -56816,6 +56900,7 @@ paths: - 'external_user' - 'creator_user_id' - 'workspace_id' + - 'tags' type: 'object' key: description: 'The actual API key string (only shown once)' @@ -57154,6 +57239,30 @@ paths: description: 'Name of the API key' example: 'My Production Key' type: 'string' + tags: + description: 'Custom key-value tags attached to this API key.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + value: null + items: + properties: + key: + description: 'Tag key, as it was entered.' + example: 'team' + type: 'string' + value: + description: 'Tag value, as it was entered, or null when the tag is just a key.' + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + - 'value' + type: 'object' + type: 'array' updated_at: description: 'ISO 8601 timestamp of when the API key was last updated' example: '2025-08-24T15:45:00Z' @@ -57207,6 +57316,7 @@ paths: - 'external_user' - 'creator_user_id' - 'workspace_id' + - 'tags' type: 'object' required: - 'data' @@ -57330,6 +57440,27 @@ paths: maxLength: 256 minLength: 1 type: 'string' + tags: + description: 'Replace the API key''s tags with this set (at most 5). Send an empty array to remove all tags.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + items: + properties: + key: + example: 'team' + type: 'string' + value: + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + type: 'object' + maxItems: 5 + type: 'array' workspace_id: description: 'Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key''s current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key''s current workspace is a no-op.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' @@ -57509,6 +57640,30 @@ paths: description: 'Name of the API key' example: 'My Production Key' type: 'string' + tags: + description: 'Custom key-value tags attached to this API key.' + example: + - key: 'team' + value: 'billing' + - key: 'beta' + value: null + items: + properties: + key: + description: 'Tag key, as it was entered.' + example: 'team' + type: 'string' + value: + description: 'Tag value, as it was entered, or null when the tag is just a key.' + example: 'billing' + type: + - 'string' + - 'null' + required: + - 'key' + - 'value' + type: 'object' + type: 'array' updated_at: description: 'ISO 8601 timestamp of when the API key was last updated' example: '2025-08-24T15:45:00Z' @@ -57562,6 +57717,7 @@ paths: - 'external_user' - 'creator_user_id' - 'workspace_id' + - 'tags' type: 'object' required: - 'data' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 7f751d4d9..cba122ef9 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:f39f4f0a46eaa08d7c1a289caab83ba05e55fbdca9fc5753048d6e651a0834e6 - sourceBlobDigest: sha256:7a247bcaba4521169bc8525cc5dc877135c852bf9abac69c56b54d926d3ed200 + sourceRevisionDigest: sha256:ef54628eec226fb9a27fb9f62f76b00199afae0ccb8cda126c2a3660f18cf07e + sourceBlobDigest: sha256:84db5b4d90dc3fc96f5774ea337beabaca528058d776a084cf8e920aa92d8710 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:f39f4f0a46eaa08d7c1a289caab83ba05e55fbdca9fc5753048d6e651a0834e6 - sourceBlobDigest: sha256:7a247bcaba4521169bc8525cc5dc877135c852bf9abac69c56b54d926d3ed200 + sourceRevisionDigest: sha256:ef54628eec226fb9a27fb9f62f76b00199afae0ccb8cda126c2a3660f18cf07e + sourceBlobDigest: sha256:84db5b4d90dc3fc96f5774ea337beabaca528058d776a084cf8e920aa92d8710 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:d8e5ce41b1cf9732455afc2cd2358680bd51960f4491aff83fcf1b02b68866a3 + codeSamplesRevisionDigest: sha256:133780529bb319337ea0c3509deeb4e5551a755b43cd1e7a343780a3cdeec3e0 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index aa21307ab..20187b4a9 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5239,4 +5239,14 @@ Based on: ### Generated - [python v1.3.247] . ### Releases -- [PyPI v1.3.247] https://pypi.org/project/openrouter/1.3.247 - . \ No newline at end of file +- [PyPI v1.3.247] https://pypi.org/project/openrouter/1.3.247 - . + +## 2026-12-04 23:49:21 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.248] . +### Releases +- [PyPI v1.3.248] https://pypi.org/project/openrouter/1.3.248 - . \ No newline at end of file diff --git a/docs/operations/createkeysdata.mdx b/docs/operations/createkeysdata.mdx index 35d57f21b..5ffab1011 100644 --- a/docs/operations/createkeysdata.mdx +++ b/docs/operations/createkeysdata.mdx @@ -26,6 +26,7 @@ The created API key information | `limit_remaining` | *Nullable[float]* | ✔️ | Remaining spending limit in USD. Credit usage always counts toward `limit`; BYOK usage counts only when `include_byok_in_limit` is true. | 74.5 | | `limit_reset` | *Nullable[str]* | ✔️ | Type of limit reset for the API key | monthly | | `name` | *str* | ✔️ | Name of the API key | My Production Key | +| `tags` | List[[operations.CreateKeysTagResponse](../operations/createkeystagresponse.mdx)] | ✔️ | Custom key-value tags attached to this API key. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta",
"value": null
}
] | | `updated_at` | *Nullable[str]* | ✔️ | ISO 8601 timestamp of when the API key was last updated | 2025-08-24T15:45:00Z | | `usage` | *float* | ✔️ | Total OpenRouter credit usage (in USD) for the API key: the spend allocated to this key, including requests funded from a credit pool. It is not a debit total for the account balance. It excludes external BYOK inference cost, which is reported separately in `byok_usage`, but a BYOK platform fee, where charged, is credit spend and is included here. | 25.5 | | `usage_daily` | *float* | ✔️ | OpenRouter credit usage (in USD) for the current UTC day. Excludes external BYOK inference cost. | 25.5 | diff --git a/docs/operations/createkeysrequestbody.mdx b/docs/operations/createkeysrequestbody.mdx index cbcf07729..d86808ae8 100644 --- a/docs/operations/createkeysrequestbody.mdx +++ b/docs/operations/createkeysrequestbody.mdx @@ -4,13 +4,14 @@ title: "CreateKeysRequestBody" ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `creator_user_id` | *OptionalNullable[str]* | ➖ | Optional user ID of the key creator. Only meaningful for organization-owned keys where a specific member is creating the key. A workspace-scoped management key may only name a member of its own workspace. | user_2dHFtVWx2n56w6HkM0000000000 | -| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ➖ | Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. | 2027-12-31T23:59:59Z | -| `external` | [Optional[operations.External]](../operations/external.mdx) | ➖ | Optional partner-defined identity associated with the created API key. | | -| `include_byok_in_limit` | *Optional[bool]* | ➖ | Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. | true | -| `limit` | *OptionalNullable[float]* | ➖ | Optional spending limit for the API key in USD | 50 | -| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../operations/createkeyslimitreset.mdx) | ➖ | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly | -| `name` | *str* | ✔️ | Name for the new API key | My New API Key | -| `workspace_id` | *Optional[str]* | ➖ | The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `creator_user_id` | *OptionalNullable[str]* | ➖ | Optional user ID of the key creator. Only meaningful for organization-owned keys where a specific member is creating the key. A workspace-scoped management key may only name a member of its own workspace. | user_2dHFtVWx2n56w6HkM0000000000 | +| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ➖ | Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. | 2027-12-31T23:59:59Z | +| `external` | [Optional[operations.External]](../operations/external.mdx) | ➖ | Optional partner-defined identity associated with the created API key. | | +| `include_byok_in_limit` | *Optional[bool]* | ➖ | Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. | true | +| `limit` | *OptionalNullable[float]* | ➖ | Optional spending limit for the API key in USD | 50 | +| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../operations/createkeyslimitreset.mdx) | ➖ | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly | +| `name` | *str* | ✔️ | Name for the new API key | My New API Key | +| `tags` | List[[operations.CreateKeysTagRequest](../operations/createkeystagrequest.mdx)] | ➖ | Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta"
}
] | +| `workspace_id` | *Optional[str]* | ➖ | The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/operations/createkeystagrequest.mdx b/docs/operations/createkeystagrequest.mdx new file mode 100644 index 000000000..92c2ebc14 --- /dev/null +++ b/docs/operations/createkeystagrequest.mdx @@ -0,0 +1,10 @@ +--- +title: "CreateKeysTagRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------- | ----------------------- | ----------------------- | ----------------------- | ----------------------- | +| `key` | *str* | ✔️ | N/A | team | +| `value` | *OptionalNullable[str]* | ➖ | N/A | billing | \ No newline at end of file diff --git a/docs/operations/createkeystagresponse.mdx b/docs/operations/createkeystagresponse.mdx new file mode 100644 index 000000000..49084ac6e --- /dev/null +++ b/docs/operations/createkeystagresponse.mdx @@ -0,0 +1,10 @@ +--- +title: "CreateKeysTagResponse" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `key` | *str* | ✔️ | Tag key, as it was entered. | team | +| `value` | *Nullable[str]* | ✔️ | Tag value, as it was entered, or null when the tag is just a key. | billing | \ No newline at end of file diff --git a/docs/operations/getkeydata.mdx b/docs/operations/getkeydata.mdx index 4c8d4969a..aa91babc2 100644 --- a/docs/operations/getkeydata.mdx +++ b/docs/operations/getkeydata.mdx @@ -26,6 +26,7 @@ The API key information | `limit_remaining` | *Nullable[float]* | ✔️ | Remaining spending limit in USD. Credit usage always counts toward `limit`; BYOK usage counts only when `include_byok_in_limit` is true. | 74.5 | | `limit_reset` | *Nullable[str]* | ✔️ | Type of limit reset for the API key | monthly | | `name` | *str* | ✔️ | Name of the API key | My Production Key | +| `tags` | List[[operations.GetKeyTag](../operations/getkeytag.mdx)] | ✔️ | Custom key-value tags attached to this API key. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta",
"value": null
}
] | | `updated_at` | *Nullable[str]* | ✔️ | ISO 8601 timestamp of when the API key was last updated | 2025-08-24T15:45:00Z | | `usage` | *float* | ✔️ | Total OpenRouter credit usage (in USD) for the API key: the spend allocated to this key, including requests funded from a credit pool. It is not a debit total for the account balance. It excludes external BYOK inference cost, which is reported separately in `byok_usage`, but a BYOK platform fee, where charged, is credit spend and is included here. | 25.5 | | `usage_daily` | *float* | ✔️ | OpenRouter credit usage (in USD) for the current UTC day. Excludes external BYOK inference cost. | 25.5 | diff --git a/docs/operations/getkeytag.mdx b/docs/operations/getkeytag.mdx new file mode 100644 index 000000000..64622a142 --- /dev/null +++ b/docs/operations/getkeytag.mdx @@ -0,0 +1,10 @@ +--- +title: "GetKeyTag" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `key` | *str* | ✔️ | Tag key, as it was entered. | team | +| `value` | *Nullable[str]* | ✔️ | Tag value, as it was entered, or null when the tag is just a key. | billing | \ No newline at end of file diff --git a/docs/operations/listdata.mdx b/docs/operations/listdata.mdx index 97881f159..d15cf0b7f 100644 --- a/docs/operations/listdata.mdx +++ b/docs/operations/listdata.mdx @@ -23,6 +23,7 @@ title: "ListData" | `limit_remaining` | *Nullable[float]* | ✔️ | Remaining spending limit in USD. Credit usage always counts toward `limit`; BYOK usage counts only when `include_byok_in_limit` is true. | 74.5 | | `limit_reset` | *Nullable[str]* | ✔️ | Type of limit reset for the API key | monthly | | `name` | *str* | ✔️ | Name of the API key | My Production Key | +| `tags` | List[[operations.ListTag](../operations/listtag.mdx)] | ✔️ | Custom key-value tags attached to this API key. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta",
"value": null
}
] | | `updated_at` | *Nullable[str]* | ✔️ | ISO 8601 timestamp of when the API key was last updated | 2025-08-24T15:45:00Z | | `usage` | *float* | ✔️ | Total OpenRouter credit usage (in USD) for the API key: the spend allocated to this key, including requests funded from a credit pool. It is not a debit total for the account balance. It excludes external BYOK inference cost, which is reported separately in `byok_usage`, but a BYOK platform fee, where charged, is credit spend and is included here. | 25.5 | | `usage_daily` | *float* | ✔️ | OpenRouter credit usage (in USD) for the current UTC day. Excludes external BYOK inference cost. | 25.5 | diff --git a/docs/operations/listrequest.mdx b/docs/operations/listrequest.mdx index 07e9fc867..9833e32ee 100644 --- a/docs/operations/listrequest.mdx +++ b/docs/operations/listrequest.mdx @@ -13,4 +13,5 @@ title: "ListRequest" | `include_expired` | *Optional[bool]* | ➖ | Whether to include expired API keys in the response. Expired keys are excluded by default and returned only when this is true. | false | | `offset` | *OptionalNullable[int]* | ➖ | Number of API keys to skip for pagination | 0 | | `workspace_id` | *Optional[str]* | ➖ | Filter API keys by workspace ID. By default an organization-scoped management key gets the default workspace; a workspace-scoped management key always gets its own workspace and cannot list another. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `tag` | *Optional[str]* | ➖ | Only return API keys with this tag: `team` matches the tag key with any value, `team:billing` that exact value (case-insensitive). | team:billing | | `creator_user_id` | *Optional[str]* | ➖ | Only return API keys created by this user ID (the `creator_user_id` on each key). Requires a management key that can view key creators. | user_2dHFtVWx2n56w6HkM0000000000 | \ No newline at end of file diff --git a/docs/operations/listtag.mdx b/docs/operations/listtag.mdx new file mode 100644 index 000000000..7a78454e9 --- /dev/null +++ b/docs/operations/listtag.mdx @@ -0,0 +1,10 @@ +--- +title: "ListTag" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `key` | *str* | ✔️ | Tag key, as it was entered. | team | +| `value` | *Nullable[str]* | ✔️ | Tag value, as it was entered, or null when the tag is just a key. | billing | \ No newline at end of file diff --git a/docs/operations/queryanalyticsrequestbody.mdx b/docs/operations/queryanalyticsrequestbody.mdx index 09d27e7e5..798482f5c 100644 --- a/docs/operations/queryanalyticsrequestbody.mdx +++ b/docs/operations/queryanalyticsrequestbody.mdx @@ -4,15 +4,16 @@ title: "QueryAnalyticsRequestBody" ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `classifier_dimensions` | [Optional[operations.ClassifierDimensions]](../operations/classifierdimensions.mdx) | ➖ | Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. | | -| `classifier_filters` | [Optional[operations.ClassifierFilters]](../operations/classifierfilters.mdx) | ➖ | Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. | | -| `dimensions` | List[*str*] | ➖ | N/A | | -| `filters` | List[[components.Filter](../components/filter_.mdx)] | ➖ | N/A | | -| `granularity` | *Optional[str]* | ➖ | Time granularity | day | -| `group_limit` | *Optional[int]* | ➖ | Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified. | 100 | -| `limit` | *Optional[int]* | ➖ | Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations. | | -| `metrics` | List[*str*] | ✔️ | N/A | | -| `order_by` | [Optional[operations.OrderBy]](../operations/orderby.mdx) | ➖ | N/A | | -| `time_range` | [Optional[operations.TimeRange]](../operations/timerange.mdx) | ➖ | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `api_key_tag_key` | *Optional[str]* | ➖ | Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each. | team | +| `classifier_dimensions` | [Optional[operations.ClassifierDimensions]](../operations/classifierdimensions.mdx) | ➖ | Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. | | +| `classifier_filters` | [Optional[operations.ClassifierFilters]](../operations/classifierfilters.mdx) | ➖ | Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. | | +| `dimensions` | List[*str*] | ➖ | N/A | | +| `filters` | List[[components.Filter](../components/filter_.mdx)] | ➖ | N/A | | +| `granularity` | *Optional[str]* | ➖ | Time granularity | day | +| `group_limit` | *Optional[int]* | ➖ | Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified. | 100 | +| `limit` | *Optional[int]* | ➖ | Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations. | | +| `metrics` | List[*str*] | ✔️ | N/A | | +| `order_by` | [Optional[operations.OrderBy]](../operations/orderby.mdx) | ➖ | N/A | | +| `time_range` | [Optional[operations.TimeRange]](../operations/timerange.mdx) | ➖ | N/A | | \ No newline at end of file diff --git a/docs/operations/updatekeysdata.mdx b/docs/operations/updatekeysdata.mdx index 8166a750f..be6562a83 100644 --- a/docs/operations/updatekeysdata.mdx +++ b/docs/operations/updatekeysdata.mdx @@ -26,6 +26,7 @@ The updated API key information | `limit_remaining` | *Nullable[float]* | ✔️ | Remaining spending limit in USD. Credit usage always counts toward `limit`; BYOK usage counts only when `include_byok_in_limit` is true. | 74.5 | | `limit_reset` | *Nullable[str]* | ✔️ | Type of limit reset for the API key | monthly | | `name` | *str* | ✔️ | Name of the API key | My Production Key | +| `tags` | List[[operations.UpdateKeysTagResponse](../operations/updatekeystagresponse.mdx)] | ✔️ | Custom key-value tags attached to this API key. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta",
"value": null
}
] | | `updated_at` | *Nullable[str]* | ✔️ | ISO 8601 timestamp of when the API key was last updated | 2025-08-24T15:45:00Z | | `usage` | *float* | ✔️ | Total OpenRouter credit usage (in USD) for the API key: the spend allocated to this key, including requests funded from a credit pool. It is not a debit total for the account balance. It excludes external BYOK inference cost, which is reported separately in `byok_usage`, but a BYOK platform fee, where charged, is credit spend and is included here. | 25.5 | | `usage_daily` | *float* | ✔️ | OpenRouter credit usage (in USD) for the current UTC day. Excludes external BYOK inference cost. | 25.5 | diff --git a/docs/operations/updatekeysrequestbody.mdx b/docs/operations/updatekeysrequestbody.mdx index 97d7f017e..2dc03917b 100644 --- a/docs/operations/updatekeysrequestbody.mdx +++ b/docs/operations/updatekeysrequestbody.mdx @@ -11,4 +11,5 @@ title: "UpdateKeysRequestBody" | `limit` | *OptionalNullable[float]* | ➖ | New spending limit for the API key in USD | 75 | | `limit_reset` | [OptionalNullable[operations.UpdateKeysLimitReset]](../operations/updatekeyslimitreset.mdx) | ➖ | New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | daily | | `name` | *Optional[str]* | ➖ | New name for the API key | Updated API Key Name | +| `tags` | List[[operations.UpdateKeysTagRequest](../operations/updatekeystagrequest.mdx)] | ➖ | Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta"
}
] | | `workspace_id` | *Optional[str]* | ➖ | Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op. | 0df9e665-d932-5740-b2c7-b52af166bc11 | \ No newline at end of file diff --git a/docs/operations/updatekeystagrequest.mdx b/docs/operations/updatekeystagrequest.mdx new file mode 100644 index 000000000..48b0ac966 --- /dev/null +++ b/docs/operations/updatekeystagrequest.mdx @@ -0,0 +1,10 @@ +--- +title: "UpdateKeysTagRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------- | ----------------------- | ----------------------- | ----------------------- | ----------------------- | +| `key` | *str* | ✔️ | N/A | team | +| `value` | *OptionalNullable[str]* | ➖ | N/A | billing | \ No newline at end of file diff --git a/docs/operations/updatekeystagresponse.mdx b/docs/operations/updatekeystagresponse.mdx new file mode 100644 index 000000000..6b246ae27 --- /dev/null +++ b/docs/operations/updatekeystagresponse.mdx @@ -0,0 +1,10 @@ +--- +title: "UpdateKeysTagResponse" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `key` | *str* | ✔️ | Tag key, as it was entered. | team | +| `value` | *Nullable[str]* | ✔️ | Tag value, as it was entered, or null when the tag is just a key. | billing | \ No newline at end of file diff --git a/docs/sdks/analytics/README.mdx b/docs/sdks/analytics/README.mdx index 6e2f6a957..6f5482742 100644 --- a/docs/sdks/analytics/README.mdx +++ b/docs/sdks/analytics/README.mdx @@ -142,22 +142,23 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `metrics` | List[*str*] | ✔️ | N/A | | -| `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.
| | -| `classifier_dimensions` | [Optional[operations.ClassifierDimensions]](../../operations/classifierdimensions.mdx) | ➖ | Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. | | -| `classifier_filters` | [Optional[operations.ClassifierFilters]](../../operations/classifierfilters.mdx) | ➖ | Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. | | -| `dimensions` | List[*str*] | ➖ | N/A | | -| `filters` | List[[components.Filter](../../components/filter_.mdx)] | ➖ | N/A | | -| `granularity` | *Optional[str]* | ➖ | Time granularity | day | -| `group_limit` | *Optional[int]* | ➖ | Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified. | 100 | -| `limit` | *Optional[int]* | ➖ | Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations. | | -| `order_by` | [Optional[operations.OrderBy]](../../operations/orderby.mdx) | ➖ | N/A | | -| `time_range` | [Optional[operations.TimeRange]](../../operations/timerange.mdx) | ➖ | N/A | | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `metrics` | List[*str*] | ✔️ | N/A | | +| `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_tag_key` | *Optional[str]* | ➖ | Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each. | team | +| `classifier_dimensions` | [Optional[operations.ClassifierDimensions]](../../operations/classifierdimensions.mdx) | ➖ | Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. | | +| `classifier_filters` | [Optional[operations.ClassifierFilters]](../../operations/classifierfilters.mdx) | ➖ | Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. | | +| `dimensions` | List[*str*] | ➖ | N/A | | +| `filters` | List[[components.Filter](../../components/filter_.mdx)] | ➖ | N/A | | +| `granularity` | *Optional[str]* | ➖ | Time granularity | day | +| `group_limit` | *Optional[int]* | ➖ | Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified. | 100 | +| `limit` | *Optional[int]* | ➖ | Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations. | | +| `order_by` | [Optional[operations.OrderBy]](../../operations/orderby.mdx) | ➖ | N/A | | +| `time_range` | [Optional[operations.TimeRange]](../../operations/timerange.mdx) | ➖ | N/A | | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response diff --git a/docs/sdks/apikeys/README.mdx b/docs/sdks/apikeys/README.mdx index e1c261779..d4304854d 100644 --- a/docs/sdks/apikeys/README.mdx +++ b/docs/sdks/apikeys/README.mdx @@ -140,20 +140,21 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `name` | *str* | ✔️ | Name for the new API key | My New API Key | -| `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.
| | -| `creator_user_id` | *OptionalNullable[str]* | ➖ | Optional user ID of the key creator. Only meaningful for organization-owned keys where a specific member is creating the key. A workspace-scoped management key may only name a member of its own workspace. | user_2dHFtVWx2n56w6HkM0000000000 | -| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ➖ | Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. | 2027-12-31T23:59:59Z | -| `external` | [Optional[operations.External]](../../operations/external.mdx) | ➖ | Optional partner-defined identity associated with the created API key. | | -| `include_byok_in_limit` | *Optional[bool]* | ➖ | Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. | true | -| `limit` | *OptionalNullable[float]* | ➖ | Optional spending limit for the API key in USD | 50 | -| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../../operations/createkeyslimitreset.mdx) | ➖ | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly | -| `workspace_id` | *Optional[str]* | ➖ | The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. | 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 | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `name` | *str* | ✔️ | Name for the new API key | My New API Key | +| `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.
| | +| `creator_user_id` | *OptionalNullable[str]* | ➖ | Optional user ID of the key creator. Only meaningful for organization-owned keys where a specific member is creating the key. A workspace-scoped management key may only name a member of its own workspace. | user_2dHFtVWx2n56w6HkM0000000000 | +| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ➖ | Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. | 2027-12-31T23:59:59Z | +| `external` | [Optional[operations.External]](../../operations/external.mdx) | ➖ | Optional partner-defined identity associated with the created API key. | | +| `include_byok_in_limit` | *Optional[bool]* | ➖ | Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. | true | +| `limit` | *OptionalNullable[float]* | ➖ | Optional spending limit for the API key in USD | 50 | +| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../../operations/createkeyslimitreset.mdx) | ➖ | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly | +| `tags` | List[[operations.CreateKeysTagRequest](../../operations/createkeystagrequest.mdx)] | ➖ | Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta"
}
] | +| `workspace_id` | *Optional[str]* | ➖ | The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -334,6 +335,7 @@ with OpenRouter( | `limit` | *OptionalNullable[float]* | ➖ | New spending limit for the API key in USD | 75 | | `limit_reset` | [OptionalNullable[operations.UpdateKeysLimitReset]](../../operations/updatekeyslimitreset.mdx) | ➖ | New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | daily | | `name` | *Optional[str]* | ➖ | New name for the API key | Updated API Key Name | +| `tags` | List[[operations.UpdateKeysTagRequest](../../operations/updatekeystagrequest.mdx)] | ➖ | Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags. | [
\{
"key": "team",
"value": "billing"
},
\{
"key": "beta"
}
] | | `workspace_id` | *Optional[str]* | ➖ | Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op. | 0df9e665-d932-5740-b2c7-b52af166bc11 | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | diff --git a/pyproject.toml b/pyproject.toml index 5525dafe2..13352aa96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.247" +version = "1.3.248" 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 f68041cee..1f21bad30 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.247" +__version__: str = "1.3.248" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.247 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.248 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/analytics.py b/src/openrouter/analytics.py index 976e0eb3d..c8c167da4 100644 --- a/src/openrouter/analytics.py +++ b/src/openrouter/analytics.py @@ -529,6 +529,7 @@ def query_analytics( http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + api_key_tag_key: Optional[str] = None, classifier_dimensions: Optional[ Union[ operations.ClassifierDimensions, @@ -568,6 +569,7 @@ def query_analytics( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param api_key_tag_key: Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each. :param classifier_dimensions: Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. :param classifier_filters: Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. :param dimensions: @@ -597,6 +599,7 @@ def query_analytics( x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, request_body=operations.QueryAnalyticsRequestBody( + api_key_tag_key=api_key_tag_key, classifier_dimensions=utils.get_pydantic_model( classifier_dimensions, Optional[operations.ClassifierDimensions] ), @@ -726,6 +729,7 @@ async def query_analytics_async( http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + api_key_tag_key: Optional[str] = None, classifier_dimensions: Optional[ Union[ operations.ClassifierDimensions, @@ -765,6 +769,7 @@ async def query_analytics_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param api_key_tag_key: Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each. :param classifier_dimensions: Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. :param classifier_filters: Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions. :param dimensions: @@ -794,6 +799,7 @@ async def query_analytics_async( x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, request_body=operations.QueryAnalyticsRequestBody( + api_key_tag_key=api_key_tag_key, classifier_dimensions=utils.get_pydantic_model( classifier_dimensions, Optional[operations.ClassifierDimensions] ), diff --git a/src/openrouter/api_keys.py b/src/openrouter/api_keys.py index dca0e9844..08188ee95 100644 --- a/src/openrouter/api_keys.py +++ b/src/openrouter/api_keys.py @@ -8,7 +8,7 @@ from openrouter.types import BaseModel, OptionalNullable, UNSET from openrouter.utils import get_security_from_env from openrouter.utils.unmarshal_json_response import unmarshal_json_response -from typing import Any, Awaitable, Dict, List, Mapping, Optional, Union, cast +from typing import Any, Awaitable, Dict, Iterable, List, Mapping, Optional, Union, cast class APIKeys(BaseSDK): @@ -361,6 +361,7 @@ def next_func() -> Optional[operations.ListResponse]: include_expired=request.include_expired, offset=next_offset, workspace_id=request.workspace_id, + tag=request.tag, creator_user_id=request.creator_user_id, ), retries=retries, @@ -528,6 +529,7 @@ async def empty_result(): include_expired=request.include_expired, offset=next_offset, workspace_id=request.workspace_id, + tag=request.tag, creator_user_id=request.creator_user_id, ), retries=retries, @@ -600,6 +602,12 @@ def create( include_byok_in_limit: Optional[bool] = None, limit: OptionalNullable[float] = UNSET, limit_reset: OptionalNullable[operations.CreateKeysLimitReset] = UNSET, + tags: Optional[ + Union[ + Iterable[operations.CreateKeysTagRequest], + Iterable[operations.CreateKeysTagRequestTypedDict], + ] + ] = None, workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, @@ -624,6 +632,7 @@ def create( :param include_byok_in_limit: Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. :param limit: Optional spending limit for the API key in USD :param limit_reset: Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. + :param tags: Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has. :param workspace_id: The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method @@ -654,6 +663,9 @@ def create( limit=limit, limit_reset=limit_reset, name=name, + tags=utils.get_pydantic_model( + tags, Optional[List[operations.CreateKeysTagRequest]] + ), workspace_id=workspace_id, ), ) @@ -772,6 +784,12 @@ async def create_async( include_byok_in_limit: Optional[bool] = None, limit: OptionalNullable[float] = UNSET, limit_reset: OptionalNullable[operations.CreateKeysLimitReset] = UNSET, + tags: Optional[ + Union[ + Iterable[operations.CreateKeysTagRequest], + Iterable[operations.CreateKeysTagRequestTypedDict], + ] + ] = None, workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, @@ -796,6 +814,7 @@ async def create_async( :param include_byok_in_limit: Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against `limit`. :param limit: Optional spending limit for the API key in USD :param limit_reset: Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. + :param tags: Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has. :param workspace_id: The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method @@ -826,6 +845,9 @@ async def create_async( limit=limit, limit_reset=limit_reset, name=name, + tags=utils.get_pydantic_model( + tags, Optional[List[operations.CreateKeysTagRequest]] + ), workspace_id=workspace_id, ), ) @@ -1493,6 +1515,12 @@ def update( limit: OptionalNullable[float] = UNSET, limit_reset: OptionalNullable[operations.UpdateKeysLimitReset] = UNSET, name: Optional[str] = None, + tags: Optional[ + Union[ + Iterable[operations.UpdateKeysTagRequest], + Iterable[operations.UpdateKeysTagRequestTypedDict], + ] + ] = None, workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, @@ -1522,6 +1550,7 @@ def update( :param limit: New spending limit for the API key in USD :param limit_reset: New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. :param name: New name for the API key + :param tags: Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags. :param workspace_id: Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method @@ -1549,6 +1578,9 @@ def update( limit=limit, limit_reset=limit_reset, name=name, + tags=utils.get_pydantic_model( + tags, Optional[List[operations.UpdateKeysTagRequest]] + ), workspace_id=workspace_id, ), ) @@ -1674,6 +1706,12 @@ async def update_async( limit: OptionalNullable[float] = UNSET, limit_reset: OptionalNullable[operations.UpdateKeysLimitReset] = UNSET, name: Optional[str] = None, + tags: Optional[ + Union[ + Iterable[operations.UpdateKeysTagRequest], + Iterable[operations.UpdateKeysTagRequestTypedDict], + ] + ] = None, workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, @@ -1703,6 +1741,7 @@ async def update_async( :param limit: New spending limit for the API key in USD :param limit_reset: New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. :param name: New name for the API key + :param tags: Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags. :param workspace_id: Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method @@ -1730,6 +1769,9 @@ async def update_async( limit=limit, limit_reset=limit_reset, name=name, + tags=utils.get_pydantic_model( + tags, Optional[List[operations.UpdateKeysTagRequest]] + ), workspace_id=workspace_id, ), ) diff --git a/src/openrouter/operations/__init__.py b/src/openrouter/operations/__init__.py index 21c692761..53d4d30e2 100644 --- a/src/openrouter/operations/__init__.py +++ b/src/openrouter/operations/__init__.py @@ -222,6 +222,10 @@ CreateKeysRequestTypedDict, CreateKeysResponse, CreateKeysResponseTypedDict, + CreateKeysTagRequest, + CreateKeysTagRequestTypedDict, + CreateKeysTagResponse, + CreateKeysTagResponseTypedDict, External, ExternalTypedDict, ) @@ -668,6 +672,8 @@ GetKeyRequestTypedDict, GetKeyResponse, GetKeyResponseTypedDict, + GetKeyTag, + GetKeyTagTypedDict, ) from .getmemberpolicyassignment import ( GetMemberPolicyAssignmentGlobals, @@ -850,6 +856,8 @@ ListResponseBody, ListResponseBodyTypedDict, ListResponseTypedDict, + ListTag, + ListTagTypedDict, ) from .listaccountpolicies import ( ListAccountPoliciesGlobals, @@ -1336,6 +1344,10 @@ UpdateKeysRequestTypedDict, UpdateKeysResponse, UpdateKeysResponseTypedDict, + UpdateKeysTagRequest, + UpdateKeysTagRequestTypedDict, + UpdateKeysTagResponse, + UpdateKeysTagResponseTypedDict, ) from .updatemodelavailabilitypolicy import ( UpdateModelAvailabilityPolicyGlobals, @@ -1575,6 +1587,10 @@ "CreateKeysRequestTypedDict", "CreateKeysResponse", "CreateKeysResponseTypedDict", + "CreateKeysTagRequest", + "CreateKeysTagRequestTypedDict", + "CreateKeysTagResponse", + "CreateKeysTagResponseTypedDict", "CreateModelAvailabilityPolicyGlobals", "CreateModelAvailabilityPolicyGlobalsTypedDict", "CreateModelAvailabilityPolicyRequest", @@ -1886,6 +1902,8 @@ "GetKeyRequestTypedDict", "GetKeyResponse", "GetKeyResponseTypedDict", + "GetKeyTag", + "GetKeyTagTypedDict", "GetMemberPolicyAssignmentGlobals", "GetMemberPolicyAssignmentGlobalsTypedDict", "GetMemberPolicyAssignmentPolicyType", @@ -2253,6 +2271,8 @@ "ListSpeechModelsGlobalsTypedDict", "ListSpeechModelsRequest", "ListSpeechModelsRequestTypedDict", + "ListTag", + "ListTagTypedDict", "ListToolsGlobals", "ListToolsGlobalsTypedDict", "ListToolsRequest", @@ -2396,6 +2416,10 @@ "UpdateKeysRequestTypedDict", "UpdateKeysResponse", "UpdateKeysResponseTypedDict", + "UpdateKeysTagRequest", + "UpdateKeysTagRequestTypedDict", + "UpdateKeysTagResponse", + "UpdateKeysTagResponseTypedDict", "UpdateModelAvailabilityPolicyGlobals", "UpdateModelAvailabilityPolicyGlobalsTypedDict", "UpdateModelAvailabilityPolicyRequest", @@ -2622,6 +2646,10 @@ "CreateKeysRequestTypedDict": ".createkeys", "CreateKeysResponse": ".createkeys", "CreateKeysResponseTypedDict": ".createkeys", + "CreateKeysTagRequest": ".createkeys", + "CreateKeysTagRequestTypedDict": ".createkeys", + "CreateKeysTagResponse": ".createkeys", + "CreateKeysTagResponseTypedDict": ".createkeys", "External": ".createkeys", "ExternalTypedDict": ".createkeys", "CreateModelAvailabilityPolicyGlobals": ".createmodelavailabilitypolicy", @@ -2946,6 +2974,8 @@ "GetKeyRequestTypedDict": ".getkey", "GetKeyResponse": ".getkey", "GetKeyResponseTypedDict": ".getkey", + "GetKeyTag": ".getkey", + "GetKeyTagTypedDict": ".getkey", "GetMemberPolicyAssignmentGlobals": ".getmemberpolicyassignment", "GetMemberPolicyAssignmentGlobalsTypedDict": ".getmemberpolicyassignment", "GetMemberPolicyAssignmentPolicyType": ".getmemberpolicyassignment", @@ -3078,6 +3108,8 @@ "ListResponseBody": ".list", "ListResponseBodyTypedDict": ".list", "ListResponseTypedDict": ".list", + "ListTag": ".list", + "ListTagTypedDict": ".list", "ListAccountPoliciesGlobals": ".listaccountpolicies", "ListAccountPoliciesGlobalsTypedDict": ".listaccountpolicies", "ListAccountPoliciesRequest": ".listaccountpolicies", @@ -3438,6 +3470,10 @@ "UpdateKeysRequestTypedDict": ".updatekeys", "UpdateKeysResponse": ".updatekeys", "UpdateKeysResponseTypedDict": ".updatekeys", + "UpdateKeysTagRequest": ".updatekeys", + "UpdateKeysTagRequestTypedDict": ".updatekeys", + "UpdateKeysTagResponse": ".updatekeys", + "UpdateKeysTagResponseTypedDict": ".updatekeys", "UpdateModelAvailabilityPolicyGlobals": ".updatemodelavailabilitypolicy", "UpdateModelAvailabilityPolicyGlobalsTypedDict": ".updatemodelavailabilitypolicy", "UpdateModelAvailabilityPolicyRequest": ".updatemodelavailabilitypolicy", diff --git a/src/openrouter/operations/createkeys.py b/src/openrouter/operations/createkeys.py index 90eeb1bda..dd410c70b 100644 --- a/src/openrouter/operations/createkeys.py +++ b/src/openrouter/operations/createkeys.py @@ -13,7 +13,7 @@ from openrouter.utils import FieldMetadata, HeaderMetadata, RequestMetadata import pydantic from pydantic import model_serializer -from typing import Literal, Optional, Union +from typing import List, Literal, Optional, Union from typing_extensions import Annotated, NotRequired, TypedDict @@ -127,6 +127,42 @@ def serialize_model(self, handler): r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.""" +class CreateKeysTagRequestTypedDict(TypedDict): + key: str + value: NotRequired[Nullable[str]] + + +class CreateKeysTagRequest(BaseModel): + key: str + + value: OptionalNullable[str] = UNSET + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["value"]) + nullable_fields = set(["value"]) + 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 + + class CreateKeysRequestBodyTypedDict(TypedDict): name: str r"""Name for the new API key""" @@ -142,6 +178,8 @@ class CreateKeysRequestBodyTypedDict(TypedDict): r"""Optional spending limit for the API key in USD""" limit_reset: NotRequired[Nullable[CreateKeysLimitReset]] r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.""" + tags: NotRequired[List[CreateKeysTagRequestTypedDict]] + r"""Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has.""" workspace_id: NotRequired[str] r"""The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere.""" @@ -168,6 +206,9 @@ class CreateKeysRequestBody(BaseModel): limit_reset: OptionalNullable[CreateKeysLimitReset] = UNSET r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.""" + tags: Optional[List[CreateKeysTagRequest]] = None + r"""Custom key-value tags for the API key (at most 5, each tag key at most once). Keys are 1-32 characters of letters, numbers, spaces and - _ . /; the optional value is 1-64 characters and may also contain ':'. Matching is case-insensitive. Your plan limits how many distinct tag keys your account uses and how many distinct values each key has.""" + workspace_id: Optional[str] = None r"""The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere.""" @@ -181,6 +222,7 @@ def serialize_model(self, handler): "include_byok_in_limit", "limit", "limit_reset", + "tags", "workspace_id", ] ) @@ -277,6 +319,35 @@ def serialize_model(self, handler): return m +class CreateKeysTagResponseTypedDict(TypedDict): + key: str + r"""Tag key, as it was entered.""" + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + +class CreateKeysTagResponse(BaseModel): + key: str + r"""Tag key, as it was entered.""" + + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + 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: + m[k] = val + + return m + + class CreateKeysDataTypedDict(TypedDict): r"""The created API key information""" @@ -312,6 +383,8 @@ class CreateKeysDataTypedDict(TypedDict): r"""Type of limit reset for the API key""" name: str r"""Name of the API key""" + tags: List[CreateKeysTagResponseTypedDict] + r"""Custom key-value tags attached to this API key.""" updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" usage: float @@ -379,6 +452,9 @@ class CreateKeysData(BaseModel): name: str r"""Name of the API key""" + tags: List[CreateKeysTagResponse] + r"""Custom key-value tags attached to this API key.""" + updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" diff --git a/src/openrouter/operations/getkey.py b/src/openrouter/operations/getkey.py index 25127de14..482383b09 100644 --- a/src/openrouter/operations/getkey.py +++ b/src/openrouter/operations/getkey.py @@ -12,7 +12,7 @@ from openrouter.utils import FieldMetadata, HeaderMetadata, PathParamMetadata import pydantic from pydantic import model_serializer -from typing import Optional +from typing import List, Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -151,6 +151,35 @@ def serialize_model(self, handler): return m +class GetKeyTagTypedDict(TypedDict): + key: str + r"""Tag key, as it was entered.""" + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + +class GetKeyTag(BaseModel): + key: str + r"""Tag key, as it was entered.""" + + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + 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: + m[k] = val + + return m + + class GetKeyDataTypedDict(TypedDict): r"""The API key information""" @@ -186,6 +215,8 @@ class GetKeyDataTypedDict(TypedDict): r"""Type of limit reset for the API key""" name: str r"""Name of the API key""" + tags: List[GetKeyTagTypedDict] + r"""Custom key-value tags attached to this API key.""" updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" usage: float @@ -253,6 +284,9 @@ class GetKeyData(BaseModel): name: str r"""Name of the API key""" + tags: List[GetKeyTag] + r"""Custom key-value tags attached to this API key.""" + updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" diff --git a/src/openrouter/operations/list.py b/src/openrouter/operations/list.py index 0b10172e2..30fdc9b8b 100644 --- a/src/openrouter/operations/list.py +++ b/src/openrouter/operations/list.py @@ -102,6 +102,8 @@ class ListRequestTypedDict(TypedDict): r"""Number of API keys to skip for pagination""" workspace_id: NotRequired[str] r"""Filter API keys by workspace ID. By default an organization-scoped management key gets the default workspace; a workspace-scoped management key always gets its own workspace and cannot list another.""" + tag: NotRequired[str] + r"""Only return API keys with this tag: `team` matches the tag key with any value, `team:billing` that exact value (case-insensitive).""" creator_user_id: NotRequired[str] r"""Only return API keys created by this user ID (the `creator_user_id` on each key). Requires a management key that can view key creators.""" @@ -159,6 +161,12 @@ class ListRequest(BaseModel): ] = None r"""Filter API keys by workspace ID. By default an organization-scoped management key gets the default workspace; a workspace-scoped management key always gets its own workspace and cannot list another.""" + tag: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Only return API keys with this tag: `team` matches the tag key with any value, `team:billing` that exact value (case-insensitive).""" + creator_user_id: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), @@ -176,6 +184,7 @@ def serialize_model(self, handler): "include_expired", "offset", "workspace_id", + "tag", "creator_user_id", ] ) @@ -202,6 +211,35 @@ def serialize_model(self, handler): return m +class ListTagTypedDict(TypedDict): + key: str + r"""Tag key, as it was entered.""" + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + +class ListTag(BaseModel): + key: str + r"""Tag key, as it was entered.""" + + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + 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: + m[k] = val + + return m + + class ListDataTypedDict(TypedDict): byok_usage: float r"""Total external BYOK usage (in USD) for the API key. This is the inference cost OpenRouter records for requests served through your own provider keys, computed from token counts and configured prices, not the amount your provider invoices you. It is not included in the `usage*` fields.""" @@ -235,6 +273,8 @@ class ListDataTypedDict(TypedDict): r"""Type of limit reset for the API key""" name: str r"""Name of the API key""" + tags: List[ListTagTypedDict] + r"""Custom key-value tags attached to this API key.""" updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" usage: float @@ -300,6 +340,9 @@ class ListData(BaseModel): name: str r"""Name of the API key""" + tags: List[ListTag] + r"""Custom key-value tags attached to this API key.""" + updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" diff --git a/src/openrouter/operations/queryanalytics.py b/src/openrouter/operations/queryanalytics.py index ffee19233..f2621a861 100644 --- a/src/openrouter/operations/queryanalytics.py +++ b/src/openrouter/operations/queryanalytics.py @@ -172,6 +172,8 @@ class TimeRange(BaseModel): class QueryAnalyticsRequestBodyTypedDict(TypedDict): metrics: List[str] + api_key_tag_key: NotRequired[str] + r"""Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each.""" classifier_dimensions: NotRequired[ClassifierDimensionsTypedDict] r"""Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace.""" classifier_filters: NotRequired[ClassifierFiltersTypedDict] @@ -191,6 +193,9 @@ class QueryAnalyticsRequestBodyTypedDict(TypedDict): class QueryAnalyticsRequestBody(BaseModel): metrics: List[str] + api_key_tag_key: Optional[str] = None + r"""Tag key to group by when `dimensions` includes `api_key_tag`, e.g. `team`. Each API key has at most one value per tag key, so groups do not overlap: keys with the tag group under its value, and keys with the tag but no value under the key name. Keys without the tag are left out of the results. Without this field, each `key:value` tag is its own group and a key with several tags counts toward each.""" + classifier_dimensions: Optional[ClassifierDimensions] = None r"""Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace.""" @@ -218,6 +223,7 @@ class QueryAnalyticsRequestBody(BaseModel): def serialize_model(self, handler): optional_fields = set( [ + "api_key_tag_key", "classifier_dimensions", "classifier_filters", "dimensions", diff --git a/src/openrouter/operations/updatekeys.py b/src/openrouter/operations/updatekeys.py index c6747043d..808efa3ba 100644 --- a/src/openrouter/operations/updatekeys.py +++ b/src/openrouter/operations/updatekeys.py @@ -18,7 +18,7 @@ ) import pydantic from pydantic import model_serializer -from typing import Literal, Optional, Union +from typing import List, Literal, Optional, Union from typing_extensions import Annotated, NotRequired, TypedDict @@ -97,6 +97,42 @@ def serialize_model(self, handler): r"""New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.""" +class UpdateKeysTagRequestTypedDict(TypedDict): + key: str + value: NotRequired[Nullable[str]] + + +class UpdateKeysTagRequest(BaseModel): + key: str + + value: OptionalNullable[str] = UNSET + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["value"]) + nullable_fields = set(["value"]) + 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 + + class UpdateKeysRequestBodyTypedDict(TypedDict): disabled: NotRequired[bool] r"""Whether to disable the API key""" @@ -108,6 +144,8 @@ class UpdateKeysRequestBodyTypedDict(TypedDict): r"""New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.""" name: NotRequired[str] r"""New name for the API key""" + tags: NotRequired[List[UpdateKeysTagRequestTypedDict]] + r"""Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags.""" workspace_id: NotRequired[str] r"""Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op.""" @@ -128,6 +166,9 @@ class UpdateKeysRequestBody(BaseModel): name: Optional[str] = None r"""New name for the API key""" + tags: Optional[List[UpdateKeysTagRequest]] = None + r"""Replace the API key's tags with this set (at most 5). Send an empty array to remove all tags.""" + workspace_id: Optional[str] = None r"""Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op.""" @@ -140,6 +181,7 @@ def serialize_model(self, handler): "limit", "limit_reset", "name", + "tags", "workspace_id", ] ) @@ -243,6 +285,35 @@ def serialize_model(self, handler): return m +class UpdateKeysTagResponseTypedDict(TypedDict): + key: str + r"""Tag key, as it was entered.""" + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + +class UpdateKeysTagResponse(BaseModel): + key: str + r"""Tag key, as it was entered.""" + + value: Nullable[str] + r"""Tag value, as it was entered, or null when the tag is just a key.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + 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: + m[k] = val + + return m + + class UpdateKeysDataTypedDict(TypedDict): r"""The updated API key information""" @@ -278,6 +349,8 @@ class UpdateKeysDataTypedDict(TypedDict): r"""Type of limit reset for the API key""" name: str r"""Name of the API key""" + tags: List[UpdateKeysTagResponseTypedDict] + r"""Custom key-value tags attached to this API key.""" updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" usage: float @@ -345,6 +418,9 @@ class UpdateKeysData(BaseModel): name: str r"""Name of the API key""" + tags: List[UpdateKeysTagResponse] + r"""Custom key-value tags attached to this API key.""" + updated_at: Nullable[str] r"""ISO 8601 timestamp of when the API key was last updated""" diff --git a/uv.lock b/uv.lock index 09fc2f96d..513611560 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.247" +version = "1.3.248" source = { editable = "." } dependencies = [ { name = "httpcore" },