@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.
- package/.zed/settings.json +10 -0
- package/_speakeasy/.github/action-inputs-config.json +53 -0
- package/_speakeasy/.github/action-security-config.json +88 -0
- package/esm/core.js +1 -0
- package/esm/funcs/analyticsGetUserActivity.js +1 -0
- package/esm/funcs/apiKeysCreate.js +1 -0
- package/esm/funcs/apiKeysDelete.js +1 -0
- package/esm/funcs/apiKeysGet.js +1 -0
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.js +1 -0
- package/esm/funcs/apiKeysList.js +1 -0
- package/esm/funcs/apiKeysUpdate.js +1 -0
- package/esm/funcs/betaResponsesSend.js +1 -0
- package/esm/funcs/call-model.d.ts +118 -0
- package/esm/funcs/call-model.js +137 -0
- package/esm/funcs/chatSend.js +1 -0
- package/esm/funcs/completionsGenerate.js +1 -0
- package/esm/funcs/creditsCreateCoinbaseCharge.js +1 -0
- package/esm/funcs/creditsGetCredits.js +1 -0
- package/esm/funcs/embeddingsGenerate.js +1 -0
- package/esm/funcs/embeddingsListModels.js +1 -0
- package/esm/funcs/endpointsList.js +1 -0
- package/esm/funcs/endpointsListZdrEndpoints.js +1 -0
- package/esm/funcs/generationsGetGeneration.js +1 -0
- package/esm/funcs/modelsCount.js +1 -0
- package/esm/funcs/modelsList.js +1 -0
- package/esm/funcs/modelsListForUser.js +1 -0
- package/esm/funcs/oAuthCreateAuthCode.js +1 -0
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.js +1 -0
- package/esm/funcs/parametersGetParameters.js +1 -0
- package/esm/funcs/providersList.js +1 -0
- package/esm/hooks/hooks.js +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/types.js +1 -0
- package/esm/index.d.ts +20 -5
- package/esm/index.js +21 -4
- package/esm/lib/anthropic-compat.d.ts +50 -0
- package/esm/lib/anthropic-compat.js +223 -0
- package/esm/lib/anthropic-compat.test.d.ts +2 -0
- package/esm/lib/anthropic-compat.test.js +479 -0
- package/esm/lib/async-params.d.ts +53 -0
- package/esm/lib/async-params.js +76 -0
- package/esm/lib/base64.js +1 -0
- package/esm/lib/chat-compat.d.ts +46 -0
- package/esm/lib/chat-compat.js +112 -0
- package/esm/lib/chat-compat.test.d.ts +2 -0
- package/esm/lib/chat-compat.test.js +282 -0
- package/esm/lib/claude-constants.d.ts +22 -0
- package/esm/lib/claude-constants.js +20 -0
- package/esm/lib/claude-type-guards.d.ts +10 -0
- package/esm/lib/claude-type-guards.js +70 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +3 -2
- package/esm/lib/dlv.js +1 -0
- package/esm/lib/encodings.js +1 -0
- package/esm/lib/env.js +1 -0
- package/esm/lib/event-streams.js +1 -0
- package/esm/lib/files.js +1 -0
- package/esm/lib/http.js +1 -0
- package/esm/lib/is-plain-object.js +1 -0
- package/esm/lib/logger.js +1 -0
- package/esm/lib/matchers.js +1 -0
- package/esm/lib/{response-wrapper.d.ts → model-result.d.ts} +29 -43
- package/esm/lib/{response-wrapper.js → model-result.js} +146 -175
- package/esm/lib/next-turn-params.d.ts +30 -0
- package/esm/lib/next-turn-params.js +129 -0
- package/esm/lib/primitives.js +1 -0
- package/esm/lib/retries.js +1 -0
- package/esm/lib/reusable-stream.js +10 -10
- package/esm/lib/schemas.js +1 -0
- package/esm/lib/sdks.js +1 -0
- package/esm/lib/security.js +1 -0
- package/esm/lib/stop-conditions.d.ts +80 -0
- package/esm/lib/stop-conditions.js +104 -0
- package/esm/lib/stream-transformers.d.ts +30 -4
- package/esm/lib/stream-transformers.js +467 -98
- package/esm/lib/stream-type-guards.d.ts +29 -0
- package/esm/lib/stream-type-guards.js +109 -0
- package/esm/lib/tool-executor.d.ts +7 -6
- package/esm/lib/tool-executor.js +4 -0
- package/esm/lib/tool-orchestrator.d.ts +7 -7
- package/esm/lib/tool-orchestrator.js +38 -10
- package/esm/lib/tool-types.d.ts +163 -29
- package/esm/lib/tool-types.js +6 -0
- package/esm/lib/tool.d.ts +99 -0
- package/esm/lib/tool.js +71 -0
- package/esm/lib/turn-context.d.ts +50 -0
- package/esm/lib/turn-context.js +59 -0
- package/esm/lib/url.js +1 -0
- package/esm/models/activityitem.js +1 -0
- package/esm/models/assistantmessage.js +1 -0
- package/esm/models/badgatewayresponseerrordata.js +1 -0
- package/esm/models/badrequestresponseerrordata.js +1 -0
- package/esm/models/chatcompletionfinishreason.js +1 -0
- package/esm/models/chaterror.js +1 -0
- package/esm/models/chatgenerationparams.js +1 -0
- package/esm/models/chatgenerationtokenusage.js +1 -0
- package/esm/models/chatmessagecontentitem.js +1 -0
- package/esm/models/chatmessagecontentitemaudio.js +1 -0
- package/esm/models/chatmessagecontentitemcachecontrol.js +1 -0
- package/esm/models/chatmessagecontentitemimage.js +1 -0
- package/esm/models/chatmessagecontentitemtext.js +1 -0
- package/esm/models/chatmessagecontentitemvideo.js +1 -0
- package/esm/models/chatmessagetokenlogprob.js +1 -0
- package/esm/models/chatmessagetokenlogprobs.js +1 -0
- package/esm/models/chatmessagetoolcall.js +1 -0
- package/esm/models/chatresponse.js +1 -0
- package/esm/models/chatresponsechoice.js +1 -0
- package/esm/models/chatstreamingchoice.js +1 -0
- package/esm/models/chatstreamingmessagechunk.js +1 -0
- package/esm/models/chatstreamingmessagetoolcall.js +1 -0
- package/esm/models/chatstreamingresponsechunk.js +1 -0
- package/esm/models/chatstreamoptions.js +1 -0
- package/esm/models/claude-message.d.ts +218 -0
- package/esm/models/claude-message.js +6 -0
- package/esm/models/completionchoice.js +1 -0
- package/esm/models/completioncreateparams.js +1 -0
- package/esm/models/completionlogprobs.js +1 -0
- package/esm/models/completionresponse.js +1 -0
- package/esm/models/completionusage.js +1 -0
- package/esm/models/createchargerequest.js +1 -0
- package/esm/models/datacollection.js +1 -0
- package/esm/models/defaultparameters.js +1 -0
- package/esm/models/edgenetworktimeoutresponseerrordata.js +1 -0
- package/esm/models/endpointstatus.js +1 -0
- package/esm/models/errors/badgatewayresponseerror.js +1 -0
- package/esm/models/errors/badrequestresponseerror.js +1 -0
- package/esm/models/errors/chaterror.js +1 -0
- package/esm/models/errors/edgenetworktimeoutresponseerror.js +1 -0
- package/esm/models/errors/forbiddenresponseerror.js +1 -0
- package/esm/models/errors/httpclienterrors.js +1 -0
- package/esm/models/errors/index.js +1 -0
- package/esm/models/errors/internalserverresponseerror.js +1 -0
- package/esm/models/errors/notfoundresponseerror.js +1 -0
- package/esm/models/errors/openrouterdefaulterror.js +1 -0
- package/esm/models/errors/openroutererror.js +1 -0
- package/esm/models/errors/payloadtoolargeresponseerror.js +1 -0
- package/esm/models/errors/paymentrequiredresponseerror.js +1 -0
- package/esm/models/errors/provideroverloadedresponseerror.js +1 -0
- package/esm/models/errors/requesttimeoutresponseerror.js +1 -0
- package/esm/models/errors/responsevalidationerror.js +1 -0
- package/esm/models/errors/sdkvalidationerror.js +1 -0
- package/esm/models/errors/serviceunavailableresponseerror.js +1 -0
- package/esm/models/errors/toomanyrequestsresponseerror.js +1 -0
- package/esm/models/errors/unauthorizedresponseerror.js +1 -0
- package/esm/models/errors/unprocessableentityresponseerror.js +1 -0
- package/esm/models/filecitation.js +1 -0
- package/esm/models/filepath.js +1 -0
- package/esm/models/forbiddenresponseerrordata.js +1 -0
- package/esm/models/imagegenerationstatus.js +1 -0
- package/esm/models/index.d.ts +1 -0
- package/esm/models/index.js +2 -0
- package/esm/models/inputmodality.js +1 -0
- package/esm/models/instructtype.js +1 -0
- package/esm/models/internalserverresponseerrordata.js +1 -0
- package/esm/models/jsonschemaconfig.js +1 -0
- package/esm/models/listendpointsresponse.js +1 -0
- package/esm/models/message.js +1 -0
- package/esm/models/model.js +1 -0
- package/esm/models/modelarchitecture.js +1 -0
- package/esm/models/modelgroup.js +1 -0
- package/esm/models/modelscountresponse.js +1 -0
- package/esm/models/modelslistresponse.js +1 -0
- package/esm/models/namedtoolchoice.js +1 -0
- package/esm/models/notfoundresponseerrordata.js +1 -0
- package/esm/models/openairesponsesannotation.js +1 -0
- package/esm/models/openairesponsesincludable.js +1 -0
- package/esm/models/openairesponsesincompletedetails.js +1 -0
- package/esm/models/openairesponsesinputunion.js +1 -0
- package/esm/models/openairesponsesprompt.js +1 -0
- package/esm/models/openairesponsesreasoningconfig.js +1 -0
- package/esm/models/openairesponsesreasoningeffort.js +1 -0
- package/esm/models/openairesponsesrefusalcontent.js +1 -0
- package/esm/models/openairesponsesresponsestatus.js +1 -0
- package/esm/models/openairesponsesservicetier.js +1 -0
- package/esm/models/openairesponsestoolchoiceunion.js +1 -0
- package/esm/models/openairesponsestruncation.js +1 -0
- package/esm/models/openresponseseasyinputmessage.js +1 -0
- package/esm/models/openresponseserrorevent.js +1 -0
- package/esm/models/openresponsesfunctioncalloutput.js +1 -0
- package/esm/models/openresponsesfunctiontoolcall.js +1 -0
- package/esm/models/openresponsesimagegencallcompleted.js +1 -0
- package/esm/models/openresponsesimagegencallgenerating.js +1 -0
- package/esm/models/openresponsesimagegencallinprogress.js +1 -0
- package/esm/models/openresponsesimagegencallpartialimage.js +1 -0
- package/esm/models/openresponsesinput.js +1 -0
- package/esm/models/openresponsesinputmessageitem.js +1 -0
- package/esm/models/openresponseslogprobs.js +1 -0
- package/esm/models/openresponsesnonstreamingresponse.js +1 -0
- package/esm/models/openresponsesreasoning.js +1 -0
- package/esm/models/openresponsesreasoningconfig.js +1 -0
- package/esm/models/openresponsesreasoningdeltaevent.js +1 -0
- package/esm/models/openresponsesreasoningdoneevent.js +1 -0
- package/esm/models/openresponsesreasoningsummarypartaddedevent.js +1 -0
- package/esm/models/openresponsesreasoningsummarytextdeltaevent.js +1 -0
- package/esm/models/openresponsesreasoningsummarytextdoneevent.js +1 -0
- package/esm/models/openresponsesrequest.js +1 -0
- package/esm/models/openresponsesresponsetext.js +1 -0
- package/esm/models/openresponsesstreamevent.js +1 -0
- package/esm/models/openresponsestoplogprobs.js +1 -0
- package/esm/models/openresponsesusage.js +1 -0
- package/esm/models/openresponseswebsearch20250826tool.js +1 -0
- package/esm/models/openresponseswebsearchpreview20250311tool.js +1 -0
- package/esm/models/openresponseswebsearchpreviewtool.js +1 -0
- package/esm/models/openresponseswebsearchtool.js +1 -0
- package/esm/models/operations/createauthkeyscode.js +1 -0
- package/esm/models/operations/createcoinbasecharge.js +1 -0
- package/esm/models/operations/createembeddings.js +1 -0
- package/esm/models/operations/createkeys.js +1 -0
- package/esm/models/operations/createresponses.js +1 -0
- package/esm/models/operations/deletekeys.js +1 -0
- package/esm/models/operations/exchangeauthcodeforapikey.js +1 -0
- package/esm/models/operations/getcredits.js +1 -0
- package/esm/models/operations/getcurrentkey.js +1 -0
- package/esm/models/operations/getgeneration.js +1 -0
- package/esm/models/operations/getkey.js +1 -0
- package/esm/models/operations/getmodels.js +1 -0
- package/esm/models/operations/getparameters.js +1 -0
- package/esm/models/operations/getuseractivity.js +1 -0
- package/esm/models/operations/index.js +1 -0
- package/esm/models/operations/list.js +1 -0
- package/esm/models/operations/listendpoints.js +1 -0
- package/esm/models/operations/listendpointszdr.js +1 -0
- package/esm/models/operations/listmodelsuser.js +1 -0
- package/esm/models/operations/listproviders.js +1 -0
- package/esm/models/operations/sendchatcompletionrequest.js +1 -0
- package/esm/models/operations/updatekeys.js +1 -0
- package/esm/models/outputitemimagegenerationcall.js +1 -0
- package/esm/models/outputmessage.js +1 -0
- package/esm/models/outputmodality.js +1 -0
- package/esm/models/parameter.js +1 -0
- package/esm/models/payloadtoolargeresponseerrordata.js +1 -0
- package/esm/models/paymentrequiredresponseerrordata.js +1 -0
- package/esm/models/pdfparserengine.js +1 -0
- package/esm/models/pdfparseroptions.js +1 -0
- package/esm/models/perrequestlimits.js +1 -0
- package/esm/models/providername.js +1 -0
- package/esm/models/provideroverloadedresponseerrordata.js +1 -0
- package/esm/models/providerpreferences.js +1 -0
- package/esm/models/providersort.js +1 -0
- package/esm/models/providersortconfig.js +1 -0
- package/esm/models/providersortunion.js +1 -0
- package/esm/models/publicendpoint.js +1 -0
- package/esm/models/publicpricing.js +1 -0
- package/esm/models/quantization.js +1 -0
- package/esm/models/reasoningsummarytext.js +1 -0
- package/esm/models/reasoningsummaryverbosity.js +1 -0
- package/esm/models/reasoningtextcontent.js +1 -0
- package/esm/models/requesttimeoutresponseerrordata.js +1 -0
- package/esm/models/responseformatjsonschema.js +1 -0
- package/esm/models/responseformattextconfig.js +1 -0
- package/esm/models/responseformattextgrammar.js +1 -0
- package/esm/models/responseinputaudio.js +1 -0
- package/esm/models/responseinputfile.js +1 -0
- package/esm/models/responseinputimage.js +1 -0
- package/esm/models/responseinputtext.js +1 -0
- package/esm/models/responseoutputtext.js +1 -0
- package/esm/models/responseserrorfield.js +1 -0
- package/esm/models/responsesformatjsonobject.js +1 -0
- package/esm/models/responsesformattext.js +1 -0
- package/esm/models/responsesformattextjsonschemaconfig.js +1 -0
- package/esm/models/responsesimagegenerationcall.js +1 -0
- package/esm/models/responsesoutputitem.js +1 -0
- package/esm/models/responsesoutputitemfilesearchcall.js +1 -0
- package/esm/models/responsesoutputitemfunctioncall.js +1 -0
- package/esm/models/responsesoutputitemreasoning.js +1 -0
- package/esm/models/responsesoutputmessage.js +1 -0
- package/esm/models/responsessearchcontextsize.js +1 -0
- package/esm/models/responseswebsearchcalloutput.js +1 -0
- package/esm/models/responseswebsearchuserlocation.js +1 -0
- package/esm/models/responsetextconfig.js +1 -0
- package/esm/models/schema0.js +1 -0
- package/esm/models/schema3.js +1 -0
- package/esm/models/security.js +1 -0
- package/esm/models/serviceunavailableresponseerrordata.js +1 -0
- package/esm/models/systemmessage.js +1 -0
- package/esm/models/toolcallstatus.js +1 -0
- package/esm/models/tooldefinitionjson.js +1 -0
- package/esm/models/toolresponsemessage.js +1 -0
- package/esm/models/toomanyrequestsresponseerrordata.js +1 -0
- package/esm/models/topproviderinfo.js +1 -0
- package/esm/models/unauthorizedresponseerrordata.js +1 -0
- package/esm/models/unprocessableentityresponseerrordata.js +1 -0
- package/esm/models/urlcitation.js +1 -0
- package/esm/models/usermessage.js +1 -0
- package/esm/models/websearchengine.js +1 -0
- package/esm/models/websearchpreviewtooluserlocation.js +1 -0
- package/esm/models/websearchstatus.js +1 -0
- package/esm/sdk/analytics.js +1 -0
- package/esm/sdk/apikeys.js +1 -0
- package/esm/sdk/beta.js +1 -0
- package/esm/sdk/chat.js +1 -0
- package/esm/sdk/completions.js +1 -0
- package/esm/sdk/credits.js +1 -0
- package/esm/sdk/embeddings.js +1 -0
- package/esm/sdk/endpoints.js +1 -0
- package/esm/sdk/generations.js +1 -0
- package/esm/sdk/index.js +1 -0
- package/esm/sdk/models.js +1 -0
- package/esm/sdk/oauth.js +1 -0
- package/esm/sdk/parameters.js +1 -0
- package/esm/sdk/providers.js +1 -0
- package/esm/sdk/responses.js +1 -0
- package/esm/sdk/sdk.d.ts +4 -10
- package/esm/sdk/sdk.js +2 -1
- package/esm/types/async.js +1 -0
- package/esm/types/blobs.js +1 -0
- package/esm/types/constdatetime.js +1 -0
- package/esm/types/discriminatedUnion.js +1 -0
- package/esm/types/enums.js +1 -0
- package/esm/types/fp.js +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/operations.js +1 -0
- package/esm/types/rfcdate.js +1 -0
- package/esm/types/streams.js +1 -0
- package/esm/types/unrecognized.js +1 -0
- package/jsr.json +1 -1
- package/package.json +6 -3
- package/esm/funcs/callModel.d.ts +0 -87
- package/esm/funcs/callModel.js +0 -215
|
@@ -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
package/esm/funcs/apiKeysGet.js
CHANGED
package/esm/funcs/apiKeysList.js
CHANGED
|
@@ -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
|
package/esm/funcs/chatSend.js
CHANGED
package/esm/funcs/modelsCount.js
CHANGED
package/esm/funcs/modelsList.js
CHANGED
package/esm/hooks/hooks.js
CHANGED
package/esm/hooks/index.js
CHANGED