@openrouter/sdk 0.12.79 → 0.13.7
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/README.md +40 -0
- package/esm/funcs/betaAnalyticsGetAnalyticsMeta.d.ts +18 -0
- package/esm/funcs/betaAnalyticsGetAnalyticsMeta.js +96 -0
- package/esm/funcs/betaAnalyticsQueryAnalytics.d.ts +18 -0
- package/esm/funcs/betaAnalyticsQueryAnalytics.js +97 -0
- package/esm/funcs/betaResponsesSend.js +1 -1
- package/esm/funcs/chatSend.js +1 -1
- package/esm/funcs/datasetsGetAppRankings.d.ts +43 -0
- package/esm/funcs/datasetsGetAppRankings.js +161 -0
- package/esm/funcs/datasetsGetBenchmarksArtificialAnalysis.d.ts +19 -0
- package/esm/funcs/datasetsGetBenchmarksArtificialAnalysis.js +102 -0
- package/esm/funcs/datasetsGetBenchmarksDesignArena.d.ts +19 -0
- package/esm/funcs/datasetsGetBenchmarksDesignArena.js +104 -0
- package/esm/funcs/filesDelete.d.ts +19 -0
- package/esm/funcs/filesDelete.js +107 -0
- package/esm/funcs/filesDownload.d.ts +18 -0
- package/esm/funcs/filesDownload.js +107 -0
- package/esm/funcs/filesList.d.ts +21 -0
- package/esm/funcs/filesList.js +131 -0
- package/esm/funcs/filesRetrieve.d.ts +19 -0
- package/esm/funcs/filesRetrieve.js +107 -0
- package/esm/funcs/filesUpload.d.ts +19 -0
- package/esm/funcs/filesUpload.js +121 -0
- package/esm/funcs/modelsGet.d.ts +19 -0
- package/esm/funcs/modelsGet.js +107 -0
- package/esm/funcs/modelsList.js +12 -0
- package/esm/funcs/oAuthCreateAuthCode.d.ts +1 -1
- package/esm/funcs/oAuthCreateAuthCode.js +1 -1
- package/esm/funcs/presetsGet.d.ts +21 -0
- package/esm/funcs/presetsGet.js +105 -0
- package/esm/funcs/presetsGetVersion.d.ts +21 -0
- package/esm/funcs/presetsGetVersion.js +109 -0
- package/esm/funcs/presetsList.d.ts +23 -0
- package/esm/funcs/presetsList.js +136 -0
- package/esm/funcs/presetsListVersions.d.ts +23 -0
- package/esm/funcs/presetsListVersions.js +142 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/aabenchmarkentry.d.ts +24 -0
- package/esm/models/aabenchmarkentry.js +23 -0
- package/esm/models/advisornestedtool.d.ts +25 -0
- package/esm/models/advisornestedtool.js +23 -0
- package/esm/models/advisorreasoning.d.ts +41 -0
- package/esm/models/advisorreasoning.js +33 -0
- package/esm/models/advisorservertoolconfig.d.ts +65 -0
- package/esm/models/advisorservertoolconfig.js +31 -0
- package/esm/models/advisorservertoolopenrouter.d.ts +28 -0
- package/esm/models/advisorservertoolopenrouter.js +20 -0
- package/esm/models/apprankingsitem.d.ts +29 -0
- package/esm/models/apprankingsitem.js +26 -0
- package/esm/models/apprankingsresponse.d.ts +16 -0
- package/esm/models/apprankingsresponse.js +17 -0
- package/esm/models/bashservertool.d.ts +28 -0
- package/esm/models/bashservertool.js +20 -0
- package/esm/models/bashservertoolconfig.d.ts +30 -0
- package/esm/models/bashservertoolconfig.js +22 -0
- package/esm/models/bashservertoolengine.d.ts +17 -0
- package/esm/models/bashservertoolengine.js +16 -0
- package/esm/models/bashservertoolenvironment.d.ts +13 -0
- package/esm/models/bashservertoolenvironment.js +16 -0
- package/esm/models/benchmarkpricing.d.ts +20 -0
- package/esm/models/benchmarkpricing.js +15 -0
- package/esm/models/benchmarksaaitem.d.ts +34 -0
- package/esm/models/benchmarksaaitem.js +29 -0
- package/esm/models/benchmarksaameta.d.ts +70 -0
- package/esm/models/benchmarksaameta.js +50 -0
- package/esm/models/benchmarksaaresponse.d.ts +13 -0
- package/esm/models/benchmarksaaresponse.js +17 -0
- package/esm/models/benchmarksdaitem.d.ts +59 -0
- package/esm/models/benchmarksdaitem.js +50 -0
- package/esm/models/benchmarksdameta.d.ts +98 -0
- package/esm/models/benchmarksdameta.js +62 -0
- package/esm/models/benchmarksdaresponse.d.ts +13 -0
- package/esm/models/benchmarksdaresponse.js +17 -0
- package/esm/models/byokproviderslug.d.ts +2 -1
- package/esm/models/byokproviderslug.js +2 -1
- package/esm/models/chatfunctiontool.d.ts +5 -2
- package/esm/models/chatfunctiontool.js +6 -0
- package/esm/models/chatrequest.d.ts +42 -0
- package/esm/models/chatrequest.js +24 -0
- package/esm/models/chatwebsearchshorthand.d.ts +10 -5
- package/esm/models/chatwebsearchshorthand.js +2 -0
- package/esm/models/containerautoenvironment.d.ts +15 -0
- package/esm/models/containerautoenvironment.js +13 -0
- package/esm/models/containerreferenceenvironment.d.ts +20 -0
- package/esm/models/containerreferenceenvironment.js +19 -0
- package/esm/models/contentfilterbuiltinentry.d.ts +5 -0
- package/esm/models/contentfilterbuiltinentry.js +7 -0
- package/esm/models/contentfilterbuiltinentryinput.d.ts +6 -0
- package/esm/models/contentfilterbuiltinentryinput.js +7 -0
- package/esm/models/contentpartaudio.d.ts +24 -0
- package/esm/models/contentpartaudio.js +27 -0
- package/esm/models/contentpartimage.d.ts +2 -9
- package/esm/models/contentpartimage.js +1 -6
- package/esm/models/contentpartvideo.d.ts +24 -0
- package/esm/models/contentpartvideo.js +27 -0
- package/esm/models/createobservabilitydestinationrequest.d.ts +1 -1
- package/esm/models/dabenchmarkentry.d.ts +32 -0
- package/esm/models/dabenchmarkentry.js +23 -0
- package/esm/models/filedeleteresponse.d.ts +21 -0
- package/esm/models/filedeleteresponse.js +20 -0
- package/esm/models/filelistresponse.d.ts +21 -0
- package/esm/models/filelistresponse.js +26 -0
- package/esm/models/filemetadata.d.ts +26 -0
- package/esm/models/filemetadata.js +33 -0
- package/esm/models/fusionanalysisresult.d.ts +88 -0
- package/esm/models/fusionanalysisresult.js +109 -0
- package/esm/models/fusioncallanalysiscompletedevent.d.ts +21 -0
- package/esm/models/fusioncallanalysiscompletedevent.js +26 -0
- package/esm/models/fusioncallanalysisinprogressevent.d.ts +17 -0
- package/esm/models/fusioncallanalysisinprogressevent.js +26 -0
- package/esm/models/fusioncallcompletedevent.d.ts +16 -0
- package/esm/models/fusioncallcompletedevent.js +24 -0
- package/esm/models/fusioncallinprogressevent.d.ts +16 -0
- package/esm/models/fusioncallinprogressevent.js +24 -0
- package/esm/models/fusioncallpaneladdedevent.d.ts +17 -0
- package/esm/models/fusioncallpaneladdedevent.js +25 -0
- package/esm/models/fusioncallpanelcompletedevent.d.ts +18 -0
- package/esm/models/fusioncallpanelcompletedevent.js +26 -0
- package/esm/models/fusioncallpaneldeltaevent.d.ts +18 -0
- package/esm/models/fusioncallpaneldeltaevent.js +26 -0
- package/esm/models/fusioncallpanelfailedevent.d.ts +19 -0
- package/esm/models/fusioncallpanelfailedevent.js +28 -0
- package/esm/models/fusioncallpanelreasoningdeltaevent.d.ts +18 -0
- package/esm/models/fusioncallpanelreasoningdeltaevent.js +26 -0
- package/esm/models/fusionplugin.d.ts +46 -0
- package/esm/models/fusionplugin.js +20 -0
- package/esm/models/fusionservertoolconfig.d.ts +27 -0
- package/esm/models/fusionservertoolconfig.js +10 -0
- package/esm/models/generationresponse.d.ts +22 -0
- package/esm/models/generationresponse.js +14 -0
- package/esm/models/getpresetresponse.d.ts +17 -0
- package/esm/models/getpresetresponse.js +15 -0
- package/esm/models/getpresetversionresponse.d.ts +17 -0
- package/esm/models/getpresetversionresponse.js +15 -0
- package/esm/models/index.d.ts +60 -0
- package/esm/models/index.js +60 -0
- package/esm/models/inputreference.d.ts +14 -0
- package/esm/models/inputreference.js +18 -0
- package/esm/models/inputsunion.d.ts +7 -4
- package/esm/models/inputsunion.js +11 -2
- package/esm/models/legacywebsearchservertool.d.ts +2 -2
- package/esm/models/listpresetsresponse.d.ts +15 -0
- package/esm/models/listpresetsresponse.js +21 -0
- package/esm/models/listpresetversionsresponse.d.ts +15 -0
- package/esm/models/listpresetversionsresponse.js +21 -0
- package/esm/models/messagesfallbackparam.d.ts +19 -0
- package/esm/models/messagesfallbackparam.js +22 -0
- package/esm/models/messagesrequest.d.ts +11 -4
- package/esm/models/messagesrequest.js +6 -0
- package/esm/models/model.d.ts +5 -0
- package/esm/models/model.js +2 -0
- package/esm/models/modelbenchmarks.d.ts +22 -0
- package/esm/models/modelbenchmarks.js +23 -0
- package/esm/models/modelresponse.d.ts +17 -0
- package/esm/models/modelresponse.js +16 -0
- package/esm/models/observabilityarizedestination.d.ts +1 -1
- package/esm/models/observabilitybraintrustdestination.d.ts +1 -1
- package/esm/models/observabilityclickhousedestination.d.ts +1 -1
- package/esm/models/observabilitydatadogdestination.d.ts +1 -1
- package/esm/models/observabilitygrafanadestination.d.ts +1 -1
- package/esm/models/observabilitylangfusedestination.d.ts +1 -1
- package/esm/models/observabilitylangsmithdestination.d.ts +1 -1
- package/esm/models/observabilitynewrelicdestination.d.ts +1 -1
- package/esm/models/observabilityopikdestination.d.ts +1 -1
- package/esm/models/observabilityotelcollectordestination.d.ts +1 -1
- package/esm/models/observabilityposthogdestination.d.ts +1 -1
- package/esm/models/observabilityrampdestination.d.ts +1 -1
- package/esm/models/observabilitys3destination.d.ts +1 -1
- package/esm/models/observabilitysentrydestination.d.ts +1 -1
- package/esm/models/observabilitysnowflakedestination.d.ts +1 -1
- package/esm/models/observabilityweavedestination.d.ts +1 -1
- package/esm/models/observabilitywebhookdestination.d.ts +1 -1
- package/esm/models/operations/createauthkeyscode.d.ts +6 -1
- package/esm/models/operations/createauthkeyscode.js +2 -0
- package/esm/models/operations/creatererank.d.ts +44 -10
- package/esm/models/operations/creatererank.js +21 -6
- package/esm/models/operations/createresponses.d.ts +3 -3
- package/esm/models/operations/createresponses.js +2 -3
- package/esm/models/operations/deletefile.d.ts +60 -0
- package/esm/models/operations/deletefile.js +24 -0
- package/esm/models/operations/downloadfilecontent.d.ts +60 -0
- package/esm/models/operations/downloadfilecontent.js +24 -0
- package/esm/models/operations/getanalyticsmeta.d.ts +198 -0
- package/esm/models/operations/getanalyticsmeta.js +141 -0
- package/esm/models/operations/getapprankings.d.ts +152 -0
- package/esm/models/operations/getapprankings.js +85 -0
- package/esm/models/operations/getbenchmarksartificialanalysis.d.ts +58 -0
- package/esm/models/operations/getbenchmarksartificialanalysis.js +22 -0
- package/esm/models/operations/getbenchmarksdesignarena.d.ts +83 -0
- package/esm/models/operations/getbenchmarksdesignarena.js +36 -0
- package/esm/models/operations/getfilemetadata.d.ts +60 -0
- package/esm/models/operations/getfilemetadata.js +24 -0
- package/esm/models/operations/getmodel.d.ts +63 -0
- package/esm/models/operations/getmodel.js +22 -0
- package/esm/models/operations/getmodels.d.ts +121 -5
- package/esm/models/operations/getmodels.js +59 -4
- package/esm/models/operations/getpreset.d.ts +58 -0
- package/esm/models/operations/getpreset.js +21 -0
- package/esm/models/operations/getpresetversion.d.ts +63 -0
- package/esm/models/operations/getpresetversion.js +22 -0
- package/esm/models/operations/index.d.ts +15 -0
- package/esm/models/operations/index.js +15 -0
- package/esm/models/operations/listbyokkeys.d.ts +2 -1
- package/esm/models/operations/listbyokkeys.js +2 -1
- package/esm/models/operations/listfiles.d.ts +77 -0
- package/esm/models/operations/listfiles.js +37 -0
- package/esm/models/operations/listpresets.d.ts +72 -0
- package/esm/models/operations/listpresets.js +35 -0
- package/esm/models/operations/listpresetversions.d.ts +77 -0
- package/esm/models/operations/listpresetversions.js +36 -0
- package/esm/models/operations/queryanalytics.d.ts +195 -0
- package/esm/models/operations/queryanalytics.js +129 -0
- package/esm/models/operations/sendchatcompletionrequest.d.ts +3 -3
- package/esm/models/operations/sendchatcompletionrequest.js +2 -3
- package/esm/models/operations/uploadfile.d.ts +82 -0
- package/esm/models/operations/uploadfile.js +45 -0
- package/esm/models/outputadvisorservertoolitem.d.ts +59 -0
- package/esm/models/outputadvisorservertoolitem.js +52 -0
- package/esm/models/outputfusionservertoolitem.d.ts +44 -43
- package/esm/models/outputfusionservertoolitem.js +49 -51
- package/esm/models/outputitems.d.ts +13 -3
- package/esm/models/outputitems.js +9 -1
- package/esm/models/outputshellcallitem.d.ts +29 -0
- package/esm/models/outputshellcallitem.js +38 -0
- package/esm/models/outputshellcalloutputitem.d.ts +48 -0
- package/esm/models/outputshellcalloutputitem.js +67 -0
- package/esm/models/outputsubagentservertoolitem.d.ts +59 -0
- package/esm/models/outputsubagentservertoolitem.js +54 -0
- package/esm/models/outputwebsearchcallitem.d.ts +2 -2
- package/esm/models/outputwebsearchcallitem.js +2 -2
- package/esm/models/preset.d.ts +27 -0
- package/esm/models/preset.js +35 -0
- package/esm/models/presetstatus.d.ts +17 -0
- package/esm/models/presetstatus.js +16 -0
- package/esm/models/presetwithdesignatedversion.d.ts +9 -14
- package/esm/models/presetwithdesignatedversion.js +4 -11
- package/esm/models/preview20250311websearchservertool.d.ts +2 -2
- package/esm/models/previewwebsearchservertool.d.ts +2 -2
- package/esm/models/promptinjectionscanscope.d.ts +18 -0
- package/esm/models/promptinjectionscanscope.js +17 -0
- package/esm/models/providername.d.ts +2 -1
- package/esm/models/providername.js +2 -1
- package/esm/models/provideroptions.d.ts +12 -0
- package/esm/models/provideroptions.js +2 -0
- package/esm/models/providerresponse.d.ts +3 -1
- package/esm/models/providerresponse.js +4 -2
- package/esm/models/rankingsdailymeta.d.ts +4 -4
- package/esm/models/rankingsdailymeta.js +3 -3
- package/esm/models/responsesrequest.d.ts +36 -8
- package/esm/models/responsesrequest.js +12 -0
- package/esm/models/searchqualitylevel.d.ts +2 -2
- package/esm/models/searchqualitylevel.js +1 -1
- package/esm/models/shellcallstatus.d.ts +17 -0
- package/esm/models/shellcallstatus.js +16 -0
- package/esm/models/shellservertoolconfig.d.ts +30 -0
- package/esm/models/shellservertoolconfig.js +22 -0
- package/esm/models/shellservertoolengine.d.ts +16 -0
- package/esm/models/shellservertoolengine.js +15 -0
- package/esm/models/shellservertoolenvironment.d.ts +13 -0
- package/esm/models/shellservertoolenvironment.js +16 -0
- package/esm/models/shellservertoolopenrouter.d.ts +21 -0
- package/esm/models/shellservertoolopenrouter.js +15 -0
- package/esm/models/streamevents.d.ts +10 -1
- package/esm/models/streamevents.js +18 -0
- package/esm/models/subagentnestedtool.d.ts +25 -0
- package/esm/models/subagentnestedtool.js +23 -0
- package/esm/models/subagentreasoning.d.ts +41 -0
- package/esm/models/subagentreasoning.js +33 -0
- package/esm/models/subagentservertoolconfig.d.ts +50 -0
- package/esm/models/subagentservertoolconfig.js +27 -0
- package/esm/models/subagentservertoolopenrouter.d.ts +28 -0
- package/esm/models/subagentservertoolopenrouter.js +20 -0
- package/esm/models/updateobservabilitydestinationrequest.d.ts +1 -1
- package/esm/models/urlcitation.d.ts +2 -0
- package/esm/models/urlcitation.js +2 -0
- package/esm/models/videogenerationrequest.d.ts +16 -4
- package/esm/models/videogenerationrequest.js +4 -2
- package/esm/models/websearchconfig.d.ts +10 -5
- package/esm/models/websearchconfig.js +2 -0
- package/esm/models/websearchengine.d.ts +1 -0
- package/esm/models/websearchengine.js +1 -0
- package/esm/models/websearchengineenum.d.ts +4 -3
- package/esm/models/websearchengineenum.js +3 -2
- package/esm/models/websearchservertool.d.ts +2 -2
- package/esm/models/websearchservertoolconfig.d.ts +10 -5
- package/esm/models/websearchservertoolconfig.js +2 -0
- package/esm/sdk/beta.d.ts +3 -0
- package/esm/sdk/beta.js +4 -0
- package/esm/sdk/betaanalytics.d.ts +19 -0
- package/esm/sdk/betaanalytics.js +29 -0
- package/esm/sdk/datasets.d.ts +46 -0
- package/esm/sdk/datasets.js +53 -0
- package/esm/sdk/files.d.ts +44 -0
- package/esm/sdk/files.js +60 -0
- package/esm/sdk/models.d.ts +7 -0
- package/esm/sdk/models.js +10 -0
- package/esm/sdk/presets.d.ts +33 -0
- package/esm/sdk/presets.js +41 -0
- package/esm/sdk/sdk.d.ts +5 -2
- package/esm/sdk/sdk.js +7 -3
- package/jsr.json +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 9dba8b973eea
|
|
4
|
+
*/
|
|
5
|
+
import { appendForm, encodeFormQuery, encodeSimple, normalizeBlob, } from "../lib/encodings.js";
|
|
6
|
+
import { bytesToBlob, getContentTypeFromFileName, readableStreamToArrayBuffer, } from "../lib/files.js";
|
|
7
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as errors from "../models/errors/index.js";
|
|
14
|
+
import * as models from "../models/index.js";
|
|
15
|
+
import * as operations from "../models/operations/index.js";
|
|
16
|
+
import { APIPromise } from "../types/async.js";
|
|
17
|
+
import { isBlobLike } from "../types/blobs.js";
|
|
18
|
+
import { isReadableStream } from "../types/streams.js";
|
|
19
|
+
/**
|
|
20
|
+
* Upload a file
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Uploads a file to be referenced in future API calls. The file is stored under the workspace of the authenticating API key. Maximum file size: 100 MB.
|
|
24
|
+
*/
|
|
25
|
+
export function filesUpload(client, request, options) {
|
|
26
|
+
return new APIPromise($do(client, request, options));
|
|
27
|
+
}
|
|
28
|
+
async function $do(client, request, options) {
|
|
29
|
+
const parsed = safeParse(request, (value) => operations.UploadFileRequest$outboundSchema.parse(value), "Input validation failed");
|
|
30
|
+
if (!parsed.ok) {
|
|
31
|
+
return [parsed, { status: "invalid" }];
|
|
32
|
+
}
|
|
33
|
+
const payload = parsed.value;
|
|
34
|
+
const body = new FormData();
|
|
35
|
+
if (isBlobLike(payload.RequestBody.file)) {
|
|
36
|
+
const file = payload.RequestBody.file;
|
|
37
|
+
const blob = await normalizeBlob(file);
|
|
38
|
+
const name = "name" in file ? file.name : undefined;
|
|
39
|
+
appendForm(body, "file", blob, name);
|
|
40
|
+
}
|
|
41
|
+
else if (isReadableStream(payload.RequestBody.file.content)) {
|
|
42
|
+
const buffer = await readableStreamToArrayBuffer(payload.RequestBody.file.content);
|
|
43
|
+
const contentType = getContentTypeFromFileName(payload.RequestBody.file.fileName)
|
|
44
|
+
|| "application/octet-stream";
|
|
45
|
+
appendForm(body, "file", bytesToBlob(buffer, contentType), payload.RequestBody.file.fileName);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const contentType = getContentTypeFromFileName(payload.RequestBody.file.fileName)
|
|
49
|
+
|| "application/octet-stream";
|
|
50
|
+
appendForm(body, "file", bytesToBlob(payload.RequestBody.file.content, contentType), payload.RequestBody.file.fileName);
|
|
51
|
+
}
|
|
52
|
+
const path = pathToFunc("/files")();
|
|
53
|
+
const query = encodeFormQuery({
|
|
54
|
+
"workspace_id": payload.workspace_id,
|
|
55
|
+
});
|
|
56
|
+
const headers = new Headers(compactMap({
|
|
57
|
+
Accept: "application/json",
|
|
58
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
59
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
60
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
61
|
+
}));
|
|
62
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
63
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
64
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
65
|
+
const context = {
|
|
66
|
+
options: client._options,
|
|
67
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
68
|
+
operationID: "uploadFile",
|
|
69
|
+
oAuth2Scopes: null,
|
|
70
|
+
resolvedSecurity: requestSecurity,
|
|
71
|
+
securitySource: client._options.apiKey,
|
|
72
|
+
retryConfig: options?.retries
|
|
73
|
+
|| client._options.retryConfig
|
|
74
|
+
|| {
|
|
75
|
+
strategy: "backoff",
|
|
76
|
+
backoff: {
|
|
77
|
+
initialInterval: 500,
|
|
78
|
+
maxInterval: 60000,
|
|
79
|
+
exponent: 1.5,
|
|
80
|
+
maxElapsedTime: 3600000,
|
|
81
|
+
},
|
|
82
|
+
retryConnectionErrors: true,
|
|
83
|
+
}
|
|
84
|
+
|| { strategy: "none" },
|
|
85
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
86
|
+
};
|
|
87
|
+
const requestRes = client._createRequest(context, {
|
|
88
|
+
security: requestSecurity,
|
|
89
|
+
method: "POST",
|
|
90
|
+
baseURL: options?.serverURL,
|
|
91
|
+
path: path,
|
|
92
|
+
headers: headers,
|
|
93
|
+
query: query,
|
|
94
|
+
body: body,
|
|
95
|
+
userAgent: client._options.userAgent,
|
|
96
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
97
|
+
}, options);
|
|
98
|
+
if (!requestRes.ok) {
|
|
99
|
+
return [requestRes, { status: "invalid" }];
|
|
100
|
+
}
|
|
101
|
+
const req = requestRes.value;
|
|
102
|
+
const doResult = await client._do(req, {
|
|
103
|
+
context,
|
|
104
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
105
|
+
retryConfig: context.retryConfig,
|
|
106
|
+
retryCodes: context.retryCodes,
|
|
107
|
+
});
|
|
108
|
+
if (!doResult.ok) {
|
|
109
|
+
return [doResult, { status: "request-error", request: req }];
|
|
110
|
+
}
|
|
111
|
+
const response = doResult.value;
|
|
112
|
+
const responseFields = {
|
|
113
|
+
HttpMeta: { Response: response, Request: req },
|
|
114
|
+
};
|
|
115
|
+
const [result] = await M.match(M.json(200, models.FileMetadata$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(413, errors.PayloadTooLargeResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
116
|
+
if (!result.ok) {
|
|
117
|
+
return [result, { status: "complete", request: req, response }];
|
|
118
|
+
}
|
|
119
|
+
return [result, { status: "complete", request: req, response }];
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=filesUpload.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OpenRouterCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { OpenRouterError } from "../models/errors/openroutererror.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import * as models from "../models/index.js";
|
|
9
|
+
import * as operations from "../models/operations/index.js";
|
|
10
|
+
import { APIPromise } from "../types/async.js";
|
|
11
|
+
import { Result } from "../types/fp.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get a model by its slug
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Returns full details for a single model identified by its author and slug (e.g. openai/gpt-4). Supports variant suffixes (e.g. openai/gpt-4:free) and resolves known slug aliases.
|
|
17
|
+
*/
|
|
18
|
+
export declare function modelsGet(client: OpenRouterCore, request: operations.GetModelRequest, options?: RequestOptions): APIPromise<Result<models.ModelResponse, errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=modelsGet.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 2318e9c140df
|
|
4
|
+
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
14
|
+
import * as operations from "../models/operations/index.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Get a model by its slug
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Returns full details for a single model identified by its author and slug (e.g. openai/gpt-4). Supports variant suffixes (e.g. openai/gpt-4:free) and resolves known slug aliases.
|
|
21
|
+
*/
|
|
22
|
+
export function modelsGet(client, request, options) {
|
|
23
|
+
return new APIPromise($do(client, request, options));
|
|
24
|
+
}
|
|
25
|
+
async function $do(client, request, options) {
|
|
26
|
+
const parsed = safeParse(request, (value) => operations.GetModelRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = null;
|
|
32
|
+
const pathParams = {
|
|
33
|
+
author: encodeSimple("author", payload.author, {
|
|
34
|
+
explode: false,
|
|
35
|
+
charEncoding: "percent",
|
|
36
|
+
}),
|
|
37
|
+
slug: encodeSimple("slug", payload.slug, {
|
|
38
|
+
explode: false,
|
|
39
|
+
charEncoding: "percent",
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
const path = pathToFunc("/model/{author}/{slug}")(pathParams);
|
|
43
|
+
const headers = new Headers(compactMap({
|
|
44
|
+
Accept: "application/json",
|
|
45
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
46
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
47
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
48
|
+
}));
|
|
49
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
50
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
51
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
52
|
+
const context = {
|
|
53
|
+
options: client._options,
|
|
54
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
55
|
+
operationID: "getModel",
|
|
56
|
+
oAuth2Scopes: null,
|
|
57
|
+
resolvedSecurity: requestSecurity,
|
|
58
|
+
securitySource: client._options.apiKey,
|
|
59
|
+
retryConfig: options?.retries
|
|
60
|
+
|| client._options.retryConfig
|
|
61
|
+
|| {
|
|
62
|
+
strategy: "backoff",
|
|
63
|
+
backoff: {
|
|
64
|
+
initialInterval: 500,
|
|
65
|
+
maxInterval: 60000,
|
|
66
|
+
exponent: 1.5,
|
|
67
|
+
maxElapsedTime: 3600000,
|
|
68
|
+
},
|
|
69
|
+
retryConnectionErrors: true,
|
|
70
|
+
}
|
|
71
|
+
|| { strategy: "none" },
|
|
72
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
73
|
+
};
|
|
74
|
+
const requestRes = client._createRequest(context, {
|
|
75
|
+
security: requestSecurity,
|
|
76
|
+
method: "GET",
|
|
77
|
+
baseURL: options?.serverURL,
|
|
78
|
+
path: path,
|
|
79
|
+
headers: headers,
|
|
80
|
+
body: body,
|
|
81
|
+
userAgent: client._options.userAgent,
|
|
82
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
83
|
+
}, options);
|
|
84
|
+
if (!requestRes.ok) {
|
|
85
|
+
return [requestRes, { status: "invalid" }];
|
|
86
|
+
}
|
|
87
|
+
const req = requestRes.value;
|
|
88
|
+
const doResult = await client._do(req, {
|
|
89
|
+
context,
|
|
90
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
91
|
+
retryConfig: context.retryConfig,
|
|
92
|
+
retryCodes: context.retryCodes,
|
|
93
|
+
});
|
|
94
|
+
if (!doResult.ok) {
|
|
95
|
+
return [doResult, { status: "request-error", request: req }];
|
|
96
|
+
}
|
|
97
|
+
const response = doResult.value;
|
|
98
|
+
const responseFields = {
|
|
99
|
+
HttpMeta: { Response: response, Request: req },
|
|
100
|
+
};
|
|
101
|
+
const [result] = await M.match(M.json(200, models.ModelResponse$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
102
|
+
if (!result.ok) {
|
|
103
|
+
return [result, { status: "complete", request: req, response }];
|
|
104
|
+
}
|
|
105
|
+
return [result, { status: "complete", request: req, response }];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=modelsGet.js.map
|
package/esm/funcs/modelsList.js
CHANGED
|
@@ -28,9 +28,21 @@ async function $do(client, request, options) {
|
|
|
28
28
|
const body = null;
|
|
29
29
|
const path = pathToFunc("/models")();
|
|
30
30
|
const query = encodeFormQuery({
|
|
31
|
+
"arch": payload?.arch,
|
|
31
32
|
"category": payload?.category,
|
|
33
|
+
"context": payload?.context,
|
|
34
|
+
"distillable": payload?.distillable,
|
|
35
|
+
"input_modalities": payload?.input_modalities,
|
|
36
|
+
"max_price": payload?.max_price,
|
|
37
|
+
"min_price": payload?.min_price,
|
|
38
|
+
"model_authors": payload?.model_authors,
|
|
32
39
|
"output_modalities": payload?.output_modalities,
|
|
40
|
+
"providers": payload?.providers,
|
|
41
|
+
"q": payload?.q,
|
|
42
|
+
"region": payload?.region,
|
|
43
|
+
"sort": payload?.sort,
|
|
33
44
|
"supported_parameters": payload?.supported_parameters,
|
|
45
|
+
"zdr": payload?.zdr,
|
|
34
46
|
});
|
|
35
47
|
const headers = new Headers(compactMap({
|
|
36
48
|
Accept: "application/json",
|
|
@@ -14,5 +14,5 @@ import { Result } from "../types/fp.js";
|
|
|
14
14
|
* @remarks
|
|
15
15
|
* Create an authorization code for the PKCE flow to generate a user-controlled API key
|
|
16
16
|
*/
|
|
17
|
-
export declare function oAuthCreateAuthCode(client: OpenRouterCore, request: operations.CreateAuthKeysCodeRequest, options?: RequestOptions): APIPromise<Result<operations.CreateAuthKeysCodeResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
17
|
+
export declare function oAuthCreateAuthCode(client: OpenRouterCore, request: operations.CreateAuthKeysCodeRequest, options?: RequestOptions): APIPromise<Result<operations.CreateAuthKeysCodeResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
18
18
|
//# sourceMappingURL=oAuthCreateAuthCode.d.ts.map
|
|
@@ -88,7 +88,7 @@ async function $do(client, request, options) {
|
|
|
88
88
|
const responseFields = {
|
|
89
89
|
HttpMeta: { Response: response, Request: req },
|
|
90
90
|
};
|
|
91
|
-
const [result] = await M.match(M.json(200, operations.CreateAuthKeysCodeResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(409, errors.ConflictResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
91
|
+
const [result] = await M.match(M.json(200, operations.CreateAuthKeysCodeResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(409, errors.ConflictResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
92
92
|
if (!result.ok) {
|
|
93
93
|
return [result, { status: "complete", request: req, response }];
|
|
94
94
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OpenRouterCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { OpenRouterError } from "../models/errors/openroutererror.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import * as models from "../models/index.js";
|
|
9
|
+
import * as operations from "../models/operations/index.js";
|
|
10
|
+
import { APIPromise } from "../types/async.js";
|
|
11
|
+
import { Result } from "../types/fp.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get a preset
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Retrieves a preset by its slug with its currently designated version inline.
|
|
17
|
+
*
|
|
18
|
+
* If set, this operation will use {@link Security.apiKey} from the global security.
|
|
19
|
+
*/
|
|
20
|
+
export declare function presetsGet(client: OpenRouterCore, request: operations.GetPresetRequest, options?: RequestOptions): APIPromise<Result<models.GetPresetResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
21
|
+
//# sourceMappingURL=presetsGet.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: dd59c30d4b79
|
|
4
|
+
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
14
|
+
import * as operations from "../models/operations/index.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Get a preset
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Retrieves a preset by its slug with its currently designated version inline.
|
|
21
|
+
*
|
|
22
|
+
* If set, this operation will use {@link Security.apiKey} from the global security.
|
|
23
|
+
*/
|
|
24
|
+
export function presetsGet(client, request, options) {
|
|
25
|
+
return new APIPromise($do(client, request, options));
|
|
26
|
+
}
|
|
27
|
+
async function $do(client, request, options) {
|
|
28
|
+
const parsed = safeParse(request, (value) => operations.GetPresetRequest$outboundSchema.parse(value), "Input validation failed");
|
|
29
|
+
if (!parsed.ok) {
|
|
30
|
+
return [parsed, { status: "invalid" }];
|
|
31
|
+
}
|
|
32
|
+
const payload = parsed.value;
|
|
33
|
+
const body = null;
|
|
34
|
+
const pathParams = {
|
|
35
|
+
slug: encodeSimple("slug", payload.slug, {
|
|
36
|
+
explode: false,
|
|
37
|
+
charEncoding: "percent",
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
const path = pathToFunc("/presets/{slug}")(pathParams);
|
|
41
|
+
const headers = new Headers(compactMap({
|
|
42
|
+
Accept: "application/json",
|
|
43
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
44
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
45
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
46
|
+
}));
|
|
47
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
48
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
49
|
+
const requestSecurity = resolveGlobalSecurity(securityInput, [0]);
|
|
50
|
+
const context = {
|
|
51
|
+
options: client._options,
|
|
52
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
53
|
+
operationID: "getPreset",
|
|
54
|
+
oAuth2Scopes: null,
|
|
55
|
+
resolvedSecurity: requestSecurity,
|
|
56
|
+
securitySource: client._options.apiKey,
|
|
57
|
+
retryConfig: options?.retries
|
|
58
|
+
|| client._options.retryConfig
|
|
59
|
+
|| {
|
|
60
|
+
strategy: "backoff",
|
|
61
|
+
backoff: {
|
|
62
|
+
initialInterval: 500,
|
|
63
|
+
maxInterval: 60000,
|
|
64
|
+
exponent: 1.5,
|
|
65
|
+
maxElapsedTime: 3600000,
|
|
66
|
+
},
|
|
67
|
+
retryConnectionErrors: true,
|
|
68
|
+
}
|
|
69
|
+
|| { strategy: "none" },
|
|
70
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
71
|
+
};
|
|
72
|
+
const requestRes = client._createRequest(context, {
|
|
73
|
+
security: requestSecurity,
|
|
74
|
+
method: "GET",
|
|
75
|
+
baseURL: options?.serverURL,
|
|
76
|
+
path: path,
|
|
77
|
+
headers: headers,
|
|
78
|
+
body: body,
|
|
79
|
+
userAgent: client._options.userAgent,
|
|
80
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
81
|
+
}, options);
|
|
82
|
+
if (!requestRes.ok) {
|
|
83
|
+
return [requestRes, { status: "invalid" }];
|
|
84
|
+
}
|
|
85
|
+
const req = requestRes.value;
|
|
86
|
+
const doResult = await client._do(req, {
|
|
87
|
+
context,
|
|
88
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
89
|
+
retryConfig: context.retryConfig,
|
|
90
|
+
retryCodes: context.retryCodes,
|
|
91
|
+
});
|
|
92
|
+
if (!doResult.ok) {
|
|
93
|
+
return [doResult, { status: "request-error", request: req }];
|
|
94
|
+
}
|
|
95
|
+
const response = doResult.value;
|
|
96
|
+
const responseFields = {
|
|
97
|
+
HttpMeta: { Response: response, Request: req },
|
|
98
|
+
};
|
|
99
|
+
const [result] = await M.match(M.json(200, models.GetPresetResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
100
|
+
if (!result.ok) {
|
|
101
|
+
return [result, { status: "complete", request: req, response }];
|
|
102
|
+
}
|
|
103
|
+
return [result, { status: "complete", request: req, response }];
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=presetsGet.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OpenRouterCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { OpenRouterError } from "../models/errors/openroutererror.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import * as models from "../models/index.js";
|
|
9
|
+
import * as operations from "../models/operations/index.js";
|
|
10
|
+
import { APIPromise } from "../types/async.js";
|
|
11
|
+
import { Result } from "../types/fp.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get a specific version of a preset
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Retrieves a specific version of a preset by its slug and version number.
|
|
17
|
+
*
|
|
18
|
+
* If set, this operation will use {@link Security.apiKey} from the global security.
|
|
19
|
+
*/
|
|
20
|
+
export declare function presetsGetVersion(client: OpenRouterCore, request: operations.GetPresetVersionRequest, options?: RequestOptions): APIPromise<Result<models.GetPresetVersionResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
21
|
+
//# sourceMappingURL=presetsGetVersion.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 565567171e74
|
|
4
|
+
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
14
|
+
import * as operations from "../models/operations/index.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Get a specific version of a preset
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Retrieves a specific version of a preset by its slug and version number.
|
|
21
|
+
*
|
|
22
|
+
* If set, this operation will use {@link Security.apiKey} from the global security.
|
|
23
|
+
*/
|
|
24
|
+
export function presetsGetVersion(client, request, options) {
|
|
25
|
+
return new APIPromise($do(client, request, options));
|
|
26
|
+
}
|
|
27
|
+
async function $do(client, request, options) {
|
|
28
|
+
const parsed = safeParse(request, (value) => operations.GetPresetVersionRequest$outboundSchema.parse(value), "Input validation failed");
|
|
29
|
+
if (!parsed.ok) {
|
|
30
|
+
return [parsed, { status: "invalid" }];
|
|
31
|
+
}
|
|
32
|
+
const payload = parsed.value;
|
|
33
|
+
const body = null;
|
|
34
|
+
const pathParams = {
|
|
35
|
+
slug: encodeSimple("slug", payload.slug, {
|
|
36
|
+
explode: false,
|
|
37
|
+
charEncoding: "percent",
|
|
38
|
+
}),
|
|
39
|
+
version: encodeSimple("version", payload.version, {
|
|
40
|
+
explode: false,
|
|
41
|
+
charEncoding: "percent",
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
const path = pathToFunc("/presets/{slug}/versions/{version}")(pathParams);
|
|
45
|
+
const headers = new Headers(compactMap({
|
|
46
|
+
Accept: "application/json",
|
|
47
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
48
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
49
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
50
|
+
}));
|
|
51
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
52
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
53
|
+
const requestSecurity = resolveGlobalSecurity(securityInput, [0]);
|
|
54
|
+
const context = {
|
|
55
|
+
options: client._options,
|
|
56
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
57
|
+
operationID: "getPresetVersion",
|
|
58
|
+
oAuth2Scopes: null,
|
|
59
|
+
resolvedSecurity: requestSecurity,
|
|
60
|
+
securitySource: client._options.apiKey,
|
|
61
|
+
retryConfig: options?.retries
|
|
62
|
+
|| client._options.retryConfig
|
|
63
|
+
|| {
|
|
64
|
+
strategy: "backoff",
|
|
65
|
+
backoff: {
|
|
66
|
+
initialInterval: 500,
|
|
67
|
+
maxInterval: 60000,
|
|
68
|
+
exponent: 1.5,
|
|
69
|
+
maxElapsedTime: 3600000,
|
|
70
|
+
},
|
|
71
|
+
retryConnectionErrors: true,
|
|
72
|
+
}
|
|
73
|
+
|| { strategy: "none" },
|
|
74
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
75
|
+
};
|
|
76
|
+
const requestRes = client._createRequest(context, {
|
|
77
|
+
security: requestSecurity,
|
|
78
|
+
method: "GET",
|
|
79
|
+
baseURL: options?.serverURL,
|
|
80
|
+
path: path,
|
|
81
|
+
headers: headers,
|
|
82
|
+
body: body,
|
|
83
|
+
userAgent: client._options.userAgent,
|
|
84
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
85
|
+
}, options);
|
|
86
|
+
if (!requestRes.ok) {
|
|
87
|
+
return [requestRes, { status: "invalid" }];
|
|
88
|
+
}
|
|
89
|
+
const req = requestRes.value;
|
|
90
|
+
const doResult = await client._do(req, {
|
|
91
|
+
context,
|
|
92
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
93
|
+
retryConfig: context.retryConfig,
|
|
94
|
+
retryCodes: context.retryCodes,
|
|
95
|
+
});
|
|
96
|
+
if (!doResult.ok) {
|
|
97
|
+
return [doResult, { status: "request-error", request: req }];
|
|
98
|
+
}
|
|
99
|
+
const response = doResult.value;
|
|
100
|
+
const responseFields = {
|
|
101
|
+
HttpMeta: { Response: response, Request: req },
|
|
102
|
+
};
|
|
103
|
+
const [result] = await M.match(M.json(200, models.GetPresetVersionResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
104
|
+
if (!result.ok) {
|
|
105
|
+
return [result, { status: "complete", request: req, response }];
|
|
106
|
+
}
|
|
107
|
+
return [result, { status: "complete", request: req, response }];
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=presetsGetVersion.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OpenRouterCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { OpenRouterError } from "../models/errors/openroutererror.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
import { PageIterator } from "../types/operations.js";
|
|
12
|
+
/**
|
|
13
|
+
* List presets
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Lists all presets for the authenticated user, ordered by most recently updated first.
|
|
17
|
+
*
|
|
18
|
+
* If set, this operation will use {@link Security.apiKey} from the global security.
|
|
19
|
+
*/
|
|
20
|
+
export declare function presetsList(client: OpenRouterCore, request?: operations.ListPresetsRequest | undefined, options?: RequestOptions): APIPromise<PageIterator<Result<operations.ListPresetsResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>, {
|
|
21
|
+
offset: number;
|
|
22
|
+
}>>;
|
|
23
|
+
//# sourceMappingURL=presetsList.d.ts.map
|