From 1f912c86b55da689702eca6fa8c96150f39a613d Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 29 Sep 2026 22:08:37 +0000 Subject: [PATCH 1/3] ## Typescript SDK Changes: * `openrouter.tools.listTools()`: **Added** * `openrouter.tools.getTool()`: **Added** --- .speakeasy/gen.lock | 294 ++++++++-- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 509 ++++++++++++++++++ .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/models/byok.mdx | 21 + docs/models/generationresponsedata.mdx | 2 +- ...n.mdx => generationresponsedataregion.mdx} | 6 +- docs/models/gettoolresponse.mdx | 50 ++ docs/models/listtoolsresponse.mdx | 25 + docs/models/listtoolsresponselinks.mdx | 19 + docs/models/modelslistresponse.mdx | 2 +- ...{links.mdx => modelslistresponselinks.mdx} | 6 +- docs/models/nativesupport.mdx | 33 ++ docs/models/operations/apiformat.mdx | 21 + docs/models/operations/gettoolglobals.mdx | 19 + docs/models/operations/gettoolrequest.mdx | 22 + docs/models/operations/gettoolresponse.mdx | 20 + docs/models/operations/gettoolsecurity.mdx | 19 + docs/models/operations/listtoolsglobals.mdx | 19 + docs/models/operations/listtoolsrequest.mdx | 22 + docs/models/operations/listtoolssecurity.mdx | 19 + docs/models/pricingsource.mdx | 21 + docs/models/servertool.mdx | 74 +++ docs/models/servertooldetails.mdx | 78 +++ docs/models/servertooldetailsstatus.mdx | 19 + .../servertooldetailssupportedapiformat.mdx | 19 + docs/models/servertoolengine.mdx | 45 ++ docs/models/servertoolenginedataregion.mdx | 19 + docs/models/servertoolexecutedby.mdx | 21 + docs/models/servertoolinputname.mdx | 28 + docs/models/servertoolinputnameapiformat.mdx | 19 + docs/models/servertoolnativemodel.mdx | 24 + docs/models/servertoolnativesupport.mdx | 23 + docs/models/servertooloutputname.mdx | 22 + docs/models/servertooloutputnameapiformat.mdx | 19 + docs/models/servertoolprice.mdx | 25 + docs/models/servertoolstatus.mdx | 19 + docs/models/servertoolsupportedapiformat.mdx | 19 + docs/sdks/tools/README.mdx | 179 ++++++ jsr.json | 2 +- package.json | 12 +- src/funcs/toolsGetTool.ts | 228 ++++++++ src/funcs/toolsListTools.ts | 226 ++++++++ src/lib/config.ts | 4 +- src/models/generationresponse.ts | 16 +- src/models/gettoolresponse.ts | 35 ++ src/models/index.ts | 11 + src/models/listtoolsresponse.ts | 69 +++ src/models/modelslistresponse.ts | 19 +- src/models/operations/gettool.ts | 138 +++++ src/models/operations/index.ts | 2 + src/models/operations/listtools.ts | 143 +++++ src/models/servertool.ts | 141 +++++ src/models/servertooldetails.ts | 177 ++++++ src/models/servertoolengine.ts | 140 +++++ src/models/servertoolexecutedby.ts | 27 + src/models/servertoolinputname.ts | 68 +++ src/models/servertoolnativemodel.ts | 33 ++ src/models/servertoolnativesupport.ts | 42 ++ src/models/servertooloutputname.ts | 63 +++ src/models/servertoolprice.ts | 48 ++ src/sdk/sdk.ts | 6 + src/sdk/tools.ts | 51 ++ 64 files changed, 3453 insertions(+), 73 deletions(-) create mode 100644 docs/models/byok.mdx rename docs/models/{dataregion.mdx => generationresponsedataregion.mdx} (63%) create mode 100644 docs/models/gettoolresponse.mdx create mode 100644 docs/models/listtoolsresponse.mdx create mode 100644 docs/models/listtoolsresponselinks.mdx rename docs/models/{links.mdx => modelslistresponselinks.mdx} (89%) create mode 100644 docs/models/nativesupport.mdx create mode 100644 docs/models/operations/apiformat.mdx create mode 100644 docs/models/operations/gettoolglobals.mdx create mode 100644 docs/models/operations/gettoolrequest.mdx create mode 100644 docs/models/operations/gettoolresponse.mdx create mode 100644 docs/models/operations/gettoolsecurity.mdx create mode 100644 docs/models/operations/listtoolsglobals.mdx create mode 100644 docs/models/operations/listtoolsrequest.mdx create mode 100644 docs/models/operations/listtoolssecurity.mdx create mode 100644 docs/models/pricingsource.mdx create mode 100644 docs/models/servertool.mdx create mode 100644 docs/models/servertooldetails.mdx create mode 100644 docs/models/servertooldetailsstatus.mdx create mode 100644 docs/models/servertooldetailssupportedapiformat.mdx create mode 100644 docs/models/servertoolengine.mdx create mode 100644 docs/models/servertoolenginedataregion.mdx create mode 100644 docs/models/servertoolexecutedby.mdx create mode 100644 docs/models/servertoolinputname.mdx create mode 100644 docs/models/servertoolinputnameapiformat.mdx create mode 100644 docs/models/servertoolnativemodel.mdx create mode 100644 docs/models/servertoolnativesupport.mdx create mode 100644 docs/models/servertooloutputname.mdx create mode 100644 docs/models/servertooloutputnameapiformat.mdx create mode 100644 docs/models/servertoolprice.mdx create mode 100644 docs/models/servertoolstatus.mdx create mode 100644 docs/models/servertoolsupportedapiformat.mdx create mode 100644 docs/sdks/tools/README.mdx create mode 100644 src/funcs/toolsGetTool.ts create mode 100644 src/funcs/toolsListTools.ts create mode 100644 src/models/gettoolresponse.ts create mode 100644 src/models/listtoolsresponse.ts create mode 100644 src/models/operations/gettool.ts create mode 100644 src/models/operations/listtools.ts create mode 100644 src/models/servertool.ts create mode 100644 src/models/servertooldetails.ts create mode 100644 src/models/servertoolengine.ts create mode 100644 src/models/servertoolexecutedby.ts create mode 100644 src/models/servertoolinputname.ts create mode 100644 src/models/servertoolnativemodel.ts create mode 100644 src/models/servertoolnativesupport.ts create mode 100644 src/models/servertooloutputname.ts create mode 100644 src/models/servertoolprice.ts create mode 100644 src/sdk/tools.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index d7c39c517..70b30ba7d 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: "" id: "" management: - docChecksum: 810dcc4db103a54f5c3b2bde8ac3d5e8 + docChecksum: 3a70839f27ad0af36a1425539a5bbe88 docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.4.6 - configChecksum: 21bbbd37a55f78b83f5d1ad6f1dc1315 + releaseVersion: 1.4.7 + configChecksum: 4d67a9ad89dc991261fa221f0435e6cf repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true persistentEdits: - generation_id: 4ec531b2-1935-4462-a2cc-321cf59960f8 - pristine_commit_hash: 67919b9bbf5a9f12c7b699d11bb07a24f6046881 - pristine_tree_hash: 2f364fad99801652559a241cff2c470340bca496 + generation_id: 53e5f7dc-ffce-49ce-850f-70d3b7e3bd73 + pristine_commit_hash: e0438e55736ac50b5afb53dbe7257b96361fb325 + pristine_tree_hash: d73edfa7f79c93d839d8ea46c8e186a92372464e features: typescript: acceptHeaders: 2.81.2 @@ -2169,6 +2169,10 @@ trackedFiles: id: 685ae36c8a54 last_write_checksum: sha1:2d5e22c6bd893304bf8ee85ea81ae49a6af38252 pristine_git_object: df8c75747c0bee1e041dcfcaddea076b981b8fd2 + docs/models/byok.mdx: + id: 66199fffec11 + last_write_checksum: sha1:ba35f7d0e423860c825f3f2885f411b6d613d491 + pristine_git_object: 38a9973f0edf58d4801ba22cd9cd864c91331a7f docs/models/byokkey.md: id: 1d4e696e1745 last_write_checksum: sha1:c2cb80b295efdd829597e676fda3790ac743045e @@ -4023,10 +4027,6 @@ trackedFiles: last_write_checksum: sha1:fd17fab426500b4ce527ac860cc982c6bce3df83 pristine_git_object: ae55fad1993d9afc358d0e569e8ad30bbe7de837 deleted: true - docs/models/dataregion.mdx: - id: 532e8a5aa63f - last_write_checksum: sha1:dea4ee7b4116b0e46ba46269de1464966fc015a5 - pristine_git_object: 52686da821cd635cfa3a85f9a6fca76c54cf26f4 docs/models/datetimeservertool.md: id: b02ea2e59c87 last_write_checksum: sha1:bfad59260102a65c226e7e81c38bcc5e8c9e224d @@ -5195,8 +5195,12 @@ trackedFiles: deleted: true docs/models/generationresponsedata.mdx: id: 567ecc8f7594 - last_write_checksum: sha1:ab16c4535269a1a0f6632625b7883c9e55c542a5 - pristine_git_object: 913a2d97d713c61c1cf71eb89c7761b1fbd4c107 + last_write_checksum: sha1:659675eccfddec19f27667879a44847c4fee468e + pristine_git_object: cd1791554d07affc20dde446d8b887b02db2833d + docs/models/generationresponsedataregion.mdx: + id: b29820c5087b + last_write_checksum: sha1:2c00c1c77ce9281f2f353a35aa8373b607afb19b + pristine_git_object: a71da2b2089ae4d5e7d61810fbda547806a25234 docs/models/getbyokkeyresponse.md: id: 84d627a7ab6a last_write_checksum: sha1:3b79a1b578028d0a03def5b050346bde8574e745 @@ -5250,6 +5254,10 @@ trackedFiles: id: 00ba09581ff7 last_write_checksum: sha1:e24f58e010cae5048bf0575f14bbda33a3316e13 pristine_git_object: 8e052f829cf9ff54e9ba0bee39a1e12a87de726b + docs/models/gettoolresponse.mdx: + id: 7ba2367178d6 + last_write_checksum: sha1:b9395d3b138e2895935fea84931b1e7e41d5084e + pristine_git_object: 106b28d3767475d8a1a66750dd9da89ef6c03362 docs/models/getworkspacebudgetresponse.mdx: id: f486a2f837eb last_write_checksum: sha1:ebb2deb16a365062e20e7a7430c8bc01e09578bb @@ -6428,10 +6436,6 @@ trackedFiles: id: 4ac2797095fd last_write_checksum: sha1:45eefe4bf307602e1cec85f5f8c131b0d3e50eae pristine_git_object: fe1d440797852da7d96ed2a2615032782f419109 - docs/models/links.mdx: - id: 77435348177f - last_write_checksum: sha1:35da11bbc0d90361f9059adc8e2b02acb8725250 - pristine_git_object: 494e00703f966b339b1c39aab7928666d4c415ab docs/models/listbyokkeysresponse.md: id: 04a91ef5b66a last_write_checksum: sha1:fbce1df10994ea265185d0112f748749a9d39e0a @@ -6511,6 +6515,14 @@ trackedFiles: id: 00c0d0c56555 last_write_checksum: sha1:0fe02b93272492468676e98db9b0d1acf4f91984 pristine_git_object: fa43be61a6bb7d53939622b943e4ca100a9232a6 + docs/models/listtoolsresponse.mdx: + id: 5e4b02e4e15f + last_write_checksum: sha1:b9116e37c6d4b4550a1acea3bde9908170ce4918 + pristine_git_object: 11485ac4b5ecda127b6e16d0f61109a20c1276ff + docs/models/listtoolsresponselinks.mdx: + id: 859bd48cfa58 + last_write_checksum: sha1:c31f7d2d8421073f27e9829e850319abdcd8f12a + pristine_git_object: f2e3b39c6b8ee542b0dd13c892fe950204459220 docs/models/listworkspacebudgetsresponse.md: id: 7b25fbff0283 last_write_checksum: sha1:ade25543d5e312c7160573411bbea9f06931fae3 @@ -7144,8 +7156,12 @@ trackedFiles: pristine_git_object: e8415a55972fe11053152efd0513db6f937d5b72 docs/models/modelslistresponse.mdx: id: e4fca550ce24 - last_write_checksum: sha1:ecdedd2ce69dcddc5dd75b8a1ad68c4f68fd8414 - pristine_git_object: 7219f0f22438b3a0ba89b5946acb06ce9ee1a321 + last_write_checksum: sha1:8053790038b96e72c22209f20a72aaa6454068fd + pristine_git_object: 418f7f126cb611732ba2aaf25e50499e450334aa + docs/models/modelslistresponselinks.mdx: + id: 1d4e86f175c9 + last_write_checksum: sha1:b3ea6235f600bd50a52c2c0eba6bc35072f24086 + pristine_git_object: 4bf366758e4f1f2aaf737403873da2f43cf41e6e docs/models/moderation.md: id: ace7cb4ee27c last_write_checksum: sha1:bcd2fab3a1355e3cb37ce2963f22e061c6b012b4 @@ -7243,6 +7259,10 @@ trackedFiles: id: ab007ceb89ee last_write_checksum: sha1:e0f49f4b291a4e26e55666de4117d4c97ed678ef pristine_git_object: 63ba6028a2f8d2dd77f29b3b4e3d0a47a7e05044 + docs/models/nativesupport.mdx: + id: 42770419553f + last_write_checksum: sha1:863c8afe5daaf06cd62d87bea86fd4a589b2809e + pristine_git_object: 67337e8c94eb197f0d229d539b9be2a05e86715b docs/models/nativetools.mdx: id: b80f1d927aa1 last_write_checksum: sha1:dc118d51a747da3f1a83a67f338cce3fb4ca9af6 @@ -8058,6 +8078,10 @@ trackedFiles: id: 149c27f32b70 last_write_checksum: sha1:5ab3c86184bf28586906db9ea1e5b4c8d4c3c13e pristine_git_object: 743923b1cd2cc2f5ae7242d6c62ec9c3e2731f9f + docs/models/operations/apiformat.mdx: + id: 7ca6f151cc13 + last_write_checksum: sha1:b8406f444bbb4e7be3aa241b0e63e695ca442dd5 + pristine_git_object: 173a3853798d27d56325f038c92503fffadc3ce3 docs/models/operations/arena.md: id: 18236c4c4904 last_write_checksum: sha1:5dcbf7f15f7ae622c831ac0c0b6865ec1bdf0266 @@ -9402,6 +9426,22 @@ trackedFiles: id: 798b3d7c2623 last_write_checksum: sha1:f1dc8bb7cd297d49fe3d1e0355c8fdcb1b0360ac pristine_git_object: 9c26cc8ca999deb10236e29a9b7aced3d9ec9bd0 + docs/models/operations/gettoolglobals.mdx: + id: 90c31c921312 + last_write_checksum: sha1:d577cca74602e2e0766bdad54f3bf9d2e2001e66 + pristine_git_object: b9e03e032a97ddffe5252eb91bf9ae1361520569 + docs/models/operations/gettoolrequest.mdx: + id: d8325ac6bd5d + last_write_checksum: sha1:75c26e77fe82c3376c20beddaefb935abf28080e + pristine_git_object: 1ac7f03a950b1aae2717314ecd93af91dfa30907 + docs/models/operations/gettoolresponse.mdx: + id: cb12da37e876 + last_write_checksum: sha1:2c8dee5aee16cffd60f93e313e6e3e54a390e80f + pristine_git_object: a60af9601d2e1cee17b7a323a0913119d4f839b2 + docs/models/operations/gettoolsecurity.mdx: + id: d91c16fd247e + last_write_checksum: sha1:217167d4fd8a5663b4128b8dd409b66e6a4c513c + pristine_git_object: 036a1f3e8e00b084fff23c63637208f039fee94b docs/models/operations/getuseractivityglobals.mdx: id: c31f07d6c741 last_write_checksum: sha1:4fef627b378ab970f1a33b0463769bb34b99112d @@ -9991,6 +10031,18 @@ trackedFiles: id: 061ed874493a last_write_checksum: sha1:3acd017ce8c3b84f544c45bac5fb0bd6ab8f8b69 pristine_git_object: 7bd81456bb269a52856f6163cd336435b66b1150 + docs/models/operations/listtoolsglobals.mdx: + id: 0514ca3a4bc5 + last_write_checksum: sha1:87ff872f30e4a52cdb4dd22191c8c7a681ed174b + pristine_git_object: 47136bbd4e6901959797283bda9fbcccbc9111fb + docs/models/operations/listtoolsrequest.mdx: + id: 4cd9c8d395ad + last_write_checksum: sha1:ce9d3eed486106ba615c928b13a2ff18052271ca + pristine_git_object: a4b7ee9ed06d033bd7d74230d2681baa5fedb5e0 + docs/models/operations/listtoolssecurity.mdx: + id: c10a0d9fd934 + last_write_checksum: sha1:d43cb228932d6a7f772171e166d91c1e25cdefa3 + pristine_git_object: 74604fb62034ec097ad2c9750b57097699d236ee docs/models/operations/listvaultsecretsglobals.mdx: id: b1d464228c32 last_write_checksum: sha1:3cf29e176ed6a14abf50cd1bf1fec532ebf27456 @@ -11885,6 +11937,10 @@ trackedFiles: id: f090bf7c3b28 last_write_checksum: sha1:03bcb74eeb5da8f6006e16adf4b3bb04456c0a4e pristine_git_object: 8ff6de441c391b40c5c53afb186ec0f204a2e21d + docs/models/pricingsource.mdx: + id: 263ce039e007 + last_write_checksum: sha1:b9a0c22ce5f3dc43786f14272752c49d77cb618c + pristine_git_object: 5997b8fb649172f71c6421b1764b4b59faa7a4aa docs/models/primarymetric.mdx: id: 7c4a8c10dda7 last_write_checksum: sha1:b9ddcac03d5e24fe60a281b91820791c6bc9c88b @@ -12728,6 +12784,70 @@ trackedFiles: id: f9005cfa3971 last_write_checksum: sha1:734cf960ef4eb3d7077298270f627503a30316dd pristine_git_object: efdcc3db8a2788f9d44b572dc493e4b373a878ae + docs/models/servertool.mdx: + id: c995f518eea9 + last_write_checksum: sha1:79b7ca33fa3c42ddc4fa1ff32d8706c0a1c4eee7 + pristine_git_object: 42075b0c305b6f4765cd9b782773dcad51da079f + docs/models/servertooldetails.mdx: + id: 528f7e31f1d9 + last_write_checksum: sha1:9fc0080d52aca67a94b283278a4f36a4c3154086 + pristine_git_object: a1d2501490101a5b5601ee9a17e1477e173bfa0e + docs/models/servertooldetailsstatus.mdx: + id: a3efff1288a4 + last_write_checksum: sha1:3efd01f6eeafb8cc1252d377128980bfb0dd3b02 + pristine_git_object: aea0e07652dcd665408d31b9a86ebb405f7bb8dc + docs/models/servertooldetailssupportedapiformat.mdx: + id: a9cf46b49b9e + last_write_checksum: sha1:df8a5e3ad2d656063a829a5ec1e0457970577394 + pristine_git_object: e40807f34dfd5c48c57b8c8d592bdce323701670 + docs/models/servertoolengine.mdx: + id: aa538562d8de + last_write_checksum: sha1:d82cf5eac244af3462f0253832634dfed304536c + pristine_git_object: aaa4f6d5c79a98931cd8b8b87a6f42294e94fc22 + docs/models/servertoolenginedataregion.mdx: + id: 59d7402c50dc + last_write_checksum: sha1:1bae949ee6dbed81614855a17a03457f4d05a443 + pristine_git_object: 08792155db0bb9f5e1cedbb24b15b902247e364b + docs/models/servertoolexecutedby.mdx: + id: 628e3c3ed835 + last_write_checksum: sha1:5fc0848ece8cebf7714c4fda7643277f806b47c7 + pristine_git_object: 34f103a63b9bd955064c2083be9530b87456eecb + docs/models/servertoolinputname.mdx: + id: e6e8b4639499 + last_write_checksum: sha1:58f5ffa34c6f2d56a046ce32e2ba5b1a22a0e945 + pristine_git_object: 333942c08463a858687858043dbc892cb07c0b42 + docs/models/servertoolinputnameapiformat.mdx: + id: b22c65727c63 + last_write_checksum: sha1:2d4cd2451a9363ee561cdacb4729cfc0b78874fb + pristine_git_object: 6bd57f906845d5209a4392f3546d42d2c910b9eb + docs/models/servertoolnativemodel.mdx: + id: cf57871cdd18 + last_write_checksum: sha1:09f661fcbf7ca15b02c5620445677f4b806599f9 + pristine_git_object: 12cf7ecacbae1401d05367a5430812c3eca06fbd + docs/models/servertoolnativesupport.mdx: + id: f1e8ef2b5c6c + last_write_checksum: sha1:a2ee970e01a4c6afff9bab27968ce85ef3d7a0ab + pristine_git_object: 4c6454276c1a78e28bd70d96c13f4cf2ce1caaf2 + docs/models/servertooloutputname.mdx: + id: f81dfa9bae90 + last_write_checksum: sha1:b88795f00c187d2706732b6ab958b8b7f9179694 + pristine_git_object: 7966c17c90502450ea686e99923a3fee124e706f + docs/models/servertooloutputnameapiformat.mdx: + id: 935f2f2bd173 + last_write_checksum: sha1:a7859a2501a5b18216c8ec32abe9547270c93622 + pristine_git_object: 3ada10e87714aa65bcf1fdc5ee4e549963698afc + docs/models/servertoolprice.mdx: + id: b21f48bcc2e4 + last_write_checksum: sha1:0ab5dc86e114dee667d6449890b1069438745c99 + pristine_git_object: f9ef474c664c47edc56cdc13768e934b3a1ee830 + docs/models/servertoolstatus.mdx: + id: 0d521bf3b482 + last_write_checksum: sha1:5c11fa0ebda7381a74f4a26ce8575c3290036ae3 + pristine_git_object: bde1d067df111a9d41d91ec00beed2548fce3266 + docs/models/servertoolsupportedapiformat.mdx: + id: 1b35b290ab08 + last_write_checksum: sha1:22a390eeee66ee9290c61d2fbec58d933800524e + pristine_git_object: 97facf9ea3ac6ab4735ee4f0bcde288779b65fa5 docs/models/servertooluse.md: id: 98bf7ef92260 last_write_checksum: sha1:bf42a3dc0d1b69375beb7367d5c22294654b0f3b @@ -14854,6 +14974,10 @@ trackedFiles: id: 55c317c71f3d last_write_checksum: sha1:bc9bdc066212391be32e4418438b965694faa2c8 pristine_git_object: b537f54a24ec9db99114c4e3c87aad4394218e5f + docs/sdks/tools/README.mdx: + id: 32d2a83beeba + last_write_checksum: sha1:82392b26ebdda2710d1e333f5b55030c8ab1eb9f + pristine_git_object: 6a9650d01cba1d9cdf69819675a867082076ae16 docs/sdks/tts/README.md: id: 0c425074d09f last_write_checksum: sha1:019ae6737c83daac03ebbe7d56c49b0d3ad11262 @@ -14911,12 +15035,12 @@ trackedFiles: pristine_git_object: 410efafd6a7f50d91ccb87131fedbe0c3d47e15a jsr.json: id: 7f6ab7767282 - last_write_checksum: sha1:996ba1aacc7316f17573e43bc67f3d8651baa65b - pristine_git_object: 9e9cb32c6c9e254abfe4fd365d2db09a39c567ad + last_write_checksum: sha1:f419d6022da62dd05faf01c3d039836cb67d2cba + pristine_git_object: 79eeb769d7db3f33b724fab4aef1a5c638d7ffe9 package.json: id: 7030d0b2f71b - last_write_checksum: sha1:f08082b9efb91b6321383f6142e3bda1bdd50444 - pristine_git_object: 34226eaddf79ac69d482a08db62a57b97a13bae3 + last_write_checksum: sha1:e90b36e826358816ee94dc60436ac1c3dbe2f0bf + pristine_git_object: 666151c75b93f81bc958f4f9a063583b88da8c7d src/core.ts: id: f431fdbcd144 last_write_checksum: sha1:5aa66b0b6a5964f3eea7f3098c2eb3c0ee9c0131 @@ -15377,6 +15501,14 @@ trackedFiles: id: 446a269bb013 last_write_checksum: sha1:371dfcdd07849de9b435b70f4a853d5296cb4101 pristine_git_object: 7ff9ffc17f233b69e4b603894acf1ef5a443b0d1 + src/funcs/toolsGetTool.ts: + id: 4234ef4b0718 + last_write_checksum: sha1:87f7c194dd18e3f2277c551baed2088f3d582d44 + pristine_git_object: 8d7c1bcd074155f036f31c05bade6641b3d464e1 + src/funcs/toolsListTools.ts: + id: c07da22ec653 + last_write_checksum: sha1:67770f16b9421f8c5e81d19db4f4e48041ea0183 + pristine_git_object: 57a7eeafda237f6c1968bfcf622674cc10e3371b src/funcs/ttsCreateSpeech.ts: id: ed304f5d6ad8 last_write_checksum: sha1:9036bff1fc295e995ac27b32a022b378b548b3bd @@ -15499,8 +15631,8 @@ trackedFiles: pristine_git_object: a187e58707bdb726ca2aff74941efe7493422d4e src/lib/config.ts: id: 320761608fb3 - last_write_checksum: sha1:f096b61448a470f4ed6d0aaa40a2475d33de641a - pristine_git_object: 9866cf0fa46b7fa7985856f1ce940eca3fad6bb5 + last_write_checksum: sha1:2aca924f42ddb1dfed57cc2bb900008a37d7c404 + pristine_git_object: 7aedcdd8a189e4c436da82e5334fafb6f3388502 src/lib/dlv.ts: id: b1988214835a last_write_checksum: sha1:eaac763b22717206a6199104e0403ed17a4e2711 @@ -17037,8 +17169,8 @@ trackedFiles: pristine_git_object: 32fced537ac9c61153c93a9f93d679ea5f1e2e18 src/models/generationresponse.ts: id: f9109ae06502 - last_write_checksum: sha1:beebb60c663b86b70e172c0a7fe4422f6561328d - pristine_git_object: 7b54936c4ca5d2d9cf7fe5af08537a0ed7e39770 + last_write_checksum: sha1:d4242bfa12a05a61f4b1e8c26bfc0f5b2276720d + pristine_git_object: 3cb344000091ef597ab72829192b0c76627e4ac9 src/models/getbyokkeyresponse.ts: id: c83ed9fbd575 last_write_checksum: sha1:8c270135769e92feab86d649563a5c6f63bdad7b @@ -17067,6 +17199,10 @@ trackedFiles: id: 3ada334326d5 last_write_checksum: sha1:978720f0c836107cb4fd3221d93e827a349acd23 pristine_git_object: bc05db7bd7d9a273ca038e9950aab7c1030665a2 + src/models/gettoolresponse.ts: + id: ef3123a53743 + last_write_checksum: sha1:cc554c9c27d023f499a22b556e3ff73375ab3162 + pristine_git_object: cd0acc18419c4f517f22caed3543cf6e66bedf48 src/models/getworkspacebudgetresponse.ts: id: ccd40e25fb1b last_write_checksum: sha1:b00cd8f433ea625940f8a3f31a37e0f130e21f8b @@ -17205,8 +17341,8 @@ trackedFiles: pristine_git_object: 7abdfe096d3adff317db6837dc689c69db92e127 src/models/index.ts: id: f93644b0f37e - last_write_checksum: sha1:2ae266385b689c45c47ae459207d258b106c0eb0 - pristine_git_object: 6a7a2dbb6a142fc2c4068a5dcd47ba4f0987dd43 + last_write_checksum: sha1:c861f4ab789c183b7bd7562b62ce7410f586d119 + pristine_git_object: 9ced5a45d5a42af874dce3d2349bc16c303ebb7a src/models/inputaudio.ts: id: 9bdc14c7565f last_write_checksum: sha1:2f8dc4c1d6a9c2927d9eb186e0ecedf7b81838e6 @@ -17439,6 +17575,10 @@ trackedFiles: id: d3fac2f94e20 last_write_checksum: sha1:f138d6ec516edff561acf3ee2038febe0fe2bd90 pristine_git_object: 5b63973a8724442c77527f11a557dfc84d5ea409 + src/models/listtoolsresponse.ts: + id: d36b0fe12aa7 + last_write_checksum: sha1:6d33f4c59f3dd1a716785edb676381ce99dafada + pristine_git_object: 0efff11ce4fa652d75b3ea5cc862f434f048f4a6 src/models/listworkspacebudgetsresponse.ts: id: 2573f31846b9 last_write_checksum: sha1:5a818c34a0c4878c3ee0864c0d20ed5680306ca8 @@ -17589,8 +17729,8 @@ trackedFiles: pristine_git_object: e2ab1ce5ab82b35958bdce0f997accad6929d7d6 src/models/modelslistresponse.ts: id: ea0e62a13d8d - last_write_checksum: sha1:e2ffb58b8938c51ef6b700d2ac32a638c9d4a021 - pristine_git_object: 8e625a6e3affce508fad974a077f7923eb4c57eb + last_write_checksum: sha1:34556e78b43d004d6f4c59be45ea55a1d2004a16 + pristine_git_object: bf1fc3855709a33e60781b8081fe5784013fa947 src/models/moderationplugin.ts: id: 309bb6cfc394 last_write_checksum: sha1:da7750a3d97ce6cdcd87f4002b289e95743fa8f6 @@ -18107,6 +18247,10 @@ trackedFiles: id: 8482753ddd33 last_write_checksum: sha1:eabf9f38dead635af268288733e71d20af1df218 pristine_git_object: 47868501a4656f1d1cb9043d12bc503df56f62dc + src/models/operations/gettool.ts: + id: 643b31a6a57a + last_write_checksum: sha1:30e18f1a7e9e98d1cc24bff088378089fbd9512d + pristine_git_object: c68951678f3debd58428b481a18fd1d8edd0cab3 src/models/operations/getuseractivity.ts: id: 19535b4511a4 last_write_checksum: sha1:a067b505696a74ba2b5515c5f6512de5d74ac109 @@ -18125,8 +18269,8 @@ trackedFiles: pristine_git_object: a052ed42bd123e79be1f05dc823c808f8c32b383 src/models/operations/index.ts: id: 0d9ffaf774d2 - last_write_checksum: sha1:cd2d2fc3f3339a115b795fa1e85e0a3056c0a45e - pristine_git_object: dffc4fdceb8ca7ff1da7d5b4731439d5953dddc6 + last_write_checksum: sha1:1ae2e2ad9252a08cb92299e9c0dd1bffc3afbe24 + pristine_git_object: a780c5cebfca999edc853e4dcb9e978a83c20f2b src/models/operations/invokeintern.ts: id: f2b19fbd8a96 last_write_checksum: sha1:55f0d7c3a2020919fbf3e92c2c7524a75a412504 @@ -18251,6 +18395,10 @@ trackedFiles: id: f6a6cc9a951f last_write_checksum: sha1:13264909ed0ea4937d7732844dfa9793ddfb09c7 pristine_git_object: 76f7457be38af733c73dd7de01d8a24bf6305b79 + src/models/operations/listtools.ts: + id: 42a61de0bc0f + last_write_checksum: sha1:5ce38fa9b53465cc8c1c3554a0fcd29b9976bd5e + pristine_git_object: 350e2ccb3955b166236b9aed66f45e12e984aaf6 src/models/operations/listvaultsecrets.ts: id: 6485557c7ef8 last_write_checksum: sha1:249cb0e75630b323dd956f4edca160c9ca825cdf @@ -18895,6 +19043,42 @@ trackedFiles: id: d90c6c784ca5 last_write_checksum: sha1:90d7a8903f46cd2ea5428527343a003511fc78c9 pristine_git_object: af44b3ab6c4b542d720f0b5b5bb31e2aa51c1862 + src/models/servertool.ts: + id: 51581c50c8ce + last_write_checksum: sha1:e3e3c7a904514e1eb50afdd88bbd074bd1b3c7e4 + pristine_git_object: 6e141eb7228ff9c8409c2b635b6ae3124aa0c1f3 + src/models/servertooldetails.ts: + id: f94cb5399ef7 + last_write_checksum: sha1:98ce80777a15302c4fea2338bcd5782c3b872ffd + pristine_git_object: e7062b17fe1053e144b8e4b4e90e6077e4c1ed9d + src/models/servertoolengine.ts: + id: 0ee547bdca50 + last_write_checksum: sha1:a0ccd8a66ba9c43701aa932dd5d14105e3f70f33 + pristine_git_object: a3937b83a6e670536d18db213df5c0754933a955 + src/models/servertoolexecutedby.ts: + id: cfa354bfe40d + last_write_checksum: sha1:b2822d095cd2eefc15c6a5444fcee04ec5cbb063 + pristine_git_object: 7939046e6ee1a2fdbe6f8fe917f04bb43e0af98f + src/models/servertoolinputname.ts: + id: deeca5c74395 + last_write_checksum: sha1:a541e552acb8553b2eaaa2e64e1a13a7f364745b + pristine_git_object: 67cafd51a268d4891c532acacaa0048e5357ef41 + src/models/servertoolnativemodel.ts: + id: 80f9cb866c58 + last_write_checksum: sha1:b3d619ca6353d6e49459d3ff84596de48e4702a0 + pristine_git_object: 971d1983517d7bff5be129cbe561261bef1cad1f + src/models/servertoolnativesupport.ts: + id: 3a84d88babcc + last_write_checksum: sha1:2eed02e8aa170737dfe71ea0f374575436ec2b51 + pristine_git_object: 710e7634bb5f8239066f908c465981a2e049d4d9 + src/models/servertooloutputname.ts: + id: 1dd915c55b83 + last_write_checksum: sha1:bc6c1f8c5492e3179637065e8b53447ee7831f7a + pristine_git_object: 3b057bbbdd31b43aafb2f186e6f740bec0e52ed6 + src/models/servertoolprice.ts: + id: d12fcc3fb6f8 + last_write_checksum: sha1:e56141b4c0e7a939d29c85ff4363a5e452f065db + pristine_git_object: 8eae59d1d2b19eacdcd5c0b5a8bbf00214ea5f95 src/models/servertoolusedetails.ts: id: 5d4b052ad0ed last_write_checksum: sha1:4c16dfb79e2cbc579594883e39dd51a142e67c14 @@ -19573,8 +19757,8 @@ trackedFiles: pristine_git_object: 8e9b4047e476a17451b5feb7e9d4a32eec7f61f8 src/sdk/sdk.ts: id: 784571af2f69 - last_write_checksum: sha1:272af33238eb84f5f569800cbfb76018253dc261 - pristine_git_object: d5726986f92f5958854fe3804915fed0cdb9eee5 + last_write_checksum: sha1:1190b7841d0cea588ae8fbcdb8029534f428ea50 + pristine_git_object: 2ddd1f313563df2c7b3a2706155e6922164bb18a src/sdk/stt.ts: id: fd9e88c22d1f last_write_checksum: sha1:59ba5f5c87bc57bf52d0b46b81e194a3099b08fb @@ -19583,6 +19767,10 @@ trackedFiles: id: af359eaea7c4 last_write_checksum: sha1:6159ff585ccef54dab6c74d100869f46f1d38360 pristine_git_object: 7e2b7285263de15e0803472e1411eea57057f5b5 + src/sdk/tools.ts: + id: f997ccdd9dd9 + last_write_checksum: sha1:85dd11ff6ba454c36c4443efaac12c212378c2d1 + pristine_git_object: 3da5c66451bd9d7d10e4d404b7eb175d4ca44de2 src/sdk/tts.ts: id: b3236e8fa217 last_write_checksum: sha1:ebe45b666f4809ceb2406e6fd6f307f9455076b3 @@ -23433,5 +23621,41 @@ examples: responses: "504": application/json: {"error": {"code": 504, "message": "Vault request timed out"}} + listTools: + speakeasy-default-list-tools: + parameters: + query: + offset: 0 + limit: 50 + responses: + "200": + application/json: {"data": [], "links": {"next": null}, "total_count": 12} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} + getTool: + speakeasy-default-get-tool: + parameters: + path: + name: "openrouter:web_search" + responses: + "200": + application/json: {"data": {"aliases": [], "default_engine": "native", "docs_url": "https://mad-skyline.info/", "engines": [{"byok": "none", "data_regions": ["global", "us"], "default_mode": "auto", "executed_by": "openrouter", "id": "exa", "name": "Exa", "pricing": [], "pricing_doc_url": null, "pricing_source": "openrouter"}], "fallback_engine": "exa", "id": "openrouter:web_search", "input_schema": {"properties": {}, "type": "object"}, "name": "Web search", "native_support": {"endpoint_count": 18, "model_count": 12, "models": []}, "output_schema": {"properties": {}, "type": "object"}, "parameters_schema": {"properties": {}, "type": "object"}, "status": "active", "summary": "", "supported_api_formats": [], "tool_description": ""}} + "401": + application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} + "403": + application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "404": + application/json: {"error": {"code": 404, "message": "Resource not found"}} + "500": + application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: "## Typescript SDK Changes:\n* `openrouter.chat.send()`: \n * `request.chatRequest.serviceTier.enum(ultrafast)` **Added**\n* `openrouter.generations.getGeneration()`: `response.data.providerResponses[].routedServiceTier.enum(ultrafast)` **Added**\n* `openrouter.presets.createPresetsChatCompletions()`: \n * `request.chatRequest.serviceTier.enum(ultrafast)` **Added**\n* `openrouter.presets.createPresetsResponses()`: \n * `request.responsesRequest.serviceTier.enum(ultrafast)` **Added**\n* `openrouter.responses.send()`: \n * `request.responsesRequest.serviceTier.enum(ultrafast)` **Added**\n* `openrouter.beta.responses.send()`: \n * `request.responsesRequest.serviceTier.enum(ultrafast)` **Added**\n" +releaseNotes: | + ## Typescript SDK Changes: + * `openrouter.tools.listTools()`: **Added** + * `openrouter.tools.getTool()`: **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 9a83cacad..792c8b9a8 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.4.6 + version: 1.4.7 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 53906591c..1c3ba1b32 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -12465,6 +12465,13 @@ components: required: - 'data' type: 'object' + GetToolResponse: + properties: + data: + $ref: '#/components/schemas/ServerToolDetails' + required: + - 'data' + type: 'object' GetWorkspaceBudgetResponse: example: data: @@ -15526,6 +15533,32 @@ components: - 'data' - 'total_count' type: 'object' + ListToolsResponse: + properties: + data: + items: + $ref: '#/components/schemas/ServerTool' + type: 'array' + links: + properties: + next: + description: 'URL for the next page of results, or null if this is the last page' + example: null + type: + - 'string' + - 'null' + required: + - 'next' + type: 'object' + total_count: + description: 'Total number of tools' + example: 12 + type: 'integer' + required: + - 'data' + - 'total_count' + - 'links' + type: 'object' ListWorkspaceBudgetsResponse: example: data: @@ -27553,6 +27586,306 @@ components: example: 'medium' type: 'string' x-speakeasy-unknown-values: allow + ServerTool: + properties: + aliases: + description: 'Every spelling accepted in `tools[].type` for this tool, including the canonical `id`, and what the call surfaces as under each' + items: + $ref: '#/components/schemas/ServerToolInputName' + type: 'array' + default_engine: + description: 'The engine a request without `parameters.engine` (or with `engine: "auto"`) runs on; `native` applies where the endpoint runs the tool itself, otherwise `fallback_engine`. A request pinned to a data region skips either engine when its `data_regions` does not list that region. Null for a tool without an engine parameter' + example: 'native' + type: + - 'string' + - 'null' + docs_url: + format: 'uri' + type: 'string' + engines: + items: + $ref: '#/components/schemas/ServerToolEngine' + type: 'array' + fallback_engine: + description: 'The engine an unpinned request runs on when `default_engine` is `native` and the endpoint does not run the tool itself; null when there is no fallback' + example: 'exa' + type: + - 'string' + - 'null' + id: + description: 'Canonical `openrouter:*` name; the stable `tools[].type` on every API format in `supported_api_formats`' + example: 'openrouter:web_search' + type: 'string' + input_schema: + additionalProperties: {} + description: 'JSON Schema of the arguments the model emits when calling the tool' + example: + properties: {} + type: 'object' + type: 'object' + name: + example: 'Web search' + type: 'string' + native_support: + $ref: '#/components/schemas/ServerToolNativeSupport' + output_schema: + additionalProperties: {} + description: 'JSON Schema of the result returned to the model; null when undeclared' + example: + properties: {} + type: 'object' + type: + - 'object' + - 'null' + parameters_schema: + additionalProperties: {} + description: 'JSON Schema for the caller-side `tools[].parameters` object' + example: + properties: {} + type: 'object' + type: 'object' + status: + enum: + - 'active' + - 'deprecated' + example: 'active' + type: 'string' + x-speakeasy-unknown-values: allow + summary: + description: 'One sentence for cards and search results; never sent to a model' + type: 'string' + supported_api_formats: + items: + enum: + - 'responses' + - 'chat-completions' + - 'anthropic-messages' + type: 'string' + x-speakeasy-unknown-values: allow + type: 'array' + tool_description: + description: 'The description sent upstream as the function tool description' + type: 'string' + required: + - 'id' + - 'name' + - 'summary' + - 'tool_description' + - 'status' + - 'docs_url' + - 'aliases' + - 'supported_api_formats' + - 'default_engine' + - 'fallback_engine' + - 'parameters_schema' + - 'input_schema' + - 'output_schema' + - 'engines' + - 'native_support' + type: 'object' + ServerToolDetails: + allOf: + - $ref: '#/components/schemas/ServerTool' + - properties: + native_support: + allOf: + - $ref: '#/components/schemas/ServerToolNativeSupport' + - properties: + models: + items: + $ref: '#/components/schemas/ServerToolNativeModel' + type: 'array' + required: + - 'models' + type: 'object' + description: 'Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively.' + example: + endpoint_count: 18 + model_count: 12 + type: 'object' + ServerToolEngine: + properties: + byok: + description: 'Whether the engine needs the caller''s own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter''s key is used unless the caller saved one), or `none`' + enum: + - 'required' + - 'optional' + - 'none' + example: 'none' + type: 'string' + x-speakeasy-unknown-values: allow + data_regions: + description: 'The data regions whose requests this engine serves without leaving the region. A request pinned to a region can only use engines that list it; `global` is always listed.' + example: + - 'global' + - 'us' + items: + enum: + - 'global' + - 'europe' + - 'us' + type: 'string' + x-speakeasy-unknown-values: allow + type: 'array' + default_mode: + description: 'The `parameters.mode` a request without one runs and bills as; null for engines without modes. The `pricing[]` row with this `mode` is what an unmoded request bills' + example: 'auto' + type: + - 'string' + - 'null' + executed_by: + $ref: '#/components/schemas/ServerToolExecutedBy' + id: + description: 'The `parameters.engine` value that selects this engine; null for the single engine of a tool without an engine parameter' + example: 'exa' + type: + - 'string' + - 'null' + name: + example: 'Exa' + type: 'string' + pricing: + description: 'The rows OpenRouter bills; non-empty exactly when `pricing_source` is `openrouter`' + items: + $ref: '#/components/schemas/ServerToolPrice' + type: 'array' + pricing_doc_url: + description: 'Where the rates are documented when `pricing_source` is `provider` or `byok`; null otherwise' + example: null + type: + - 'string' + - 'null' + pricing_source: + description: 'Who bills the engine''s calls beyond the model''s tokens: `openrouter` (the `pricing` rows, from the caller''s credits), `provider` (a per-call tool fee from the model''s provider on the inference call, at its own rates), `byok` (the engine''s vendor, against the caller''s own key), or `none` (no charge)' + enum: + - 'openrouter' + - 'provider' + - 'byok' + - 'none' + example: 'openrouter' + type: 'string' + x-speakeasy-unknown-values: allow + required: + - 'id' + - 'name' + - 'executed_by' + - 'data_regions' + - 'byok' + - 'default_mode' + - 'pricing_source' + - 'pricing_doc_url' + - 'pricing' + type: 'object' + ServerToolExecutedBy: + description: 'Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller''s application after the call is returned (`client`).' + enum: + - 'provider' + - 'openrouter' + - 'client' + example: 'openrouter' + type: 'string' + x-speakeasy-unknown-values: allow + ServerToolInputName: + properties: + api_formats: + description: 'API formats that accept this spelling in `tools[].type`' + items: + enum: + - 'responses' + - 'chat-completions' + - 'anthropic-messages' + type: 'string' + x-speakeasy-unknown-values: allow + type: 'array' + output_names: + description: 'What the call surfaces as on each accepting API format when requested under this spelling; a format is absent when the call is not visible to the caller' + items: + $ref: '#/components/schemas/ServerToolOutputName' + type: 'array' + type: + example: 'web_search_20250305' + type: 'string' + required: + - 'type' + - 'api_formats' + - 'output_names' + type: 'object' + ServerToolNativeModel: + properties: + providers: + example: + - 'Anthropic' + - 'Google' + items: + type: 'string' + type: 'array' + slug: + example: 'anthropic/claude-4.5-sonnet' + type: 'string' + required: + - 'slug' + - 'providers' + type: 'object' + ServerToolNativeSupport: + description: 'Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively.' + example: + endpoint_count: 18 + model_count: 12 + properties: + endpoint_count: + example: 18 + type: 'integer' + model_count: + example: 12 + type: 'integer' + required: + - 'endpoint_count' + - 'model_count' + type: 'object' + ServerToolOutputName: + properties: + api_format: + enum: + - 'responses' + - 'chat-completions' + - 'anthropic-messages' + type: 'string' + x-speakeasy-unknown-values: allow + name: + description: 'Anthropic Messages `server_tool_use` block `name`, when the call surfaces as one' + example: 'web_search' + type: 'string' + type: + description: 'Output item `type` on Responses, content block `type` on Anthropic Messages, `reasoning_details[].type` on Chat Completions' + example: 'web_search_call' + type: 'string' + required: + - 'api_format' + - 'type' + type: 'object' + ServerToolPrice: + properties: + max_units_per_call: + type: 'integer' + mode: + description: 'The `parameters.mode` this price applies to; null for prices that do not depend on the mode. A request bills exactly one `request` row' + example: 'auto' + type: + - 'string' + - 'null' + price: + description: 'USD per unit, as a decimal string' + example: '0.007' + type: 'string' + unit: + example: 'request' + type: 'string' + required: + - 'mode' + - 'unit' + - 'price' + - 'max_units_per_call' + type: 'object' ServerToolUseDetails: description: 'Usage for server-side tool execution (e.g., web search)' example: @@ -48574,6 +48907,180 @@ paths: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" + /tools: + get: + description: 'Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively.' + operationId: 'listTools' + parameters: + - description: 'Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned' + in: 'query' + name: 'offset' + required: false + schema: + default: 0 + description: 'Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned' + example: 0 + minimum: 0 + type: + - 'integer' + - 'null' + - description: 'Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned' + in: 'query' + name: 'limit' + required: false + schema: + default: 50 + description: 'Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned' + example: 50 + maximum: 100 + minimum: 1 + type: 'integer' + - description: 'Only tools usable on this API format' + in: 'query' + name: 'api_format' + required: false + schema: + description: 'Only tools usable on this API format' + enum: + - 'responses' + - 'chat-completions' + - 'anthropic-messages' + example: 'responses' + type: 'string' + x-speakeasy-unknown-values: allow + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListToolsResponse' + description: 'The server tool catalog' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + security: + - bearer: [] + summary: 'List server tools' + tags: + - 'Tools' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" + /tools/{name}: + get: + description: 'One server tool by canonical name or any accepted alias, with the models that run it natively.' + operationId: 'getTool' + parameters: + - description: 'Canonical `openrouter:*` name or any accepted `tools[].type` alias' + in: 'path' + name: 'name' + required: true + schema: + description: 'Canonical `openrouter:*` name or any accepted `tools[].type` alias' + example: 'openrouter:web_search' + type: 'string' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetToolResponse' + description: 'The server tool' + '308': + description: 'An alias was given; `Location` is the canonical tool URL' + headers: + Location: + required: true + schema: + example: '/api/v1/tools/openrouter:web_search' + type: 'string' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Missing Authentication header' + schema: + $ref: '#/components/schemas/UnauthorizedResponse' + description: 'Unauthorized - Authentication required or invalid credentials' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'Only management keys can perform this operation' + schema: + $ref: '#/components/schemas/ForbiddenResponse' + description: 'Forbidden - Authentication successful but insufficient permissions' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Resource not found' + schema: + $ref: '#/components/schemas/NotFoundResponse' + description: 'Not Found - Resource does not exist' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Internal Server Error' + schema: + $ref: '#/components/schemas/InternalServerResponse' + description: 'Internal Server Error - Unexpected server error' + security: + - bearer: [] + summary: 'Get a server tool' + tags: + - 'Tools' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" /vault/interns/{internId}/effective-secrets: get: description: 'Lists, one entry per name, the secret the intern''s outbound requests receive: its own secrets, secrets from an attached vault, and workspace secrets, including ones stored before workspace-scoped storage. Where several vaults hold a name, the entry is the one that wins, in the order intern, attached, workspace. The same resolution decides what outbound requests receive, so this list and the intern''s requests agree. `scope` says which vault the entry comes from. Responses carry metadata only, never values. Results are ordered by name and paginated with `limit` and `offset`. Returns 404 when the intern''s attached vault is no longer available, since the intern then receives no secrets. The scope is selected by the API key: workspace routes act on the key''s active workspace and intern routes act on one intern inside that workspace. There is no default workspace and no fallback to another scope. Every vault route, including reads, requires access to the Intern API programme and returns 404 outside it. An intern''s own API key is confined to that intern: it can always read the intern''s secrets and effective secrets, writes to them follow the rules above, and every other intern and every workspace route answers 404. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.' @@ -51781,6 +52288,8 @@ tags: - description: 'Text-to-speech endpoints' name: 'TTS' x-displayName: 'Speech' + - description: 'The catalog of server tools OpenRouter runs on behalf of a model: accepted `tools[].type` spellings per API format, engines and pricing, and which endpoints run each tool natively. See https://openrouter.ai/docs/guides/features/server-tools.' + name: 'Tools' - description: 'Store host-bound secrets for a workspace or for one intern. Scope is selected by the API key. Responses return metadata only, never secret values. See https://openrouter.ai/docs/guides/ori/vault.' name: 'Vault' - description: 'Video Generation endpoints' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 80ae092b5..95694c8c5 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:5b00a6173efea5949a08d0441bec7b273ec8c62adef935063dd50b6511a32f80 - sourceBlobDigest: sha256:9deafc0f104b438951032e34aa91c672aba4ac18937c3eec014a6d8f1281058b + sourceRevisionDigest: sha256:af8bbdc4d7dba2a586d5d4c41082e2d3859e7372a066fafd21a43e1bb86ebd12 + sourceBlobDigest: sha256:f01789f97fc4a253b4bc1c48ac0d882cdee7314ea2e25fe306bf606349b15c39 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:5b00a6173efea5949a08d0441bec7b273ec8c62adef935063dd50b6511a32f80 - sourceBlobDigest: sha256:9deafc0f104b438951032e34aa91c672aba4ac18937c3eec014a6d8f1281058b + sourceRevisionDigest: sha256:af8bbdc4d7dba2a586d5d4c41082e2d3859e7372a066fafd21a43e1bb86ebd12 + sourceBlobDigest: sha256:f01789f97fc4a253b4bc1c48ac0d882cdee7314ea2e25fe306bf606349b15c39 codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:0e692b6feca1e05041a2d1f506522933e16465e7c52200331d5f7314822673ca + codeSamplesRevisionDigest: sha256:76c7b09269f98f21a752ff5c253a959f1e664bbb89b4125b4da741230c441a77 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index 807597ad4..208b2c2d5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4216,4 +4216,14 @@ Based on: ### Generated - [typescript v1.4.6] . ### Releases -- [NPM v1.4.6] https://www.npmjs.com/package/@openrouter/sdk/v/1.4.6 - . \ No newline at end of file +- [NPM v1.4.6] https://www.npmjs.com/package/@openrouter/sdk/v/1.4.6 - . + +## 2026-09-29 22:05:37 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.4.7] . +### Releases +- [NPM v1.4.7] https://www.npmjs.com/package/@openrouter/sdk/v/1.4.7 - . \ No newline at end of file diff --git a/docs/models/byok.mdx b/docs/models/byok.mdx new file mode 100644 index 000000000..38a9973f0 --- /dev/null +++ b/docs/models/byok.mdx @@ -0,0 +1,21 @@ +--- +title: "BYOK" +--- + +Whether the engine needs the caller's own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter's key is used unless the caller saved one), or `none` + +## Example Usage + +```typescript +import { BYOK } from "@openrouter/sdk/models"; + +let value: BYOK = "none"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"required" | "optional" | "none" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/generationresponsedata.mdx b/docs/models/generationresponsedata.mdx index 913a2d97d..cd1791554 100644 --- a/docs/models/generationresponsedata.mdx +++ b/docs/models/generationresponsedata.mdx @@ -68,7 +68,7 @@ let value: GenerationResponseData = { | `cacheDiscount` | *number* | :heavy_check_mark: | Discount applied due to caching | 0.0002 | | `cancelled` | *boolean* | :heavy_check_mark: | Whether the generation was cancelled | false | | `createdAt` | *string* | :heavy_check_mark: | ISO 8601 timestamp of when the generation was created | 2024-07-15T23:33:19.433273+00:00 | -| `dataRegion` | [models.DataRegion](../models/dataregion.mdx) | :heavy_check_mark: | The data region this generation was routed through: 'global', 'europe', or 'us'. | global | +| `dataRegion` | [models.GenerationResponseDataRegion](../models/generationresponsedataregion.mdx) | :heavy_check_mark: | The data region this generation was routed through: 'global', 'europe', or 'us'. | global | | `externalUser` | *string* | :heavy_check_mark: | External user identifier | user-123 | | `finishReason` | *string* | :heavy_check_mark: | Reason the generation finished | stop | | `generationTime` | *number* | :heavy_check_mark: | Time taken for generation in milliseconds | 1200 | diff --git a/docs/models/dataregion.mdx b/docs/models/generationresponsedataregion.mdx similarity index 63% rename from docs/models/dataregion.mdx rename to docs/models/generationresponsedataregion.mdx index 52686da82..a71da2b20 100644 --- a/docs/models/dataregion.mdx +++ b/docs/models/generationresponsedataregion.mdx @@ -1,5 +1,5 @@ --- -title: "DataRegion" +title: "GenerationResponseDataRegion" --- The data region this generation was routed through: 'global', 'europe', or 'us'. @@ -7,9 +7,9 @@ The data region this generation was routed through: 'global', 'europe', or 'us'. ## Example Usage ```typescript -import { DataRegion } from "@openrouter/sdk/models"; +import { GenerationResponseDataRegion } from "@openrouter/sdk/models"; -let value: DataRegion = "global"; +let value: GenerationResponseDataRegion = "global"; // Open enum: unrecognized values are captured as Unrecognized ``` diff --git a/docs/models/gettoolresponse.mdx b/docs/models/gettoolresponse.mdx new file mode 100644 index 000000000..106b28d37 --- /dev/null +++ b/docs/models/gettoolresponse.mdx @@ -0,0 +1,50 @@ +--- +title: "GetToolResponse" +--- + +## Example Usage + +```typescript +import { GetToolResponse } from "@openrouter/sdk/models"; + +let value: GetToolResponse = { + data: { + aliases: [], + defaultEngine: "native", + docsUrl: "https://aged-mountain.net/", + engines: [], + fallbackEngine: "exa", + id: "openrouter:web_search", + inputSchema: { + "properties": {}, + "type": "object", + }, + name: "Web search", + nativeSupport: { + endpointCount: 18, + modelCount: 12, + models: [], + }, + outputSchema: { + "properties": {}, + "type": "object", + }, + parametersSchema: { + "properties": {}, + "type": "object", + }, + status: "active", + summary: "", + supportedApiFormats: [ + "responses", + ], + toolDescription: "", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `data` | [models.ServerToolDetails](../models/servertooldetails.mdx) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/listtoolsresponse.mdx b/docs/models/listtoolsresponse.mdx new file mode 100644 index 000000000..11485ac4b --- /dev/null +++ b/docs/models/listtoolsresponse.mdx @@ -0,0 +1,25 @@ +--- +title: "ListToolsResponse" +--- + +## Example Usage + +```typescript +import { ListToolsResponse } from "@openrouter/sdk/models"; + +let value: ListToolsResponse = { + data: [], + links: { + next: null, + }, + totalCount: 12, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `data` | [models.ServerTool](../models/servertool.mdx)[] | :heavy_check_mark: | N/A | | +| `links` | [models.ListToolsResponseLinks](../models/listtoolsresponselinks.mdx) | :heavy_check_mark: | N/A | | +| `totalCount` | *number* | :heavy_check_mark: | Total number of tools | 12 | \ No newline at end of file diff --git a/docs/models/listtoolsresponselinks.mdx b/docs/models/listtoolsresponselinks.mdx new file mode 100644 index 000000000..f2e3b39c6 --- /dev/null +++ b/docs/models/listtoolsresponselinks.mdx @@ -0,0 +1,19 @@ +--- +title: "ListToolsResponseLinks" +--- + +## Example Usage + +```typescript +import { ListToolsResponseLinks } from "@openrouter/sdk/models"; + +let value: ListToolsResponseLinks = { + next: null, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `next` | *string* | :heavy_check_mark: | URL for the next page of results, or null if this is the last page | null | \ No newline at end of file diff --git a/docs/models/modelslistresponse.mdx b/docs/models/modelslistresponse.mdx index 7219f0f22..418f7f126 100644 --- a/docs/models/modelslistresponse.mdx +++ b/docs/models/modelslistresponse.mdx @@ -60,5 +60,5 @@ let value: ModelsListResponse = { | Field | Type | Required | Description | Example | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data` | [models.Model](../models/model.mdx)[] | :heavy_check_mark: | List of available models | [
\{
"architecture": \{
"input_modalities": [
"text"
],
"instruct_type": "chatml",
"modality": "text-\u003etext",
"output_modalities": [
"text"
],
"tokenizer": "GPT"
},
"canonical_slug": "openai/gpt-4",
"context_length": 8192,
"created": 1692901234,
"default_parameters": null,
"description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.",
"expiration_date": null,
"id": "openai/gpt-4",
"knowledge_cutoff": null,
"links": \{
"details": "/api/v1/models/openai/gpt-4/endpoints"
},
"name": "GPT-4",
"per_request_limits": null,
"pricing": \{
"completion": "0.00006",
"image": "0",
"prompt": "0.00003",
"request": "0"
},
"supported_parameters": [
"temperature",
"top_p",
"max_tokens"
],
"supported_voices": null,
"top_provider": \{
"context_length": 8192,
"is_moderated": true,
"max_completion_tokens": 4096
}
}
] | -| `links` | [models.Links](../models/links.mdx) | :heavy_check_mark: | Pagination links | | +| `links` | [models.ModelsListResponseLinks](../models/modelslistresponselinks.mdx) | :heavy_check_mark: | Pagination links | | | `totalCount` | *number* | :heavy_check_mark: | Total number of models matching the query | 150 | \ No newline at end of file diff --git a/docs/models/links.mdx b/docs/models/modelslistresponselinks.mdx similarity index 89% rename from docs/models/links.mdx rename to docs/models/modelslistresponselinks.mdx index 494e00703..4bf366758 100644 --- a/docs/models/links.mdx +++ b/docs/models/modelslistresponselinks.mdx @@ -1,5 +1,5 @@ --- -title: "Links" +title: "ModelsListResponseLinks" --- Pagination links @@ -7,9 +7,9 @@ Pagination links ## Example Usage ```typescript -import { Links } from "@openrouter/sdk/models"; +import { ModelsListResponseLinks } from "@openrouter/sdk/models"; -let value: Links = { +let value: ModelsListResponseLinks = { next: "/api/v1/models?offset=500&limit=500", }; ``` diff --git a/docs/models/nativesupport.mdx b/docs/models/nativesupport.mdx new file mode 100644 index 000000000..67337e8c9 --- /dev/null +++ b/docs/models/nativesupport.mdx @@ -0,0 +1,33 @@ +--- +title: "NativeSupport" +--- + +Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + +## Example Usage + +```typescript +import { NativeSupport } from "@openrouter/sdk/models"; + +let value: NativeSupport = { + endpointCount: 18, + modelCount: 12, + models: [ + { + providers: [ + "Anthropic", + "Google", + ], + slug: "anthropic/claude-4.5-sonnet", + }, + ], +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `endpointCount` | *number* | :heavy_check_mark: | N/A | 18 | +| `modelCount` | *number* | :heavy_check_mark: | N/A | 12 | +| `models` | [models.ServerToolNativeModel](../models/servertoolnativemodel.mdx)[] | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/operations/apiformat.mdx b/docs/models/operations/apiformat.mdx new file mode 100644 index 000000000..173a38537 --- /dev/null +++ b/docs/models/operations/apiformat.mdx @@ -0,0 +1,21 @@ +--- +title: "ApiFormat" +--- + +Only tools usable on this API format + +## Example Usage + +```typescript +import { ApiFormat } from "@openrouter/sdk/models/operations"; + +let value: ApiFormat = "responses"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"responses" | "chat-completions" | "anthropic-messages" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/operations/gettoolglobals.mdx b/docs/models/operations/gettoolglobals.mdx new file mode 100644 index 000000000..b9e03e032 --- /dev/null +++ b/docs/models/operations/gettoolglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "GetToolGlobals" +--- + +## Example Usage + +```typescript +import { GetToolGlobals } from "@openrouter/sdk/models/operations"; + +let value: GetToolGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/gettoolrequest.mdx b/docs/models/operations/gettoolrequest.mdx new file mode 100644 index 000000000..1ac7f03a9 --- /dev/null +++ b/docs/models/operations/gettoolrequest.mdx @@ -0,0 +1,22 @@ +--- +title: "GetToolRequest" +--- + +## Example Usage + +```typescript +import { GetToolRequest } from "@openrouter/sdk/models/operations"; + +let value: GetToolRequest = { + name: "openrouter:web_search", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `name` | *string* | :heavy_check_mark: | Canonical `openrouter:*` name or any accepted `tools[].type` alias | openrouter:web_search | \ No newline at end of file diff --git a/docs/models/operations/gettoolresponse.mdx b/docs/models/operations/gettoolresponse.mdx new file mode 100644 index 000000000..a60af9601 --- /dev/null +++ b/docs/models/operations/gettoolresponse.mdx @@ -0,0 +1,20 @@ +--- +title: "GetToolResponse" +--- + +## Example Usage + +```typescript +import { GetToolResponse } from "@openrouter/sdk/models/operations"; + +let value: GetToolResponse = { + headers: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | +| `headers` | Record\ | :heavy_check_mark: | N/A | +| `result` | [models.GetToolResponse](../../models/gettoolresponse.mdx) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/operations/gettoolsecurity.mdx b/docs/models/operations/gettoolsecurity.mdx new file mode 100644 index 000000000..036a1f3e8 --- /dev/null +++ b/docs/models/operations/gettoolsecurity.mdx @@ -0,0 +1,19 @@ +--- +title: "GetToolSecurity" +--- + +## Example Usage + +```typescript +import { GetToolSecurity } from "@openrouter/sdk/models/operations"; + +let value: GetToolSecurity = { + bearer: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `bearer` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/listtoolsglobals.mdx b/docs/models/operations/listtoolsglobals.mdx new file mode 100644 index 000000000..47136bbd4 --- /dev/null +++ b/docs/models/operations/listtoolsglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "ListToolsGlobals" +--- + +## Example Usage + +```typescript +import { ListToolsGlobals } from "@openrouter/sdk/models/operations"; + +let value: ListToolsGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/listtoolsrequest.mdx b/docs/models/operations/listtoolsrequest.mdx new file mode 100644 index 000000000..a4b7ee9ed --- /dev/null +++ b/docs/models/operations/listtoolsrequest.mdx @@ -0,0 +1,22 @@ +--- +title: "ListToolsRequest" +--- + +## Example Usage + +```typescript +import { ListToolsRequest } from "@openrouter/sdk/models/operations"; + +let value: ListToolsRequest = {}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `offset` | *number* | :heavy_minus_sign: | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 | +| `limit` | *number* | :heavy_minus_sign: | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 | +| `apiFormat` | [operations.ApiFormat](../../models/operations/apiformat.mdx) | :heavy_minus_sign: | Only tools usable on this API format | responses | \ No newline at end of file diff --git a/docs/models/operations/listtoolssecurity.mdx b/docs/models/operations/listtoolssecurity.mdx new file mode 100644 index 000000000..74604fb62 --- /dev/null +++ b/docs/models/operations/listtoolssecurity.mdx @@ -0,0 +1,19 @@ +--- +title: "ListToolsSecurity" +--- + +## Example Usage + +```typescript +import { ListToolsSecurity } from "@openrouter/sdk/models/operations"; + +let value: ListToolsSecurity = { + bearer: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `bearer` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/pricingsource.mdx b/docs/models/pricingsource.mdx new file mode 100644 index 000000000..5997b8fb6 --- /dev/null +++ b/docs/models/pricingsource.mdx @@ -0,0 +1,21 @@ +--- +title: "PricingSource" +--- + +Who bills the engine's calls beyond the model's tokens: `openrouter` (the `pricing` rows, from the caller's credits), `provider` (a per-call tool fee from the model's provider on the inference call, at its own rates), `byok` (the engine's vendor, against the caller's own key), or `none` (no charge) + +## Example Usage + +```typescript +import { PricingSource } from "@openrouter/sdk/models"; + +let value: PricingSource = "openrouter"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"openrouter" | "provider" | "byok" | "none" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertool.mdx b/docs/models/servertool.mdx new file mode 100644 index 000000000..42075b0c3 --- /dev/null +++ b/docs/models/servertool.mdx @@ -0,0 +1,74 @@ +--- +title: "ServerTool" +--- + +## Example Usage + +```typescript +import { ServerTool } from "@openrouter/sdk/models"; + +let value: ServerTool = { + aliases: [], + defaultEngine: "native", + docsUrl: "https://upset-tenement.org", + engines: [ + { + byok: "none", + dataRegions: [ + "global", + "us", + ], + defaultMode: "auto", + executedBy: "openrouter", + id: "exa", + name: "Exa", + pricing: [], + pricingDocUrl: null, + pricingSource: "openrouter", + }, + ], + fallbackEngine: "exa", + id: "openrouter:web_search", + inputSchema: { + "properties": {}, + "type": "object", + }, + name: "Web search", + nativeSupport: { + endpointCount: 18, + modelCount: 12, + }, + outputSchema: { + "properties": {}, + "type": "object", + }, + parametersSchema: { + "properties": {}, + "type": "object", + }, + status: "active", + summary: "", + supportedApiFormats: [], + toolDescription: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `aliases` | [models.ServerToolInputName](../models/servertoolinputname.mdx)[] | :heavy_check_mark: | Every spelling accepted in `tools[].type` for this tool, including the canonical `id`, and what the call surfaces as under each | | +| `defaultEngine` | *string* | :heavy_check_mark: | The engine a request without `parameters.engine` (or with `engine: "auto"`) runs on; `native` applies where the endpoint runs the tool itself, otherwise `fallback_engine`. A request pinned to a data region skips either engine when its `data_regions` does not list that region. Null for a tool without an engine parameter | native | +| `docsUrl` | *string* | :heavy_check_mark: | N/A | | +| `engines` | [models.ServerToolEngine](../models/servertoolengine.mdx)[] | :heavy_check_mark: | N/A | | +| `fallbackEngine` | *string* | :heavy_check_mark: | The engine an unpinned request runs on when `default_engine` is `native` and the endpoint does not run the tool itself; null when there is no fallback | exa | +| `id` | *string* | :heavy_check_mark: | Canonical `openrouter:*` name; the stable `tools[].type` on every API format in `supported_api_formats` | openrouter:web_search | +| `inputSchema` | Record\ | :heavy_check_mark: | JSON Schema of the arguments the model emits when calling the tool | \{
"properties": \{},
"type": "object"
} | +| `name` | *string* | :heavy_check_mark: | N/A | Web search | +| `nativeSupport` | [models.ServerToolNativeSupport](../models/servertoolnativesupport.mdx) | :heavy_check_mark: | Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. | \{
"endpoint_count": 18,
"model_count": 12
} | +| `outputSchema` | Record\ | :heavy_check_mark: | JSON Schema of the result returned to the model; null when undeclared | \{
"properties": \{},
"type": "object"
} | +| `parametersSchema` | Record\ | :heavy_check_mark: | JSON Schema for the caller-side `tools[].parameters` object | \{
"properties": \{},
"type": "object"
} | +| `status` | [models.ServerToolStatus](../models/servertoolstatus.mdx) | :heavy_check_mark: | N/A | active | +| `summary` | *string* | :heavy_check_mark: | One sentence for cards and search results; never sent to a model | | +| `supportedApiFormats` | [models.ServerToolSupportedApiFormat](../models/servertoolsupportedapiformat.mdx)[] | :heavy_check_mark: | N/A | | +| `toolDescription` | *string* | :heavy_check_mark: | The description sent upstream as the function tool description | | \ No newline at end of file diff --git a/docs/models/servertooldetails.mdx b/docs/models/servertooldetails.mdx new file mode 100644 index 000000000..a1d250149 --- /dev/null +++ b/docs/models/servertooldetails.mdx @@ -0,0 +1,78 @@ +--- +title: "ServerToolDetails" +--- + +## Example Usage + +```typescript +import { ServerToolDetails } from "@openrouter/sdk/models"; + +let value: ServerToolDetails = { + aliases: [ + { + apiFormats: [ + "anthropic-messages", + ], + outputNames: [], + type: "web_search_20250305", + }, + ], + defaultEngine: "native", + docsUrl: "https://mysterious-testing.info", + engines: [], + fallbackEngine: "exa", + id: "openrouter:web_search", + inputSchema: { + "properties": {}, + "type": "object", + }, + name: "Web search", + nativeSupport: { + endpointCount: 18, + modelCount: 12, + models: [ + { + providers: [ + "Anthropic", + "Google", + ], + slug: "anthropic/claude-4.5-sonnet", + }, + ], + }, + outputSchema: { + "properties": {}, + "type": "object", + }, + parametersSchema: { + "properties": {}, + "type": "object", + }, + status: "active", + summary: "", + supportedApiFormats: [ + "anthropic-messages", + ], + toolDescription: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `aliases` | [models.ServerToolInputName](../models/servertoolinputname.mdx)[] | :heavy_check_mark: | Every spelling accepted in `tools[].type` for this tool, including the canonical `id`, and what the call surfaces as under each | | +| `defaultEngine` | *string* | :heavy_check_mark: | The engine a request without `parameters.engine` (or with `engine: "auto"`) runs on; `native` applies where the endpoint runs the tool itself, otherwise `fallback_engine`. A request pinned to a data region skips either engine when its `data_regions` does not list that region. Null for a tool without an engine parameter | native | +| `docsUrl` | *string* | :heavy_check_mark: | N/A | | +| `engines` | [models.ServerToolEngine](../models/servertoolengine.mdx)[] | :heavy_check_mark: | N/A | | +| `fallbackEngine` | *string* | :heavy_check_mark: | The engine an unpinned request runs on when `default_engine` is `native` and the endpoint does not run the tool itself; null when there is no fallback | exa | +| `id` | *string* | :heavy_check_mark: | Canonical `openrouter:*` name; the stable `tools[].type` on every API format in `supported_api_formats` | openrouter:web_search | +| `inputSchema` | Record\ | :heavy_check_mark: | JSON Schema of the arguments the model emits when calling the tool | \{
"properties": \{},
"type": "object"
} | +| `name` | *string* | :heavy_check_mark: | N/A | Web search | +| `nativeSupport` | [models.NativeSupport](../models/nativesupport.mdx) | :heavy_check_mark: | Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. | \{
"endpoint_count": 18,
"model_count": 12
} | +| `outputSchema` | Record\ | :heavy_check_mark: | JSON Schema of the result returned to the model; null when undeclared | \{
"properties": \{},
"type": "object"
} | +| `parametersSchema` | Record\ | :heavy_check_mark: | JSON Schema for the caller-side `tools[].parameters` object | \{
"properties": \{},
"type": "object"
} | +| `status` | [models.ServerToolDetailsStatus](../models/servertooldetailsstatus.mdx) | :heavy_check_mark: | N/A | active | +| `summary` | *string* | :heavy_check_mark: | One sentence for cards and search results; never sent to a model | | +| `supportedApiFormats` | [models.ServerToolDetailsSupportedApiFormat](../models/servertooldetailssupportedapiformat.mdx)[] | :heavy_check_mark: | N/A | | +| `toolDescription` | *string* | :heavy_check_mark: | The description sent upstream as the function tool description | | \ No newline at end of file diff --git a/docs/models/servertooldetailsstatus.mdx b/docs/models/servertooldetailsstatus.mdx new file mode 100644 index 000000000..aea0e0765 --- /dev/null +++ b/docs/models/servertooldetailsstatus.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolDetailsStatus" +--- + +## Example Usage + +```typescript +import { ServerToolDetailsStatus } from "@openrouter/sdk/models"; + +let value: ServerToolDetailsStatus = "active"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"active" | "deprecated" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertooldetailssupportedapiformat.mdx b/docs/models/servertooldetailssupportedapiformat.mdx new file mode 100644 index 000000000..e40807f34 --- /dev/null +++ b/docs/models/servertooldetailssupportedapiformat.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolDetailsSupportedApiFormat" +--- + +## Example Usage + +```typescript +import { ServerToolDetailsSupportedApiFormat } from "@openrouter/sdk/models"; + +let value: ServerToolDetailsSupportedApiFormat = "chat-completions"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"responses" | "chat-completions" | "anthropic-messages" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolengine.mdx b/docs/models/servertoolengine.mdx new file mode 100644 index 000000000..aaa4f6d5c --- /dev/null +++ b/docs/models/servertoolengine.mdx @@ -0,0 +1,45 @@ +--- +title: "ServerToolEngine" +--- + +## Example Usage + +```typescript +import { ServerToolEngine } from "@openrouter/sdk/models"; + +let value: ServerToolEngine = { + byok: "none", + dataRegions: [ + "global", + "us", + ], + defaultMode: "auto", + executedBy: "openrouter", + id: "exa", + name: "Exa", + pricing: [ + { + maxUnitsPerCall: 769230, + mode: "auto", + price: "0.007", + unit: "request", + }, + ], + pricingDocUrl: null, + pricingSource: "openrouter", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `byok` | [models.BYOK](../models/byok.mdx) | :heavy_check_mark: | Whether the engine needs the caller's own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter's key is used unless the caller saved one), or `none` | none | +| `dataRegions` | [models.ServerToolEngineDataRegion](../models/servertoolenginedataregion.mdx)[] | :heavy_check_mark: | The data regions whose requests this engine serves without leaving the region. A request pinned to a region can only use engines that list it; `global` is always listed. | [
"global",
"us"
] | +| `defaultMode` | *string* | :heavy_check_mark: | The `parameters.mode` a request without one runs and bills as; null for engines without modes. The `pricing[]` row with this `mode` is what an unmoded request bills | auto | +| `executedBy` | [models.ServerToolExecutedBy](../models/servertoolexecutedby.mdx) | :heavy_check_mark: | Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`). | openrouter | +| `id` | *string* | :heavy_check_mark: | The `parameters.engine` value that selects this engine; null for the single engine of a tool without an engine parameter | exa | +| `name` | *string* | :heavy_check_mark: | N/A | Exa | +| `pricing` | [models.ServerToolPrice](../models/servertoolprice.mdx)[] | :heavy_check_mark: | The rows OpenRouter bills; non-empty exactly when `pricing_source` is `openrouter` | | +| `pricingDocUrl` | *string* | :heavy_check_mark: | Where the rates are documented when `pricing_source` is `provider` or `byok`; null otherwise | null | +| `pricingSource` | [models.PricingSource](../models/pricingsource.mdx) | :heavy_check_mark: | Who bills the engine's calls beyond the model's tokens: `openrouter` (the `pricing` rows, from the caller's credits), `provider` (a per-call tool fee from the model's provider on the inference call, at its own rates), `byok` (the engine's vendor, against the caller's own key), or `none` (no charge) | openrouter | \ No newline at end of file diff --git a/docs/models/servertoolenginedataregion.mdx b/docs/models/servertoolenginedataregion.mdx new file mode 100644 index 000000000..08792155d --- /dev/null +++ b/docs/models/servertoolenginedataregion.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolEngineDataRegion" +--- + +## Example Usage + +```typescript +import { ServerToolEngineDataRegion } from "@openrouter/sdk/models"; + +let value: ServerToolEngineDataRegion = "global"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"global" | "europe" | "us" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolexecutedby.mdx b/docs/models/servertoolexecutedby.mdx new file mode 100644 index 000000000..34f103a63 --- /dev/null +++ b/docs/models/servertoolexecutedby.mdx @@ -0,0 +1,21 @@ +--- +title: "ServerToolExecutedBy" +--- + +Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`). + +## Example Usage + +```typescript +import { ServerToolExecutedBy } from "@openrouter/sdk/models"; + +let value: ServerToolExecutedBy = "openrouter"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"provider" | "openrouter" | "client" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolinputname.mdx b/docs/models/servertoolinputname.mdx new file mode 100644 index 000000000..333942c08 --- /dev/null +++ b/docs/models/servertoolinputname.mdx @@ -0,0 +1,28 @@ +--- +title: "ServerToolInputName" +--- + +## Example Usage + +```typescript +import { ServerToolInputName } from "@openrouter/sdk/models"; + +let value: ServerToolInputName = { + apiFormats: [], + outputNames: [ + { + apiFormat: "anthropic-messages", + type: "web_search_call", + }, + ], + type: "web_search_20250305", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apiFormats` | [models.ServerToolInputNameApiFormat](../models/servertoolinputnameapiformat.mdx)[] | :heavy_check_mark: | API formats that accept this spelling in `tools[].type` | | +| `outputNames` | [models.ServerToolOutputName](../models/servertooloutputname.mdx)[] | :heavy_check_mark: | What the call surfaces as on each accepting API format when requested under this spelling; a format is absent when the call is not visible to the caller | | +| `type` | *string* | :heavy_check_mark: | N/A | web_search_20250305 | \ No newline at end of file diff --git a/docs/models/servertoolinputnameapiformat.mdx b/docs/models/servertoolinputnameapiformat.mdx new file mode 100644 index 000000000..6bd57f906 --- /dev/null +++ b/docs/models/servertoolinputnameapiformat.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolInputNameApiFormat" +--- + +## Example Usage + +```typescript +import { ServerToolInputNameApiFormat } from "@openrouter/sdk/models"; + +let value: ServerToolInputNameApiFormat = "anthropic-messages"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"responses" | "chat-completions" | "anthropic-messages" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolnativemodel.mdx b/docs/models/servertoolnativemodel.mdx new file mode 100644 index 000000000..12cf7ecac --- /dev/null +++ b/docs/models/servertoolnativemodel.mdx @@ -0,0 +1,24 @@ +--- +title: "ServerToolNativeModel" +--- + +## Example Usage + +```typescript +import { ServerToolNativeModel } from "@openrouter/sdk/models"; + +let value: ServerToolNativeModel = { + providers: [ + "Anthropic", + "Google", + ], + slug: "anthropic/claude-4.5-sonnet", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------- | --------------------------- | --------------------------- | --------------------------- | --------------------------- | +| `providers` | *string*[] | :heavy_check_mark: | N/A | [
"Anthropic",
"Google"
] | +| `slug` | *string* | :heavy_check_mark: | N/A | anthropic/claude-4.5-sonnet | \ No newline at end of file diff --git a/docs/models/servertoolnativesupport.mdx b/docs/models/servertoolnativesupport.mdx new file mode 100644 index 000000000..4c6454276 --- /dev/null +++ b/docs/models/servertoolnativesupport.mdx @@ -0,0 +1,23 @@ +--- +title: "ServerToolNativeSupport" +--- + +Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + +## Example Usage + +```typescript +import { ServerToolNativeSupport } from "@openrouter/sdk/models"; + +let value: ServerToolNativeSupport = { + endpointCount: 18, + modelCount: 12, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `endpointCount` | *number* | :heavy_check_mark: | N/A | 18 | +| `modelCount` | *number* | :heavy_check_mark: | N/A | 12 | \ No newline at end of file diff --git a/docs/models/servertooloutputname.mdx b/docs/models/servertooloutputname.mdx new file mode 100644 index 000000000..7966c17c9 --- /dev/null +++ b/docs/models/servertooloutputname.mdx @@ -0,0 +1,22 @@ +--- +title: "ServerToolOutputName" +--- + +## Example Usage + +```typescript +import { ServerToolOutputName } from "@openrouter/sdk/models"; + +let value: ServerToolOutputName = { + apiFormat: "chat-completions", + type: "web_search_call", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| `apiFormat` | [models.ServerToolOutputNameApiFormat](../models/servertooloutputnameapiformat.mdx) | :heavy_check_mark: | N/A | | +| `name` | *string* | :heavy_minus_sign: | Anthropic Messages `server_tool_use` block `name`, when the call surfaces as one | web_search | +| `type` | *string* | :heavy_check_mark: | Output item `type` on Responses, content block `type` on Anthropic Messages, `reasoning_details[].type` on Chat Completions | web_search_call | \ No newline at end of file diff --git a/docs/models/servertooloutputnameapiformat.mdx b/docs/models/servertooloutputnameapiformat.mdx new file mode 100644 index 000000000..3ada10e87 --- /dev/null +++ b/docs/models/servertooloutputnameapiformat.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolOutputNameApiFormat" +--- + +## Example Usage + +```typescript +import { ServerToolOutputNameApiFormat } from "@openrouter/sdk/models"; + +let value: ServerToolOutputNameApiFormat = "chat-completions"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"responses" | "chat-completions" | "anthropic-messages" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolprice.mdx b/docs/models/servertoolprice.mdx new file mode 100644 index 000000000..f9ef474c6 --- /dev/null +++ b/docs/models/servertoolprice.mdx @@ -0,0 +1,25 @@ +--- +title: "ServerToolPrice" +--- + +## Example Usage + +```typescript +import { ServerToolPrice } from "@openrouter/sdk/models"; + +let value: ServerToolPrice = { + maxUnitsPerCall: 803046, + mode: "auto", + price: "0.007", + unit: "request", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `maxUnitsPerCall` | *number* | :heavy_check_mark: | N/A | | +| `mode` | *string* | :heavy_check_mark: | The `parameters.mode` this price applies to; null for prices that do not depend on the mode. A request bills exactly one `request` row | auto | +| `price` | *string* | :heavy_check_mark: | USD per unit, as a decimal string | 0.007 | +| `unit` | *string* | :heavy_check_mark: | N/A | request | \ No newline at end of file diff --git a/docs/models/servertoolstatus.mdx b/docs/models/servertoolstatus.mdx new file mode 100644 index 000000000..bde1d067d --- /dev/null +++ b/docs/models/servertoolstatus.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolStatus" +--- + +## Example Usage + +```typescript +import { ServerToolStatus } from "@openrouter/sdk/models"; + +let value: ServerToolStatus = "active"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"active" | "deprecated" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/servertoolsupportedapiformat.mdx b/docs/models/servertoolsupportedapiformat.mdx new file mode 100644 index 000000000..97facf9ea --- /dev/null +++ b/docs/models/servertoolsupportedapiformat.mdx @@ -0,0 +1,19 @@ +--- +title: "ServerToolSupportedApiFormat" +--- + +## Example Usage + +```typescript +import { ServerToolSupportedApiFormat } from "@openrouter/sdk/models"; + +let value: ServerToolSupportedApiFormat = "responses"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"responses" | "chat-completions" | "anthropic-messages" | Unrecognized +``` \ No newline at end of file diff --git a/docs/sdks/tools/README.mdx b/docs/sdks/tools/README.mdx new file mode 100644 index 000000000..6a9650d01 --- /dev/null +++ b/docs/sdks/tools/README.mdx @@ -0,0 +1,179 @@ +--- +title: "Tools" +description: "The catalog of server tools OpenRouter runs on behalf of a model: accepted `tools[].type` spellings per API format, engines and pricing, and which endpoints run each tool natively. See https://openrouter.ai/docs/guides/features/server-tools." +--- + +## Overview + +The catalog of server tools OpenRouter runs on behalf of a model: accepted `tools[].type` spellings per API format, engines and pricing, and which endpoints run each tool natively. See https://openrouter.ai/docs/guides/features/server-tools. + +### Available Operations + +* [listTools](#listtools) - List server tools +* [getTool](#gettool) - Get a server tool + +## listTools + +Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", +}); + +async function run() { + const result = await openRouter.tools.listTools({ + bearer: process.env["OPENROUTER_BEARER"] ?? "", + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { toolsListTools } from "@openrouter/sdk/funcs/toolsListTools.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", +}); + +async function run() { + const res = await toolsListTools(openRouter, { + bearer: process.env["OPENROUTER_BEARER"] ?? "", + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("toolsListTools failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.ListToolsRequest](../../models/operations/listtoolsrequest.mdx) | :heavy_check_mark: | The request object to use for the request. | +| `security` | [operations.ListToolsSecurity](../../models/operations/listtoolssecurity.mdx) | :heavy_check_mark: | The security requirements to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[models.ListToolsResponse](../../models/listtoolsresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## getTool + +One server tool by canonical name or any accepted alias, with the models that run it natively. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", +}); + +async function run() { + const result = await openRouter.tools.getTool({ + bearer: process.env["OPENROUTER_BEARER"] ?? "", + }, { + name: "openrouter:web_search", + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { toolsGetTool } from "@openrouter/sdk/funcs/toolsGetTool.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", +}); + +async function run() { + const res = await toolsGetTool(openRouter, { + bearer: process.env["OPENROUTER_BEARER"] ?? "", + }, { + name: "openrouter:web_search", + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("toolsGetTool failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.GetToolRequest](../../models/operations/gettoolrequest.mdx) | :heavy_check_mark: | The request object to use for the request. | +| `security` | [operations.GetToolSecurity](../../models/operations/gettoolsecurity.mdx) | :heavy_check_mark: | The security requirements to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.GetToolResponse](../../models/operations/gettoolresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | +| errors.UnauthorizedResponseError | 401 | application/json | +| errors.ForbiddenResponseError | 403 | application/json | +| errors.NotFoundResponseError | 404 | application/json | +| errors.InternalServerResponseError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/jsr.json b/jsr.json index 9e9cb32c6..79eeb769d 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.4.6", + "version": "1.4.7", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 34226eadd..666151c75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.4.6", + "version": "1.4.7", "author": "OpenRouter", "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.", "keywords": [ @@ -73,15 +73,15 @@ "lint": "eslint --cache --max-warnings=0 src", "build": "tsc && node scripts/unbarrel-imports.js", "prepublishOnly": "npm run build", - "typecheck": "tsc --noEmit", - "compile": "tsc && node scripts/unbarrel-imports.js", "postinstall": "node scripts/check-types.js || true", "prepare": "npm run build", "test": "vitest --run --project unit", - "test:watch": "vitest --watch --project unit", - "typecheck:transit": "exit 0", "test:e2e": "vitest --run --project e2e", - "test:transit": "exit 0" + "test:transit": "exit 0", + "typecheck": "tsc --noEmit", + "typecheck:transit": "exit 0", + "compile": "tsc && node scripts/unbarrel-imports.js", + "test:watch": "vitest --watch --project unit" }, "peerDependencies": { diff --git a/src/funcs/toolsGetTool.ts b/src/funcs/toolsGetTool.ts new file mode 100644 index 000000000..8d7c1bcd0 --- /dev/null +++ b/src/funcs/toolsGetTool.ts @@ -0,0 +1,228 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 4234ef4b0718 + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Get a server tool + * + * @remarks + * One server tool by canonical name or any accepted alias, with the models that run it natively. + */ +export function toolsGetTool( + client: OpenRouterCore, + security: operations.GetToolSecurity, + request: operations.GetToolRequest, + options?: RequestOptions, +): APIPromise< + Result< + operations.GetToolResponse | undefined, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + security, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + security: operations.GetToolSecurity, + request: operations.GetToolRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.GetToolResponse | undefined, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => operations.GetToolRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + name: encodeSimple("name", payload.name, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/tools/{name}")(pathParams); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const requestSecurity = resolveSecurity( + [ + { + fieldName: "Authorization", + type: "http:bearer", + value: security?.bearer, + }, + ], + ); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "getTool", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: security, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.GetToolResponse | undefined, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.GetToolResponse$inboundSchema.optional(), { + key: "Result", + }), + M.nil(308, operations.GetToolResponse$inboundSchema.optional(), { + hdrs: true, + }), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/toolsListTools.ts b/src/funcs/toolsListTools.ts new file mode 100644 index 000000000..57a7eeafd --- /dev/null +++ b/src/funcs/toolsListTools.ts @@ -0,0 +1,226 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: c07da22ec653 + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * List server tools + * + * @remarks + * Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively. + */ +export function toolsListTools( + client: OpenRouterCore, + security: operations.ListToolsSecurity, + request?: operations.ListToolsRequest | undefined, + options?: RequestOptions, +): APIPromise< + Result< + models.ListToolsResponse, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + security, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + security: operations.ListToolsSecurity, + request?: operations.ListToolsRequest | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + models.ListToolsResponse, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => + operations.ListToolsRequest$outboundSchema.optional().parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/tools")(); + + const query = encodeFormQuery({ + "api_format": payload?.api_format, + "limit": payload?.limit, + "offset": payload?.offset, + }); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload?.["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload?.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload?.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const requestSecurity = resolveSecurity( + [ + { + fieldName: "Authorization", + type: "http:bearer", + value: security?.bearer, + }, + ], + ); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "listTools", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: security, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + query: query, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + models.ListToolsResponse, + | errors.UnauthorizedResponseError + | errors.ForbiddenResponseError + | errors.NotFoundResponseError + | errors.InternalServerResponseError + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, models.ListToolsResponse$inboundSchema), + M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), + M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), + M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), + M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/lib/config.ts b/src/lib/config.ts index 516a8122b..22ce924ba 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -79,7 +79,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "1.4.6", + sdkVersion: "1.4.7", genVersion: "2.914.0", - userAgent: "speakeasy-sdk/typescript 1.4.6 2.914.0 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.4.7 2.914.0 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/generationresponse.ts b/src/models/generationresponse.ts index 7b54936c4..3cb344000 100644 --- a/src/models/generationresponse.ts +++ b/src/models/generationresponse.ts @@ -36,7 +36,7 @@ export type ApiType = OpenEnum; /** * The data region this generation was routed through: 'global', 'europe', or 'us'. */ -export const DataRegion = { +export const GenerationResponseDataRegion = { Global: "global", Europe: "europe", Us: "us", @@ -44,7 +44,9 @@ export const DataRegion = { /** * The data region this generation was routed through: 'global', 'europe', or 'us'. */ -export type DataRegion = OpenEnum; +export type GenerationResponseDataRegion = OpenEnum< + typeof GenerationResponseDataRegion +>; /** * Generation data @@ -73,7 +75,7 @@ export type GenerationResponseData = { /** * The data region this generation was routed through: 'global', 'europe', or 'us'. */ - dataRegion: DataRegion; + dataRegion: GenerationResponseDataRegion; /** * External user identifier */ @@ -247,8 +249,10 @@ export const ApiType$inboundSchema: z.ZodType = openEnums .inboundSchema(ApiType); /** @internal */ -export const DataRegion$inboundSchema: z.ZodType = - openEnums.inboundSchema(DataRegion); +export const GenerationResponseDataRegion$inboundSchema: z.ZodType< + GenerationResponseDataRegion, + unknown +> = openEnums.inboundSchema(GenerationResponseDataRegion); /** @internal */ export const GenerationResponseData$inboundSchema: z.ZodType< @@ -260,7 +264,7 @@ export const GenerationResponseData$inboundSchema: z.ZodType< cache_discount: z.nullable(z.number()), cancelled: z.nullable(z.boolean()), created_at: z.string(), - data_region: DataRegion$inboundSchema, + data_region: GenerationResponseDataRegion$inboundSchema, external_user: z.nullable(z.string()), finish_reason: z.nullable(z.string()), generation_time: z.nullable(z.number()), diff --git a/src/models/gettoolresponse.ts b/src/models/gettoolresponse.ts new file mode 100644 index 000000000..cd0acc184 --- /dev/null +++ b/src/models/gettoolresponse.ts @@ -0,0 +1,35 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: ef3123a53743 + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + ServerToolDetails, + ServerToolDetails$inboundSchema, +} from "./servertooldetails.js"; + +export type GetToolResponse = { + data: ServerToolDetails; +}; + +/** @internal */ +export const GetToolResponse$inboundSchema: z.ZodType< + GetToolResponse, + unknown +> = z.object({ + data: ServerToolDetails$inboundSchema, +}); + +export function getToolResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetToolResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetToolResponse' from JSON`, + ); +} diff --git a/src/models/index.ts b/src/models/index.ts index 6a7a2dbb6..9ced5a45d 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -349,6 +349,7 @@ export * from "./getpresetresponse.js"; export * from "./getpresetversionresponse.js"; export * from "./getscimgroupmappingresponse.js"; export * from "./getscimsyncjobresponse.js"; +export * from "./gettoolresponse.js"; export * from "./getworkspacebudgetresponse.js"; export * from "./getworkspaceresponse.js"; export * from "./goneresponseerrordata.js"; @@ -441,6 +442,7 @@ export * from "./listpresetversionsresponse.js"; export * from "./listprivateendpointsresponse.js"; export * from "./listscimgroupmappingsresponse.js"; export * from "./listscimgroupsresponse.js"; +export * from "./listtoolsresponse.js"; export * from "./listworkspacebudgetsresponse.js"; export * from "./listworkspacemembersresponse.js"; export * from "./listworkspacesresponse.js"; @@ -665,6 +667,15 @@ export * from "./searchmodelsservertoolconfig.js"; export * from "./searchmodelsservertoolopenrouter.js"; export * from "./searchqualitylevel.js"; export * from "./security.js"; +export * from "./servertool.js"; +export * from "./servertooldetails.js"; +export * from "./servertoolengine.js"; +export * from "./servertoolexecutedby.js"; +export * from "./servertoolinputname.js"; +export * from "./servertoolnativemodel.js"; +export * from "./servertoolnativesupport.js"; +export * from "./servertooloutputname.js"; +export * from "./servertoolprice.js"; export * from "./servertoolusedetails.js"; export * from "./serviceunavailableresponseerrordata.js"; export * from "./sessioncostitem.js"; diff --git a/src/models/listtoolsresponse.ts b/src/models/listtoolsresponse.ts new file mode 100644 index 000000000..0efff11ce --- /dev/null +++ b/src/models/listtoolsresponse.ts @@ -0,0 +1,69 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: d36b0fe12aa7 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { ServerTool, ServerTool$inboundSchema } from "./servertool.js"; + +export type ListToolsResponseLinks = { + /** + * URL for the next page of results, or null if this is the last page + */ + next: string | null; +}; + +export type ListToolsResponse = { + data: Array; + links: ListToolsResponseLinks; + /** + * Total number of tools + */ + totalCount: number; +}; + +/** @internal */ +export const ListToolsResponseLinks$inboundSchema: z.ZodType< + ListToolsResponseLinks, + unknown +> = z.object({ + next: z.nullable(z.string()), +}); + +export function listToolsResponseLinksFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListToolsResponseLinks$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListToolsResponseLinks' from JSON`, + ); +} + +/** @internal */ +export const ListToolsResponse$inboundSchema: z.ZodType< + ListToolsResponse, + unknown +> = z.object({ + data: z.array(ServerTool$inboundSchema), + links: z.lazy(() => ListToolsResponseLinks$inboundSchema), + total_count: z.int(), +}).transform((v) => { + return remap$(v, { + "total_count": "totalCount", + }); +}); + +export function listToolsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListToolsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListToolsResponse' from JSON`, + ); +} diff --git a/src/models/modelslistresponse.ts b/src/models/modelslistresponse.ts index 8e625a6e3..bf1fc3855 100644 --- a/src/models/modelslistresponse.ts +++ b/src/models/modelslistresponse.ts @@ -13,7 +13,7 @@ import { Model, Model$inboundSchema } from "./model.js"; /** * Pagination links */ -export type Links = { +export type ModelsListResponseLinks = { /** * URL for the next page of results, or null if this is the last page */ @@ -31,7 +31,7 @@ export type ModelsListResponse = { /** * Pagination links */ - links: Links; + links: ModelsListResponseLinks; /** * Total number of models matching the query */ @@ -39,17 +39,20 @@ export type ModelsListResponse = { }; /** @internal */ -export const Links$inboundSchema: z.ZodType = z.object({ +export const ModelsListResponseLinks$inboundSchema: z.ZodType< + ModelsListResponseLinks, + unknown +> = z.object({ next: z.nullable(z.string()), }); -export function linksFromJSON( +export function modelsListResponseLinksFromJSON( jsonString: string, -): SafeParseResult { +): SafeParseResult { return safeParse( jsonString, - (x) => Links$inboundSchema.parse(JSON.parse(x)), - `Failed to parse 'Links' from JSON`, + (x) => ModelsListResponseLinks$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModelsListResponseLinks' from JSON`, ); } @@ -59,7 +62,7 @@ export const ModelsListResponse$inboundSchema: z.ZodType< unknown > = z.object({ data: z.array(Model$inboundSchema), - links: z.lazy(() => Links$inboundSchema), + links: z.lazy(() => ModelsListResponseLinks$inboundSchema), total_count: z.int(), }).transform((v) => { return remap$(v, { diff --git a/src/models/operations/gettool.ts b/src/models/operations/gettool.ts new file mode 100644 index 000000000..c68951678 --- /dev/null +++ b/src/models/operations/gettool.ts @@ -0,0 +1,138 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 643b31a6a57a + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import * as models from "../index.js"; + +export type GetToolGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type GetToolSecurity = { + bearer: string; +}; + +export type GetToolRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Canonical `openrouter:*` name or any accepted `tools[].type` alias + */ + name: string; +}; + +export type GetToolResponse = { + headers: { [k: string]: Array }; + result?: models.GetToolResponse | undefined; +}; + +/** @internal */ +export type GetToolSecurity$Outbound = { + bearer: string; +}; + +/** @internal */ +export const GetToolSecurity$outboundSchema: z.ZodType< + GetToolSecurity$Outbound, + GetToolSecurity +> = z.object({ + bearer: z.string(), +}); + +export function getToolSecurityToJSON( + getToolSecurity: GetToolSecurity, +): string { + return JSON.stringify(GetToolSecurity$outboundSchema.parse(getToolSecurity)); +} + +/** @internal */ +export type GetToolRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + name: string; +}; + +/** @internal */ +export const GetToolRequest$outboundSchema: z.ZodType< + GetToolRequest$Outbound, + GetToolRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + name: z.string(), +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + }); +}); + +export function getToolRequestToJSON(getToolRequest: GetToolRequest): string { + return JSON.stringify(GetToolRequest$outboundSchema.parse(getToolRequest)); +} + +/** @internal */ +export const GetToolResponse$inboundSchema: z.ZodType< + GetToolResponse, + unknown +> = z.object({ + Headers: z.record(z.string(), z.array(z.string())).default({}), + Result: models.GetToolResponse$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "Headers": "headers", + "Result": "result", + }); +}); + +export function getToolResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetToolResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetToolResponse' from JSON`, + ); +} diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index dffc4fdce..a780c5ceb 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -81,6 +81,7 @@ export * from "./getscimgroupmapping.js"; export * from "./getscimsyncjob.js"; export * from "./getsessioncost.js"; export * from "./gettaskclassifications.js"; +export * from "./gettool.js"; export * from "./getuseractivity.js"; export * from "./getvideos.js"; export * from "./getworkspace.js"; @@ -116,6 +117,7 @@ export * from "./listprivateendpoints.js"; export * from "./listproviders.js"; export * from "./listscimgroupmappings.js"; export * from "./listscimgroups.js"; +export * from "./listtools.js"; export * from "./listvaultsecrets.js"; export * from "./listvideoscontent.js"; export * from "./listvideosmodels.js"; diff --git a/src/models/operations/listtools.ts b/src/models/operations/listtools.ts new file mode 100644 index 000000000..350e2ccb3 --- /dev/null +++ b/src/models/operations/listtools.ts @@ -0,0 +1,143 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 42a61de0bc0f + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as openEnums from "../../types/enums.js"; +import { OpenEnum } from "../../types/enums.js"; + +export type ListToolsGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type ListToolsSecurity = { + bearer: string; +}; + +/** + * Only tools usable on this API format + */ +export const ApiFormat = { + Responses: "responses", + ChatCompletions: "chat-completions", + AnthropicMessages: "anthropic-messages", +} as const; +/** + * Only tools usable on this API format + */ +export type ApiFormat = OpenEnum; + +export type ListToolsRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned + */ + offset?: number | null | undefined; + /** + * Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned + */ + limit?: number | undefined; + /** + * Only tools usable on this API format + */ + apiFormat?: ApiFormat | undefined; +}; + +/** @internal */ +export type ListToolsSecurity$Outbound = { + bearer: string; +}; + +/** @internal */ +export const ListToolsSecurity$outboundSchema: z.ZodType< + ListToolsSecurity$Outbound, + ListToolsSecurity +> = z.object({ + bearer: z.string(), +}); + +export function listToolsSecurityToJSON( + listToolsSecurity: ListToolsSecurity, +): string { + return JSON.stringify( + ListToolsSecurity$outboundSchema.parse(listToolsSecurity), + ); +} + +/** @internal */ +export const ApiFormat$outboundSchema: z.ZodType = openEnums + .outboundSchema(ApiFormat); + +/** @internal */ +export type ListToolsRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + offset: number | null; + limit: number; + api_format?: string | undefined; +}; + +/** @internal */ +export const ListToolsRequest$outboundSchema: z.ZodType< + ListToolsRequest$Outbound, + ListToolsRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + offset: z.nullable(z.int().default(0)), + limit: z.int().default(50), + apiFormat: ApiFormat$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + apiFormat: "api_format", + }); +}); + +export function listToolsRequestToJSON( + listToolsRequest: ListToolsRequest, +): string { + return JSON.stringify( + ListToolsRequest$outboundSchema.parse(listToolsRequest), + ); +} diff --git a/src/models/servertool.ts b/src/models/servertool.ts new file mode 100644 index 000000000..6e141eb72 --- /dev/null +++ b/src/models/servertool.ts @@ -0,0 +1,141 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 51581c50c8ce + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + ServerToolEngine, + ServerToolEngine$inboundSchema, +} from "./servertoolengine.js"; +import { + ServerToolInputName, + ServerToolInputName$inboundSchema, +} from "./servertoolinputname.js"; +import { + ServerToolNativeSupport, + ServerToolNativeSupport$inboundSchema, +} from "./servertoolnativesupport.js"; + +export const ServerToolStatus = { + Active: "active", + Deprecated: "deprecated", +} as const; +export type ServerToolStatus = OpenEnum; + +export const ServerToolSupportedApiFormat = { + Responses: "responses", + ChatCompletions: "chat-completions", + AnthropicMessages: "anthropic-messages", +} as const; +export type ServerToolSupportedApiFormat = OpenEnum< + typeof ServerToolSupportedApiFormat +>; + +export type ServerTool = { + /** + * Every spelling accepted in `tools[].type` for this tool, including the canonical `id`, and what the call surfaces as under each + */ + aliases: Array; + /** + * The engine a request without `parameters.engine` (or with `engine: "auto"`) runs on; `native` applies where the endpoint runs the tool itself, otherwise `fallback_engine`. A request pinned to a data region skips either engine when its `data_regions` does not list that region. Null for a tool without an engine parameter + */ + defaultEngine: string | null; + docsUrl: string; + engines: Array; + /** + * The engine an unpinned request runs on when `default_engine` is `native` and the endpoint does not run the tool itself; null when there is no fallback + */ + fallbackEngine: string | null; + /** + * Canonical `openrouter:*` name; the stable `tools[].type` on every API format in `supported_api_formats` + */ + id: string; + /** + * JSON Schema of the arguments the model emits when calling the tool + */ + inputSchema: { [k: string]: any }; + name: string; + /** + * Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + */ + nativeSupport: ServerToolNativeSupport; + /** + * JSON Schema of the result returned to the model; null when undeclared + */ + outputSchema: { [k: string]: any } | null; + /** + * JSON Schema for the caller-side `tools[].parameters` object + */ + parametersSchema: { [k: string]: any }; + status: ServerToolStatus; + /** + * One sentence for cards and search results; never sent to a model + */ + summary: string; + supportedApiFormats: Array; + /** + * The description sent upstream as the function tool description + */ + toolDescription: string; +}; + +/** @internal */ +export const ServerToolStatus$inboundSchema: z.ZodType< + ServerToolStatus, + unknown +> = openEnums.inboundSchema(ServerToolStatus); + +/** @internal */ +export const ServerToolSupportedApiFormat$inboundSchema: z.ZodType< + ServerToolSupportedApiFormat, + unknown +> = openEnums.inboundSchema(ServerToolSupportedApiFormat); + +/** @internal */ +export const ServerTool$inboundSchema: z.ZodType = z + .object({ + aliases: z.array(ServerToolInputName$inboundSchema), + default_engine: z.nullable(z.string()), + docs_url: z.string(), + engines: z.array(ServerToolEngine$inboundSchema), + fallback_engine: z.nullable(z.string()), + id: z.string(), + input_schema: z.record(z.string(), z.any()), + name: z.string(), + native_support: ServerToolNativeSupport$inboundSchema, + output_schema: z.nullable(z.record(z.string(), z.any())), + parameters_schema: z.record(z.string(), z.any()), + status: ServerToolStatus$inboundSchema, + summary: z.string(), + supported_api_formats: z.array(ServerToolSupportedApiFormat$inboundSchema), + tool_description: z.string(), + }).transform((v) => { + return remap$(v, { + "default_engine": "defaultEngine", + "docs_url": "docsUrl", + "fallback_engine": "fallbackEngine", + "input_schema": "inputSchema", + "native_support": "nativeSupport", + "output_schema": "outputSchema", + "parameters_schema": "parametersSchema", + "supported_api_formats": "supportedApiFormats", + "tool_description": "toolDescription", + }); + }); + +export function serverToolFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerTool$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerTool' from JSON`, + ); +} diff --git a/src/models/servertooldetails.ts b/src/models/servertooldetails.ts new file mode 100644 index 000000000..e7062b17f --- /dev/null +++ b/src/models/servertooldetails.ts @@ -0,0 +1,177 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: f94cb5399ef7 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + ServerToolEngine, + ServerToolEngine$inboundSchema, +} from "./servertoolengine.js"; +import { + ServerToolInputName, + ServerToolInputName$inboundSchema, +} from "./servertoolinputname.js"; +import { + ServerToolNativeModel, + ServerToolNativeModel$inboundSchema, +} from "./servertoolnativemodel.js"; + +/** + * Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + */ +export type NativeSupport = { + endpointCount: number; + modelCount: number; + models: Array; +}; + +export const ServerToolDetailsStatus = { + Active: "active", + Deprecated: "deprecated", +} as const; +export type ServerToolDetailsStatus = OpenEnum; + +export const ServerToolDetailsSupportedApiFormat = { + Responses: "responses", + ChatCompletions: "chat-completions", + AnthropicMessages: "anthropic-messages", +} as const; +export type ServerToolDetailsSupportedApiFormat = OpenEnum< + typeof ServerToolDetailsSupportedApiFormat +>; + +export type ServerToolDetails = { + /** + * Every spelling accepted in `tools[].type` for this tool, including the canonical `id`, and what the call surfaces as under each + */ + aliases: Array; + /** + * The engine a request without `parameters.engine` (or with `engine: "auto"`) runs on; `native` applies where the endpoint runs the tool itself, otherwise `fallback_engine`. A request pinned to a data region skips either engine when its `data_regions` does not list that region. Null for a tool without an engine parameter + */ + defaultEngine: string | null; + docsUrl: string; + engines: Array; + /** + * The engine an unpinned request runs on when `default_engine` is `native` and the endpoint does not run the tool itself; null when there is no fallback + */ + fallbackEngine: string | null; + /** + * Canonical `openrouter:*` name; the stable `tools[].type` on every API format in `supported_api_formats` + */ + id: string; + /** + * JSON Schema of the arguments the model emits when calling the tool + */ + inputSchema: { [k: string]: any }; + name: string; + /** + * Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + */ + nativeSupport: NativeSupport; + /** + * JSON Schema of the result returned to the model; null when undeclared + */ + outputSchema: { [k: string]: any } | null; + /** + * JSON Schema for the caller-side `tools[].parameters` object + */ + parametersSchema: { [k: string]: any }; + status: ServerToolDetailsStatus; + /** + * One sentence for cards and search results; never sent to a model + */ + summary: string; + supportedApiFormats: Array; + /** + * The description sent upstream as the function tool description + */ + toolDescription: string; +}; + +/** @internal */ +export const NativeSupport$inboundSchema: z.ZodType = z + .object({ + endpoint_count: z.int(), + model_count: z.int(), + models: z.array(ServerToolNativeModel$inboundSchema), + }).transform((v) => { + return remap$(v, { + "endpoint_count": "endpointCount", + "model_count": "modelCount", + }); + }); + +export function nativeSupportFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => NativeSupport$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'NativeSupport' from JSON`, + ); +} + +/** @internal */ +export const ServerToolDetailsStatus$inboundSchema: z.ZodType< + ServerToolDetailsStatus, + unknown +> = openEnums.inboundSchema(ServerToolDetailsStatus); + +/** @internal */ +export const ServerToolDetailsSupportedApiFormat$inboundSchema: z.ZodType< + ServerToolDetailsSupportedApiFormat, + unknown +> = openEnums.inboundSchema(ServerToolDetailsSupportedApiFormat); + +/** @internal */ +export const ServerToolDetails$inboundSchema: z.ZodType< + ServerToolDetails, + unknown +> = z.object({ + aliases: z.array(ServerToolInputName$inboundSchema), + default_engine: z.nullable(z.string()), + docs_url: z.string(), + engines: z.array(ServerToolEngine$inboundSchema), + fallback_engine: z.nullable(z.string()), + id: z.string(), + input_schema: z.record(z.string(), z.any()), + name: z.string(), + native_support: z.lazy(() => NativeSupport$inboundSchema), + output_schema: z.nullable(z.record(z.string(), z.any())), + parameters_schema: z.record(z.string(), z.any()), + status: ServerToolDetailsStatus$inboundSchema, + summary: z.string(), + supported_api_formats: z.array( + ServerToolDetailsSupportedApiFormat$inboundSchema, + ), + tool_description: z.string(), +}).transform((v) => { + return remap$(v, { + "default_engine": "defaultEngine", + "docs_url": "docsUrl", + "fallback_engine": "fallbackEngine", + "input_schema": "inputSchema", + "native_support": "nativeSupport", + "output_schema": "outputSchema", + "parameters_schema": "parametersSchema", + "supported_api_formats": "supportedApiFormats", + "tool_description": "toolDescription", + }); +}); + +export function serverToolDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolDetails' from JSON`, + ); +} diff --git a/src/models/servertoolengine.ts b/src/models/servertoolengine.ts new file mode 100644 index 000000000..a3937b83a --- /dev/null +++ b/src/models/servertoolengine.ts @@ -0,0 +1,140 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 0ee547bdca50 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + ServerToolExecutedBy, + ServerToolExecutedBy$inboundSchema, +} from "./servertoolexecutedby.js"; +import { + ServerToolPrice, + ServerToolPrice$inboundSchema, +} from "./servertoolprice.js"; + +/** + * Whether the engine needs the caller's own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter's key is used unless the caller saved one), or `none` + */ +export const BYOK = { + Required: "required", + Optional: "optional", + None: "none", +} as const; +/** + * Whether the engine needs the caller's own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter's key is used unless the caller saved one), or `none` + */ +export type BYOK = OpenEnum; + +export const ServerToolEngineDataRegion = { + Global: "global", + Europe: "europe", + Us: "us", +} as const; +export type ServerToolEngineDataRegion = OpenEnum< + typeof ServerToolEngineDataRegion +>; + +/** + * Who bills the engine's calls beyond the model's tokens: `openrouter` (the `pricing` rows, from the caller's credits), `provider` (a per-call tool fee from the model's provider on the inference call, at its own rates), `byok` (the engine's vendor, against the caller's own key), or `none` (no charge) + */ +export const PricingSource = { + Openrouter: "openrouter", + Provider: "provider", + BYOK: "byok", + None: "none", +} as const; +/** + * Who bills the engine's calls beyond the model's tokens: `openrouter` (the `pricing` rows, from the caller's credits), `provider` (a per-call tool fee from the model's provider on the inference call, at its own rates), `byok` (the engine's vendor, against the caller's own key), or `none` (no charge) + */ +export type PricingSource = OpenEnum; + +export type ServerToolEngine = { + /** + * Whether the engine needs the caller's own key, saved in plugin settings: `required` (OpenRouter holds none), `optional` (OpenRouter's key is used unless the caller saved one), or `none` + */ + byok: BYOK; + /** + * The data regions whose requests this engine serves without leaving the region. A request pinned to a region can only use engines that list it; `global` is always listed. + */ + dataRegions: Array; + /** + * The `parameters.mode` a request without one runs and bills as; null for engines without modes. The `pricing[]` row with this `mode` is what an unmoded request bills + */ + defaultMode: string | null; + /** + * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`). + */ + executedBy: ServerToolExecutedBy; + /** + * The `parameters.engine` value that selects this engine; null for the single engine of a tool without an engine parameter + */ + id: string | null; + name: string; + /** + * The rows OpenRouter bills; non-empty exactly when `pricing_source` is `openrouter` + */ + pricing: Array; + /** + * Where the rates are documented when `pricing_source` is `provider` or `byok`; null otherwise + */ + pricingDocUrl: string | null; + /** + * Who bills the engine's calls beyond the model's tokens: `openrouter` (the `pricing` rows, from the caller's credits), `provider` (a per-call tool fee from the model's provider on the inference call, at its own rates), `byok` (the engine's vendor, against the caller's own key), or `none` (no charge) + */ + pricingSource: PricingSource; +}; + +/** @internal */ +export const BYOK$inboundSchema: z.ZodType = openEnums + .inboundSchema(BYOK); + +/** @internal */ +export const ServerToolEngineDataRegion$inboundSchema: z.ZodType< + ServerToolEngineDataRegion, + unknown +> = openEnums.inboundSchema(ServerToolEngineDataRegion); + +/** @internal */ +export const PricingSource$inboundSchema: z.ZodType = + openEnums.inboundSchema(PricingSource); + +/** @internal */ +export const ServerToolEngine$inboundSchema: z.ZodType< + ServerToolEngine, + unknown +> = z.object({ + byok: BYOK$inboundSchema, + data_regions: z.array(ServerToolEngineDataRegion$inboundSchema), + default_mode: z.nullable(z.string()), + executed_by: ServerToolExecutedBy$inboundSchema, + id: z.nullable(z.string()), + name: z.string(), + pricing: z.array(ServerToolPrice$inboundSchema), + pricing_doc_url: z.nullable(z.string()), + pricing_source: PricingSource$inboundSchema, +}).transform((v) => { + return remap$(v, { + "data_regions": "dataRegions", + "default_mode": "defaultMode", + "executed_by": "executedBy", + "pricing_doc_url": "pricingDocUrl", + "pricing_source": "pricingSource", + }); +}); + +export function serverToolEngineFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolEngine$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolEngine' from JSON`, + ); +} diff --git a/src/models/servertoolexecutedby.ts b/src/models/servertoolexecutedby.ts new file mode 100644 index 000000000..7939046e6 --- /dev/null +++ b/src/models/servertoolexecutedby.ts @@ -0,0 +1,27 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: cfa354bfe40d + */ + +import * as z from "zod/v4"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; + +/** + * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`). + */ +export const ServerToolExecutedBy = { + Provider: "provider", + Openrouter: "openrouter", + Client: "client", +} as const; +/** + * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`). + */ +export type ServerToolExecutedBy = OpenEnum; + +/** @internal */ +export const ServerToolExecutedBy$inboundSchema: z.ZodType< + ServerToolExecutedBy, + unknown +> = openEnums.inboundSchema(ServerToolExecutedBy); diff --git a/src/models/servertoolinputname.ts b/src/models/servertoolinputname.ts new file mode 100644 index 000000000..67cafd51a --- /dev/null +++ b/src/models/servertoolinputname.ts @@ -0,0 +1,68 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: deeca5c74395 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; +import { + ServerToolOutputName, + ServerToolOutputName$inboundSchema, +} from "./servertooloutputname.js"; + +export const ServerToolInputNameApiFormat = { + Responses: "responses", + ChatCompletions: "chat-completions", + AnthropicMessages: "anthropic-messages", +} as const; +export type ServerToolInputNameApiFormat = OpenEnum< + typeof ServerToolInputNameApiFormat +>; + +export type ServerToolInputName = { + /** + * API formats that accept this spelling in `tools[].type` + */ + apiFormats: Array; + /** + * What the call surfaces as on each accepting API format when requested under this spelling; a format is absent when the call is not visible to the caller + */ + outputNames: Array; + type: string; +}; + +/** @internal */ +export const ServerToolInputNameApiFormat$inboundSchema: z.ZodType< + ServerToolInputNameApiFormat, + unknown +> = openEnums.inboundSchema(ServerToolInputNameApiFormat); + +/** @internal */ +export const ServerToolInputName$inboundSchema: z.ZodType< + ServerToolInputName, + unknown +> = z.object({ + api_formats: z.array(ServerToolInputNameApiFormat$inboundSchema), + output_names: z.array(ServerToolOutputName$inboundSchema), + type: z.string(), +}).transform((v) => { + return remap$(v, { + "api_formats": "apiFormats", + "output_names": "outputNames", + }); +}); + +export function serverToolInputNameFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolInputName$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolInputName' from JSON`, + ); +} diff --git a/src/models/servertoolnativemodel.ts b/src/models/servertoolnativemodel.ts new file mode 100644 index 000000000..971d19835 --- /dev/null +++ b/src/models/servertoolnativemodel.ts @@ -0,0 +1,33 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 80f9cb866c58 + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type ServerToolNativeModel = { + providers: Array; + slug: string; +}; + +/** @internal */ +export const ServerToolNativeModel$inboundSchema: z.ZodType< + ServerToolNativeModel, + unknown +> = z.object({ + providers: z.array(z.string()), + slug: z.string(), +}); + +export function serverToolNativeModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolNativeModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolNativeModel' from JSON`, + ); +} diff --git a/src/models/servertoolnativesupport.ts b/src/models/servertoolnativesupport.ts new file mode 100644 index 000000000..710e7634b --- /dev/null +++ b/src/models/servertoolnativesupport.ts @@ -0,0 +1,42 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 3a84d88babcc + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +/** + * Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively. + */ +export type ServerToolNativeSupport = { + endpointCount: number; + modelCount: number; +}; + +/** @internal */ +export const ServerToolNativeSupport$inboundSchema: z.ZodType< + ServerToolNativeSupport, + unknown +> = z.object({ + endpoint_count: z.int(), + model_count: z.int(), +}).transform((v) => { + return remap$(v, { + "endpoint_count": "endpointCount", + "model_count": "modelCount", + }); +}); + +export function serverToolNativeSupportFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolNativeSupport$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolNativeSupport' from JSON`, + ); +} diff --git a/src/models/servertooloutputname.ts b/src/models/servertooloutputname.ts new file mode 100644 index 000000000..3b057bbbd --- /dev/null +++ b/src/models/servertooloutputname.ts @@ -0,0 +1,63 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 1dd915c55b83 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import * as openEnums from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export const ServerToolOutputNameApiFormat = { + Responses: "responses", + ChatCompletions: "chat-completions", + AnthropicMessages: "anthropic-messages", +} as const; +export type ServerToolOutputNameApiFormat = OpenEnum< + typeof ServerToolOutputNameApiFormat +>; + +export type ServerToolOutputName = { + apiFormat: ServerToolOutputNameApiFormat; + /** + * Anthropic Messages `server_tool_use` block `name`, when the call surfaces as one + */ + name?: string | undefined; + /** + * Output item `type` on Responses, content block `type` on Anthropic Messages, `reasoning_details[].type` on Chat Completions + */ + type: string; +}; + +/** @internal */ +export const ServerToolOutputNameApiFormat$inboundSchema: z.ZodType< + ServerToolOutputNameApiFormat, + unknown +> = openEnums.inboundSchema(ServerToolOutputNameApiFormat); + +/** @internal */ +export const ServerToolOutputName$inboundSchema: z.ZodType< + ServerToolOutputName, + unknown +> = z.object({ + api_format: ServerToolOutputNameApiFormat$inboundSchema, + name: z.string().optional(), + type: z.string(), +}).transform((v) => { + return remap$(v, { + "api_format": "apiFormat", + }); +}); + +export function serverToolOutputNameFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolOutputName$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolOutputName' from JSON`, + ); +} diff --git a/src/models/servertoolprice.ts b/src/models/servertoolprice.ts new file mode 100644 index 000000000..8eae59d1d --- /dev/null +++ b/src/models/servertoolprice.ts @@ -0,0 +1,48 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: d12fcc3fb6f8 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type ServerToolPrice = { + maxUnitsPerCall: number; + /** + * The `parameters.mode` this price applies to; null for prices that do not depend on the mode. A request bills exactly one `request` row + */ + mode: string | null; + /** + * USD per unit, as a decimal string + */ + price: string; + unit: string; +}; + +/** @internal */ +export const ServerToolPrice$inboundSchema: z.ZodType< + ServerToolPrice, + unknown +> = z.object({ + max_units_per_call: z.int(), + mode: z.nullable(z.string()), + price: z.string(), + unit: z.string(), +}).transform((v) => { + return remap$(v, { + "max_units_per_call": "maxUnitsPerCall", + }); +}); + +export function serverToolPriceFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServerToolPrice$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServerToolPrice' from JSON`, + ); +} diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index d5726986f..2ddd1f313 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -35,6 +35,7 @@ import { Responses } from "./responses.js"; import { Scim } from "./scim.js"; import { STT } from "./stt.js"; import { SystemOne } from "./systemone.js"; +import { Tools } from "./tools.js"; import { TTS } from "./tts.js"; import { Vault } from "./vault.js"; import { VideoGeneration } from "./videogeneration.js"; @@ -213,6 +214,11 @@ export class OpenRouter extends ClientSDK { return (this._systemOne ??= new SystemOne(this._options)); } + private _tools?: Tools; + get tools(): Tools { + return (this._tools ??= new Tools(this._options)); + } + private _vault?: Vault; get vault(): Vault { return (this._vault ??= new Vault(this._options)); diff --git a/src/sdk/tools.ts b/src/sdk/tools.ts new file mode 100644 index 000000000..3da5c6645 --- /dev/null +++ b/src/sdk/tools.ts @@ -0,0 +1,51 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: f997ccdd9dd9 + */ + +import { toolsGetTool } from "../funcs/toolsGetTool.js"; +import { toolsListTools } from "../funcs/toolsListTools.js"; +import { ClientSDK, RequestOptions } from "../lib/sdks.js"; +import * as models from "../models/index.js"; +import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; + +export class Tools extends ClientSDK { + /** + * List server tools + * + * @remarks + * Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively. + */ + async listTools( + security: operations.ListToolsSecurity, + request?: operations.ListToolsRequest | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(toolsListTools( + this, + security, + request, + options, + )); + } + + /** + * Get a server tool + * + * @remarks + * One server tool by canonical name or any accepted alias, with the models that run it natively. + */ + async getTool( + security: operations.GetToolSecurity, + request: operations.GetToolRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(toolsGetTool( + this, + security, + request, + options, + )); + } +} From 63cef765c839713ec32e1eb18cd9fd4671269465 Mon Sep 17 00:00:00 2001 From: "speakeasy-github[bot]" <128539517+speakeasy-github[bot]@users.noreply.github.com> Date: Tue, 29 Sep 2026 22:08:47 +0000 Subject: [PATCH 2/3] empty commit to trigger [run-tests] workflow From f8bdf9c761d1e2848d3f8367c71544da98caf724 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Sep 2026 22:09:03 +0000 Subject: [PATCH 3/3] Chore: regenerate docs navigation Auto-generated-by: update-generated-files-action; https://github.com/OpenRouterTeam/typescript-sdk/actions/runs/36637804894 --- docs/docs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs.json b/docs/docs.json index c118c6487..224348707 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -41,6 +41,7 @@ "sdks/scim/README", "sdks/stt/README", "sdks/systemone/README", + "sdks/tools/README", "sdks/tts/README", "sdks/vault/README", "sdks/videogeneration/README",