From 2f91fced557af8df22b6e4f404b005657b8e2236 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Mon, 9 Nov 2026 23:06:18 +0000 Subject: [PATCH 1/2] ## Python SDK Changes: * `open_router.presets.delete()`: **Added** * `open_router.presets.restore()`: **Added** * `open_router.presets.list()`: * `request.workspace_id` **Added** * `error.status[404]` **Added** * `open_router.presets.get()`: `request.workspace_id` **Added** * `open_router.presets.list_versions()`: `request.workspace_id` **Added** * `open_router.presets.get_version()`: `request.workspace_id` **Added** --- .speakeasy/gen.lock | 175 +- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 257 ++- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/components/deferredbm25search.mdx | 14 +- docs/components/deferredregexsearch.mdx | 12 +- .../createpresetschatcompletionsrequest.mdx | 2 +- .../createpresetsmessagesrequest.mdx | 16 +- .../createpresetsresponsesrequest.mdx | 2 +- docs/operations/deletepresetglobals.mdx | 11 + docs/operations/deletepresetrequest.mdx | 13 + docs/operations/getpresetrequest.mdx | 13 +- docs/operations/getpresetversionrequest.mdx | 15 +- docs/operations/listpresetsrequest.mdx | 15 +- docs/operations/listpresetversionsrequest.mdx | 17 +- docs/operations/restorepresetglobals.mdx | 11 + docs/operations/restorepresetrequest.mdx | 13 + docs/sdks/presets/README.mdx | 181 +- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- .../components/deferredbm25search.py | 4 +- .../components/deferredregexsearch.py | 4 +- src/openrouter/operations/__init__.py | 28 + .../createpresetschatcompletions.py | 4 +- .../operations/createpresetsmessages.py | 4 +- .../operations/createpresetsresponses.py | 4 +- src/openrouter/operations/deletepreset.py | 162 ++ src/openrouter/operations/getpreset.py | 22 +- src/openrouter/operations/getpresetversion.py | 22 +- src/openrouter/operations/listpresets.py | 9 + .../operations/listpresetversions.py | 9 + src/openrouter/operations/restorepreset.py | 162 ++ src/openrouter/presets.py | 2002 +++++++++++------ uv.lock | 2 +- 35 files changed, 2376 insertions(+), 859 deletions(-) create mode 100644 docs/operations/deletepresetglobals.mdx create mode 100644 docs/operations/deletepresetrequest.mdx create mode 100644 docs/operations/restorepresetglobals.mdx create mode 100644 docs/operations/restorepresetrequest.mdx create mode 100644 src/openrouter/operations/deletepreset.py create mode 100644 src/openrouter/operations/restorepreset.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 41670ddde..b9e75efd1 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: f9ef0523e69556d771c8c6cdab2acf29 + docChecksum: 6690c5e4056ba9157a21c7b63f3b75be docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.145 - configChecksum: 36b7e3c798da97c3b07ec53054b10538 + releaseVersion: 1.3.146 + configChecksum: 99c4be4baae50bfee64dfbb81b0761f9 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 168fe494-2f39-4515-9344-286669084364 - pristine_commit_hash: 435f652f58d934d058272e252b2f706455c7624c - pristine_tree_hash: 1ec4b776174096a5c317de0f655900dd9c705658 + generation_id: e1eb6ff3-32c3-4af7-812d-5efa0d14c98a + pristine_commit_hash: fd56fd103b44ef129d685b2c70911ea91c4ecbc5 + pristine_tree_hash: 03fe43c339dfc26da730cef242298fb63e56b90b features: python: acceptHeaders: 3.0.0 @@ -3132,8 +3132,8 @@ trackedFiles: pristine_git_object: 78c74a24e624245cbbfe2f989c4301442bbb5fee docs/components/deferredbm25search.mdx: id: 28b5539be31d - last_write_checksum: sha1:738c355d3c517649ef2fe2882775aae25e210e04 - pristine_git_object: f9e7fee3c75a43014fe085f18c61672eb3e398af + last_write_checksum: sha1:ccd7ad596354d8e93a31ae9ad0d10b7671e030a0 + pristine_git_object: 8ddc1ff9d98774d1a3fca11c51d1ccac86306e7e docs/components/deferredbm25searchtype.mdx: id: 7c08005a05ac last_write_checksum: sha1:4c12129e0ab52db31056314a17628cbfedb600b8 @@ -3148,8 +3148,8 @@ trackedFiles: pristine_git_object: 8accaf302940a8ab39f159badc6daccad7fddd75 docs/components/deferredregexsearch.mdx: id: 8b88be545243 - last_write_checksum: sha1:74034ff60550e5a9da3746e63aef9a36163d4064 - pristine_git_object: 6b387eac8ed1c8a6f9ebaa86ad1028acf5800e46 + last_write_checksum: sha1:f63cdbc1da0481f3a1578af55799f4901137d8f7 + pristine_git_object: 54b082bc0e5e5f58bce738e11d31153beafab469 docs/components/deferredregexsearchtype.mdx: id: bcec87810dd1 last_write_checksum: sha1:59b772e53fc1109c2cc4f42f4cf21405c35830a6 @@ -9780,24 +9780,24 @@ trackedFiles: pristine_git_object: f6af0e4e21faac835e366abd424eda79974aaf57 docs/operations/createpresetschatcompletionsrequest.mdx: id: 39f1178223c5 - last_write_checksum: sha1:7aaa6e517356a8db5cd7f06ea1a53708ff8ef402 - pristine_git_object: 6c49b8fd1b0e1e040f36e1627ec989013428c0c0 + last_write_checksum: sha1:0d0426b18c77b744899d87a87606f76514a66321 + pristine_git_object: b525012c1da008be2c4271fc024985d400640c82 docs/operations/createpresetsmessagesglobals.mdx: id: 3480905d3f56 last_write_checksum: sha1:38818aaa22cff31c5832e2cb726ca06a0ff456cf pristine_git_object: 49374471b605acda0e35f52a432693a7a70743f7 docs/operations/createpresetsmessagesrequest.mdx: id: fb3300b6e323 - last_write_checksum: sha1:5521ab909f1df1a0910823bc60708eab20469273 - pristine_git_object: b9b3de1c8f9d8a8e98b1639c7601a5fd5e885d71 + last_write_checksum: sha1:55ffd25a8a2f4a408675585840c86164f58a4978 + pristine_git_object: d6390732abb855bb2cf5b13ff85a8fde59d036fb docs/operations/createpresetsresponsesglobals.mdx: id: 88e0cbfc3d73 last_write_checksum: sha1:015bc5b26913801ad7b8d228d0307549551c1d1f pristine_git_object: f410ec4d4dbf3768da9a1cb68c3489a40abee2b4 docs/operations/createpresetsresponsesrequest.mdx: id: 6f3505cc8829 - last_write_checksum: sha1:90eec9d99e4a3b596d6312cf6a7092433ebf3704 - pristine_git_object: 7455c712d8ea0139fe58d49b21d438db1a9ef242 + last_write_checksum: sha1:77673e5ae23832c0cc23f7cb6d53da917ba8d6d5 + pristine_git_object: d5681880800bdf252584b5c61b73680898cc4c0f docs/operations/createprivateendpointglobals.mdx: id: b0efb5dcb7f7 last_write_checksum: sha1:fddea5dbb750e51aa56c3c0b4a7b014b8f6d75ae @@ -10002,6 +10002,14 @@ trackedFiles: id: 86192950ff34 last_write_checksum: sha1:e39618604d212e664bfde11dad67cca222d48d78 pristine_git_object: 31956a5376e07e32ede9eac4e379848fa4bc872a + docs/operations/deletepresetglobals.mdx: + id: ac2642f45615 + last_write_checksum: sha1:44e219a3e11b3c50e0af1f120dbe439de58b69fd + pristine_git_object: 945193d212860b05eee4d26ddca0dc6a08b69a5f + docs/operations/deletepresetrequest.mdx: + id: d068931238a3 + last_write_checksum: sha1:664c8d246629a6065e5cc0eb86af5b40e248b327 + pristine_git_object: dbda91ee2cca436ac8b53ef97e1f95931b38b5da docs/operations/deleteprivateendpointglobals.mdx: id: 19a0cf7a5211 last_write_checksum: sha1:c9438b4301337428995ec5dac508be040b84c528 @@ -10404,16 +10412,16 @@ trackedFiles: pristine_git_object: e1a943be034984f51a31600888108b1904079196 docs/operations/getpresetrequest.mdx: id: 88368deaa06d - last_write_checksum: sha1:589b67c60ea08af125c47ac4d526beecea0bf813 - pristine_git_object: a01071730b29696e16e43440296091272c29168c + last_write_checksum: sha1:a669765b521b9133fb20504cf3d22eb45cd4c5cd + pristine_git_object: 37799222d6f60ee42f2be099f175c923c065e4fa docs/operations/getpresetversionglobals.mdx: id: be6fdbd36a45 last_write_checksum: sha1:ca796205f1df410f2dd9ee04a967a1e3b4fe199d pristine_git_object: dbabdd2fb611af3ff5b93a35efeee4b14c3457d7 docs/operations/getpresetversionrequest.mdx: id: 970105a3a642 - last_write_checksum: sha1:100ae3c6fd8c2f3d379cbc9ea733a8b30206f50d - pristine_git_object: 14245cb50461496d9f93c2656e3370b51c49b731 + last_write_checksum: sha1:5bbd6360e6eeb35557f77a3a5b0b2f5dfc8c8896 + pristine_git_object: 201561fb05ce22ab9a7ab00ae5178a528f0b9184 docs/operations/getprivateendpointglobals.mdx: id: 5d8a9d4f2aec last_write_checksum: sha1:4f3c4d7cc4721435c9faed5c4aa2d17b8baa9adc @@ -10904,8 +10912,8 @@ trackedFiles: pristine_git_object: a0d0bd85de920663402f2f1d9de1192951a43bd5 docs/operations/listpresetsrequest.mdx: id: e346ae8fa12f - last_write_checksum: sha1:51d1bc56747a357e4489fe7f71d8e96c0d7dd55f - pristine_git_object: 947e5e16a047631810d62ba3c0f40dd2a9e92a25 + last_write_checksum: sha1:ac6c2038ff4549957ac47bf165caa02c109c07ea + pristine_git_object: d12bc16e122eb7721a2c7af98c0cf08545ee9d5b docs/operations/listpresetsresponse.mdx: id: 70641d06b5cb last_write_checksum: sha1:c4438a24931361add5a8f3b3d7012d333827f42e @@ -10916,8 +10924,8 @@ trackedFiles: pristine_git_object: f043e963b260d4c1221608fef2975c3f379406bf docs/operations/listpresetversionsrequest.mdx: id: 3ec15e417b29 - last_write_checksum: sha1:13e64a0af9677a3e25ba414625ff037603b0ff91 - pristine_git_object: 763f4e948fbc32241d77df41070e9bda18e8c8f2 + last_write_checksum: sha1:8b58da40862a71e0fc0f699678e8734d134992ff + pristine_git_object: d24e662d4d35f0cf6e1757b58b8d0fb9c5bf1137 docs/operations/listpresetversionsresponse.mdx: id: b6ecb3a03b2b last_write_checksum: sha1:f6520addc01e522d8d1fb5113cc6a5350e03c906 @@ -11150,6 +11158,14 @@ trackedFiles: id: 363fb8a0ddd6 last_write_checksum: sha1:ce7d9ba61f903de7446102d09d412e5813d77f1b pristine_git_object: b7f772318bb3da788acb989aba6067371db53634 + docs/operations/restorepresetglobals.mdx: + id: ea86b55b1d04 + last_write_checksum: sha1:25b7504bd9112906713ed1534f023bc1360a84e4 + pristine_git_object: 1c479470935d79dffa1bf5f1991894300d2e59e3 + docs/operations/restorepresetrequest.mdx: + id: 4a26bde69250 + last_write_checksum: sha1:a767d9cc054a6f22daa7f8a35c299117207dd75d + pristine_git_object: 8a9c2c68a48e861c6c6768409d72255bf2b73aea docs/operations/result.mdx: id: b68db2e6b7af last_write_checksum: sha1:bb37c167c00a68f74c80c769beb66ddd73c65441 @@ -11512,8 +11528,8 @@ trackedFiles: pristine_git_object: 4762825df814e75d1f9c2c4067444270f4ec7b60 docs/sdks/presets/README.mdx: id: eeb505928d52 - last_write_checksum: sha1:b212acff61c8199c686876c5bb40f4f63e4c3461 - pristine_git_object: f6e29f23187c26fd808d118faa15a3b246b094b9 + last_write_checksum: sha1:45197a0baafd43d668d1b713eb1e17733282ea61 + pristine_git_object: bbae48172a2146cb8b3cef449501f0c009665f07 docs/sdks/privateendpoints/README.mdx: id: 54dee70b8cc7 last_write_checksum: sha1:df30945c0fcc9fa7e507ea2dbbfc275946151ebd @@ -11572,8 +11588,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:94de086238f22a1802927794e8baa0d9054bbf8c - pristine_git_object: 57128b55afd32082a528498edbe28902f48fb563 + last_write_checksum: sha1:66ed447cad17473f1f997e19cfc20e17b9141515 + pristine_git_object: 9b19c601aff3d43346f91e3178448c47005f77cf scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -11600,8 +11616,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:018efc7e376fd7638c16a8d84620f95646e549fc - pristine_git_object: ca535bec293320d6179842137b2df3dd3c2862c3 + last_write_checksum: sha1:3a0268fd1a6d68fe9d67aa61f3e80f85ebefd902 + pristine_git_object: 663c95c93aa58f3cf179eb89bff71f3e675c9933 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -12980,16 +12996,16 @@ trackedFiles: pristine_git_object: dccefb2123d06d6d9920e7035f21a8ab5e7b86a8 src/openrouter/components/deferredbm25search.py: id: b988bf147d9f - last_write_checksum: sha1:244c07f05441fa084c7c7ea881b81580ab58b977 - pristine_git_object: a90be50d8b9bf7624c15dc0a8e77d59c58ffc87a + last_write_checksum: sha1:7404a7adf6715afb808d32cce175fb5fbbe7ff48 + pristine_git_object: 8c3427aca4dfbd7e51d77d2e26b07fa5912b37ff src/openrouter/components/deferredcustomsearch.py: id: 71d9d33ba373 last_write_checksum: sha1:1b308d057e8b27d8a7da76b1edf47734ab11dd0c pristine_git_object: b47ed4f8a5b51b416f3105bb22b93dddf23e7aa6 src/openrouter/components/deferredregexsearch.py: id: 64f28f2cc1af - last_write_checksum: sha1:97a0a3a31f5223c0aea16482f3b2d600806f1a5c - pristine_git_object: c354e6dbcedcec520d770714fe70089c18d7d3c5 + last_write_checksum: sha1:e25e6d7d18bdabba7869ead01e88d70a9204a545 + pristine_git_object: c988c33eaf849d75f25cd3076c427ebd4bc3c2b7 src/openrouter/components/deferredtoolscontrol.py: id: b8b6ceef6f86 last_write_checksum: sha1:95f45f6727a077a2bb436c9eb1414065d455a1cb @@ -15648,8 +15664,8 @@ trackedFiles: pristine_git_object: 4a35ede011d09dddab042e2c00413ce4f6be655e src/openrouter/operations/__init__.py: id: 9afcea1e7161 - last_write_checksum: sha1:e487b8826ac4840df1c3649cb95d0209350ff7d0 - pristine_git_object: 488f95f3bafca987e61517199876475e61d2cd94 + last_write_checksum: sha1:698becc71b7c317e30a1849cd5ecd6b4fba66051 + pristine_git_object: a20109487634a5025d8e33f0c04e62637c90cd56 src/openrouter/operations/activateprivateendpoint.py: id: 3b39eec5d66f last_write_checksum: sha1:9406e6b3d38c82895fd795f637702ef579cc6d36 @@ -15768,16 +15784,16 @@ trackedFiles: pristine_git_object: debb2873f91e98e56a12c112f59f1c7634dfd4df src/openrouter/operations/createpresetschatcompletions.py: id: 946ce40bf5bf - last_write_checksum: sha1:eb730461fbd4e8a0c9b78bea3ba741c7ad48f1fa - pristine_git_object: 5bd641f0888065d169ac8f66fca72b00f695ebe2 + last_write_checksum: sha1:f57a734e9b1f712c10e1baf1a17af66d0ad73222 + pristine_git_object: 07fe9b08f3d094c3eff69abd25f5510adab5db9d src/openrouter/operations/createpresetsmessages.py: id: 62021b3fbcdd - last_write_checksum: sha1:8fbb43d4999f37c3df0eecc765f01eea8015d0af - pristine_git_object: 12a2642ff10567b655b02a84fa1a711ec52a2680 + last_write_checksum: sha1:5e176a602546005b7b47e3492b77c7ae4acde568 + pristine_git_object: 8755af664857960536934aafff6f82fdd6e20b99 src/openrouter/operations/createpresetsresponses.py: id: 42f8d73c9c81 - last_write_checksum: sha1:204ad9a62fd2af24e1464e32117d47fb3d49405a - pristine_git_object: 4291ce0ee9720d11ff4698ce79b1b262d011dd4b + last_write_checksum: sha1:e617d5ca061ff35a59247158d6d0d922f4424afb + pristine_git_object: b1a8c8854e073cca8facb8125b34f19192b7ffaf src/openrouter/operations/createprivateendpoint.py: id: 4c2fd54c9685 last_write_checksum: sha1:1b90429bdf4fce7a572624bff66ca21bff48b546 @@ -15862,6 +15878,10 @@ trackedFiles: id: efcdc4e7e19d last_write_checksum: sha1:975fb2edbcb96c6e890d1ed6ce2101ae261600d8 pristine_git_object: 92560ae6d7ad4399f3f1f8a2bf9347ac5f0d7283 + src/openrouter/operations/deletepreset.py: + id: 6dc146556c75 + last_write_checksum: sha1:11a7a00c4ab59a19fb3de2c96d52e6c8bdd03fcb + pristine_git_object: 6d0581621742fc15277025bffc56dc9ea7920f2c src/openrouter/operations/deleteprivateendpoint.py: id: c61fc1252b0e last_write_checksum: sha1:c6142890856e97d65522da974e0454484230ecfa @@ -15996,12 +16016,12 @@ trackedFiles: pristine_git_object: 27e5380f6fe2855ab0a37f7c3ea1d61c0d43e5f7 src/openrouter/operations/getpreset.py: id: 8819dbeb2074 - last_write_checksum: sha1:035b83ddf36d83cba7892aac4763ee973f0f83e8 - pristine_git_object: 95dbd5c272049df2b34ec7a511858b2d017e917c + last_write_checksum: sha1:d3720a923309e975953697156ffa8036023e825f + pristine_git_object: 3b363b18717c5ad7f79cb48e4df7a207f5f102d4 src/openrouter/operations/getpresetversion.py: id: 220006e17d37 - last_write_checksum: sha1:b7a8663b5a480eb0dfc5ede991ed40600c35b31d - pristine_git_object: cbcc9abe2ab38d7e7bd3cbc79acfda4da6b630e0 + last_write_checksum: sha1:4df7759b6c4bd63b594bede2fd2fe8087dd6adaa + pristine_git_object: 71075b291ec725e42bf8a03fcb66c7e6ffab4190 src/openrouter/operations/getprivateendpoint.py: id: cec9e371c5f6 last_write_checksum: sha1:d07ec56edb56cc14a1ce268c60289c63e0c386fb @@ -16168,12 +16188,12 @@ trackedFiles: pristine_git_object: bab4420d737b66ae01eb72c70892ec4b2b4cfea8 src/openrouter/operations/listpresets.py: id: ecdc7097aab7 - last_write_checksum: sha1:4b209724a3bf1627ca12250d165806bed44fb8ac - pristine_git_object: 64002d1db512b764485ec7cff8348e741079a71f + last_write_checksum: sha1:ee7c1cccf1caafb6a0fc04efb16476db2301233b + pristine_git_object: ba0db5e5869232ba8a1c5b372ae05684ca4faea9 src/openrouter/operations/listpresetversions.py: id: 697cf707300b - last_write_checksum: sha1:da897aa354eef6c675649e1a1c09ff97eff7add4 - pristine_git_object: 22c7b85ea089a8917a37f7c12555f06dfa69e670 + last_write_checksum: sha1:4343ecae6732c60493f3a885a8431b6018ab3f20 + pristine_git_object: a6abd3bfade1b5ce2300924d16724f19bf3c9d96 src/openrouter/operations/listprivateendpoints.py: id: e8ea708382f5 last_write_checksum: sha1:a8ad625eef75179574d1389a513995ef0eeeca52 @@ -16230,6 +16250,10 @@ trackedFiles: id: d76c63ff66f6 last_write_checksum: sha1:7902d3cac3a3efda6358b9d55f633c2820f6c0be pristine_git_object: ffee192330d5854fb37564c66bf370bb37c8a243 + src/openrouter/operations/restorepreset.py: + id: 60fe5377a465 + last_write_checksum: sha1:7d400992c42990fcc106f00c868d647962dabc9f + pristine_git_object: 168f7fba7712c02c3a684eae193ebdd80af5a1c1 src/openrouter/operations/sendchatcompletionrequest.py: id: d9fee71bb577 last_write_checksum: sha1:0cba4011b8e305270ac30f88cb7ab59b6aefe619 @@ -16320,8 +16344,8 @@ trackedFiles: pristine_git_object: 228602282f43dd94fb7703bb47b45a570c1aa8d2 src/openrouter/presets.py: id: bd0c40379dcd - last_write_checksum: sha1:1fe2f2960f506c3e41acfd13982a474a5498a9de - pristine_git_object: 49957cba51faee0bf1a587e9c12a06cd5f1bdd28 + last_write_checksum: sha1:e43c29c2767a41140255cc9c3b18946ad6fb3831 + pristine_git_object: c40ca7d9e8bc5a3c89f76da4b2eb8c7b6f4d17e1 src/openrouter/private_endpoints.py: id: fdbce8846ed0 last_write_checksum: sha1:3d7385776334bff0c853f956633941c4fe1bc42e @@ -17672,6 +17696,8 @@ examples: application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} "503": application/json: {"error": {"code": 503, "message": "Service temporarily unavailable"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} getPreset: speakeasy-default-get-preset: parameters: @@ -21504,8 +21530,45 @@ examples: application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + deletePreset: + speakeasy-default-delete-preset: + parameters: + path: + slug: "my-preset" + responses: + "200": + application/json: {"data": {"created_at": "2026-04-20T10:00:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "description": null, "designated_version_id": "550e8400-e29b-41d4-a716-446655440000", "id": "650e8400-e29b-41d4-a716-446655440001", "name": "my-preset", "slug": "my-preset", "status": "active", "status_updated_at": null, "updated_at": "2026-04-20T10:00:00Z", "workspace_id": "750e8400-e29b-41d4-a716-446655440002", "designated_version": {"config": {"model": "openai/gpt-4o", "temperature": 0.7}, "created_at": "2026-04-20T10:00:00Z", "creator_id": "user_2dHFtVWx2n56w6HkM0000000000", "id": "550e8400-e29b-41d4-a716-446655440000", "preset_id": "650e8400-e29b-41d4-a716-446655440001", "system_prompt": "You are a helpful assistant.", "updated_at": "2026-04-20T10:00:00Z", "version": 1}}} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + restorePreset: + speakeasy-default-restore-preset: + parameters: + path: + slug: "my-preset" + responses: + "200": + application/json: {"data": {"created_at": "2026-04-20T10:00:00Z", "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000", "description": null, "designated_version_id": "550e8400-e29b-41d4-a716-446655440000", "id": "650e8400-e29b-41d4-a716-446655440001", "name": "my-preset", "slug": "my-preset", "status": "active", "status_updated_at": null, "updated_at": "2026-04-20T10:00:00Z", "workspace_id": "750e8400-e29b-41d4-a716-446655440002", "designated_version": {"config": {"model": "openai/gpt-4o", "temperature": 0.7}, "created_at": "2026-04-20T10:00:00Z", "creator_id": "user_2dHFtVWx2n56w6HkM0000000000", "id": "550e8400-e29b-41d4-a716-446655440000", "preset_id": "650e8400-e29b-41d4-a716-446655440001", "system_prompt": "You are a helpful assistant.", "updated_at": "2026-04-20T10:00:00Z", "version": 1}}} + "400": + application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: | - ## Python SDK Changes: - * `open_router.batch.create_batches()`: `response.results[].response.body.union(OpenResponsesResult).error.code.enum(flex_unavailable)` **Added** - * `open_router.batch.get_batches()`: `response.results[].response.body.union(OpenResponsesResult).error.code.enum(flex_unavailable)` **Added** +releaseNotes: "## Python SDK Changes:\n* `open_router.presets.delete()`: **Added**\n* `open_router.presets.restore()`: **Added**\n* `open_router.presets.list()`: \n * `request.workspace_id` **Added**\n * `error.status[404]` **Added**\n* `open_router.presets.get()`: `request.workspace_id` **Added**\n* `open_router.presets.list_versions()`: `request.workspace_id` **Added**\n* `open_router.presets.get_version()`: `request.workspace_id` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index df7ef430d..a8094bc58 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.145 + version: 1.3.146 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 5c788dbbf..4453b87ff 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -12110,7 +12110,7 @@ components: max_results: type: 'integer' miss_sources: - description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model''s own words, the query''s leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools'' names (the union of every deferred tool name''s tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker''s issue tools). Direct tools, including a client''s built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.' + description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model''s own words, the query''s leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools'' names (the union of every deferred tool name''s tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker''s issue tools). Direct tools, including a client''s built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.' type: 'boolean' siblings: description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.' @@ -12159,7 +12159,7 @@ components: max_results: type: 'integer' miss_sources: - description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model''s own words, the query''s leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools'' names (the union of every deferred tool name''s tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker''s issue tools). Direct tools, including a client''s built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.' + description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model''s own words, the query''s leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools'' names (the union of every deferred tool name''s tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker''s issue tools). Direct tools, including a client''s built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.' type: 'boolean' siblings: description: 'Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.' @@ -53456,6 +53456,15 @@ paths: maximum: 100 minimum: 1 type: 'integer' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' responses: '200': content: @@ -53507,6 +53516,16 @@ paths: schema: $ref: '#/components/schemas/ForbiddenResponse' description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' '500': content: application/json: @@ -53549,6 +53568,101 @@ paths: - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" /presets/{slug}: + delete: + description: 'Archives a preset: it no longer resolves for inference and is hidden from get and list. The preset and its versions are kept, so the slug stays taken; restore it with `POST /presets/{slug}/restore`. Deleting an already-archived preset succeeds again. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field.' + operationId: 'deletePreset' + parameters: + - description: 'URL-safe slug identifying the preset.' + in: 'path' + name: 'slug' + required: true + schema: + description: 'URL-safe slug identifying the preset.' + example: 'my-preset' + minLength: 1 + type: 'string' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetPresetResponse' + description: 'The archived preset with its designated version.' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + security: + - apiKey: [] + summary: 'Delete a preset' + tags: + - 'Presets' + x-speakeasy-name-override: 'delete' get: description: 'Retrieves a preset by its slug with its currently designated version inline.' operationId: 'getPreset' @@ -53562,6 +53676,15 @@ paths: example: 'my-preset' minLength: 1 type: 'string' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' responses: '200': content: @@ -53677,12 +53800,12 @@ paths: example: 'my-preset' minLength: 1 type: 'string' - - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' in: 'query' name: 'workspace_id' required: false schema: - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' example: '750e8400-e29b-41d4-a716-446655440002' format: 'uuid' type: 'string' @@ -53814,12 +53937,12 @@ paths: example: 'my-preset' minLength: 1 type: 'string' - - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' in: 'query' name: 'workspace_id' required: false schema: - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' example: '750e8400-e29b-41d4-a716-446655440002' format: 'uuid' type: 'string' @@ -53950,12 +54073,12 @@ paths: example: 'my-preset' minLength: 1 type: 'string' - - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' in: 'query' name: 'workspace_id' required: false schema: - description: 'Workspace to create the preset in. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' example: '750e8400-e29b-41d4-a716-446655440002' format: 'uuid' type: 'string' @@ -54068,6 +54191,106 @@ paths: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" + /presets/{slug}/restore: + post: + description: 'Re-activates an archived preset so it resolves for inference again. No version is created and the designated version is unchanged. Restoring an active preset returns it unchanged. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field.' + operationId: 'restorePreset' + parameters: + - description: 'URL-safe slug identifying the preset.' + in: 'path' + name: 'slug' + required: true + schema: + description: 'URL-safe slug identifying the preset.' + example: 'my-preset' + minLength: 1 + type: 'string' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetPresetResponse' + description: 'The restored preset with its designated version.' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid request parameters' + schema: + $ref: '#/components/schemas/BadRequestResponse' + description: 'Bad Request - Invalid request parameters or malformed input' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + security: + - apiKey: [] + summary: 'Restore a preset' + tags: + - 'Presets' + x-speakeasy-name-override: 'restore' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" /presets/{slug}/versions: get: description: 'Lists all versions of a preset, ordered by version number ascending (oldest first).' @@ -54106,6 +54329,15 @@ paths: maximum: 100 minimum: 1 type: 'integer' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' responses: '200': content: @@ -54230,6 +54462,15 @@ paths: example: '1' minLength: 1 type: 'string' + - description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + in: 'query' + name: 'workspace_id' + required: false + schema: + description: 'Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key''s workspace for a key limited to one workspace, otherwise to the account''s default workspace.' + example: '750e8400-e29b-41d4-a716-446655440002' + format: 'uuid' + type: 'string' responses: '200': content: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 2bce4b9b4..659769e54 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:8f4960d11d269efeae653ee7ad32770d38b16e72206aecdbbeafd103084f3a4d - sourceBlobDigest: sha256:a8af3960be16e168ddc7faa2956d27470484d502080c48abe9ff9e33e8a879e5 + sourceRevisionDigest: sha256:fb2c69a9f7cae96fdc498fada1f06f4be6648f6cb27129f54495319a8e374e88 + sourceBlobDigest: sha256:81d40dba10925d897266e61041a9918f25d02f5d31becfaf3774840b9288fe25 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:8f4960d11d269efeae653ee7ad32770d38b16e72206aecdbbeafd103084f3a4d - sourceBlobDigest: sha256:a8af3960be16e168ddc7faa2956d27470484d502080c48abe9ff9e33e8a879e5 + sourceRevisionDigest: sha256:fb2c69a9f7cae96fdc498fada1f06f4be6648f6cb27129f54495319a8e374e88 + sourceBlobDigest: sha256:81d40dba10925d897266e61041a9918f25d02f5d31becfaf3774840b9288fe25 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:46a4d1bfa3be93d80ceffe858e9758dff49fdf5611367b21b05e66628962beb7 + codeSamplesRevisionDigest: sha256:96f8594f33b6f3884491a4fed5484fc1593c23b8ee968a9e09a9e295c25f9221 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index 56b663bb1..fdc036313 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4219,4 +4219,14 @@ Based on: ### Generated - [python v1.3.145] . ### Releases -- [PyPI v1.3.145] https://pypi.org/project/openrouter/1.3.145 - . \ No newline at end of file +- [PyPI v1.3.145] https://pypi.org/project/openrouter/1.3.145 - . + +## 2026-11-09 23:03:13 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.146] . +### Releases +- [PyPI v1.3.146] https://pypi.org/project/openrouter/1.3.146 - . \ No newline at end of file diff --git a/docs/components/deferredbm25search.mdx b/docs/components/deferredbm25search.mdx index f9e7fee3c..8ddc1ff9d 100644 --- a/docs/components/deferredbm25search.mdx +++ b/docs/components/deferredbm25search.mdx @@ -7,10 +7,10 @@ Deterministic BM25 retrieval over supplied tool definitions. ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `max_results` | *Optional[int]* | ➖ | N/A | -| `miss_sources` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only. | -| `siblings` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone. | -| `spread` | *Optional[bool]* | ➖ | Universal profile only, for keyword searches the router answers through the `tool_search` wrapper. When true, a result spreads across sources: of the 3 x limit best-scoring candidates, those scoring at least 60% of the best match take at most 2 slots per source (MCP server, namespace or shared `_` prefix; a tool with no source is never capped), and the remaining slots fill in score order, so a catalog with several systems for one job (web search, page extraction) shows one of each instead of the top system's siblings. Absent or false: results are the best matches in score order. | -| `type` | [components.DeferredBm25SearchType](../components/deferredbm25searchtype.mdx) | ✔️ | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `max_results` | *Optional[int]* | ➖ | N/A | +| `miss_sources` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only. | +| `siblings` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone. | +| `spread` | *Optional[bool]* | ➖ | Universal profile only, for keyword searches the router answers through the `tool_search` wrapper. When true, a result spreads across sources: of the 3 x limit best-scoring candidates, those scoring at least 60% of the best match take at most 2 slots per source (MCP server, namespace or shared `_` prefix; a tool with no source is never capped), and the remaining slots fill in score order, so a catalog with several systems for one job (web search, page extraction) shows one of each instead of the top system's siblings. Absent or false: results are the best matches in score order. | +| `type` | [components.DeferredBm25SearchType](../components/deferredbm25searchtype.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/components/deferredregexsearch.mdx b/docs/components/deferredregexsearch.mdx index 6b387eac8..54b082bc0 100644 --- a/docs/components/deferredregexsearch.mdx +++ b/docs/components/deferredregexsearch.mdx @@ -7,9 +7,9 @@ Versioned safe-regex retrieval over supplied tool definitions. ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `max_results` | *Optional[int]* | ➖ | N/A | -| `miss_sources` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only. | -| `siblings` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone. | -| `type` | [components.DeferredRegexSearchType](../components/deferredregexsearchtype.mdx) | ✔️ | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `max_results` | *Optional[int]* | ➖ | N/A | +| `miss_sources` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only. | +| `siblings` | *Optional[bool]* | ➖ | Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone. | +| `type` | [components.DeferredRegexSearchType](../components/deferredregexsearchtype.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/operations/createpresetschatcompletionsrequest.mdx b/docs/operations/createpresetschatcompletionsrequest.mdx index 6c49b8fd1..b525012c1 100644 --- a/docs/operations/createpresetschatcompletionsrequest.mdx +++ b/docs/operations/createpresetschatcompletionsrequest.mdx @@ -10,5 +10,5 @@ title: "CreatePresetsChatCompletionsRequest" | `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.
| | | `slug` | *str* | ✔️ | URL-safe slug identifying the preset. Created if it does not exist. | my-preset | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | | `chat_request` | [components.ChatRequest](../components/chatrequest.mdx) | ✔️ | N/A | \{
"max_tokens": 150,
"messages": [
\{
"content": "You are a helpful assistant.",
"role": "system"
},
\{
"content": "What is the capital of France?",
"role": "user"
}
],
"model": "openai/gpt-4",
"temperature": 0.7
} | \ No newline at end of file diff --git a/docs/operations/createpresetsmessagesrequest.mdx b/docs/operations/createpresetsmessagesrequest.mdx index b9b3de1c8..d6390732a 100644 --- a/docs/operations/createpresetsmessagesrequest.mdx +++ b/docs/operations/createpresetsmessagesrequest.mdx @@ -4,11 +4,11 @@ title: "CreatePresetsMessagesRequest" ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. Created if it does not exist. | my-preset | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | -| `messages_request` | [components.MessagesRequest](../components/messagesrequest.mdx) | ✔️ | N/A | \{
"max_tokens": 1024,
"messages": [
\{
"content": "Hello, how are you?",
"role": "user"
}
],
"model": "anthropic/claude-4.5-sonnet-20250929",
"temperature": 0.7
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. Created if it does not exist. | my-preset | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `messages_request` | [components.MessagesRequest](../components/messagesrequest.mdx) | ✔️ | N/A | \{
"max_tokens": 1024,
"messages": [
\{
"content": "Hello, how are you?",
"role": "user"
}
],
"model": "anthropic/claude-4.5-sonnet-20250929",
"temperature": 0.7
} | \ No newline at end of file diff --git a/docs/operations/createpresetsresponsesrequest.mdx b/docs/operations/createpresetsresponsesrequest.mdx index 7455c712d..d56818808 100644 --- a/docs/operations/createpresetsresponsesrequest.mdx +++ b/docs/operations/createpresetsresponsesrequest.mdx @@ -10,5 +10,5 @@ title: "CreatePresetsResponsesRequest" | `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.
| | | `slug` | *str* | ✔️ | URL-safe slug identifying the preset. Created if it does not exist. | my-preset | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | | `responses_request` | [components.ResponsesRequest](../components/responsesrequest.mdx) | ✔️ | N/A | \{
"input": [
\{
"content": "Hello, how are you?",
"role": "user",
"type": "message"
}
],
"model": "anthropic/claude-4.5-sonnet-20250929",
"temperature": 0.7,
"tools": [
\{
"description": "Get the current weather in a given location",
"name": "get_current_weather",
"parameters": \{
"properties": \{
"location": \{
"type": "string"
}
},
"type": "object"
},
"type": "function"
}
],
"top_p": 0.9
} | \ No newline at end of file diff --git a/docs/operations/deletepresetglobals.mdx b/docs/operations/deletepresetglobals.mdx new file mode 100644 index 000000000..945193d21 --- /dev/null +++ b/docs/operations/deletepresetglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "DeletePresetGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/operations/deletepresetrequest.mdx b/docs/operations/deletepresetrequest.mdx new file mode 100644 index 000000000..dbda91ee2 --- /dev/null +++ b/docs/operations/deletepresetrequest.mdx @@ -0,0 +1,13 @@ +--- +title: "DeletePresetRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/operations/getpresetrequest.mdx b/docs/operations/getpresetrequest.mdx index a01071730..37799222d 100644 --- a/docs/operations/getpresetrequest.mdx +++ b/docs/operations/getpresetrequest.mdx @@ -4,9 +4,10 @@ title: "GetPresetRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/operations/getpresetversionrequest.mdx b/docs/operations/getpresetversionrequest.mdx index 14245cb50..201561fb0 100644 --- a/docs/operations/getpresetversionrequest.mdx +++ b/docs/operations/getpresetversionrequest.mdx @@ -4,10 +4,11 @@ title: "GetPresetVersionRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | -| `version` | *str* | ✔️ | Version number of the preset. | 1 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `version` | *str* | ✔️ | Version number of the preset. | 1 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/operations/listpresetsrequest.mdx b/docs/operations/listpresetsrequest.mdx index 947e5e16a..d12bc16e1 100644 --- a/docs/operations/listpresetsrequest.mdx +++ b/docs/operations/listpresetsrequest.mdx @@ -4,10 +4,11 @@ title: "ListPresetsRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | -| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/operations/listpresetversionsrequest.mdx b/docs/operations/listpresetversionsrequest.mdx index 763f4e948..d24e662d4 100644 --- a/docs/operations/listpresetversionsrequest.mdx +++ b/docs/operations/listpresetversionsrequest.mdx @@ -4,11 +4,12 @@ title: "ListPresetVersionsRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | -| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | -| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/operations/restorepresetglobals.mdx b/docs/operations/restorepresetglobals.mdx new file mode 100644 index 000000000..1c4794709 --- /dev/null +++ b/docs/operations/restorepresetglobals.mdx @@ -0,0 +1,11 @@ +--- +title: "RestorePresetGlobals" +--- + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/operations/restorepresetrequest.mdx b/docs/operations/restorepresetrequest.mdx new file mode 100644 index 000000000..8a9c2c68a --- /dev/null +++ b/docs/operations/restorepresetrequest.mdx @@ -0,0 +1,13 @@ +--- +title: "RestorePresetRequest" +--- + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | \ No newline at end of file diff --git a/docs/sdks/presets/README.mdx b/docs/sdks/presets/README.mdx index f6e29f231..bbae48172 100644 --- a/docs/sdks/presets/README.mdx +++ b/docs/sdks/presets/README.mdx @@ -10,10 +10,12 @@ Presets endpoints ### Available Operations * [list](#list) - List presets +* [delete](#delete) - Delete a preset * [get](#get) - Get a preset * [create_presets_chat_completions](#create_presets_chat_completions) - Create a preset from a chat-completions request body * [create_presets_messages](#create_presets_messages) - Create a preset from a messages request body * [create_presets_responses](#create_presets_responses) - Create a preset from a responses request body +* [restore](#restore) - Restore a preset * [list_versions](#list_versions) - List versions of a preset * [get_version](#get_version) - Get a specific version of a preset @@ -46,14 +48,15 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | -| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -66,10 +69,63 @@ with OpenRouter( | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | +## delete + +Archives a preset: it no longer resolves for inference and is hidden from get and list. The preset and its versions are kept, so the slug stays taken; restore it with `POST /presets/{slug}/restore`. Deleting an already-archived preset succeeds again. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. + +### Example Usage + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.presets.delete(slug="my-preset") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.GetPresetResponse](../../components/getpresetresponse.mdx)** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + ## get Retrieves a preset by its slug with its currently designated version inline. @@ -97,13 +153,14 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -164,7 +221,7 @@ with OpenRouter( | `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | | `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.mdx) | ➖ | Debug options for inspecting request transformations (streaming only) | \{
"echo_upstream_body": true
} | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | @@ -264,7 +321,7 @@ with OpenRouter( | `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | | `context_management` | [OptionalNullable[components.ContextManagement]](../../components/contextmanagement.mdx) | ➖ | N/A | | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | @@ -342,7 +399,7 @@ with OpenRouter( | `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `workspace_id` | *Optional[str]* | ➖ | Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | | `access_programs` | [Optional[components.ResponsesRequestAccessPrograms]](../../components/responsesrequestaccessprograms.mdx) | ➖ | OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. | \{
"cyber": "standard"
} | | `background` | *OptionalNullable[bool]* | ➖ | N/A | | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | @@ -402,6 +459,58 @@ with OpenRouter( | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | +## restore + +Re-activates an archived preset so it resolves for inference again. No version is created and the designated version is unchanged. Restoring an active preset returns it unchanged. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. + +### Example Usage + +```python +from openrouter import OpenRouter +import os + + +with OpenRouter( + http_referer="", + x_open_router_title="", + x_open_router_categories="", + api_key=os.getenv("OPENROUTER_API_KEY", ""), +) as open_router: + + res = open_router.presets.restore(slug="my-preset") + + # Handle response + print(res) + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | + +### Response + +**[components.GetPresetResponse](../../components/getpresetresponse.mdx)** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.BadRequestResponseError | 400 | application/json | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + ## list_versions Lists all versions of a preset, ordered by version number ascending (oldest first). @@ -431,15 +540,16 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | -| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *OptionalNullable[int]* | ➖ | Number of records to skip for pagination | 0 | +| `limit` | *Optional[int]* | ➖ | Maximum number of records to return (max 100) | 50 | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -484,14 +594,15 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | -| `version` | *str* | ✔️ | Version number of the preset. | 1 | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `slug` | *str* | ✔️ | URL-safe slug identifying the preset. | my-preset | +| `version` | *str* | ✔️ | Version number of the preset. | 1 | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `workspace_id` | *Optional[str]* | ➖ | Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. | 750e8400-e29b-41d4-a716-446655440002 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response diff --git a/pyproject.toml b/pyproject.toml index 57128b55a..9b19c601a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.145" +version = "1.3.146" 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 ca535bec2..663c95c93 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.145" +__version__: str = "1.3.146" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.145 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.146 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/deferredbm25search.py b/src/openrouter/components/deferredbm25search.py index a90be50d8..8c3427aca 100644 --- a/src/openrouter/components/deferredbm25search.py +++ b/src/openrouter/components/deferredbm25search.py @@ -16,7 +16,7 @@ class DeferredBm25SearchTypedDict(TypedDict): type: DeferredBm25SearchType max_results: NotRequired[int] miss_sources: NotRequired[bool] - r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.""" + r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.""" siblings: NotRequired[bool] r"""Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.""" spread: NotRequired[bool] @@ -31,7 +31,7 @@ class DeferredBm25Search(BaseModel): max_results: Optional[int] = None miss_sources: Optional[bool] = None - r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.""" + r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.""" siblings: Optional[bool] = None r"""Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.""" diff --git a/src/openrouter/components/deferredregexsearch.py b/src/openrouter/components/deferredregexsearch.py index c354e6dbc..c988c33ea 100644 --- a/src/openrouter/components/deferredregexsearch.py +++ b/src/openrouter/components/deferredregexsearch.py @@ -16,7 +16,7 @@ class DeferredRegexSearchTypedDict(TypedDict): type: DeferredRegexSearchType max_results: NotRequired[int] miss_sources: NotRequired[bool] - r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.""" + r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.""" siblings: NotRequired[bool] r"""Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.""" @@ -29,7 +29,7 @@ class DeferredRegexSearch(BaseModel): max_results: Optional[int] = None miss_sources: Optional[bool] = None - r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. When true, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. Absent or false: a miss suggests other keywords and the closest names only.""" + r"""Universal profile only, for searches the router answers through the `tool_search` wrapper. Unless false, a search that matches nothing also names the deferred sources this search covers (namespaces, MCP servers, and shared `_` prefixes; up to 40 names or 2,000 characters, with a count of any omitted) and tells the model that a source the search does not cover is unreachable through it in this request, so it can make a client tool call the task already needs (or a read-only one) and search again on a later turn instead of concluding the integration is missing. A hit gets the same guidance after its matches when, as a heuristic on the model's own words, the query's leading word has 3 to 64 characters, no query word names a searchable source, and the leading word is not among the words of the deferred tools' names (the union of every deferred tool name's tokens, whole and split as the search index splits names; a camel-case word counts when each of its parts is), with descriptions left out so a tool that merely mentions another product cannot mask it (`jira create issue` answered with another tracker's issue tools). Direct tools, including a client's built-in tools, are already in the tool list and are not named. False: a miss suggests other keywords and the closest names only.""" siblings: Optional[bool] = None r"""Universal profile only, for searches the router answers through the `tool_search` wrapper; code-mode `search()` and a client-owned tool search list the matched tools alone. When true, each result also names up to 16 other deferred tools of every source a match came from, so a model that found one tool of an MCP server learns its neighbours without another search. Absent or false: results list the matched tools alone.""" diff --git a/src/openrouter/operations/__init__.py b/src/openrouter/operations/__init__.py index 488f95f3b..a20109487 100644 --- a/src/openrouter/operations/__init__.py +++ b/src/openrouter/operations/__init__.py @@ -405,6 +405,12 @@ DeleteObservabilityDestinationRequest, DeleteObservabilityDestinationRequestTypedDict, ) + from .deletepreset import ( + DeletePresetGlobals, + DeletePresetGlobalsTypedDict, + DeletePresetRequest, + DeletePresetRequestTypedDict, + ) from .deleteprivateendpoint import ( DeletePrivateEndpointGlobals, DeletePrivateEndpointGlobalsTypedDict, @@ -1135,6 +1141,12 @@ TimeRange, TimeRangeTypedDict, ) + from .restorepreset import ( + RestorePresetGlobals, + RestorePresetGlobalsTypedDict, + RestorePresetRequest, + RestorePresetRequestTypedDict, + ) from .sendchatcompletionrequest import ( SendChatCompletionRequestGlobals, SendChatCompletionRequestGlobalsTypedDict, @@ -1557,6 +1569,10 @@ "DeleteObservabilityDestinationGlobalsTypedDict", "DeleteObservabilityDestinationRequest", "DeleteObservabilityDestinationRequestTypedDict", + "DeletePresetGlobals", + "DeletePresetGlobalsTypedDict", + "DeletePresetRequest", + "DeletePresetRequestTypedDict", "DeletePrivateEndpointGlobals", "DeletePrivateEndpointGlobalsTypedDict", "DeletePrivateEndpointRequest", @@ -2104,6 +2120,10 @@ "RateLimitTypedDict", "Region", "ResponseFormat", + "RestorePresetGlobals", + "RestorePresetGlobalsTypedDict", + "RestorePresetRequest", + "RestorePresetRequestTypedDict", "Result", "ResultTypedDict", "Role", @@ -2518,6 +2538,10 @@ "DeleteObservabilityDestinationGlobalsTypedDict": ".deleteobservabilitydestination", "DeleteObservabilityDestinationRequest": ".deleteobservabilitydestination", "DeleteObservabilityDestinationRequestTypedDict": ".deleteobservabilitydestination", + "DeletePresetGlobals": ".deletepreset", + "DeletePresetGlobalsTypedDict": ".deletepreset", + "DeletePresetRequest": ".deletepreset", + "DeletePresetRequestTypedDict": ".deletepreset", "DeletePrivateEndpointGlobals": ".deleteprivateendpoint", "DeletePrivateEndpointGlobalsTypedDict": ".deleteprivateendpoint", "DeletePrivateEndpointRequest": ".deleteprivateendpoint", @@ -3064,6 +3088,10 @@ "QueryAnalyticsResponseTypedDict": ".queryanalytics", "TimeRange": ".queryanalytics", "TimeRangeTypedDict": ".queryanalytics", + "RestorePresetGlobals": ".restorepreset", + "RestorePresetGlobalsTypedDict": ".restorepreset", + "RestorePresetRequest": ".restorepreset", + "RestorePresetRequestTypedDict": ".restorepreset", "SendChatCompletionRequestGlobals": ".sendchatcompletionrequest", "SendChatCompletionRequestGlobalsTypedDict": ".sendchatcompletionrequest", "SendChatCompletionRequestRequest": ".sendchatcompletionrequest", diff --git a/src/openrouter/operations/createpresetschatcompletions.py b/src/openrouter/operations/createpresetschatcompletions.py index 5bd641f08..07fe9b08f 100644 --- a/src/openrouter/operations/createpresetschatcompletions.py +++ b/src/openrouter/operations/createpresetschatcompletions.py @@ -98,7 +98,7 @@ class CreatePresetsChatCompletionsRequestTypedDict(TypedDict): """ workspace_id: NotRequired[str] - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class CreatePresetsChatCompletionsRequest(BaseModel): @@ -144,7 +144,7 @@ class CreatePresetsChatCompletionsRequest(BaseModel): Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/src/openrouter/operations/createpresetsmessages.py b/src/openrouter/operations/createpresetsmessages.py index 12a2642ff..8755af664 100644 --- a/src/openrouter/operations/createpresetsmessages.py +++ b/src/openrouter/operations/createpresetsmessages.py @@ -98,7 +98,7 @@ class CreatePresetsMessagesRequestTypedDict(TypedDict): """ workspace_id: NotRequired[str] - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class CreatePresetsMessagesRequest(BaseModel): @@ -144,7 +144,7 @@ class CreatePresetsMessagesRequest(BaseModel): Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/src/openrouter/operations/createpresetsresponses.py b/src/openrouter/operations/createpresetsresponses.py index 4291ce0ee..b1a8c8854 100644 --- a/src/openrouter/operations/createpresetsresponses.py +++ b/src/openrouter/operations/createpresetsresponses.py @@ -98,7 +98,7 @@ class CreatePresetsResponsesRequestTypedDict(TypedDict): """ workspace_id: NotRequired[str] - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class CreatePresetsResponsesRequest(BaseModel): @@ -144,7 +144,7 @@ class CreatePresetsResponsesRequest(BaseModel): Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/src/openrouter/operations/deletepreset.py b/src/openrouter/operations/deletepreset.py new file mode 100644 index 000000000..6d0581621 --- /dev/null +++ b/src/openrouter/operations/deletepreset.py @@ -0,0 +1,162 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class DeletePresetGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class DeletePresetGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class DeletePresetRequestTypedDict(TypedDict): + slug: str + r"""URL-safe slug identifying the preset.""" + http_referer: NotRequired[str] + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + + +class DeletePresetRequest(BaseModel): + slug: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""URL-safe slug identifying the preset.""" + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "HTTP-Referer", + "X-OpenRouter-Title", + "X-OpenRouter-Categories", + "workspace_id", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/operations/getpreset.py b/src/openrouter/operations/getpreset.py index 95dbd5c27..3b363b187 100644 --- a/src/openrouter/operations/getpreset.py +++ b/src/openrouter/operations/getpreset.py @@ -2,7 +2,12 @@ from __future__ import annotations from openrouter.types import BaseModel, UNSET_SENTINEL -from openrouter.utils import FieldMetadata, HeaderMetadata, PathParamMetadata +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) import pydantic from pydantic import model_serializer from typing import Optional @@ -89,6 +94,8 @@ class GetPresetRequestTypedDict(TypedDict): r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. """ + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class GetPresetRequest(BaseModel): @@ -125,10 +132,21 @@ class GetPresetRequest(BaseModel): """ + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( - ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + [ + "HTTP-Referer", + "X-OpenRouter-Title", + "X-OpenRouter-Categories", + "workspace_id", + ] ) serialized = handler(self) m = {} diff --git a/src/openrouter/operations/getpresetversion.py b/src/openrouter/operations/getpresetversion.py index cbcc9abe2..71075b291 100644 --- a/src/openrouter/operations/getpresetversion.py +++ b/src/openrouter/operations/getpresetversion.py @@ -2,7 +2,12 @@ from __future__ import annotations from openrouter.types import BaseModel, UNSET_SENTINEL -from openrouter.utils import FieldMetadata, HeaderMetadata, PathParamMetadata +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) import pydantic from pydantic import model_serializer from typing import Optional @@ -91,6 +96,8 @@ class GetPresetVersionRequestTypedDict(TypedDict): r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. """ + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class GetPresetVersionRequest(BaseModel): @@ -132,10 +139,21 @@ class GetPresetVersionRequest(BaseModel): """ + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( - ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + [ + "HTTP-Referer", + "X-OpenRouter-Title", + "X-OpenRouter-Categories", + "workspace_id", + ] ) serialized = handler(self) m = {} diff --git a/src/openrouter/operations/listpresets.py b/src/openrouter/operations/listpresets.py index 64002d1db..ba0db5e58 100644 --- a/src/openrouter/operations/listpresets.py +++ b/src/openrouter/operations/listpresets.py @@ -92,6 +92,8 @@ class ListPresetsRequestTypedDict(TypedDict): r"""Number of records to skip for pagination""" limit: NotRequired[int] r"""Maximum number of records to return (max 100)""" + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class ListPresetsRequest(BaseModel): @@ -135,6 +137,12 @@ class ListPresetsRequest(BaseModel): ] = 50 r"""Maximum number of records to return (max 100)""" + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -144,6 +152,7 @@ def serialize_model(self, handler): "X-OpenRouter-Categories", "offset", "limit", + "workspace_id", ] ) nullable_fields = set(["offset"]) diff --git a/src/openrouter/operations/listpresetversions.py b/src/openrouter/operations/listpresetversions.py index 22c7b85ea..a6abd3bfa 100644 --- a/src/openrouter/operations/listpresetversions.py +++ b/src/openrouter/operations/listpresetversions.py @@ -101,6 +101,8 @@ class ListPresetVersionsRequestTypedDict(TypedDict): r"""Number of records to skip for pagination""" limit: NotRequired[int] r"""Maximum number of records to return (max 100)""" + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" class ListPresetVersionsRequest(BaseModel): @@ -149,6 +151,12 @@ class ListPresetVersionsRequest(BaseModel): ] = 50 r"""Maximum number of records to return (max 100)""" + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -158,6 +166,7 @@ def serialize_model(self, handler): "X-OpenRouter-Categories", "offset", "limit", + "workspace_id", ] ) nullable_fields = set(["offset"]) diff --git a/src/openrouter/operations/restorepreset.py b/src/openrouter/operations/restorepreset.py new file mode 100644 index 000000000..168f7fba7 --- /dev/null +++ b/src/openrouter/operations/restorepreset.py @@ -0,0 +1,162 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UNSET_SENTINEL +from openrouter.utils import ( + FieldMetadata, + HeaderMetadata, + PathParamMetadata, + QueryParamMetadata, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class RestorePresetGlobalsTypedDict(TypedDict): + http_referer: NotRequired[str] + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + +class RestorePresetGlobals(BaseModel): + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + ["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class RestorePresetRequestTypedDict(TypedDict): + slug: str + r"""URL-safe slug identifying the preset.""" + http_referer: NotRequired[str] + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + x_open_router_title: NotRequired[str] + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + x_open_router_categories: NotRequired[str] + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + workspace_id: NotRequired[str] + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + + +class RestorePresetRequest(BaseModel): + slug: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""URL-safe slug identifying the preset.""" + + http_referer: Annotated[ + Optional[str], + pydantic.Field(alias="HTTP-Referer"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + """ + + x_open_router_title: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Title"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + """ + + x_open_router_categories: Annotated[ + Optional[str], + pydantic.Field(alias="X-OpenRouter-Categories"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + """ + + workspace_id: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "HTTP-Referer", + "X-OpenRouter-Title", + "X-OpenRouter-Categories", + "workspace_id", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/presets.py b/src/openrouter/presets.py index 49957cba5..c40ca7d9e 100644 --- a/src/openrouter/presets.py +++ b/src/openrouter/presets.py @@ -21,6 +21,7 @@ def list( x_open_router_categories: Optional[str] = None, offset: OptionalNullable[int] = 0, limit: Optional[int] = 50, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -41,6 +42,7 @@ def list( :param offset: Number of records to skip for pagination :param limit: Maximum number of records to return (max 100) + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -62,6 +64,7 @@ def list( x_open_router_categories=x_open_router_categories, offset=offset, limit=limit, + workspace_id=workspace_id, ) req = self._build_request( @@ -137,6 +140,7 @@ def next_func() -> Optional[operations.ListPresetsResponse]: x_open_router_categories=x_open_router_categories, offset=next_offset, limit=limit, + workspace_id=workspace_id, retries=retries, server_url=server_url, timeout_ms=timeout_ms, @@ -166,6 +170,11 @@ def next_func() -> Optional[operations.ListPresetsResponse]: errors.ForbiddenResponseErrorData, http_res ) raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res @@ -197,6 +206,7 @@ async def list_async( x_open_router_categories: Optional[str] = None, offset: OptionalNullable[int] = 0, limit: Optional[int] = 50, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -217,6 +227,7 @@ async def list_async( :param offset: Number of records to skip for pagination :param limit: Maximum number of records to return (max 100) + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -238,6 +249,7 @@ async def list_async( x_open_router_categories=x_open_router_categories, offset=offset, limit=limit, + workspace_id=workspace_id, ) req = self._build_request_async( @@ -316,6 +328,7 @@ async def empty_result(): x_open_router_categories=x_open_router_categories, offset=next_offset, limit=limit, + workspace_id=workspace_id, retries=retries, server_url=server_url, timeout_ms=timeout_ms, @@ -345,6 +358,11 @@ async def empty_result(): errors.ForbiddenResponseErrorData, http_res ) raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res @@ -368,21 +386,22 @@ async def empty_result(): raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - def get( + def delete( self, *, slug: str, http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, ) -> components.GetPresetResponse: - r"""Get a preset + r"""Delete a preset - Retrieves a preset by its slug with its currently designated version inline. + Archives a preset: it no longer resolves for inference and is hidden from get and list. The preset and its versions are kept, so the slug stays taken; restore it with `POST /presets/{slug}/restore`. Deleting an already-archived preset succeeds again. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. If set, this operation will use `api_key` from the global security. @@ -394,6 +413,7 @@ def get( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -409,15 +429,16 @@ def get( else: base_url = self._get_url(base_url, url_variables) - request = operations.GetPresetRequest( + request = operations.DeletePresetRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, + workspace_id=workspace_id, ) req = self._build_request( - method="GET", + method="DELETE", path="/presets/{slug}", base_url=base_url, url_variables=url_variables, @@ -428,7 +449,7 @@ def get( user_agent_header="user-agent", accept_header_value="application/json", http_headers=http_headers, - _globals=operations.GetPresetGlobals( + _globals=operations.DeletePresetGlobals( http_referer=self.sdk_configuration.globals.http_referer, x_open_router_title=self.sdk_configuration.globals.x_open_router_title, x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, @@ -455,7 +476,7 @@ def get( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="getPreset", + operation_id="deletePreset", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, components.Security @@ -491,16 +512,16 @@ def get( errors.NotFoundResponseErrorData, http_res ) raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res ) raise errors.InternalServerResponseError(response_data, http_res) - if utils.match_response(http_res, "503", "application/json"): - response_data = unmarshal_json_response( - errors.ServiceUnavailableResponseErrorData, http_res - ) - raise errors.ServiceUnavailableResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.OpenRouterDefaultError( @@ -514,21 +535,22 @@ def get( raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - async def get_async( + async def delete_async( self, *, slug: str, http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, ) -> components.GetPresetResponse: - r"""Get a preset + r"""Delete a preset - Retrieves a preset by its slug with its currently designated version inline. + Archives a preset: it no longer resolves for inference and is hidden from get and list. The preset and its versions are kept, so the slug stays taken; restore it with `POST /presets/{slug}/restore`. Deleting an already-archived preset succeeds again. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. If set, this operation will use `api_key` from the global security. @@ -540,6 +562,7 @@ async def get_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -555,15 +578,16 @@ async def get_async( else: base_url = self._get_url(base_url, url_variables) - request = operations.GetPresetRequest( + request = operations.DeletePresetRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, + workspace_id=workspace_id, ) req = self._build_request_async( - method="GET", + method="DELETE", path="/presets/{slug}", base_url=base_url, url_variables=url_variables, @@ -574,7 +598,7 @@ async def get_async( user_agent_header="user-agent", accept_header_value="application/json", http_headers=http_headers, - _globals=operations.GetPresetGlobals( + _globals=operations.DeletePresetGlobals( http_referer=self.sdk_configuration.globals.http_referer, x_open_router_title=self.sdk_configuration.globals.x_open_router_title, x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, @@ -601,7 +625,7 @@ async def get_async( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="getPreset", + operation_id="deletePreset", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, components.Security @@ -637,16 +661,16 @@ async def get_async( errors.NotFoundResponseErrorData, http_res ) raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res ) raise errors.InternalServerResponseError(response_data, http_res) - if utils.match_response(http_res, "503", "application/json"): - response_data = unmarshal_json_response( - errors.ServiceUnavailableResponseErrorData, http_res - ) - raise errors.ServiceUnavailableResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( @@ -660,129 +684,26 @@ async def get_async( raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - def create_presets_chat_completions( + def get( self, *, slug: str, - messages: Union[ - Iterable[components.ChatMessages], - Iterable[components.ChatMessagesTypedDict], - ], http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, workspace_id: Optional[str] = None, - cache_control: Optional[ - Union[ - components.AnthropicCacheControlDirective, - components.AnthropicCacheControlDirectiveTypedDict, - ] - ] = None, - debug: Optional[ - Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] - ] = None, - deferred_tools: Optional[ - Union[ - components.DeferredToolsControl, - components.DeferredToolsControlTypedDict, - ] - ] = None, - frequency_penalty: OptionalNullable[float] = UNSET, - image_config: Optional[ - Union[ - Mapping[str, components.ImageConfig], - Mapping[str, components.ImageConfigTypedDict], - ] - ] = None, - logit_bias: OptionalNullable[Mapping[str, float]] = UNSET, - logprobs: OptionalNullable[bool] = UNSET, - max_completion_tokens: OptionalNullable[int] = UNSET, - max_tokens: OptionalNullable[int] = UNSET, - metadata: Optional[Mapping[str, str]] = None, - min_p: OptionalNullable[float] = UNSET, - modalities: Optional[Iterable[components.Modality]] = None, - model: Optional[str] = None, - models: Optional[Iterable[str]] = None, - parallel_tool_calls: OptionalNullable[bool] = UNSET, - plugins: Optional[ - Union[ - Iterable[components.ChatRequestPlugin], - Iterable[components.ChatRequestPluginTypedDict], - ] - ] = None, - prediction: OptionalNullable[ - Union[components.Prediction, components.PredictionTypedDict] - ] = UNSET, - presence_penalty: OptionalNullable[float] = UNSET, - prompt_cache_key: OptionalNullable[str] = UNSET, - prompt_cache_options: OptionalNullable[ - Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] - ] = UNSET, - provider: OptionalNullable[ - Union[ - components.ProviderPreferences, components.ProviderPreferencesTypedDict - ] - ] = UNSET, - reasoning: Optional[ - Union[ - components.ChatRequestReasoning, - components.ChatRequestReasoningTypedDict, - ] - ] = None, - reasoning_effort: OptionalNullable[ - components.ChatRequestReasoningEffort - ] = UNSET, - repetition_penalty: OptionalNullable[float] = UNSET, - response_format: Optional[ - Union[components.ResponseFormat, components.ResponseFormatTypedDict] - ] = None, - seed: OptionalNullable[int] = UNSET, - service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET, - session_id: Optional[str] = None, - stop: OptionalNullable[ - Union[components.ChatRequestStop, components.ChatRequestStopTypedDict] - ] = UNSET, - stop_server_tools_when: Optional[ - Union[ - Iterable[components.StopServerToolsWhenCondition], - Iterable[components.StopServerToolsWhenConditionTypedDict], - ] - ] = None, - stream: Optional[bool] = False, - stream_options: OptionalNullable[ - Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict] - ] = UNSET, - temperature: OptionalNullable[float] = UNSET, - tool_choice: Optional[ - Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict] - ] = None, - tools: Optional[ - Union[ - Iterable[components.ChatFunctionTool], - Iterable[components.ChatFunctionToolTypedDict], - ] - ] = None, - top_a: OptionalNullable[float] = UNSET, - top_k: OptionalNullable[int] = UNSET, - top_logprobs: OptionalNullable[int] = UNSET, - top_p: OptionalNullable[float] = UNSET, - trace: Optional[ - Union[components.TraceConfig, components.TraceConfigTypedDict] - ] = None, - user: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> components.CreatePresetFromInferenceResponse: - r"""Create a preset from a chat-completions request body + ) -> components.GetPresetResponse: + r"""Get a preset - Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. + Retrieves a preset by its slug with its currently designated version inline. If set, this operation will use `api_key` from the global security. - :param slug: URL-safe slug identifying the preset. Created if it does not exist. - :param messages: List of messages for the conversation + :param slug: URL-safe slug identifying the preset. :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application. @@ -790,48 +711,7 @@ def create_presets_chat_completions( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. - :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. - :param debug: Debug options for inspecting request transformations (streaming only) - :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. - :param frequency_penalty: Frequency penalty (-2.0 to 2.0) - :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. - :param logit_bias: Token logit bias adjustments - :param logprobs: Return log probabilities - :param max_completion_tokens: Maximum tokens in completion - :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. - :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) - :param min_p: Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter. - :param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\". - :param model: Model to use for completion - :param models: Models to use for completion - :param parallel_tool_calls: Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. - :param plugins: Plugins you want to enable for this request, including their settings. - :param prediction: Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance. - :param presence_penalty: Presence penalty (-2.0 to 2.0) - :param prompt_cache_key: - :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. - :param provider: When multiple model providers are available, optionally indicate your routing preference. - :param reasoning: Configuration options for reasoning models - :param reasoning_effort: Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ. - :param repetition_penalty: Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter. - :param response_format: Response format configuration - :param seed: Random seed for deterministic outputs - :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. - :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. - :param stop: Stop sequences (up to 4) - :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. - :param stream: Enable streaming response - :param stream_options: Streaming configuration options - :param temperature: Sampling temperature (0-2) - :param tool_choice: Tool choice configuration - :param tools: Available tools for function calling - :param top_a: Consider only tokens with \"sufficiently high\" probabilities based on the probability of the most likely token. Not all providers support this parameter. - :param top_k: Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter. - :param top_logprobs: Number of top log probabilities to return (0-20) - :param top_p: Nucleus sampling parameter (0-1) - :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. - :param user: Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -847,15 +727,837 @@ def create_presets_chat_completions( else: base_url = self._get_url(base_url, url_variables) - request = operations.CreatePresetsChatCompletionsRequest( + request = operations.GetPresetRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, workspace_id=workspace_id, - chat_request=components.ChatRequest( - cache_control=utils.get_pydantic_model( - cache_control, Optional[components.AnthropicCacheControlDirective] + ) + + req = self._build_request( + method="GET", + path="/presets/{slug}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.GetPresetGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + allowed_fields=["api_key"], + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="getPreset", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Presets"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response(components.GetPresetResponse, http_res) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "503", "application/json"): + response_data = unmarshal_json_response( + errors.ServiceUnavailableResponseErrorData, http_res + ) + raise errors.ServiceUnavailableResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def get_async( + self, + *, + slug: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.GetPresetResponse: + r"""Get a preset + + Retrieves a preset by its slug with its currently designated version inline. + + If set, this operation will use `api_key` from the global security. + + :param slug: URL-safe slug identifying the preset. + :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.GetPresetRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + slug=slug, + workspace_id=workspace_id, + ) + + req = self._build_request_async( + method="GET", + path="/presets/{slug}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.GetPresetGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + allowed_fields=["api_key"], + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="getPreset", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Presets"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response(components.GetPresetResponse, http_res) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "503", "application/json"): + response_data = unmarshal_json_response( + errors.ServiceUnavailableResponseErrorData, http_res + ) + raise errors.ServiceUnavailableResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + def create_presets_chat_completions( + self, + *, + slug: str, + messages: Union[ + Iterable[components.ChatMessages], + Iterable[components.ChatMessagesTypedDict], + ], + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, + cache_control: Optional[ + Union[ + components.AnthropicCacheControlDirective, + components.AnthropicCacheControlDirectiveTypedDict, + ] + ] = None, + debug: Optional[ + Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] + ] = None, + deferred_tools: Optional[ + Union[ + components.DeferredToolsControl, + components.DeferredToolsControlTypedDict, + ] + ] = None, + frequency_penalty: OptionalNullable[float] = UNSET, + image_config: Optional[ + Union[ + Mapping[str, components.ImageConfig], + Mapping[str, components.ImageConfigTypedDict], + ] + ] = None, + logit_bias: OptionalNullable[Mapping[str, float]] = UNSET, + logprobs: OptionalNullable[bool] = UNSET, + max_completion_tokens: OptionalNullable[int] = UNSET, + max_tokens: OptionalNullable[int] = UNSET, + metadata: Optional[Mapping[str, str]] = None, + min_p: OptionalNullable[float] = UNSET, + modalities: Optional[Iterable[components.Modality]] = None, + model: Optional[str] = None, + models: Optional[Iterable[str]] = None, + parallel_tool_calls: OptionalNullable[bool] = UNSET, + plugins: Optional[ + Union[ + Iterable[components.ChatRequestPlugin], + Iterable[components.ChatRequestPluginTypedDict], + ] + ] = None, + prediction: OptionalNullable[ + Union[components.Prediction, components.PredictionTypedDict] + ] = UNSET, + presence_penalty: OptionalNullable[float] = UNSET, + prompt_cache_key: OptionalNullable[str] = UNSET, + prompt_cache_options: OptionalNullable[ + Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] + ] = UNSET, + provider: OptionalNullable[ + Union[ + components.ProviderPreferences, components.ProviderPreferencesTypedDict + ] + ] = UNSET, + reasoning: Optional[ + Union[ + components.ChatRequestReasoning, + components.ChatRequestReasoningTypedDict, + ] + ] = None, + reasoning_effort: OptionalNullable[ + components.ChatRequestReasoningEffort + ] = UNSET, + repetition_penalty: OptionalNullable[float] = UNSET, + response_format: Optional[ + Union[components.ResponseFormat, components.ResponseFormatTypedDict] + ] = None, + seed: OptionalNullable[int] = UNSET, + service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET, + session_id: Optional[str] = None, + stop: OptionalNullable[ + Union[components.ChatRequestStop, components.ChatRequestStopTypedDict] + ] = UNSET, + stop_server_tools_when: Optional[ + Union[ + Iterable[components.StopServerToolsWhenCondition], + Iterable[components.StopServerToolsWhenConditionTypedDict], + ] + ] = None, + stream: Optional[bool] = False, + stream_options: OptionalNullable[ + Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict] + ] = UNSET, + temperature: OptionalNullable[float] = UNSET, + tool_choice: Optional[ + Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict] + ] = None, + tools: Optional[ + Union[ + Iterable[components.ChatFunctionTool], + Iterable[components.ChatFunctionToolTypedDict], + ] + ] = None, + top_a: OptionalNullable[float] = UNSET, + top_k: OptionalNullable[int] = UNSET, + top_logprobs: OptionalNullable[int] = UNSET, + top_p: OptionalNullable[float] = UNSET, + trace: Optional[ + Union[components.TraceConfig, components.TraceConfigTypedDict] + ] = None, + user: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CreatePresetFromInferenceResponse: + r"""Create a preset from a chat-completions request body + + Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. + + If set, this operation will use `api_key` from the global security. + + :param slug: URL-safe slug identifying the preset. Created if it does not exist. + :param messages: List of messages for the conversation + :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param debug: Debug options for inspecting request transformations (streaming only) + :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. + :param frequency_penalty: Frequency penalty (-2.0 to 2.0) + :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. + :param logit_bias: Token logit bias adjustments + :param logprobs: Return log probabilities + :param max_completion_tokens: Maximum tokens in completion + :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. + :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) + :param min_p: Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter. + :param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\". + :param model: Model to use for completion + :param models: Models to use for completion + :param parallel_tool_calls: Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. + :param plugins: Plugins you want to enable for this request, including their settings. + :param prediction: Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance. + :param presence_penalty: Presence penalty (-2.0 to 2.0) + :param prompt_cache_key: + :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. + :param provider: When multiple model providers are available, optionally indicate your routing preference. + :param reasoning: Configuration options for reasoning models + :param reasoning_effort: Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ. + :param repetition_penalty: Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter. + :param response_format: Response format configuration + :param seed: Random seed for deterministic outputs + :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. + :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. + :param stop: Stop sequences (up to 4) + :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. + :param stream: Enable streaming response + :param stream_options: Streaming configuration options + :param temperature: Sampling temperature (0-2) + :param tool_choice: Tool choice configuration + :param tools: Available tools for function calling + :param top_a: Consider only tokens with \"sufficiently high\" probabilities based on the probability of the most likely token. Not all providers support this parameter. + :param top_k: Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter. + :param top_logprobs: Number of top log probabilities to return (0-20) + :param top_p: Nucleus sampling parameter (0-1) + :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. + :param user: Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.CreatePresetsChatCompletionsRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + slug=slug, + workspace_id=workspace_id, + chat_request=components.ChatRequest( + cache_control=utils.get_pydantic_model( + cache_control, Optional[components.AnthropicCacheControlDirective] + ), + debug=utils.get_pydantic_model( + debug, Optional[components.ChatDebugOptions] + ), + deferred_tools=utils.get_pydantic_model( + deferred_tools, Optional[components.DeferredToolsControl] + ), + frequency_penalty=frequency_penalty, + image_config=utils.unmarshal( + image_config, Optional[Dict[str, components.ImageConfig]] + ), + logit_bias=utils.unmarshal( + logit_bias, OptionalNullable[Dict[str, float]] + ), + logprobs=logprobs, + max_completion_tokens=max_completion_tokens, + max_tokens=max_tokens, + messages=utils.get_pydantic_model( + messages, List[components.ChatMessages] + ), + metadata=utils.unmarshal(metadata, Optional[Dict[str, str]]), + min_p=min_p, + modalities=utils.unmarshal( + modalities, Optional[List[components.Modality]] + ), + model=model, + models=utils.unmarshal(models, Optional[List[str]]), + parallel_tool_calls=parallel_tool_calls, + plugins=utils.get_pydantic_model( + plugins, Optional[List[components.ChatRequestPlugin]] + ), + prediction=utils.get_pydantic_model( + prediction, OptionalNullable[components.Prediction] + ), + presence_penalty=presence_penalty, + prompt_cache_key=prompt_cache_key, + prompt_cache_options=utils.get_pydantic_model( + prompt_cache_options, + OptionalNullable[components.PromptCacheOptions], + ), + provider=utils.get_pydantic_model( + provider, OptionalNullable[components.ProviderPreferences] + ), + reasoning=utils.get_pydantic_model( + reasoning, Optional[components.ChatRequestReasoning] + ), + reasoning_effort=reasoning_effort, + repetition_penalty=repetition_penalty, + response_format=utils.get_pydantic_model( + response_format, Optional[components.ResponseFormat] + ), + seed=seed, + service_tier=service_tier, + session_id=session_id, + stop=utils.unmarshal( + stop, OptionalNullable[components.ChatRequestStop] + ), + stop_server_tools_when=utils.get_pydantic_model( + stop_server_tools_when, + Optional[List[components.StopServerToolsWhenCondition]], + ), + stream=stream, + stream_options=utils.get_pydantic_model( + stream_options, OptionalNullable[components.ChatStreamOptions] + ), + temperature=temperature, + tool_choice=utils.get_pydantic_model( + tool_choice, Optional[components.ChatToolChoice] + ), + tools=utils.get_pydantic_model( + tools, Optional[List[components.ChatFunctionTool]] + ), + top_a=top_a, + top_k=top_k, + top_logprobs=top_logprobs, + top_p=top_p, + trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), + user=user, + ), + ) + + req = self._build_request( + method="POST", + path="/presets/{slug}/chat/completions", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.CreatePresetsChatCompletionsGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.chat_request, False, False, "json", components.ChatRequest + ), + allow_empty_value=None, + allowed_fields=["api_key"], + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="createPresetsChatCompletions", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Presets"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response( + components.CreatePresetFromInferenceResponse, http_res + ) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def create_presets_chat_completions_async( + self, + *, + slug: str, + messages: Union[ + Iterable[components.ChatMessages], + Iterable[components.ChatMessagesTypedDict], + ], + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, + cache_control: Optional[ + Union[ + components.AnthropicCacheControlDirective, + components.AnthropicCacheControlDirectiveTypedDict, + ] + ] = None, + debug: Optional[ + Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] + ] = None, + deferred_tools: Optional[ + Union[ + components.DeferredToolsControl, + components.DeferredToolsControlTypedDict, + ] + ] = None, + frequency_penalty: OptionalNullable[float] = UNSET, + image_config: Optional[ + Union[ + Mapping[str, components.ImageConfig], + Mapping[str, components.ImageConfigTypedDict], + ] + ] = None, + logit_bias: OptionalNullable[Mapping[str, float]] = UNSET, + logprobs: OptionalNullable[bool] = UNSET, + max_completion_tokens: OptionalNullable[int] = UNSET, + max_tokens: OptionalNullable[int] = UNSET, + metadata: Optional[Mapping[str, str]] = None, + min_p: OptionalNullable[float] = UNSET, + modalities: Optional[Iterable[components.Modality]] = None, + model: Optional[str] = None, + models: Optional[Iterable[str]] = None, + parallel_tool_calls: OptionalNullable[bool] = UNSET, + plugins: Optional[ + Union[ + Iterable[components.ChatRequestPlugin], + Iterable[components.ChatRequestPluginTypedDict], + ] + ] = None, + prediction: OptionalNullable[ + Union[components.Prediction, components.PredictionTypedDict] + ] = UNSET, + presence_penalty: OptionalNullable[float] = UNSET, + prompt_cache_key: OptionalNullable[str] = UNSET, + prompt_cache_options: OptionalNullable[ + Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] + ] = UNSET, + provider: OptionalNullable[ + Union[ + components.ProviderPreferences, components.ProviderPreferencesTypedDict + ] + ] = UNSET, + reasoning: Optional[ + Union[ + components.ChatRequestReasoning, + components.ChatRequestReasoningTypedDict, + ] + ] = None, + reasoning_effort: OptionalNullable[ + components.ChatRequestReasoningEffort + ] = UNSET, + repetition_penalty: OptionalNullable[float] = UNSET, + response_format: Optional[ + Union[components.ResponseFormat, components.ResponseFormatTypedDict] + ] = None, + seed: OptionalNullable[int] = UNSET, + service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET, + session_id: Optional[str] = None, + stop: OptionalNullable[ + Union[components.ChatRequestStop, components.ChatRequestStopTypedDict] + ] = UNSET, + stop_server_tools_when: Optional[ + Union[ + Iterable[components.StopServerToolsWhenCondition], + Iterable[components.StopServerToolsWhenConditionTypedDict], + ] + ] = None, + stream: Optional[bool] = False, + stream_options: OptionalNullable[ + Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict] + ] = UNSET, + temperature: OptionalNullable[float] = UNSET, + tool_choice: Optional[ + Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict] + ] = None, + tools: Optional[ + Union[ + Iterable[components.ChatFunctionTool], + Iterable[components.ChatFunctionToolTypedDict], + ] + ] = None, + top_a: OptionalNullable[float] = UNSET, + top_k: OptionalNullable[int] = UNSET, + top_logprobs: OptionalNullable[int] = UNSET, + top_p: OptionalNullable[float] = UNSET, + trace: Optional[ + Union[components.TraceConfig, components.TraceConfigTypedDict] + ] = None, + user: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.CreatePresetFromInferenceResponse: + r"""Create a preset from a chat-completions request body + + Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. + + If set, this operation will use `api_key` from the global security. + + :param slug: URL-safe slug identifying the preset. Created if it does not exist. + :param messages: List of messages for the conversation + :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param debug: Debug options for inspecting request transformations (streaming only) + :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. + :param frequency_penalty: Frequency penalty (-2.0 to 2.0) + :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. + :param logit_bias: Token logit bias adjustments + :param logprobs: Return log probabilities + :param max_completion_tokens: Maximum tokens in completion + :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. + :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) + :param min_p: Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter. + :param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\". + :param model: Model to use for completion + :param models: Models to use for completion + :param parallel_tool_calls: Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. + :param plugins: Plugins you want to enable for this request, including their settings. + :param prediction: Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance. + :param presence_penalty: Presence penalty (-2.0 to 2.0) + :param prompt_cache_key: + :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. + :param provider: When multiple model providers are available, optionally indicate your routing preference. + :param reasoning: Configuration options for reasoning models + :param reasoning_effort: Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ. + :param repetition_penalty: Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter. + :param response_format: Response format configuration + :param seed: Random seed for deterministic outputs + :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. + :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. + :param stop: Stop sequences (up to 4) + :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. + :param stream: Enable streaming response + :param stream_options: Streaming configuration options + :param temperature: Sampling temperature (0-2) + :param tool_choice: Tool choice configuration + :param tools: Available tools for function calling + :param top_a: Consider only tokens with \"sufficiently high\" probabilities based on the probability of the most likely token. Not all providers support this parameter. + :param top_k: Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter. + :param top_logprobs: Number of top log probabilities to return (0-20) + :param top_p: Nucleus sampling parameter (0-1) + :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. + :param user: Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.CreatePresetsChatCompletionsRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + slug=slug, + workspace_id=workspace_id, + chat_request=components.ChatRequest( + cache_control=utils.get_pydantic_model( + cache_control, Optional[components.AnthropicCacheControlDirective] ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] @@ -937,7 +1639,7 @@ def create_presets_chat_completions( ), ) - req = self._build_request( + req = self._build_request_async( method="POST", path="/presets/{slug}/chat/completions", base_url=base_url, @@ -975,7 +1677,7 @@ def create_presets_chat_completions( if isinstance(retries, utils.RetryConfig): retry_config = (retries, ["5XX"]) - http_res = self.do_request( + http_res = await self.do_request_async( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", @@ -1028,26 +1730,29 @@ def create_presets_chat_completions( ) raise errors.InternalServerResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - async def create_presets_chat_completions_async( + def create_presets_messages( self, *, slug: str, - messages: Union[ - Iterable[components.ChatMessages], - Iterable[components.ChatMessagesTypedDict], + messages: Nullable[ + Union[ + Iterable[components.MessagesMessageParam], + Iterable[components.MessagesMessageParamTypedDict], + ] ], + model: str, http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, @@ -1058,94 +1763,79 @@ async def create_presets_chat_completions_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, - debug: Optional[ - Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] - ] = None, + context_management: OptionalNullable[ + Union[components.ContextManagement, components.ContextManagementTypedDict] + ] = UNSET, deferred_tools: Optional[ Union[ components.DeferredToolsControl, components.DeferredToolsControlTypedDict, ] ] = None, - frequency_penalty: OptionalNullable[float] = UNSET, - image_config: Optional[ + fallbacks: OptionalNullable[ Union[ - Mapping[str, components.ImageConfig], - Mapping[str, components.ImageConfigTypedDict], + Iterable[components.MessagesFallbackParam], + Iterable[components.MessagesFallbackParamTypedDict], + ] + ] = UNSET, + max_tokens: Optional[int] = None, + metadata: Optional[ + Union[ + components.MessagesRequestMetadata, + components.MessagesRequestMetadataTypedDict, ] ] = None, - logit_bias: OptionalNullable[Mapping[str, float]] = UNSET, - logprobs: OptionalNullable[bool] = UNSET, - max_completion_tokens: OptionalNullable[int] = UNSET, - max_tokens: OptionalNullable[int] = UNSET, - metadata: Optional[Mapping[str, str]] = None, - min_p: OptionalNullable[float] = UNSET, - modalities: Optional[Iterable[components.Modality]] = None, - model: Optional[str] = None, models: Optional[Iterable[str]] = None, - parallel_tool_calls: OptionalNullable[bool] = UNSET, + output_config: Optional[ + Union[ + components.MessagesOutputConfig, + components.MessagesOutputConfigTypedDict, + ] + ] = None, plugins: Optional[ Union[ - Iterable[components.ChatRequestPlugin], - Iterable[components.ChatRequestPluginTypedDict], + Iterable[components.MessagesRequestPlugin], + Iterable[components.MessagesRequestPluginTypedDict], ] ] = None, - prediction: OptionalNullable[ - Union[components.Prediction, components.PredictionTypedDict] - ] = UNSET, - presence_penalty: OptionalNullable[float] = UNSET, - prompt_cache_key: OptionalNullable[str] = UNSET, - prompt_cache_options: OptionalNullable[ - Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] - ] = UNSET, provider: OptionalNullable[ Union[ components.ProviderPreferences, components.ProviderPreferencesTypedDict ] ] = UNSET, - reasoning: Optional[ + safeguards: OptionalNullable[ Union[ - components.ChatRequestReasoning, - components.ChatRequestReasoningTypedDict, + Iterable[components.AnthropicSafeguard], + Iterable[components.AnthropicSafeguardTypedDict], ] - ] = None, - reasoning_effort: OptionalNullable[ - components.ChatRequestReasoningEffort ] = UNSET, - repetition_penalty: OptionalNullable[float] = UNSET, - response_format: Optional[ - Union[components.ResponseFormat, components.ResponseFormatTypedDict] - ] = None, - seed: OptionalNullable[int] = UNSET, - service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET, + service_tier: Optional[str] = None, session_id: Optional[str] = None, - stop: OptionalNullable[ - Union[components.ChatRequestStop, components.ChatRequestStopTypedDict] - ] = UNSET, + speed: OptionalNullable[components.Speed] = UNSET, + stop_sequences: Optional[Iterable[str]] = None, stop_server_tools_when: Optional[ Union[ Iterable[components.StopServerToolsWhenCondition], Iterable[components.StopServerToolsWhenConditionTypedDict], ] ] = None, - stream: Optional[bool] = False, - stream_options: OptionalNullable[ - Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict] - ] = UNSET, - temperature: OptionalNullable[float] = UNSET, + stream: Optional[bool] = None, + system: Optional[Union[components.System, components.SystemTypedDict]] = None, + temperature: Optional[float] = None, + thinking: Optional[ + Union[components.Thinking, components.ThinkingTypedDict] + ] = None, tool_choice: Optional[ - Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict] + Union[components.ToolChoice, components.ToolChoiceTypedDict] ] = None, tools: Optional[ Union[ - Iterable[components.ChatFunctionTool], - Iterable[components.ChatFunctionToolTypedDict], + Iterable[components.MessagesRequestToolUnion], + Iterable[components.MessagesRequestToolUnionTypedDict], ] ] = None, - top_a: OptionalNullable[float] = UNSET, - top_k: OptionalNullable[int] = UNSET, - top_logprobs: OptionalNullable[int] = UNSET, - top_p: OptionalNullable[float] = UNSET, + top_k: Optional[int] = None, + top_p: Optional[float] = None, trace: Optional[ Union[components.TraceConfig, components.TraceConfigTypedDict] ] = None, @@ -1155,14 +1845,15 @@ async def create_presets_chat_completions_async( timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, ) -> components.CreatePresetFromInferenceResponse: - r"""Create a preset from a chat-completions request body + r"""Create a preset from a messages request body Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. If set, this operation will use `api_key` from the global security. :param slug: URL-safe slug identifying the preset. Created if it does not exist. - :param messages: List of messages for the conversation + :param messages: + :param model: :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application. @@ -1170,48 +1861,33 @@ async def create_presets_chat_completions_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. - :param debug: Debug options for inspecting request transformations (streaming only) + :param context_management: :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. - :param frequency_penalty: Frequency penalty (-2.0 to 2.0) - :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. - :param logit_bias: Token logit bias adjustments - :param logprobs: Return log probabilities - :param max_completion_tokens: Maximum tokens in completion - :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. - :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) - :param min_p: Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter. - :param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\". - :param model: Model to use for completion - :param models: Models to use for completion - :param parallel_tool_calls: Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. - :param plugins: Plugins you want to enable for this request, including their settings. - :param prediction: Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance. - :param presence_penalty: Presence penalty (-2.0 to 2.0) - :param prompt_cache_key: - :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. - :param provider: When multiple model providers are available, optionally indicate your routing preference. - :param reasoning: Configuration options for reasoning models - :param reasoning_effort: Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ. - :param repetition_penalty: Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter. - :param response_format: Response format configuration - :param seed: Random seed for deterministic outputs - :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. + :param fallbacks: Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with `models`. Each entry accepts only `model`. Maximum of 3 entries. + :param max_tokens: + :param metadata: + :param models: + :param output_config: Configuration for controlling output behavior. Supports the effort parameter and structured output format. + :param plugins: Plugins you want to enable for this request, including their settings. + :param provider: When multiple model providers are available, optionally indicate your routing preference. + :param safeguards: + :param service_tier: :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. - :param stop: Stop sequences (up to 4) + :param speed: + :param stop_sequences: :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. - :param stream: Enable streaming response - :param stream_options: Streaming configuration options - :param temperature: Sampling temperature (0-2) - :param tool_choice: Tool choice configuration - :param tools: Available tools for function calling - :param top_a: Consider only tokens with \"sufficiently high\" probabilities based on the probability of the most likely token. Not all providers support this parameter. - :param top_k: Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter. - :param top_logprobs: Number of top log probabilities to return (0-20) - :param top_p: Nucleus sampling parameter (0-1) + :param stream: + :param system: + :param temperature: + :param thinking: + :param tool_choice: + :param tools: + :param top_k: + :param top_p: :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. - :param user: Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. + :param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -1227,99 +1903,76 @@ async def create_presets_chat_completions_async( else: base_url = self._get_url(base_url, url_variables) - request = operations.CreatePresetsChatCompletionsRequest( + request = operations.CreatePresetsMessagesRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, workspace_id=workspace_id, - chat_request=components.ChatRequest( + messages_request=components.MessagesRequest( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), - debug=utils.get_pydantic_model( - debug, Optional[components.ChatDebugOptions] + context_management=utils.get_pydantic_model( + context_management, OptionalNullable[components.ContextManagement] ), deferred_tools=utils.get_pydantic_model( deferred_tools, Optional[components.DeferredToolsControl] ), - frequency_penalty=frequency_penalty, - image_config=utils.unmarshal( - image_config, Optional[Dict[str, components.ImageConfig]] - ), - logit_bias=utils.unmarshal( - logit_bias, OptionalNullable[Dict[str, float]] + fallbacks=utils.get_pydantic_model( + fallbacks, OptionalNullable[List[components.MessagesFallbackParam]] ), - logprobs=logprobs, - max_completion_tokens=max_completion_tokens, max_tokens=max_tokens, messages=utils.get_pydantic_model( - messages, List[components.ChatMessages] + messages, Nullable[List[components.MessagesMessageParam]] ), - metadata=utils.unmarshal(metadata, Optional[Dict[str, str]]), - min_p=min_p, - modalities=utils.unmarshal( - modalities, Optional[List[components.Modality]] + metadata=utils.get_pydantic_model( + metadata, Optional[components.MessagesRequestMetadata] ), model=model, models=utils.unmarshal(models, Optional[List[str]]), - parallel_tool_calls=parallel_tool_calls, - plugins=utils.get_pydantic_model( - plugins, Optional[List[components.ChatRequestPlugin]] - ), - prediction=utils.get_pydantic_model( - prediction, OptionalNullable[components.Prediction] + output_config=utils.get_pydantic_model( + output_config, Optional[components.MessagesOutputConfig] ), - presence_penalty=presence_penalty, - prompt_cache_key=prompt_cache_key, - prompt_cache_options=utils.get_pydantic_model( - prompt_cache_options, - OptionalNullable[components.PromptCacheOptions], + plugins=utils.get_pydantic_model( + plugins, Optional[List[components.MessagesRequestPlugin]] ), provider=utils.get_pydantic_model( provider, OptionalNullable[components.ProviderPreferences] ), - reasoning=utils.get_pydantic_model( - reasoning, Optional[components.ChatRequestReasoning] - ), - reasoning_effort=reasoning_effort, - repetition_penalty=repetition_penalty, - response_format=utils.get_pydantic_model( - response_format, Optional[components.ResponseFormat] + safeguards=utils.get_pydantic_model( + safeguards, OptionalNullable[List[components.AnthropicSafeguard]] ), - seed=seed, service_tier=service_tier, session_id=session_id, - stop=utils.unmarshal( - stop, OptionalNullable[components.ChatRequestStop] - ), + speed=speed, + stop_sequences=utils.unmarshal(stop_sequences, Optional[List[str]]), stop_server_tools_when=utils.get_pydantic_model( stop_server_tools_when, Optional[List[components.StopServerToolsWhenCondition]], ), stream=stream, - stream_options=utils.get_pydantic_model( - stream_options, OptionalNullable[components.ChatStreamOptions] - ), + system=utils.get_pydantic_model(system, Optional[components.System]), temperature=temperature, + thinking=utils.get_pydantic_model( + thinking, Optional[components.Thinking] + ), tool_choice=utils.get_pydantic_model( - tool_choice, Optional[components.ChatToolChoice] + tool_choice, Optional[components.ToolChoice] ), tools=utils.get_pydantic_model( - tools, Optional[List[components.ChatFunctionTool]] + tools, Optional[List[components.MessagesRequestToolUnion]] ), - top_a=top_a, top_k=top_k, - top_logprobs=top_logprobs, top_p=top_p, trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), user=user, ), ) - req = self._build_request_async( + req = self._build_request( method="POST", - path="/presets/{slug}/chat/completions", + path="/presets/{slug}/messages", base_url=base_url, url_variables=url_variables, request=request, @@ -1329,14 +1982,18 @@ async def create_presets_chat_completions_async( user_agent_header="user-agent", accept_header_value="application/json", http_headers=http_headers, - _globals=operations.CreatePresetsChatCompletionsGlobals( + _globals=operations.CreatePresetsMessagesGlobals( http_referer=self.sdk_configuration.globals.http_referer, x_open_router_title=self.sdk_configuration.globals.x_open_router_title, x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, ), security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( - request.chat_request, False, False, "json", components.ChatRequest + request.messages_request, + False, + False, + "json", + components.MessagesRequest, ), allow_empty_value=None, allowed_fields=["api_key"], @@ -1355,11 +2012,11 @@ async def create_presets_chat_completions_async( if isinstance(retries, utils.RetryConfig): retry_config = (retries, ["5XX"]) - http_res = await self.do_request_async( + http_res = self.do_request( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="createPresetsChatCompletions", + operation_id="createPresetsMessages", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, components.Security @@ -1408,19 +2065,19 @@ async def create_presets_chat_completions_async( ) raise errors.InternalServerResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) + http_res_text = utils.stream_to_text(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) if utils.match_response(http_res, "5XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) + http_res_text = utils.stream_to_text(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - def create_presets_messages( + async def create_presets_messages_async( self, *, slug: str, @@ -1539,7 +2196,7 @@ def create_presets_messages( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. :param context_management: :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. @@ -1648,7 +2305,7 @@ def create_presets_messages( ), ) - req = self._build_request( + req = self._build_request_async( method="POST", path="/presets/{slug}/messages", base_url=base_url, @@ -1690,7 +2347,7 @@ def create_presets_messages( if isinstance(retries, utils.RetryConfig): retry_config = (retries, ["5XX"]) - http_res = self.do_request( + http_res = await self.do_request_async( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", @@ -1743,130 +2400,145 @@ def create_presets_messages( ) raise errors.InternalServerResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - async def create_presets_messages_async( + def create_presets_responses( self, *, slug: str, - messages: Nullable[ - Union[ - Iterable[components.MessagesMessageParam], - Iterable[components.MessagesMessageParamTypedDict], - ] - ], - model: str, http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, workspace_id: Optional[str] = None, + access_programs: Optional[ + Union[ + components.ResponsesRequestAccessPrograms, + components.ResponsesRequestAccessProgramsTypedDict, + ] + ] = None, + background: OptionalNullable[bool] = UNSET, cache_control: Optional[ Union[ components.AnthropicCacheControlDirective, components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, - context_management: OptionalNullable[ - Union[components.ContextManagement, components.ContextManagementTypedDict] - ] = UNSET, + debug: Optional[ + Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] + ] = None, deferred_tools: Optional[ Union[ components.DeferredToolsControl, components.DeferredToolsControlTypedDict, ] ] = None, - fallbacks: OptionalNullable[ - Union[ - Iterable[components.MessagesFallbackParam], - Iterable[components.MessagesFallbackParamTypedDict], - ] - ] = UNSET, - max_tokens: Optional[int] = None, - metadata: Optional[ + frequency_penalty: OptionalNullable[float] = UNSET, + image_config: Optional[ Union[ - components.MessagesRequestMetadata, - components.MessagesRequestMetadataTypedDict, + Mapping[str, components.ImageConfig], + Mapping[str, components.ImageConfigTypedDict], ] ] = None, + include: OptionalNullable[Iterable[components.ResponseIncludesEnum]] = UNSET, + input: Optional[ + Union[components.InputsUnion, components.InputsUnionTypedDict] + ] = None, + instructions: OptionalNullable[str] = UNSET, + max_output_tokens: OptionalNullable[int] = UNSET, + max_tool_calls: OptionalNullable[int] = UNSET, + metadata: OptionalNullable[Mapping[str, str]] = UNSET, + modalities: Optional[Iterable[components.OutputModalityEnum]] = None, + model: Optional[str] = None, models: Optional[Iterable[str]] = None, - output_config: Optional[ + parallel_tool_calls: OptionalNullable[bool] = UNSET, + plugins: Optional[ Union[ - components.MessagesOutputConfig, - components.MessagesOutputConfigTypedDict, + Iterable[components.ResponsesRequestPlugin], + Iterable[components.ResponsesRequestPluginTypedDict], ] ] = None, - plugins: Optional[ + presence_penalty: OptionalNullable[float] = UNSET, + previous_response_id: Optional[Any] = None, + prompt: OptionalNullable[ Union[ - Iterable[components.MessagesRequestPlugin], - Iterable[components.MessagesRequestPluginTypedDict], + components.StoredPromptTemplate, + components.StoredPromptTemplateTypedDict, ] - ] = None, + ] = UNSET, + prompt_cache_key: OptionalNullable[str] = UNSET, + prompt_cache_options: OptionalNullable[ + Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] + ] = UNSET, provider: OptionalNullable[ Union[ components.ProviderPreferences, components.ProviderPreferencesTypedDict ] ] = UNSET, - safeguards: OptionalNullable[ + reasoning: OptionalNullable[ + Union[components.ReasoningConfig, components.ReasoningConfigTypedDict] + ] = UNSET, + safety_identifier: OptionalNullable[str] = UNSET, + service_tier: OptionalNullable[components.ResponsesRequestServiceTier] = "auto", + session_id: Optional[str] = None, + stop: OptionalNullable[ Union[ - Iterable[components.AnthropicSafeguard], - Iterable[components.AnthropicSafeguardTypedDict], + components.ResponsesRequestStop, + components.ResponsesRequestStopTypedDict, ] ] = UNSET, - service_tier: Optional[str] = None, - session_id: Optional[str] = None, - speed: OptionalNullable[components.Speed] = UNSET, - stop_sequences: Optional[Iterable[str]] = None, stop_server_tools_when: Optional[ Union[ Iterable[components.StopServerToolsWhenCondition], Iterable[components.StopServerToolsWhenConditionTypedDict], ] ] = None, - stream: Optional[bool] = None, - system: Optional[Union[components.System, components.SystemTypedDict]] = None, - temperature: Optional[float] = None, - thinking: Optional[ - Union[components.Thinking, components.ThinkingTypedDict] + stream: Optional[bool] = False, + temperature: OptionalNullable[float] = UNSET, + text: Optional[ + Union[components.TextExtendedConfig, components.TextExtendedConfigTypedDict] ] = None, tool_choice: Optional[ - Union[components.ToolChoice, components.ToolChoiceTypedDict] + Union[ + components.OpenAIResponsesToolChoiceUnion, + components.OpenAIResponsesToolChoiceUnionTypedDict, + ] ] = None, tools: Optional[ Union[ - Iterable[components.MessagesRequestToolUnion], - Iterable[components.MessagesRequestToolUnionTypedDict], + Iterable[components.ResponsesRequestToolUnion], + Iterable[components.ResponsesRequestToolUnionTypedDict], ] ] = None, top_k: Optional[int] = None, - top_p: Optional[float] = None, + top_logprobs: OptionalNullable[int] = UNSET, + top_p: OptionalNullable[float] = UNSET, trace: Optional[ Union[components.TraceConfig, components.TraceConfigTypedDict] ] = None, + truncation: OptionalNullable[components.OpenAIResponsesTruncation] = UNSET, user: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, ) -> components.CreatePresetFromInferenceResponse: - r"""Create a preset from a messages request body + r"""Create a preset from a responses request body Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. If set, this operation will use `api_key` from the global security. :param slug: URL-safe slug identifying the preset. Created if it does not exist. - :param messages: - :param model: :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application. @@ -1874,32 +2546,47 @@ async def create_presets_messages_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. + :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. - :param context_management: + :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. - :param fallbacks: Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with `models`. Each entry accepts only `model`. Maximum of 3 entries. - :param max_tokens: - :param metadata: + :param frequency_penalty: + :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. + :param include: + :param input: Input for a response request - can be a string or array of items + :param instructions: + :param max_output_tokens: + :param max_tool_calls: Maximum number of server-tool (e.g. `openrouter:web_search`) agent steps the model may take during a request. Defaults to 30, which is also the maximum. Ignored when `stop_server_tools_when` is set. + :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. + :param modalities: Output modalities for the response. Supported values are \"text\" and \"image\". + :param model: :param models: - :param output_config: Configuration for controlling output behavior. Supports the effort parameter and structured output format. + :param parallel_tool_calls: :param plugins: Plugins you want to enable for this request, including their settings. + :param presence_penalty: + :param previous_response_id: Not supported on this proxy. Each response request is independent: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead. + :param prompt: + :param prompt_cache_key: + :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. :param provider: When multiple model providers are available, optionally indicate your routing preference. - :param safeguards: - :param service_tier: + :param reasoning: Configuration for reasoning mode in the response + :param safety_identifier: Recommended per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. + :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. - :param speed: - :param stop_sequences: + :param stop: Stop sequences (up to 4) :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. :param stream: - :param system: :param temperature: - :param thinking: + :param text: Text output configuration including format and verbosity :param tool_choice: :param tools: :param top_k: + :param top_logprobs: :param top_p: :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. + :param truncation: :param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method @@ -1916,76 +2603,96 @@ async def create_presets_messages_async( else: base_url = self._get_url(base_url, url_variables) - request = operations.CreatePresetsMessagesRequest( + request = operations.CreatePresetsResponsesRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, workspace_id=workspace_id, - messages_request=components.MessagesRequest( + responses_request=components.ResponsesRequest( + access_programs=utils.get_pydantic_model( + access_programs, Optional[components.ResponsesRequestAccessPrograms] + ), + background=background, cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), - context_management=utils.get_pydantic_model( - context_management, OptionalNullable[components.ContextManagement] + debug=utils.get_pydantic_model( + debug, Optional[components.ChatDebugOptions] ), deferred_tools=utils.get_pydantic_model( deferred_tools, Optional[components.DeferredToolsControl] ), - fallbacks=utils.get_pydantic_model( - fallbacks, OptionalNullable[List[components.MessagesFallbackParam]] + frequency_penalty=frequency_penalty, + image_config=utils.unmarshal( + image_config, Optional[Dict[str, components.ImageConfig]] ), - max_tokens=max_tokens, - messages=utils.get_pydantic_model( - messages, Nullable[List[components.MessagesMessageParam]] + include=utils.unmarshal( + include, OptionalNullable[List[components.ResponseIncludesEnum]] ), - metadata=utils.get_pydantic_model( - metadata, Optional[components.MessagesRequestMetadata] + input=utils.get_pydantic_model(input, Optional[components.InputsUnion]), + instructions=instructions, + max_output_tokens=max_output_tokens, + max_tool_calls=max_tool_calls, + metadata=utils.unmarshal(metadata, OptionalNullable[Dict[str, str]]), + modalities=utils.unmarshal( + modalities, Optional[List[components.OutputModalityEnum]] ), model=model, models=utils.unmarshal(models, Optional[List[str]]), - output_config=utils.get_pydantic_model( - output_config, Optional[components.MessagesOutputConfig] - ), + parallel_tool_calls=parallel_tool_calls, plugins=utils.get_pydantic_model( - plugins, Optional[List[components.MessagesRequestPlugin]] + plugins, Optional[List[components.ResponsesRequestPlugin]] + ), + presence_penalty=presence_penalty, + previous_response_id=previous_response_id, + prompt=utils.get_pydantic_model( + prompt, OptionalNullable[components.StoredPromptTemplate] + ), + prompt_cache_key=prompt_cache_key, + prompt_cache_options=utils.get_pydantic_model( + prompt_cache_options, + OptionalNullable[components.PromptCacheOptions], ), provider=utils.get_pydantic_model( provider, OptionalNullable[components.ProviderPreferences] ), - safeguards=utils.get_pydantic_model( - safeguards, OptionalNullable[List[components.AnthropicSafeguard]] + reasoning=utils.get_pydantic_model( + reasoning, OptionalNullable[components.ReasoningConfig] ), + safety_identifier=safety_identifier, service_tier=service_tier, session_id=session_id, - speed=speed, - stop_sequences=utils.unmarshal(stop_sequences, Optional[List[str]]), + stop=utils.unmarshal( + stop, OptionalNullable[components.ResponsesRequestStop] + ), stop_server_tools_when=utils.get_pydantic_model( stop_server_tools_when, Optional[List[components.StopServerToolsWhenCondition]], ), stream=stream, - system=utils.get_pydantic_model(system, Optional[components.System]), temperature=temperature, - thinking=utils.get_pydantic_model( - thinking, Optional[components.Thinking] + text=utils.get_pydantic_model( + text, Optional[components.TextExtendedConfig] ), tool_choice=utils.get_pydantic_model( - tool_choice, Optional[components.ToolChoice] + tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion] ), tools=utils.get_pydantic_model( - tools, Optional[List[components.MessagesRequestToolUnion]] + tools, Optional[List[components.ResponsesRequestToolUnion]] ), top_k=top_k, + top_logprobs=top_logprobs, top_p=top_p, trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), + truncation=truncation, user=user, ), ) - req = self._build_request_async( + req = self._build_request( method="POST", - path="/presets/{slug}/messages", + path="/presets/{slug}/responses", base_url=base_url, url_variables=url_variables, request=request, @@ -1995,18 +2702,18 @@ async def create_presets_messages_async( user_agent_header="user-agent", accept_header_value="application/json", http_headers=http_headers, - _globals=operations.CreatePresetsMessagesGlobals( + _globals=operations.CreatePresetsResponsesGlobals( http_referer=self.sdk_configuration.globals.http_referer, x_open_router_title=self.sdk_configuration.globals.x_open_router_title, x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, ), security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( - request.messages_request, + request.responses_request, False, False, "json", - components.MessagesRequest, + components.ResponsesRequest, ), allow_empty_value=None, allowed_fields=["api_key"], @@ -2025,11 +2732,11 @@ async def create_presets_messages_async( if isinstance(retries, utils.RetryConfig): retry_config = (retries, ["5XX"]) - http_res = await self.do_request_async( + http_res = self.do_request( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="createPresetsMessages", + operation_id="createPresetsResponses", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, components.Security @@ -2078,19 +2785,19 @@ async def create_presets_messages_async( ) raise errors.InternalServerResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) + http_res_text = utils.stream_to_text(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) if utils.match_response(http_res, "5XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) + http_res_text = utils.stream_to_text(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - def create_presets_responses( + async def create_presets_responses_async( self, *, slug: str, @@ -2224,7 +2931,7 @@ def create_presets_responses( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. @@ -2368,7 +3075,7 @@ def create_presets_responses( ), ) - req = self._build_request( + req = self._build_request_async( method="POST", path="/presets/{slug}/responses", base_url=base_url, @@ -2410,7 +3117,7 @@ def create_presets_responses( if isinstance(retries, utils.RetryConfig): retry_config = (retries, ["5XX"]) - http_res = self.do_request( + http_res = await self.do_request_async( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", @@ -2463,19 +3170,168 @@ def create_presets_responses( ) raise errors.InternalServerResponseError(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) + http_res_text = await utils.stream_to_text_async(http_res) raise errors.OpenRouterDefaultError( "API error occurred", http_res, http_res_text ) raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - async def create_presets_responses_async( + def restore( + self, + *, + slug: str, + http_referer: Optional[str] = None, + x_open_router_title: Optional[str] = None, + x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> components.GetPresetResponse: + r"""Restore a preset + + Re-activates an archived preset so it resolves for inference again. No version is created and the designated version is unchanged. Restoring an active preset returns it unchanged. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. + + If set, this operation will use `api_key` from the global security. + + :param slug: URL-safe slug identifying the preset. + :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. + This is used to track API usage per application. + + :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard. + + :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + :param http_headers: Additional headers to set or replace on requests. + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = operations.RestorePresetRequest( + http_referer=http_referer, + x_open_router_title=x_open_router_title, + x_open_router_categories=x_open_router_categories, + slug=slug, + workspace_id=workspace_id, + ) + + req = self._build_request( + method="POST", + path="/presets/{slug}/restore", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + _globals=operations.RestorePresetGlobals( + http_referer=self.sdk_configuration.globals.http_referer, + x_open_router_title=self.sdk_configuration.globals.x_open_router_title, + x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + allowed_fields=["api_key"], + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["5XX"]) + + http_res = self.do_request( + hook_ctx=HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="restorePreset", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, components.Security + ), + tags=["Presets"], + extensions=None, + ), + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + retry_config=retry_config, + ) + + response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return unmarshal_json_response(components.GetPresetResponse, http_res) + if utils.match_response(http_res, "400", "application/json"): + response_data = unmarshal_json_response( + errors.BadRequestResponseErrorData, http_res + ) + raise errors.BadRequestResponseError(response_data, http_res) + if utils.match_response(http_res, "401", "application/json"): + response_data = unmarshal_json_response( + errors.UnauthorizedResponseErrorData, http_res + ) + raise errors.UnauthorizedResponseError(response_data, http_res) + if utils.match_response(http_res, "403", "application/json"): + response_data = unmarshal_json_response( + errors.ForbiddenResponseErrorData, http_res + ) + raise errors.ForbiddenResponseError(response_data, http_res) + if utils.match_response(http_res, "404", "application/json"): + response_data = unmarshal_json_response( + errors.NotFoundResponseErrorData, http_res + ) + raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) + if utils.match_response(http_res, "500", "application/json"): + response_data = unmarshal_json_response( + errors.InternalServerResponseErrorData, http_res + ) + raise errors.InternalServerResponseError(response_data, http_res) + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "API error occurred", http_res, http_res_text + ) + + raise errors.OpenRouterDefaultError("Unexpected response received", http_res) + + async def restore_async( self, *, slug: str, @@ -2483,125 +3339,18 @@ async def create_presets_responses_async( x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, workspace_id: Optional[str] = None, - access_programs: Optional[ - Union[ - components.ResponsesRequestAccessPrograms, - components.ResponsesRequestAccessProgramsTypedDict, - ] - ] = None, - background: OptionalNullable[bool] = UNSET, - cache_control: Optional[ - Union[ - components.AnthropicCacheControlDirective, - components.AnthropicCacheControlDirectiveTypedDict, - ] - ] = None, - debug: Optional[ - Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] - ] = None, - deferred_tools: Optional[ - Union[ - components.DeferredToolsControl, - components.DeferredToolsControlTypedDict, - ] - ] = None, - frequency_penalty: OptionalNullable[float] = UNSET, - image_config: Optional[ - Union[ - Mapping[str, components.ImageConfig], - Mapping[str, components.ImageConfigTypedDict], - ] - ] = None, - include: OptionalNullable[Iterable[components.ResponseIncludesEnum]] = UNSET, - input: Optional[ - Union[components.InputsUnion, components.InputsUnionTypedDict] - ] = None, - instructions: OptionalNullable[str] = UNSET, - max_output_tokens: OptionalNullable[int] = UNSET, - max_tool_calls: OptionalNullable[int] = UNSET, - metadata: OptionalNullable[Mapping[str, str]] = UNSET, - modalities: Optional[Iterable[components.OutputModalityEnum]] = None, - model: Optional[str] = None, - models: Optional[Iterable[str]] = None, - parallel_tool_calls: OptionalNullable[bool] = UNSET, - plugins: Optional[ - Union[ - Iterable[components.ResponsesRequestPlugin], - Iterable[components.ResponsesRequestPluginTypedDict], - ] - ] = None, - presence_penalty: OptionalNullable[float] = UNSET, - previous_response_id: Optional[Any] = None, - prompt: OptionalNullable[ - Union[ - components.StoredPromptTemplate, - components.StoredPromptTemplateTypedDict, - ] - ] = UNSET, - prompt_cache_key: OptionalNullable[str] = UNSET, - prompt_cache_options: OptionalNullable[ - Union[components.PromptCacheOptions, components.PromptCacheOptionsTypedDict] - ] = UNSET, - provider: OptionalNullable[ - Union[ - components.ProviderPreferences, components.ProviderPreferencesTypedDict - ] - ] = UNSET, - reasoning: OptionalNullable[ - Union[components.ReasoningConfig, components.ReasoningConfigTypedDict] - ] = UNSET, - safety_identifier: OptionalNullable[str] = UNSET, - service_tier: OptionalNullable[components.ResponsesRequestServiceTier] = "auto", - session_id: Optional[str] = None, - stop: OptionalNullable[ - Union[ - components.ResponsesRequestStop, - components.ResponsesRequestStopTypedDict, - ] - ] = UNSET, - stop_server_tools_when: Optional[ - Union[ - Iterable[components.StopServerToolsWhenCondition], - Iterable[components.StopServerToolsWhenConditionTypedDict], - ] - ] = None, - stream: Optional[bool] = False, - temperature: OptionalNullable[float] = UNSET, - text: Optional[ - Union[components.TextExtendedConfig, components.TextExtendedConfigTypedDict] - ] = None, - tool_choice: Optional[ - Union[ - components.OpenAIResponsesToolChoiceUnion, - components.OpenAIResponsesToolChoiceUnionTypedDict, - ] - ] = None, - tools: Optional[ - Union[ - Iterable[components.ResponsesRequestToolUnion], - Iterable[components.ResponsesRequestToolUnionTypedDict], - ] - ] = None, - top_k: Optional[int] = None, - top_logprobs: OptionalNullable[int] = UNSET, - top_p: OptionalNullable[float] = UNSET, - trace: Optional[ - Union[components.TraceConfig, components.TraceConfigTypedDict] - ] = None, - truncation: OptionalNullable[components.OpenAIResponsesTruncation] = UNSET, - user: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> components.CreatePresetFromInferenceResponse: - r"""Create a preset from a responses request body + ) -> components.GetPresetResponse: + r"""Restore a preset - Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. + Re-activates an archived preset so it resolves for inference again. No version is created and the designated version is unchanged. Restoring an active preset returns it unchanged. A disabled preset returns 409. Requires a read-write [management key](/docs/guides/overview/auth/management-api-keys); inference API keys are rejected. `workspace_id` may be sent as a query parameter or a JSON body field. If set, this operation will use `api_key` from the global security. - :param slug: URL-safe slug identifying the preset. Created if it does not exist. + :param slug: URL-safe slug identifying the preset. :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application. @@ -2609,48 +3358,7 @@ async def create_presets_responses_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. - :param workspace_id: Workspace to create the preset in. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. - :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. - :param background: - :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. - :param debug: Debug options for inspecting request transformations (streaming only) - :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. - :param frequency_penalty: - :param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. - :param include: - :param input: Input for a response request - can be a string or array of items - :param instructions: - :param max_output_tokens: - :param max_tool_calls: Maximum number of server-tool (e.g. `openrouter:web_search`) agent steps the model may take during a request. Defaults to 30, which is also the maximum. Ignored when `stop_server_tools_when` is set. - :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. - :param modalities: Output modalities for the response. Supported values are \"text\" and \"image\". - :param model: - :param models: - :param parallel_tool_calls: - :param plugins: Plugins you want to enable for this request, including their settings. - :param presence_penalty: - :param previous_response_id: Not supported on this proxy. Each response request is independent: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead. - :param prompt: - :param prompt_cache_key: - :param prompt_cache_options: Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. `ttl` sets the minimum cache lifetime for every breakpoint the request writes: \"30m\" (default) or \"12h\" (billed at the higher 12h cache-write rate). Only supported by OpenAI GPT-5.6 and newer. - :param provider: When multiple model providers are available, optionally indicate your routing preference. - :param reasoning: Configuration for reasoning mode in the response - :param safety_identifier: Recommended per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account. - :param service_tier: The service tier to use for processing this request. `fast` is accepted as an alias for `priority`. `ultrafast` prefers ultrafast endpoints and falls back to `priority`, then default endpoints. - :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. - :param stop: Stop sequences (up to 4) - :param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call. - :param stream: - :param temperature: - :param text: Text output configuration including format and verbosity - :param tool_choice: - :param tools: - :param top_k: - :param top_logprobs: - :param top_p: - :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. - :param truncation: - :param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -2666,118 +3374,32 @@ async def create_presets_responses_async( else: base_url = self._get_url(base_url, url_variables) - request = operations.CreatePresetsResponsesRequest( + request = operations.RestorePresetRequest( http_referer=http_referer, x_open_router_title=x_open_router_title, x_open_router_categories=x_open_router_categories, slug=slug, workspace_id=workspace_id, - responses_request=components.ResponsesRequest( - access_programs=utils.get_pydantic_model( - access_programs, Optional[components.ResponsesRequestAccessPrograms] - ), - background=background, - cache_control=utils.get_pydantic_model( - cache_control, Optional[components.AnthropicCacheControlDirective] - ), - debug=utils.get_pydantic_model( - debug, Optional[components.ChatDebugOptions] - ), - deferred_tools=utils.get_pydantic_model( - deferred_tools, Optional[components.DeferredToolsControl] - ), - frequency_penalty=frequency_penalty, - image_config=utils.unmarshal( - image_config, Optional[Dict[str, components.ImageConfig]] - ), - include=utils.unmarshal( - include, OptionalNullable[List[components.ResponseIncludesEnum]] - ), - input=utils.get_pydantic_model(input, Optional[components.InputsUnion]), - instructions=instructions, - max_output_tokens=max_output_tokens, - max_tool_calls=max_tool_calls, - metadata=utils.unmarshal(metadata, OptionalNullable[Dict[str, str]]), - modalities=utils.unmarshal( - modalities, Optional[List[components.OutputModalityEnum]] - ), - model=model, - models=utils.unmarshal(models, Optional[List[str]]), - parallel_tool_calls=parallel_tool_calls, - plugins=utils.get_pydantic_model( - plugins, Optional[List[components.ResponsesRequestPlugin]] - ), - presence_penalty=presence_penalty, - previous_response_id=previous_response_id, - prompt=utils.get_pydantic_model( - prompt, OptionalNullable[components.StoredPromptTemplate] - ), - prompt_cache_key=prompt_cache_key, - prompt_cache_options=utils.get_pydantic_model( - prompt_cache_options, - OptionalNullable[components.PromptCacheOptions], - ), - provider=utils.get_pydantic_model( - provider, OptionalNullable[components.ProviderPreferences] - ), - reasoning=utils.get_pydantic_model( - reasoning, OptionalNullable[components.ReasoningConfig] - ), - safety_identifier=safety_identifier, - service_tier=service_tier, - session_id=session_id, - stop=utils.unmarshal( - stop, OptionalNullable[components.ResponsesRequestStop] - ), - stop_server_tools_when=utils.get_pydantic_model( - stop_server_tools_when, - Optional[List[components.StopServerToolsWhenCondition]], - ), - stream=stream, - temperature=temperature, - text=utils.get_pydantic_model( - text, Optional[components.TextExtendedConfig] - ), - tool_choice=utils.get_pydantic_model( - tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion] - ), - tools=utils.get_pydantic_model( - tools, Optional[List[components.ResponsesRequestToolUnion]] - ), - top_k=top_k, - top_logprobs=top_logprobs, - top_p=top_p, - trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), - truncation=truncation, - user=user, - ), ) req = self._build_request_async( method="POST", - path="/presets/{slug}/responses", + path="/presets/{slug}/restore", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + request_body_required=False, request_has_path_params=True, request_has_query_params=True, user_agent_header="user-agent", accept_header_value="application/json", http_headers=http_headers, - _globals=operations.CreatePresetsResponsesGlobals( + _globals=operations.RestorePresetGlobals( http_referer=self.sdk_configuration.globals.http_referer, x_open_router_title=self.sdk_configuration.globals.x_open_router_title, x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.responses_request, - False, - False, - "json", - components.ResponsesRequest, - ), allow_empty_value=None, allowed_fields=["api_key"], timeout_ms=timeout_ms, @@ -2799,7 +3421,7 @@ async def create_presets_responses_async( hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="createPresetsResponses", + operation_id="restorePreset", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, components.Security @@ -2814,9 +3436,7 @@ async def create_presets_responses_async( response_data: Any = None if utils.match_response(http_res, "200", "application/json"): - return unmarshal_json_response( - components.CreatePresetFromInferenceResponse, http_res - ) + return unmarshal_json_response(components.GetPresetResponse, http_res) if utils.match_response(http_res, "400", "application/json"): response_data = unmarshal_json_response( errors.BadRequestResponseErrorData, http_res @@ -2869,6 +3489,7 @@ def list_versions( x_open_router_categories: Optional[str] = None, offset: OptionalNullable[int] = 0, limit: Optional[int] = 50, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -2890,6 +3511,7 @@ def list_versions( :param offset: Number of records to skip for pagination :param limit: Maximum number of records to return (max 100) + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -2912,6 +3534,7 @@ def list_versions( slug=slug, offset=offset, limit=limit, + workspace_id=workspace_id, ) req = self._build_request( @@ -2988,6 +3611,7 @@ def next_func() -> Optional[operations.ListPresetVersionsResponse]: x_open_router_categories=x_open_router_categories, offset=next_offset, limit=limit, + workspace_id=workspace_id, retries=retries, server_url=server_url, timeout_ms=timeout_ms, @@ -3054,6 +3678,7 @@ async def list_versions_async( x_open_router_categories: Optional[str] = None, offset: OptionalNullable[int] = 0, limit: Optional[int] = 50, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -3075,6 +3700,7 @@ async def list_versions_async( :param offset: Number of records to skip for pagination :param limit: Maximum number of records to return (max 100) + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -3097,6 +3723,7 @@ async def list_versions_async( slug=slug, offset=offset, limit=limit, + workspace_id=workspace_id, ) req = self._build_request_async( @@ -3176,6 +3803,7 @@ async def empty_result(): x_open_router_categories=x_open_router_categories, offset=next_offset, limit=limit, + workspace_id=workspace_id, retries=retries, server_url=server_url, timeout_ms=timeout_ms, @@ -3241,6 +3869,7 @@ def get_version( http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -3261,6 +3890,7 @@ def get_version( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -3282,6 +3912,7 @@ def get_version( x_open_router_categories=x_open_router_categories, slug=slug, version=version, + workspace_id=workspace_id, ) req = self._build_request( @@ -3392,6 +4023,7 @@ async def get_version_async( http_referer: Optional[str] = None, x_open_router_title: Optional[str] = None, x_open_router_categories: Optional[str] = None, + workspace_id: Optional[str] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -3412,6 +4044,7 @@ async def get_version_async( :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings. + :param workspace_id: Workspace to act in. Also accepted as a `workspace_id` field in a JSON request body. Defaults to the key's workspace for a key limited to one workspace, otherwise to the account's default workspace. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -3433,6 +4066,7 @@ async def get_version_async( x_open_router_categories=x_open_router_categories, slug=slug, version=version, + workspace_id=workspace_id, ) req = self._build_request_async( diff --git a/uv.lock b/uv.lock index a9f65524d..8e8252d0f 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.145" +version = "1.3.146" source = { editable = "." } dependencies = [ { name = "httpcore" }, From 3289a4903aaa66f9e351572f5758afdffdf0d605 Mon Sep 17 00:00:00 2001 From: "speakeasy-github[bot]" <128539517+speakeasy-github[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:06:26 +0000 Subject: [PATCH 2/2] empty commit to trigger [run-tests] workflow