@openrouter/sdk 0.3.2 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/.zed/settings.json +10 -0
  2. package/_speakeasy/.github/action-inputs-config.json +53 -0
  3. package/_speakeasy/.github/action-security-config.json +88 -0
  4. package/esm/core.js +1 -0
  5. package/esm/funcs/analyticsGetUserActivity.js +1 -0
  6. package/esm/funcs/apiKeysCreate.js +1 -0
  7. package/esm/funcs/apiKeysDelete.js +1 -0
  8. package/esm/funcs/apiKeysGet.js +1 -0
  9. package/esm/funcs/apiKeysGetCurrentKeyMetadata.js +1 -0
  10. package/esm/funcs/apiKeysList.js +1 -0
  11. package/esm/funcs/apiKeysUpdate.js +1 -0
  12. package/esm/funcs/betaResponsesSend.js +1 -0
  13. package/esm/funcs/call-model.d.ts +118 -0
  14. package/esm/funcs/call-model.js +137 -0
  15. package/esm/funcs/chatSend.js +1 -0
  16. package/esm/funcs/completionsGenerate.js +1 -0
  17. package/esm/funcs/creditsCreateCoinbaseCharge.js +1 -0
  18. package/esm/funcs/creditsGetCredits.js +1 -0
  19. package/esm/funcs/embeddingsGenerate.js +1 -0
  20. package/esm/funcs/embeddingsListModels.js +1 -0
  21. package/esm/funcs/endpointsList.js +1 -0
  22. package/esm/funcs/endpointsListZdrEndpoints.js +1 -0
  23. package/esm/funcs/generationsGetGeneration.js +1 -0
  24. package/esm/funcs/modelsCount.js +1 -0
  25. package/esm/funcs/modelsList.js +1 -0
  26. package/esm/funcs/modelsListForUser.js +1 -0
  27. package/esm/funcs/oAuthCreateAuthCode.js +1 -0
  28. package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.js +1 -0
  29. package/esm/funcs/parametersGetParameters.js +1 -0
  30. package/esm/funcs/providersList.js +1 -0
  31. package/esm/hooks/hooks.js +1 -0
  32. package/esm/hooks/index.js +1 -0
  33. package/esm/hooks/types.js +1 -0
  34. package/esm/index.d.ts +20 -5
  35. package/esm/index.js +21 -4
  36. package/esm/lib/anthropic-compat.d.ts +50 -0
  37. package/esm/lib/anthropic-compat.js +223 -0
  38. package/esm/lib/anthropic-compat.test.d.ts +2 -0
  39. package/esm/lib/anthropic-compat.test.js +479 -0
  40. package/esm/lib/async-params.d.ts +53 -0
  41. package/esm/lib/async-params.js +76 -0
  42. package/esm/lib/base64.js +1 -0
  43. package/esm/lib/chat-compat.d.ts +46 -0
  44. package/esm/lib/chat-compat.js +112 -0
  45. package/esm/lib/chat-compat.test.d.ts +2 -0
  46. package/esm/lib/chat-compat.test.js +282 -0
  47. package/esm/lib/claude-constants.d.ts +22 -0
  48. package/esm/lib/claude-constants.js +20 -0
  49. package/esm/lib/claude-type-guards.d.ts +10 -0
  50. package/esm/lib/claude-type-guards.js +70 -0
  51. package/esm/lib/config.d.ts +2 -2
  52. package/esm/lib/config.js +3 -2
  53. package/esm/lib/dlv.js +1 -0
  54. package/esm/lib/encodings.js +1 -0
  55. package/esm/lib/env.js +1 -0
  56. package/esm/lib/event-streams.js +1 -0
  57. package/esm/lib/files.js +1 -0
  58. package/esm/lib/http.js +1 -0
  59. package/esm/lib/is-plain-object.js +1 -0
  60. package/esm/lib/logger.js +1 -0
  61. package/esm/lib/matchers.js +1 -0
  62. package/esm/lib/{response-wrapper.d.ts → model-result.d.ts} +29 -43
  63. package/esm/lib/{response-wrapper.js → model-result.js} +146 -175
  64. package/esm/lib/next-turn-params.d.ts +30 -0
  65. package/esm/lib/next-turn-params.js +129 -0
  66. package/esm/lib/primitives.js +1 -0
  67. package/esm/lib/retries.js +1 -0
  68. package/esm/lib/reusable-stream.js +10 -10
  69. package/esm/lib/schemas.js +1 -0
  70. package/esm/lib/sdks.js +1 -0
  71. package/esm/lib/security.js +1 -0
  72. package/esm/lib/stop-conditions.d.ts +80 -0
  73. package/esm/lib/stop-conditions.js +104 -0
  74. package/esm/lib/stream-transformers.d.ts +30 -4
  75. package/esm/lib/stream-transformers.js +467 -98
  76. package/esm/lib/stream-type-guards.d.ts +29 -0
  77. package/esm/lib/stream-type-guards.js +109 -0
  78. package/esm/lib/tool-executor.d.ts +7 -6
  79. package/esm/lib/tool-executor.js +4 -0
  80. package/esm/lib/tool-orchestrator.d.ts +7 -7
  81. package/esm/lib/tool-orchestrator.js +38 -10
  82. package/esm/lib/tool-types.d.ts +163 -29
  83. package/esm/lib/tool-types.js +6 -0
  84. package/esm/lib/tool.d.ts +99 -0
  85. package/esm/lib/tool.js +71 -0
  86. package/esm/lib/turn-context.d.ts +50 -0
  87. package/esm/lib/turn-context.js +59 -0
  88. package/esm/lib/url.js +1 -0
  89. package/esm/models/activityitem.js +1 -0
  90. package/esm/models/assistantmessage.js +1 -0
  91. package/esm/models/badgatewayresponseerrordata.js +1 -0
  92. package/esm/models/badrequestresponseerrordata.js +1 -0
  93. package/esm/models/chatcompletionfinishreason.js +1 -0
  94. package/esm/models/chaterror.js +1 -0
  95. package/esm/models/chatgenerationparams.js +1 -0
  96. package/esm/models/chatgenerationtokenusage.js +1 -0
  97. package/esm/models/chatmessagecontentitem.js +1 -0
  98. package/esm/models/chatmessagecontentitemaudio.js +1 -0
  99. package/esm/models/chatmessagecontentitemcachecontrol.js +1 -0
  100. package/esm/models/chatmessagecontentitemimage.js +1 -0
  101. package/esm/models/chatmessagecontentitemtext.js +1 -0
  102. package/esm/models/chatmessagecontentitemvideo.js +1 -0
  103. package/esm/models/chatmessagetokenlogprob.js +1 -0
  104. package/esm/models/chatmessagetokenlogprobs.js +1 -0
  105. package/esm/models/chatmessagetoolcall.js +1 -0
  106. package/esm/models/chatresponse.js +1 -0
  107. package/esm/models/chatresponsechoice.js +1 -0
  108. package/esm/models/chatstreamingchoice.js +1 -0
  109. package/esm/models/chatstreamingmessagechunk.js +1 -0
  110. package/esm/models/chatstreamingmessagetoolcall.js +1 -0
  111. package/esm/models/chatstreamingresponsechunk.js +1 -0
  112. package/esm/models/chatstreamoptions.js +1 -0
  113. package/esm/models/claude-message.d.ts +218 -0
  114. package/esm/models/claude-message.js +6 -0
  115. package/esm/models/completionchoice.js +1 -0
  116. package/esm/models/completioncreateparams.js +1 -0
  117. package/esm/models/completionlogprobs.js +1 -0
  118. package/esm/models/completionresponse.js +1 -0
  119. package/esm/models/completionusage.js +1 -0
  120. package/esm/models/createchargerequest.js +1 -0
  121. package/esm/models/datacollection.js +1 -0
  122. package/esm/models/defaultparameters.js +1 -0
  123. package/esm/models/edgenetworktimeoutresponseerrordata.js +1 -0
  124. package/esm/models/endpointstatus.js +1 -0
  125. package/esm/models/errors/badgatewayresponseerror.js +1 -0
  126. package/esm/models/errors/badrequestresponseerror.js +1 -0
  127. package/esm/models/errors/chaterror.js +1 -0
  128. package/esm/models/errors/edgenetworktimeoutresponseerror.js +1 -0
  129. package/esm/models/errors/forbiddenresponseerror.js +1 -0
  130. package/esm/models/errors/httpclienterrors.js +1 -0
  131. package/esm/models/errors/index.js +1 -0
  132. package/esm/models/errors/internalserverresponseerror.js +1 -0
  133. package/esm/models/errors/notfoundresponseerror.js +1 -0
  134. package/esm/models/errors/openrouterdefaulterror.js +1 -0
  135. package/esm/models/errors/openroutererror.js +1 -0
  136. package/esm/models/errors/payloadtoolargeresponseerror.js +1 -0
  137. package/esm/models/errors/paymentrequiredresponseerror.js +1 -0
  138. package/esm/models/errors/provideroverloadedresponseerror.js +1 -0
  139. package/esm/models/errors/requesttimeoutresponseerror.js +1 -0
  140. package/esm/models/errors/responsevalidationerror.js +1 -0
  141. package/esm/models/errors/sdkvalidationerror.js +1 -0
  142. package/esm/models/errors/serviceunavailableresponseerror.js +1 -0
  143. package/esm/models/errors/toomanyrequestsresponseerror.js +1 -0
  144. package/esm/models/errors/unauthorizedresponseerror.js +1 -0
  145. package/esm/models/errors/unprocessableentityresponseerror.js +1 -0
  146. package/esm/models/filecitation.js +1 -0
  147. package/esm/models/filepath.js +1 -0
  148. package/esm/models/forbiddenresponseerrordata.js +1 -0
  149. package/esm/models/imagegenerationstatus.js +1 -0
  150. package/esm/models/index.d.ts +1 -0
  151. package/esm/models/index.js +2 -0
  152. package/esm/models/inputmodality.js +1 -0
  153. package/esm/models/instructtype.js +1 -0
  154. package/esm/models/internalserverresponseerrordata.js +1 -0
  155. package/esm/models/jsonschemaconfig.js +1 -0
  156. package/esm/models/listendpointsresponse.js +1 -0
  157. package/esm/models/message.js +1 -0
  158. package/esm/models/model.js +1 -0
  159. package/esm/models/modelarchitecture.js +1 -0
  160. package/esm/models/modelgroup.js +1 -0
  161. package/esm/models/modelscountresponse.js +1 -0
  162. package/esm/models/modelslistresponse.js +1 -0
  163. package/esm/models/namedtoolchoice.js +1 -0
  164. package/esm/models/notfoundresponseerrordata.js +1 -0
  165. package/esm/models/openairesponsesannotation.js +1 -0
  166. package/esm/models/openairesponsesincludable.js +1 -0
  167. package/esm/models/openairesponsesincompletedetails.js +1 -0
  168. package/esm/models/openairesponsesinputunion.js +1 -0
  169. package/esm/models/openairesponsesprompt.js +1 -0
  170. package/esm/models/openairesponsesreasoningconfig.js +1 -0
  171. package/esm/models/openairesponsesreasoningeffort.js +1 -0
  172. package/esm/models/openairesponsesrefusalcontent.js +1 -0
  173. package/esm/models/openairesponsesresponsestatus.js +1 -0
  174. package/esm/models/openairesponsesservicetier.js +1 -0
  175. package/esm/models/openairesponsestoolchoiceunion.js +1 -0
  176. package/esm/models/openairesponsestruncation.js +1 -0
  177. package/esm/models/openresponseseasyinputmessage.js +1 -0
  178. package/esm/models/openresponseserrorevent.js +1 -0
  179. package/esm/models/openresponsesfunctioncalloutput.js +1 -0
  180. package/esm/models/openresponsesfunctiontoolcall.js +1 -0
  181. package/esm/models/openresponsesimagegencallcompleted.js +1 -0
  182. package/esm/models/openresponsesimagegencallgenerating.js +1 -0
  183. package/esm/models/openresponsesimagegencallinprogress.js +1 -0
  184. package/esm/models/openresponsesimagegencallpartialimage.js +1 -0
  185. package/esm/models/openresponsesinput.js +1 -0
  186. package/esm/models/openresponsesinputmessageitem.js +1 -0
  187. package/esm/models/openresponseslogprobs.js +1 -0
  188. package/esm/models/openresponsesnonstreamingresponse.js +1 -0
  189. package/esm/models/openresponsesreasoning.js +1 -0
  190. package/esm/models/openresponsesreasoningconfig.js +1 -0
  191. package/esm/models/openresponsesreasoningdeltaevent.js +1 -0
  192. package/esm/models/openresponsesreasoningdoneevent.js +1 -0
  193. package/esm/models/openresponsesreasoningsummarypartaddedevent.js +1 -0
  194. package/esm/models/openresponsesreasoningsummarytextdeltaevent.js +1 -0
  195. package/esm/models/openresponsesreasoningsummarytextdoneevent.js +1 -0
  196. package/esm/models/openresponsesrequest.js +1 -0
  197. package/esm/models/openresponsesresponsetext.js +1 -0
  198. package/esm/models/openresponsesstreamevent.js +1 -0
  199. package/esm/models/openresponsestoplogprobs.js +1 -0
  200. package/esm/models/openresponsesusage.js +1 -0
  201. package/esm/models/openresponseswebsearch20250826tool.js +1 -0
  202. package/esm/models/openresponseswebsearchpreview20250311tool.js +1 -0
  203. package/esm/models/openresponseswebsearchpreviewtool.js +1 -0
  204. package/esm/models/openresponseswebsearchtool.js +1 -0
  205. package/esm/models/operations/createauthkeyscode.js +1 -0
  206. package/esm/models/operations/createcoinbasecharge.js +1 -0
  207. package/esm/models/operations/createembeddings.js +1 -0
  208. package/esm/models/operations/createkeys.js +1 -0
  209. package/esm/models/operations/createresponses.js +1 -0
  210. package/esm/models/operations/deletekeys.js +1 -0
  211. package/esm/models/operations/exchangeauthcodeforapikey.js +1 -0
  212. package/esm/models/operations/getcredits.js +1 -0
  213. package/esm/models/operations/getcurrentkey.js +1 -0
  214. package/esm/models/operations/getgeneration.js +1 -0
  215. package/esm/models/operations/getkey.js +1 -0
  216. package/esm/models/operations/getmodels.js +1 -0
  217. package/esm/models/operations/getparameters.js +1 -0
  218. package/esm/models/operations/getuseractivity.js +1 -0
  219. package/esm/models/operations/index.js +1 -0
  220. package/esm/models/operations/list.js +1 -0
  221. package/esm/models/operations/listendpoints.js +1 -0
  222. package/esm/models/operations/listendpointszdr.js +1 -0
  223. package/esm/models/operations/listmodelsuser.js +1 -0
  224. package/esm/models/operations/listproviders.js +1 -0
  225. package/esm/models/operations/sendchatcompletionrequest.js +1 -0
  226. package/esm/models/operations/updatekeys.js +1 -0
  227. package/esm/models/outputitemimagegenerationcall.js +1 -0
  228. package/esm/models/outputmessage.js +1 -0
  229. package/esm/models/outputmodality.js +1 -0
  230. package/esm/models/parameter.js +1 -0
  231. package/esm/models/payloadtoolargeresponseerrordata.js +1 -0
  232. package/esm/models/paymentrequiredresponseerrordata.js +1 -0
  233. package/esm/models/pdfparserengine.js +1 -0
  234. package/esm/models/pdfparseroptions.js +1 -0
  235. package/esm/models/perrequestlimits.js +1 -0
  236. package/esm/models/providername.js +1 -0
  237. package/esm/models/provideroverloadedresponseerrordata.js +1 -0
  238. package/esm/models/providerpreferences.js +1 -0
  239. package/esm/models/providersort.js +1 -0
  240. package/esm/models/providersortconfig.js +1 -0
  241. package/esm/models/providersortunion.js +1 -0
  242. package/esm/models/publicendpoint.js +1 -0
  243. package/esm/models/publicpricing.js +1 -0
  244. package/esm/models/quantization.js +1 -0
  245. package/esm/models/reasoningsummarytext.js +1 -0
  246. package/esm/models/reasoningsummaryverbosity.js +1 -0
  247. package/esm/models/reasoningtextcontent.js +1 -0
  248. package/esm/models/requesttimeoutresponseerrordata.js +1 -0
  249. package/esm/models/responseformatjsonschema.js +1 -0
  250. package/esm/models/responseformattextconfig.js +1 -0
  251. package/esm/models/responseformattextgrammar.js +1 -0
  252. package/esm/models/responseinputaudio.js +1 -0
  253. package/esm/models/responseinputfile.js +1 -0
  254. package/esm/models/responseinputimage.js +1 -0
  255. package/esm/models/responseinputtext.js +1 -0
  256. package/esm/models/responseoutputtext.js +1 -0
  257. package/esm/models/responseserrorfield.js +1 -0
  258. package/esm/models/responsesformatjsonobject.js +1 -0
  259. package/esm/models/responsesformattext.js +1 -0
  260. package/esm/models/responsesformattextjsonschemaconfig.js +1 -0
  261. package/esm/models/responsesimagegenerationcall.js +1 -0
  262. package/esm/models/responsesoutputitem.js +1 -0
  263. package/esm/models/responsesoutputitemfilesearchcall.js +1 -0
  264. package/esm/models/responsesoutputitemfunctioncall.js +1 -0
  265. package/esm/models/responsesoutputitemreasoning.js +1 -0
  266. package/esm/models/responsesoutputmessage.js +1 -0
  267. package/esm/models/responsessearchcontextsize.js +1 -0
  268. package/esm/models/responseswebsearchcalloutput.js +1 -0
  269. package/esm/models/responseswebsearchuserlocation.js +1 -0
  270. package/esm/models/responsetextconfig.js +1 -0
  271. package/esm/models/schema0.js +1 -0
  272. package/esm/models/schema3.js +1 -0
  273. package/esm/models/security.js +1 -0
  274. package/esm/models/serviceunavailableresponseerrordata.js +1 -0
  275. package/esm/models/systemmessage.js +1 -0
  276. package/esm/models/toolcallstatus.js +1 -0
  277. package/esm/models/tooldefinitionjson.js +1 -0
  278. package/esm/models/toolresponsemessage.js +1 -0
  279. package/esm/models/toomanyrequestsresponseerrordata.js +1 -0
  280. package/esm/models/topproviderinfo.js +1 -0
  281. package/esm/models/unauthorizedresponseerrordata.js +1 -0
  282. package/esm/models/unprocessableentityresponseerrordata.js +1 -0
  283. package/esm/models/urlcitation.js +1 -0
  284. package/esm/models/usermessage.js +1 -0
  285. package/esm/models/websearchengine.js +1 -0
  286. package/esm/models/websearchpreviewtooluserlocation.js +1 -0
  287. package/esm/models/websearchstatus.js +1 -0
  288. package/esm/sdk/analytics.js +1 -0
  289. package/esm/sdk/apikeys.js +1 -0
  290. package/esm/sdk/beta.js +1 -0
  291. package/esm/sdk/chat.js +1 -0
  292. package/esm/sdk/completions.js +1 -0
  293. package/esm/sdk/credits.js +1 -0
  294. package/esm/sdk/embeddings.js +1 -0
  295. package/esm/sdk/endpoints.js +1 -0
  296. package/esm/sdk/generations.js +1 -0
  297. package/esm/sdk/index.js +1 -0
  298. package/esm/sdk/models.js +1 -0
  299. package/esm/sdk/oauth.js +1 -0
  300. package/esm/sdk/parameters.js +1 -0
  301. package/esm/sdk/providers.js +1 -0
  302. package/esm/sdk/responses.js +1 -0
  303. package/esm/sdk/sdk.d.ts +4 -10
  304. package/esm/sdk/sdk.js +2 -1
  305. package/esm/types/async.js +1 -0
  306. package/esm/types/blobs.js +1 -0
  307. package/esm/types/constdatetime.js +1 -0
  308. package/esm/types/discriminatedUnion.js +1 -0
  309. package/esm/types/enums.js +1 -0
  310. package/esm/types/fp.js +1 -0
  311. package/esm/types/index.js +1 -0
  312. package/esm/types/operations.js +1 -0
  313. package/esm/types/rfcdate.js +1 -0
  314. package/esm/types/streams.js +1 -0
  315. package/esm/types/unrecognized.js +1 -0
  316. package/jsr.json +1 -1
  317. package/package.json +6 -3
  318. package/esm/funcs/callModel.d.ts +0 -87
  319. package/esm/funcs/callModel.js +0 -215
@@ -0,0 +1,10 @@
1
+ {
2
+ "tab_size": 2,
3
+ "project_name": "@openrouter/sdk",
4
+ "formatter": {
5
+ "language_server": {
6
+ "name": "eslint"
7
+ }
8
+ },
9
+ "language_servers": ["!biome", "..."]
10
+ }
@@ -0,0 +1,53 @@
1
+ [
2
+ {
3
+ "name": "mode",
4
+ "validation_regex": "/^(direct|pr)$/.source",
5
+ "validation_message": "Must be `direct` or `pr`"
6
+ },
7
+ {
8
+ "name": "speakeasy_version",
9
+ "validation_regex": "/^[\\w.\\-]+$/.source",
10
+ "validation_message": "Letters, numbers, or .-_ only"
11
+ },
12
+ {
13
+ "name": "openapi_doc_location",
14
+ "validation_regex": "/^((https?):\\/\\/([\\w\\-]+\\.)+\\w+(\\/.*)?|[\\w.\\-\\/]+)$/i.source",
15
+ "validation_message": "Must be a valid server URL or file path containing letters, numbers, or .-_/ only"
16
+ },
17
+ {
18
+ "name": "openapi_doc_auth_header",
19
+ "validation_regex": "/^[A-Za-z\\-]+$/.source",
20
+ "validation_message": "Letters or - only"
21
+ },
22
+ {
23
+ "name": "create_release"
24
+ },
25
+ {
26
+ "name": "publish_python",
27
+ "language": "python"
28
+ },
29
+ {
30
+ "name": "publish_typescript",
31
+ "language": "typescript"
32
+ },
33
+ {
34
+ "name": "publish_java",
35
+ "language": "java"
36
+ },
37
+ {
38
+ "name": "publish_php",
39
+ "language": "php"
40
+ },
41
+ {
42
+ "name": "publish_ruby",
43
+ "language": "ruby"
44
+ },
45
+ {
46
+ "name": "publish_csharp",
47
+ "language": "csharp"
48
+ },
49
+ {
50
+ "name": "publish_terraform",
51
+ "language": "terraform"
52
+ }
53
+ ]
@@ -0,0 +1,88 @@
1
+ [
2
+ {
3
+ "name": "pypi_token",
4
+ "secret_name": "PYPI_TOKEN",
5
+ "validation_regex": "/^[\\w.\\-]+$/.source",
6
+ "validation_message": "Letters, numbers, or .-_ only",
7
+ "language": "python"
8
+ },
9
+ {
10
+ "name": "npm_token",
11
+ "secret_name": "NPM_TOKEN",
12
+ "validation_regex": "/^[\\w.\\-]+$/.source",
13
+ "validation_message": "Letters, numbers, or .-_ only",
14
+ "language": "typescript"
15
+ },
16
+ {
17
+ "name": "packagist_username",
18
+ "validation_regex": "/^[\\w.\\-]+$/.source",
19
+ "validation_message": "Letters, numbers, or .-_ only",
20
+ "language": "php"
21
+ },
22
+ {
23
+ "name": "packagist_token",
24
+ "validation_regex": "/^[\\w.\\-]+$/.source",
25
+ "validation_message": "Letters, numbers, or .-_ only",
26
+ "language": "php"
27
+ },
28
+ {
29
+ "name": "openapi_doc_auth_token",
30
+ "secret_name": "SPEC_TOKEN",
31
+ "validation_regex": "/^[\\w.\\-]+$/.source",
32
+ "validation_message": "Letters, numbers, or .-_ only"
33
+ },
34
+ {
35
+ "name": "speakeasy_api_key",
36
+ "secret_name": "SPEAKEASY_API_KEY",
37
+ "validation_regex": "/^[\\w.\\-]+$/.source",
38
+ "validation_message": "Letters, numbers, or .-_ only"
39
+ },
40
+ {
41
+ "name": "ossrh_username",
42
+ "secret_name": "MAVEN_USERNAME",
43
+ "validation_regex": "/^[\\w.\\-]+$/.source",
44
+ "validation_message": "Letters, numbers, or .-_ only",
45
+ "language": "java"
46
+ },
47
+ {
48
+ "name": "ossrh_password",
49
+ "secret_name": "MAVEN_PASSWORD",
50
+ "language": "java"
51
+ },
52
+ {
53
+ "name": "java_gpg_secret_key",
54
+ "validation_regex": "/^[\\w.\\-\\t \\r\\n]+$/.source",
55
+ "validation_message": "Letters, numbers, tabs, spaces, newlines, or .-_ only",
56
+ "language": "java"
57
+ },
58
+ {
59
+ "name": "java_gpg_passphrase",
60
+ "language": "java"
61
+ },
62
+ {
63
+ "name": "terraform_gpg_secret_key",
64
+ "secret_name": "TERRAFORM_GPG_SECRET_KEY",
65
+ "validation_regex": "/^[\\w.\\-\\t \\r\\n]+$/.source",
66
+ "validation_message": "Letters, numbers, tabs, spaces, newlines, or .-_ only",
67
+ "language": "terraform"
68
+ },
69
+ {
70
+ "name": "terraform_gpg_passphrase",
71
+ "secret_name": "TERRAFORM_GPG_PASSPHRASE",
72
+ "language": "terraform"
73
+ },
74
+ {
75
+ "name": "rubygems_auth_token",
76
+ "secret_name": "RUBYGEMS_AUTH_TOKEN",
77
+ "language": "ruby"
78
+ },
79
+ {
80
+ "name": "nuget_api_key",
81
+ "secret_name": "NUGET_API_KEY",
82
+ "language": "csharp"
83
+ },
84
+ {
85
+ "name": "slack_webhook_url",
86
+ "secret_name": "SLACK_WEBHOOK_URL"
87
+ }
88
+ ]
package/esm/core.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f431fdbcd144
3
4
  */
4
5
  import { ClientSDK } from "./lib/sdks.js";
5
6
  /**
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 6525bcc66ab5
3
4
  */
4
5
  import { encodeFormQuery } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 133e2c5f487c
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: c151c399f75f
3
4
  */
4
5
  import { encodeSimple } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 12a5c2abbddd
3
4
  */
4
5
  import { encodeSimple } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: d9449cb31931
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 2afc8d8f1ce0
3
4
  */
4
5
  import { encodeFormQuery } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 05700884934b
3
4
  */
4
5
  import { encodeJSON, encodeSimple } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: c5c4ab0c3f76
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -0,0 +1,118 @@
1
+ import type { OpenRouterCore } from '../core.js';
2
+ import type { CallModelInput } from '../lib/async-params.js';
3
+ import type { RequestOptions } from '../lib/sdks.js';
4
+ import type { Tool } from '../lib/tool-types.js';
5
+ import { ModelResult } from '../lib/model-result.js';
6
+ export type { CallModelInput } from '../lib/async-params.js';
7
+ /**
8
+ * Get a response with multiple consumption patterns
9
+ *
10
+ * @remarks
11
+ * Creates a response using the OpenResponses API and returns
12
+ * a wrapper that allows consuming the response in multiple ways:
13
+ *
14
+ * - `await response.getText()` - Get just the text content (tools auto-executed)
15
+ * - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
16
+ * - `for await (const delta of response.getTextStream())` - Stream text deltas
17
+ * - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
18
+ * - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
19
+ * - `for await (const toolCall of response.getToolCallsStream())` - Stream structured tool calls
20
+ * - `await response.getToolCalls()` - Get all tool calls from completed response
21
+ * - `for await (const msg of response.getNewMessagesStream())` - Stream incremental message updates
22
+ * - `for await (const event of response.getFullResponsesStream())` - Stream all events (incl. tool preliminary)
23
+ *
24
+ * All consumption patterns can be used concurrently on the same response.
25
+ *
26
+ * For message format conversion, use the helper functions:
27
+ * - `fromChatMessages()` / `toChatMessage()` for OpenAI chat format
28
+ * - `fromClaudeMessages()` / `toClaudeMessage()` for Anthropic Claude format
29
+ *
30
+ * **Async Function Support:**
31
+ *
32
+ * Any field in CallModelInput can be a function that computes the value dynamically
33
+ * based on the conversation context. You can mix static values and functions in the
34
+ * same request. Functions are resolved before EVERY turn, allowing parameters to
35
+ * adapt as the conversation progresses.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Mix static and dynamic values
40
+ * const result = callModel(client, {
41
+ * model: 'gpt-4', // static
42
+ * temperature: (ctx) => Math.min(ctx.numberOfTurns * 0.2, 1.0), // dynamic
43
+ * input: [{ type: 'text', text: 'Hello' }], // static
44
+ * });
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Switch models based on conversation length
50
+ * const result = callModel(client, {
51
+ * model: (ctx) => ctx.numberOfTurns > 3 ? 'gpt-4' : 'gpt-3.5-turbo',
52
+ * input: [{ type: 'text', text: 'Complex question' }],
53
+ * });
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Use async functions to fetch dynamic values
59
+ * const result = callModel(client, {
60
+ * model: 'gpt-4',
61
+ * instructions: async (ctx) => {
62
+ * const userPrefs = await fetchUserPreferences();
63
+ * return `You are a helpful assistant. User preferences: ${userPrefs}`;
64
+ * },
65
+ * input: [{ type: 'text', text: 'Help me' }],
66
+ * });
67
+ * ```
68
+ *
69
+ * Async functions receive `TurnContext` with:
70
+ * - `numberOfTurns`: Current turn number (0-indexed, 0 = initial request)
71
+ * - `messageHistory`: Current conversation messages
72
+ * - `model`: Current model selection (if set)
73
+ * - `models`: Current models array (if set)
74
+ *
75
+ * **Execution Order:**
76
+ * Functions are resolved at the START of each turn in this order:
77
+ * 1. Async functions (parallel resolution)
78
+ * 2. Tool execution (if tools called by model)
79
+ * 3. nextTurnParams functions (if defined on tools)
80
+ * 4. API request with resolved values
81
+ *
82
+ * **Stop Conditions:**
83
+ *
84
+ * Control when tool execution stops using the `stopWhen` parameter:
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Stop after 3 steps
89
+ * stopWhen: stepCountIs(3)
90
+ *
91
+ * // Stop when a specific tool is called
92
+ * stopWhen: hasToolCall('finalizeResults')
93
+ *
94
+ * // Multiple conditions (OR logic - stops if ANY is true)
95
+ * stopWhen: [
96
+ * stepCountIs(10), // Safety: max 10 steps
97
+ * maxCost(0.50), // Budget: max $0.50
98
+ * hasToolCall('finalize') // Logic: stop when finalize called
99
+ * ]
100
+ *
101
+ * // Custom condition with full step history
102
+ * stopWhen: ({ steps }) => {
103
+ * const totalCalls = steps.reduce((sum, s) => sum + s.toolCalls.length, 0);
104
+ * return totalCalls >= 20; // Stop after 20 total tool calls
105
+ * }
106
+ * ```
107
+ *
108
+ * Available helper functions:
109
+ * - `stepCountIs(n)` - Stop after n steps
110
+ * - `hasToolCall(name)` - Stop when tool is called
111
+ * - `maxTokensUsed(n)` - Stop when token usage exceeds n
112
+ * - `maxCost(n)` - Stop when cost exceeds n dollars
113
+ * - `finishReasonIs(reason)` - Stop on specific finish reason
114
+ *
115
+ * Default: `stepCountIs(5)` if not specified
116
+ */
117
+ export declare function callModel<TTools extends readonly Tool[]>(client: OpenRouterCore, request: CallModelInput<TTools>, options?: RequestOptions): ModelResult<TTools>;
118
+ //# sourceMappingURL=call-model.d.ts.map
@@ -0,0 +1,137 @@
1
+ import { ModelResult } from '../lib/model-result.js';
2
+ import { convertToolsToAPIFormat } from '../lib/tool-executor.js';
3
+ /**
4
+ * Get a response with multiple consumption patterns
5
+ *
6
+ * @remarks
7
+ * Creates a response using the OpenResponses API and returns
8
+ * a wrapper that allows consuming the response in multiple ways:
9
+ *
10
+ * - `await response.getText()` - Get just the text content (tools auto-executed)
11
+ * - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
12
+ * - `for await (const delta of response.getTextStream())` - Stream text deltas
13
+ * - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
14
+ * - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
15
+ * - `for await (const toolCall of response.getToolCallsStream())` - Stream structured tool calls
16
+ * - `await response.getToolCalls()` - Get all tool calls from completed response
17
+ * - `for await (const msg of response.getNewMessagesStream())` - Stream incremental message updates
18
+ * - `for await (const event of response.getFullResponsesStream())` - Stream all events (incl. tool preliminary)
19
+ *
20
+ * All consumption patterns can be used concurrently on the same response.
21
+ *
22
+ * For message format conversion, use the helper functions:
23
+ * - `fromChatMessages()` / `toChatMessage()` for OpenAI chat format
24
+ * - `fromClaudeMessages()` / `toClaudeMessage()` for Anthropic Claude format
25
+ *
26
+ * **Async Function Support:**
27
+ *
28
+ * Any field in CallModelInput can be a function that computes the value dynamically
29
+ * based on the conversation context. You can mix static values and functions in the
30
+ * same request. Functions are resolved before EVERY turn, allowing parameters to
31
+ * adapt as the conversation progresses.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Mix static and dynamic values
36
+ * const result = callModel(client, {
37
+ * model: 'gpt-4', // static
38
+ * temperature: (ctx) => Math.min(ctx.numberOfTurns * 0.2, 1.0), // dynamic
39
+ * input: [{ type: 'text', text: 'Hello' }], // static
40
+ * });
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Switch models based on conversation length
46
+ * const result = callModel(client, {
47
+ * model: (ctx) => ctx.numberOfTurns > 3 ? 'gpt-4' : 'gpt-3.5-turbo',
48
+ * input: [{ type: 'text', text: 'Complex question' }],
49
+ * });
50
+ * ```
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Use async functions to fetch dynamic values
55
+ * const result = callModel(client, {
56
+ * model: 'gpt-4',
57
+ * instructions: async (ctx) => {
58
+ * const userPrefs = await fetchUserPreferences();
59
+ * return `You are a helpful assistant. User preferences: ${userPrefs}`;
60
+ * },
61
+ * input: [{ type: 'text', text: 'Help me' }],
62
+ * });
63
+ * ```
64
+ *
65
+ * Async functions receive `TurnContext` with:
66
+ * - `numberOfTurns`: Current turn number (0-indexed, 0 = initial request)
67
+ * - `messageHistory`: Current conversation messages
68
+ * - `model`: Current model selection (if set)
69
+ * - `models`: Current models array (if set)
70
+ *
71
+ * **Execution Order:**
72
+ * Functions are resolved at the START of each turn in this order:
73
+ * 1. Async functions (parallel resolution)
74
+ * 2. Tool execution (if tools called by model)
75
+ * 3. nextTurnParams functions (if defined on tools)
76
+ * 4. API request with resolved values
77
+ *
78
+ * **Stop Conditions:**
79
+ *
80
+ * Control when tool execution stops using the `stopWhen` parameter:
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Stop after 3 steps
85
+ * stopWhen: stepCountIs(3)
86
+ *
87
+ * // Stop when a specific tool is called
88
+ * stopWhen: hasToolCall('finalizeResults')
89
+ *
90
+ * // Multiple conditions (OR logic - stops if ANY is true)
91
+ * stopWhen: [
92
+ * stepCountIs(10), // Safety: max 10 steps
93
+ * maxCost(0.50), // Budget: max $0.50
94
+ * hasToolCall('finalize') // Logic: stop when finalize called
95
+ * ]
96
+ *
97
+ * // Custom condition with full step history
98
+ * stopWhen: ({ steps }) => {
99
+ * const totalCalls = steps.reduce((sum, s) => sum + s.toolCalls.length, 0);
100
+ * return totalCalls >= 20; // Stop after 20 total tool calls
101
+ * }
102
+ * ```
103
+ *
104
+ * Available helper functions:
105
+ * - `stepCountIs(n)` - Stop after n steps
106
+ * - `hasToolCall(name)` - Stop when tool is called
107
+ * - `maxTokensUsed(n)` - Stop when token usage exceeds n
108
+ * - `maxCost(n)` - Stop when cost exceeds n dollars
109
+ * - `finishReasonIs(reason)` - Stop on specific finish reason
110
+ *
111
+ * Default: `stepCountIs(5)` if not specified
112
+ */
113
+ export function callModel(client, request, options) {
114
+ const { tools, stopWhen, ...apiRequest } = request;
115
+ // Convert tools to API format - no cast needed now that convertToolsToAPIFormat accepts readonly
116
+ const apiTools = tools ? convertToolsToAPIFormat(tools) : undefined;
117
+ // Build the request with converted tools
118
+ // Note: async functions are resolved later in ModelResult.executeToolsIfNeeded()
119
+ // The request can have async fields (functions) or sync fields, and the tools are converted to API format
120
+ const finalRequest = {
121
+ ...apiRequest,
122
+ };
123
+ if (apiTools !== undefined) {
124
+ finalRequest['tools'] = apiTools;
125
+ }
126
+ return new ModelResult({
127
+ client,
128
+ request: finalRequest,
129
+ options: options ?? {},
130
+ // Preserve the exact TTools type instead of widening to Tool[]
131
+ tools: tools,
132
+ ...(stopWhen !== undefined && {
133
+ stopWhen,
134
+ }),
135
+ });
136
+ }
137
+ //# sourceMappingURL=call-model.js.map
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 8c3aa3c963bf
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 54a6e7c9b712
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: e07ee6831da3
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 88fdc1315137
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f6455fcfe2c8
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: dbe9751f8369
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: ea932ec09987
3
4
  */
4
5
  import { encodeSimple } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 4efb7ea3e48f
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: dac2d205a08d
3
4
  */
4
5
  import { encodeFormQuery } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 371adfc67b48
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: deff050b46c5
3
4
  */
4
5
  import { encodeFormQuery } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: db628dd3c179
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 8a79f27722c0
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 3386ec12d934
3
4
  */
4
5
  import { encodeJSON } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 565ce9801e34
3
4
  */
4
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
5
6
  import * as M from "../lib/matchers.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 8ad87e7210ae
3
4
  */
4
5
  import * as M from "../lib/matchers.js";
5
6
  import { compactMap } from "../lib/primitives.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: a2463fc6f69b
3
4
  */
4
5
  import { initHooks } from "./registration.js";
5
6
  export class SDKHooks {
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 5f2dab62b520
3
4
  */
4
5
  export * from "./hooks.js";
5
6
  export * from "./types.js";
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 2a02d86ec24f
3
4
  */
4
5
  export {};
5
6
  //# sourceMappingURL=types.js.map