@openrouter/sdk 0.5.1 → 0.9.11
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/FUNCTIONS.md +5 -1
- package/esm/funcs/analyticsGetUserActivity.d.ts +1 -1
- package/esm/funcs/analyticsGetUserActivity.js +4 -2
- package/esm/funcs/apiKeysCreate.d.ts +1 -1
- package/esm/funcs/apiKeysCreate.js +5 -3
- package/esm/funcs/apiKeysDelete.d.ts +1 -1
- package/esm/funcs/apiKeysDelete.js +3 -1
- package/esm/funcs/apiKeysGet.d.ts +1 -1
- package/esm/funcs/apiKeysGet.js +3 -1
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.d.ts +1 -1
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.js +14 -3
- package/esm/funcs/apiKeysList.d.ts +1 -1
- package/esm/funcs/apiKeysList.js +4 -2
- package/esm/funcs/apiKeysUpdate.d.ts +1 -1
- package/esm/funcs/apiKeysUpdate.js +3 -1
- package/esm/funcs/betaResponsesSend.d.ts +9 -5
- package/esm/funcs/betaResponsesSend.js +10 -5
- package/esm/funcs/chatSend.d.ts +11 -7
- package/esm/funcs/chatSend.js +28 -7
- package/esm/funcs/creditsCreateCoinbaseCharge.d.ts +1 -2
- package/esm/funcs/creditsCreateCoinbaseCharge.js +7 -4
- package/esm/funcs/creditsGetCredits.d.ts +2 -2
- package/esm/funcs/creditsGetCredits.js +15 -4
- package/esm/funcs/embeddingsGenerate.js +4 -2
- package/esm/funcs/embeddingsListModels.d.ts +2 -1
- package/esm/funcs/embeddingsListModels.js +15 -3
- package/esm/funcs/endpointsList.js +2 -0
- package/esm/funcs/endpointsListZdrEndpoints.d.ts +1 -1
- package/esm/funcs/endpointsListZdrEndpoints.js +14 -3
- package/esm/funcs/generationsGetGeneration.js +3 -1
- package/esm/funcs/guardrailsBulkAssignKeys.d.ts +1 -1
- package/esm/funcs/guardrailsBulkAssignKeys.js +3 -1
- package/esm/funcs/guardrailsBulkAssignMembers.d.ts +1 -1
- package/esm/funcs/guardrailsBulkAssignMembers.js +3 -1
- package/esm/funcs/guardrailsBulkUnassignKeys.d.ts +1 -1
- package/esm/funcs/guardrailsBulkUnassignKeys.js +3 -1
- package/esm/funcs/guardrailsBulkUnassignMembers.d.ts +1 -1
- package/esm/funcs/guardrailsBulkUnassignMembers.js +3 -1
- package/esm/funcs/guardrailsCreate.d.ts +1 -1
- package/esm/funcs/guardrailsCreate.js +5 -3
- package/esm/funcs/guardrailsDelete.d.ts +1 -1
- package/esm/funcs/guardrailsDelete.js +3 -1
- package/esm/funcs/guardrailsGet.d.ts +1 -1
- package/esm/funcs/guardrailsGet.js +3 -1
- package/esm/funcs/guardrailsList.d.ts +1 -1
- package/esm/funcs/guardrailsList.js +4 -2
- package/esm/funcs/guardrailsListGuardrailKeyAssignments.d.ts +1 -1
- package/esm/funcs/guardrailsListGuardrailKeyAssignments.js +3 -1
- package/esm/funcs/guardrailsListGuardrailMemberAssignments.d.ts +1 -1
- package/esm/funcs/guardrailsListGuardrailMemberAssignments.js +3 -1
- package/esm/funcs/guardrailsListKeyAssignments.d.ts +1 -1
- package/esm/funcs/guardrailsListKeyAssignments.js +4 -2
- package/esm/funcs/guardrailsListMemberAssignments.d.ts +1 -1
- package/esm/funcs/guardrailsListMemberAssignments.js +4 -2
- package/esm/funcs/guardrailsUpdate.d.ts +1 -1
- package/esm/funcs/guardrailsUpdate.js +3 -1
- package/esm/funcs/modelsCount.d.ts +2 -1
- package/esm/funcs/modelsCount.js +15 -3
- package/esm/funcs/modelsList.js +3 -1
- package/esm/funcs/modelsListForUser.d.ts +1 -1
- package/esm/funcs/modelsListForUser.js +15 -3
- package/esm/funcs/oAuthCreateAuthCode.js +4 -2
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.js +4 -2
- package/esm/funcs/providersList.d.ts +1 -1
- package/esm/funcs/providersList.js +14 -3
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/lib/model-result.d.ts +3 -5
- package/esm/lib/model-result.js +98 -46
- package/esm/models/assistantmessage.d.ts +47 -36
- package/esm/models/assistantmessage.js +35 -47
- package/esm/models/assistantmessageimages.d.ts +33 -0
- package/esm/models/assistantmessageimages.js +44 -0
- package/esm/models/chatgenerationparams.d.ts +318 -182
- package/esm/models/chatgenerationparams.js +157 -143
- package/esm/models/chatgenerationtokenusage.d.ts +48 -0
- package/esm/models/chatmessagecontentitem.d.ts +15 -10
- package/esm/models/chatmessagecontentitem.js +25 -4
- package/esm/models/chatmessagecontentitemaudio.d.ts +20 -2
- package/esm/models/chatmessagecontentitemaudio.js +9 -2
- package/esm/models/chatmessagecontentitemcachecontrol.d.ts +14 -3
- package/esm/models/chatmessagecontentitemcachecontrol.js +9 -2
- package/esm/models/chatmessagecontentitemimage.d.ts +26 -3
- package/esm/models/chatmessagecontentitemimage.js +12 -2
- package/esm/models/chatmessagecontentitemtext.d.ts +17 -2
- package/esm/models/chatmessagecontentitemtext.js +9 -2
- package/esm/models/chatmessagecontentitemvideo.d.ts +12 -55
- package/esm/models/chatmessagecontentitemvideo.js +5 -72
- package/esm/models/chatmessagecontentitemvideolegacy.d.ts +28 -0
- package/esm/models/chatmessagecontentitemvideolegacy.js +33 -0
- package/esm/models/chatmessagetokenlogprob.d.ts +15 -0
- package/esm/models/chatmessagetokenlogprobs.d.ts +9 -0
- package/esm/models/chatmessagetoolcall.d.ts +23 -2
- package/esm/models/chatmessagetoolcall.js +9 -2
- package/esm/models/chatresponse.d.ts +29 -1
- package/esm/models/chatresponse.js +6 -1
- package/esm/models/chatresponsechoice.d.ts +13 -2
- package/esm/models/chatresponsechoice.js +1 -2
- package/esm/models/chatstreamingchoice.d.ts +13 -2
- package/esm/models/chatstreamingchoice.js +1 -2
- package/esm/models/chatstreamingmessagechunk.d.ts +29 -2
- package/esm/models/chatstreamingmessagechunk.js +5 -2
- package/esm/models/chatstreamingmessagetoolcall.d.ts +38 -1
- package/esm/models/chatstreamingmessagetoolcall.js +9 -1
- package/esm/models/chatstreamingresponsechunk.d.ts +45 -11
- package/esm/models/chatstreamingresponsechunk.js +11 -25
- package/esm/models/chatstreamoptions.d.ts +8 -0
- package/esm/models/debugoptions.d.ts +18 -0
- package/esm/models/debugoptions.js +18 -0
- package/esm/models/developermessage.d.ts +35 -0
- package/esm/models/developermessage.js +24 -0
- package/esm/models/errors/index.d.ts +0 -1
- package/esm/models/errors/index.js +0 -1
- package/esm/models/index.d.ts +13 -5
- package/esm/models/index.js +13 -5
- package/esm/models/jsonschemaconfig.d.ts +17 -2
- package/esm/models/jsonschemaconfig.js +1 -1
- package/esm/models/message.d.ts +10 -23
- package/esm/models/message.js +3 -20
- package/esm/models/modelscountresponse.d.ts +4 -4
- package/esm/models/modelscountresponse.js +4 -4
- package/esm/models/namedtoolchoice.d.ts +15 -2
- package/esm/models/namedtoolchoice.js +6 -1
- package/esm/models/openairesponsesreasoningconfig.d.ts +1 -1
- package/esm/models/openairesponsesreasoningconfig.js +1 -1
- package/esm/models/openresponsesnonstreamingresponse.d.ts +4 -4
- package/esm/models/openresponsesnonstreamingresponse.js +3 -3
- package/esm/models/openresponsesreasoning.d.ts +2 -2
- package/esm/models/openresponsesreasoning.js +1 -1
- package/esm/models/openresponsesreasoningconfig.d.ts +2 -2
- package/esm/models/openresponsesreasoningconfig.js +1 -1
- package/esm/models/openresponsesrequest.d.ts +31 -13
- package/esm/models/openresponsesrequest.js +25 -0
- package/esm/models/operations/bulkassignkeystoguardrail.d.ts +30 -0
- package/esm/models/operations/bulkassignkeystoguardrail.js +4 -0
- package/esm/models/operations/bulkassignmemberstoguardrail.d.ts +30 -0
- package/esm/models/operations/bulkassignmemberstoguardrail.js +4 -0
- package/esm/models/operations/bulkunassignkeysfromguardrail.d.ts +30 -0
- package/esm/models/operations/bulkunassignkeysfromguardrail.js +4 -0
- package/esm/models/operations/bulkunassignmembersfromguardrail.d.ts +30 -0
- package/esm/models/operations/bulkunassignmembersfromguardrail.js +4 -0
- package/esm/models/operations/createauthkeyscode.d.ts +66 -2
- package/esm/models/operations/createauthkeyscode.js +30 -1
- package/esm/models/operations/createcoinbasecharge.d.ts +41 -0
- package/esm/models/operations/createcoinbasecharge.js +16 -0
- package/esm/models/operations/createembeddings.d.ts +42 -2
- package/esm/models/operations/createembeddings.js +16 -1
- package/esm/models/operations/createguardrail.d.ts +42 -2
- package/esm/models/operations/createguardrail.js +16 -1
- package/esm/models/operations/createkeys.d.ts +42 -2
- package/esm/models/operations/createkeys.js +16 -1
- package/esm/models/operations/createresponses.d.ts +40 -0
- package/esm/models/operations/createresponses.js +16 -0
- package/esm/models/operations/deleteguardrail.d.ts +30 -0
- package/esm/models/operations/deleteguardrail.js +8 -0
- package/esm/models/operations/deletekeys.d.ts +30 -0
- package/esm/models/operations/deletekeys.js +8 -0
- package/esm/models/operations/exchangeauthcodeforapikey.d.ts +42 -2
- package/esm/models/operations/exchangeauthcodeforapikey.js +16 -1
- package/esm/models/operations/getcredits.d.ts +38 -0
- package/esm/models/operations/getcredits.js +13 -0
- package/esm/models/operations/getcurrentkey.d.ts +45 -1
- package/esm/models/operations/getcurrentkey.js +15 -0
- package/esm/models/operations/getgeneration.d.ts +153 -0
- package/esm/models/operations/getgeneration.js +135 -0
- package/esm/models/operations/getguardrail.d.ts +30 -0
- package/esm/models/operations/getguardrail.js +7 -0
- package/esm/models/operations/getkey.d.ts +30 -0
- package/esm/models/operations/getkey.js +7 -0
- package/esm/models/operations/getmodels.d.ts +30 -0
- package/esm/models/operations/getmodels.js +4 -0
- package/esm/models/operations/getuseractivity.d.ts +30 -0
- package/esm/models/operations/getuseractivity.js +8 -0
- package/esm/models/operations/index.d.ts +2 -0
- package/esm/models/operations/index.js +2 -0
- package/esm/models/operations/list.d.ts +30 -0
- package/esm/models/operations/list.js +4 -0
- package/esm/models/operations/listembeddingsmodels.d.ts +40 -0
- package/esm/models/operations/listembeddingsmodels.js +20 -0
- package/esm/models/operations/listendpoints.d.ts +30 -0
- package/esm/models/operations/listendpoints.js +8 -0
- package/esm/models/operations/listendpointszdr.d.ts +38 -0
- package/esm/models/operations/listendpointszdr.js +14 -0
- package/esm/models/operations/listguardrailkeyassignments.d.ts +30 -0
- package/esm/models/operations/listguardrailkeyassignments.js +7 -0
- package/esm/models/operations/listguardrailmemberassignments.d.ts +30 -0
- package/esm/models/operations/listguardrailmemberassignments.js +7 -0
- package/esm/models/operations/listguardrails.d.ts +30 -0
- package/esm/models/operations/listguardrails.js +7 -0
- package/esm/models/operations/listkeyassignments.d.ts +30 -0
- package/esm/models/operations/listkeyassignments.js +7 -0
- package/esm/models/operations/listmemberassignments.d.ts +30 -0
- package/esm/models/operations/listmemberassignments.js +7 -0
- package/esm/models/operations/listmodelscount.d.ts +40 -0
- package/esm/models/operations/listmodelscount.js +20 -0
- package/esm/models/operations/listmodelsuser.d.ts +38 -0
- package/esm/models/operations/listmodelsuser.js +14 -0
- package/esm/models/operations/listproviders.d.ts +38 -0
- package/esm/models/operations/listproviders.js +13 -0
- package/esm/models/operations/sendchatcompletionrequest.d.ts +53 -1
- package/esm/models/operations/sendchatcompletionrequest.js +36 -2
- package/esm/models/operations/updateguardrail.d.ts +30 -0
- package/esm/models/operations/updateguardrail.js +4 -0
- package/esm/models/operations/updatekeys.d.ts +30 -0
- package/esm/models/operations/updatekeys.js +4 -0
- package/esm/models/providername.d.ts +4 -0
- package/esm/models/providername.js +4 -0
- package/esm/models/providerpreferences.d.ts +46 -27
- package/esm/models/providerpreferences.js +29 -15
- package/esm/models/providersort.d.ts +6 -0
- package/esm/models/providersort.js +3 -0
- package/esm/models/providersortconfig.d.ts +30 -2
- package/esm/models/providersortconfig.js +15 -2
- package/esm/models/publicendpoint.d.ts +0 -39
- package/esm/models/publicpricing.d.ts +0 -39
- package/esm/models/reasoningdetailencrypted.d.ts +42 -0
- package/esm/models/reasoningdetailencrypted.js +42 -0
- package/esm/models/reasoningdetailsummary.d.ts +42 -0
- package/esm/models/reasoningdetailsummary.js +42 -0
- package/esm/models/reasoningdetailtext.d.ts +44 -0
- package/esm/models/reasoningdetailtext.js +44 -0
- package/esm/models/reasoningdetailunion.d.ts +19 -0
- package/esm/models/reasoningdetailunion.js +28 -0
- package/esm/models/responseformatjsonobject.d.ts +20 -0
- package/esm/models/responseformatjsonobject.js +21 -0
- package/esm/models/responseformatjsonschema.d.ts +6 -0
- package/esm/models/responseformattext.d.ts +15 -0
- package/esm/models/responseformattext.js +13 -0
- package/esm/models/responseformattextconfig.d.ts +3 -3
- package/esm/models/responseformattextconfig.js +3 -3
- package/esm/models/responseformattextgrammar.d.ts +6 -0
- package/esm/models/responseformattextpython.d.ts +15 -0
- package/esm/models/responseformattextpython.js +13 -0
- package/esm/models/responseserrorfield.d.ts +4 -4
- package/esm/models/responseserrorfield.js +4 -4
- package/esm/models/responsesoutputitemreasoning.d.ts +2 -2
- package/esm/models/responsesoutputitemreasoning.js +2 -2
- package/esm/models/systemmessage.d.ts +12 -0
- package/esm/models/toolchoiceoption.d.ts +31 -0
- package/esm/models/toolchoiceoption.js +32 -0
- package/esm/models/tooldefinitionjson.d.ts +38 -4
- package/esm/models/tooldefinitionjson.js +14 -2
- package/esm/models/toolresponsemessage.d.ts +12 -0
- package/esm/models/usermessage.d.ts +12 -0
- package/esm/models/videoinput.d.ts +23 -0
- package/esm/models/videoinput.js +22 -0
- package/esm/sdk/analytics.d.ts +1 -1
- package/esm/sdk/analytics.js +1 -1
- package/esm/sdk/apikeys.d.ts +6 -6
- package/esm/sdk/apikeys.js +7 -7
- package/esm/sdk/chat.d.ts +10 -6
- package/esm/sdk/credits.d.ts +3 -4
- package/esm/sdk/credits.js +3 -3
- package/esm/sdk/embeddings.d.ts +1 -1
- package/esm/sdk/embeddings.js +2 -2
- package/esm/sdk/endpoints.d.ts +1 -1
- package/esm/sdk/endpoints.js +2 -2
- package/esm/sdk/guardrails.d.ts +13 -13
- package/esm/sdk/guardrails.js +13 -13
- package/esm/sdk/models.d.ts +2 -2
- package/esm/sdk/models.js +4 -4
- package/esm/sdk/providers.d.ts +1 -1
- package/esm/sdk/providers.js +2 -2
- package/esm/sdk/responses.d.ts +9 -5
- package/esm/sdk/sdk.d.ts +2 -2
- package/esm/sdk/sdk.js +3 -3
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/esm/models/chaterror.d.ts +0 -17
- package/esm/models/chaterror.js +0 -25
- package/esm/models/errors/chaterror.d.ts +0 -19
- package/esm/models/errors/chaterror.js +0 -32
- package/esm/models/providersortunion.d.ts +0 -10
- package/esm/models/providersortunion.js +0 -13
- package/esm/models/responsesformatjsonobject.d.ts +0 -20
- package/esm/models/responsesformatjsonobject.js +0 -21
- package/esm/models/schema0.d.ts +0 -84
- package/esm/models/schema0.js +0 -87
- package/esm/models/schema2.d.ts +0 -92
- package/esm/models/schema2.js +0 -109
package/esm/funcs/modelsCount.js
CHANGED
|
@@ -2,23 +2,34 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: 371adfc67b48
|
|
4
4
|
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
5
6
|
import * as M from "../lib/matchers.js";
|
|
6
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
9
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
8
10
|
import { pathToFunc } from "../lib/url.js";
|
|
9
11
|
import * as errors from "../models/errors/index.js";
|
|
10
12
|
import * as models from "../models/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
11
14
|
import { APIPromise } from "../types/async.js";
|
|
12
15
|
/**
|
|
13
16
|
* Get total count of available models
|
|
14
17
|
*/
|
|
15
|
-
export function modelsCount(client, options) {
|
|
16
|
-
return new APIPromise($do(client, options));
|
|
18
|
+
export function modelsCount(client, request, options) {
|
|
19
|
+
return new APIPromise($do(client, request, options));
|
|
17
20
|
}
|
|
18
|
-
async function $do(client, options) {
|
|
21
|
+
async function $do(client, request, options) {
|
|
22
|
+
const parsed = safeParse(request, (value) => operations.ListModelsCountRequest$outboundSchema.optional().parse(value), "Input validation failed");
|
|
23
|
+
if (!parsed.ok) {
|
|
24
|
+
return [parsed, { status: "invalid" }];
|
|
25
|
+
}
|
|
26
|
+
const payload = parsed.value;
|
|
27
|
+
const body = null;
|
|
19
28
|
const path = pathToFunc("/models/count")();
|
|
20
29
|
const headers = new Headers(compactMap({
|
|
21
30
|
Accept: "application/json",
|
|
31
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
32
|
+
"X-Title": encodeSimple("X-Title", payload?.["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
22
33
|
}));
|
|
23
34
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
24
35
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -41,6 +52,7 @@ async function $do(client, options) {
|
|
|
41
52
|
baseURL: options?.serverURL,
|
|
42
53
|
path: path,
|
|
43
54
|
headers: headers,
|
|
55
|
+
body: body,
|
|
44
56
|
userAgent: client._options.userAgent,
|
|
45
57
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
46
58
|
}, options);
|
package/esm/funcs/modelsList.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: deff050b46c5
|
|
4
4
|
*/
|
|
5
|
-
import { encodeFormQuery } from "../lib/encodings.js";
|
|
5
|
+
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
6
6
|
import * as M from "../lib/matchers.js";
|
|
7
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
8
|
import { safeParse } from "../lib/schemas.js";
|
|
@@ -32,6 +32,8 @@ async function $do(client, request, options) {
|
|
|
32
32
|
});
|
|
33
33
|
const headers = new Headers(compactMap({
|
|
34
34
|
Accept: "application/json",
|
|
35
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
36
|
+
"X-Title": encodeSimple("X-Title", payload?.["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
35
37
|
}));
|
|
36
38
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
37
39
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -15,5 +15,5 @@ import { Result } from "../types/fp.js";
|
|
|
15
15
|
* @remarks
|
|
16
16
|
* List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/logging), and [guardrails](https://openrouter.ai/docs/guides/features/guardrails). If requesting through `eu.openrouter.ai/api/v1/...` the results will be filtered to models that satisfy [EU in-region routing](https://openrouter.ai/docs/guides/privacy/logging#enterprise-eu-in-region-routing).
|
|
17
17
|
*/
|
|
18
|
-
export declare function modelsListForUser(client: OpenRouterCore, security: operations.ListModelsUserSecurity, options?: RequestOptions): APIPromise<Result<models.ModelsListResponse, errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
18
|
+
export declare function modelsListForUser(client: OpenRouterCore, security: operations.ListModelsUserSecurity, request?: operations.ListModelsUserRequest | undefined, options?: RequestOptions): APIPromise<Result<models.ModelsListResponse, errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
19
|
//# sourceMappingURL=modelsListForUser.d.ts.map
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: db628dd3c179
|
|
4
4
|
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
5
6
|
import * as M from "../lib/matchers.js";
|
|
6
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
9
|
import { resolveSecurity } from "../lib/security.js";
|
|
8
10
|
import { pathToFunc } from "../lib/url.js";
|
|
9
11
|
import * as errors from "../models/errors/index.js";
|
|
10
12
|
import * as models from "../models/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
11
14
|
import { APIPromise } from "../types/async.js";
|
|
12
15
|
/**
|
|
13
16
|
* List models filtered by user provider preferences, privacy settings, and guardrails
|
|
@@ -15,13 +18,21 @@ import { APIPromise } from "../types/async.js";
|
|
|
15
18
|
* @remarks
|
|
16
19
|
* List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/logging), and [guardrails](https://openrouter.ai/docs/guides/features/guardrails). If requesting through `eu.openrouter.ai/api/v1/...` the results will be filtered to models that satisfy [EU in-region routing](https://openrouter.ai/docs/guides/privacy/logging#enterprise-eu-in-region-routing).
|
|
17
20
|
*/
|
|
18
|
-
export function modelsListForUser(client, security, options) {
|
|
19
|
-
return new APIPromise($do(client, security, options));
|
|
21
|
+
export function modelsListForUser(client, security, request, options) {
|
|
22
|
+
return new APIPromise($do(client, security, request, options));
|
|
20
23
|
}
|
|
21
|
-
async function $do(client, security, options) {
|
|
24
|
+
async function $do(client, security, request, options) {
|
|
25
|
+
const parsed = safeParse(request, (value) => operations.ListModelsUserRequest$outboundSchema.optional().parse(value), "Input validation failed");
|
|
26
|
+
if (!parsed.ok) {
|
|
27
|
+
return [parsed, { status: "invalid" }];
|
|
28
|
+
}
|
|
29
|
+
const payload = parsed.value;
|
|
30
|
+
const body = null;
|
|
22
31
|
const path = pathToFunc("/models/user")();
|
|
23
32
|
const headers = new Headers(compactMap({
|
|
24
33
|
Accept: "application/json",
|
|
34
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
35
|
+
"X-Title": encodeSimple("X-Title", payload?.["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
25
36
|
}));
|
|
26
37
|
const requestSecurity = resolveSecurity([
|
|
27
38
|
{
|
|
@@ -48,6 +59,7 @@ async function $do(client, security, options) {
|
|
|
48
59
|
baseURL: options?.serverURL,
|
|
49
60
|
path: path,
|
|
50
61
|
headers: headers,
|
|
62
|
+
body: body,
|
|
51
63
|
userAgent: client._options.userAgent,
|
|
52
64
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
53
65
|
}, options);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: 8a79f27722c0
|
|
4
4
|
*/
|
|
5
|
-
import { encodeJSON } from "../lib/encodings.js";
|
|
5
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
6
6
|
import * as M from "../lib/matchers.js";
|
|
7
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
8
|
import { safeParse } from "../lib/schemas.js";
|
|
@@ -26,11 +26,13 @@ async function $do(client, request, options) {
|
|
|
26
26
|
return [parsed, { status: "invalid" }];
|
|
27
27
|
}
|
|
28
28
|
const payload = parsed.value;
|
|
29
|
-
const body = encodeJSON("body", payload, { explode: true });
|
|
29
|
+
const body = encodeJSON("body", payload.RequestBody, { explode: true });
|
|
30
30
|
const path = pathToFunc("/auth/keys/code")();
|
|
31
31
|
const headers = new Headers(compactMap({
|
|
32
32
|
"Content-Type": "application/json",
|
|
33
33
|
Accept: "application/json",
|
|
34
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
35
|
+
"X-Title": encodeSimple("X-Title", payload["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
34
36
|
}));
|
|
35
37
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
36
38
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: 3386ec12d934
|
|
4
4
|
*/
|
|
5
|
-
import { encodeJSON } from "../lib/encodings.js";
|
|
5
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
6
6
|
import * as M from "../lib/matchers.js";
|
|
7
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
8
|
import { safeParse } from "../lib/schemas.js";
|
|
@@ -26,11 +26,13 @@ async function $do(client, request, options) {
|
|
|
26
26
|
return [parsed, { status: "invalid" }];
|
|
27
27
|
}
|
|
28
28
|
const payload = parsed.value;
|
|
29
|
-
const body = encodeJSON("body", payload, { explode: true });
|
|
29
|
+
const body = encodeJSON("body", payload.RequestBody, { explode: true });
|
|
30
30
|
const path = pathToFunc("/auth/keys")();
|
|
31
31
|
const headers = new Headers(compactMap({
|
|
32
32
|
"Content-Type": "application/json",
|
|
33
33
|
Accept: "application/json",
|
|
34
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
35
|
+
"X-Title": encodeSimple("X-Title", payload["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
34
36
|
}));
|
|
35
37
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
36
38
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -11,5 +11,5 @@ import { Result } from "../types/fp.js";
|
|
|
11
11
|
/**
|
|
12
12
|
* List all providers
|
|
13
13
|
*/
|
|
14
|
-
export declare function providersList(client: OpenRouterCore, options?: RequestOptions): APIPromise<Result<operations.ListProvidersResponse, errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
14
|
+
export declare function providersList(client: OpenRouterCore, request?: operations.ListProvidersRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListProvidersResponse, errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
15
15
|
//# sourceMappingURL=providersList.d.ts.map
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: 8ad87e7210ae
|
|
4
4
|
*/
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
5
6
|
import * as M from "../lib/matchers.js";
|
|
6
7
|
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
9
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
8
10
|
import { pathToFunc } from "../lib/url.js";
|
|
9
11
|
import * as errors from "../models/errors/index.js";
|
|
@@ -12,13 +14,21 @@ import { APIPromise } from "../types/async.js";
|
|
|
12
14
|
/**
|
|
13
15
|
* List all providers
|
|
14
16
|
*/
|
|
15
|
-
export function providersList(client, options) {
|
|
16
|
-
return new APIPromise($do(client, options));
|
|
17
|
+
export function providersList(client, request, options) {
|
|
18
|
+
return new APIPromise($do(client, request, options));
|
|
17
19
|
}
|
|
18
|
-
async function $do(client, options) {
|
|
20
|
+
async function $do(client, request, options) {
|
|
21
|
+
const parsed = safeParse(request, (value) => operations.ListProvidersRequest$outboundSchema.optional().parse(value), "Input validation failed");
|
|
22
|
+
if (!parsed.ok) {
|
|
23
|
+
return [parsed, { status: "invalid" }];
|
|
24
|
+
}
|
|
25
|
+
const payload = parsed.value;
|
|
26
|
+
const body = null;
|
|
19
27
|
const path = pathToFunc("/providers")();
|
|
20
28
|
const headers = new Headers(compactMap({
|
|
21
29
|
Accept: "application/json",
|
|
30
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
31
|
+
"X-Title": encodeSimple("X-Title", payload?.["X-Title"] ?? client._options.xTitle, { explode: false, charEncoding: "none" }),
|
|
22
32
|
}));
|
|
23
33
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
24
34
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -41,6 +51,7 @@ async function $do(client, options) {
|
|
|
41
51
|
baseURL: options?.serverURL,
|
|
42
52
|
path: path,
|
|
43
53
|
headers: headers,
|
|
54
|
+
body: body,
|
|
44
55
|
userAgent: client._options.userAgent,
|
|
45
56
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
46
57
|
}, options);
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
51
51
|
export declare const SDK_METADATA: {
|
|
52
52
|
readonly language: "typescript";
|
|
53
53
|
readonly openapiDocVersion: "1.0.0";
|
|
54
|
-
readonly sdkVersion: "0.
|
|
54
|
+
readonly sdkVersion: "0.9.11";
|
|
55
55
|
readonly genVersion: "2.788.4";
|
|
56
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.
|
|
56
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.9.11 2.788.4 1.0.0 @openrouter/sdk";
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=config.d.ts.map
|
package/esm/lib/config.js
CHANGED
|
@@ -26,8 +26,8 @@ export function serverURLFromOptions(options) {
|
|
|
26
26
|
export const SDK_METADATA = {
|
|
27
27
|
language: "typescript",
|
|
28
28
|
openapiDocVersion: "1.0.0",
|
|
29
|
-
sdkVersion: "0.
|
|
29
|
+
sdkVersion: "0.9.11",
|
|
30
30
|
genVersion: "2.788.4",
|
|
31
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
31
|
+
userAgent: "speakeasy-sdk/typescript 0.9.11 2.788.4 1.0.0 @openrouter/sdk",
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=config.js.map
|
|
@@ -119,8 +119,7 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
|
|
|
119
119
|
*/
|
|
120
120
|
private hasExecutableToolCalls;
|
|
121
121
|
/**
|
|
122
|
-
* Execute tools that can auto-execute (don't require approval).
|
|
123
|
-
* Processes tool calls that are approved for automatic execution.
|
|
122
|
+
* Execute tools that can auto-execute (don't require approval) in parallel.
|
|
124
123
|
*
|
|
125
124
|
* @param toolCalls - The tool calls to execute
|
|
126
125
|
* @param turnContext - The current turn context
|
|
@@ -139,9 +138,8 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
|
|
|
139
138
|
*/
|
|
140
139
|
private handleApprovalCheck;
|
|
141
140
|
/**
|
|
142
|
-
* Execute all tools in a single round.
|
|
143
|
-
*
|
|
144
|
-
* Emits tool.result events after each tool execution completes.
|
|
141
|
+
* Execute all tools in a single round in parallel.
|
|
142
|
+
* Emits tool.result events after tool execution completes.
|
|
145
143
|
*
|
|
146
144
|
* @param toolCalls - The tool calls to execute
|
|
147
145
|
* @param turnContext - The current turn context
|
package/esm/lib/model-result.js
CHANGED
|
@@ -230,25 +230,40 @@ export class ModelResult {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
-
* Execute tools that can auto-execute (don't require approval).
|
|
234
|
-
* Processes tool calls that are approved for automatic execution.
|
|
233
|
+
* Execute tools that can auto-execute (don't require approval) in parallel.
|
|
235
234
|
*
|
|
236
235
|
* @param toolCalls - The tool calls to execute
|
|
237
236
|
* @param turnContext - The current turn context
|
|
238
237
|
* @returns Array of unsent tool results for later submission
|
|
239
238
|
*/
|
|
240
239
|
async executeAutoApproveTools(toolCalls, turnContext) {
|
|
241
|
-
const
|
|
242
|
-
for (const tc of toolCalls) {
|
|
240
|
+
const toolCallPromises = toolCalls.map(async (tc) => {
|
|
243
241
|
const tool = this.options.tools?.find(t => t.function.name === tc.name);
|
|
244
|
-
if (!tool || !hasExecuteFunction(tool))
|
|
245
|
-
|
|
242
|
+
if (!tool || !hasExecuteFunction(tool)) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
246
245
|
const result = await executeTool(tool, tc, turnContext);
|
|
247
246
|
if (result.error) {
|
|
248
|
-
|
|
247
|
+
return createRejectedResult(tc.id, String(tc.name), result.error.message);
|
|
249
248
|
}
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
return createUnsentResult(tc.id, String(tc.name), result.result);
|
|
250
|
+
});
|
|
251
|
+
const settledResults = await Promise.allSettled(toolCallPromises);
|
|
252
|
+
const results = [];
|
|
253
|
+
for (let i = 0; i < settledResults.length; i++) {
|
|
254
|
+
const settled = settledResults[i];
|
|
255
|
+
const tc = toolCalls[i];
|
|
256
|
+
if (!settled || !tc)
|
|
257
|
+
continue;
|
|
258
|
+
if (settled.status === 'rejected') {
|
|
259
|
+
const errorMessage = settled.reason instanceof Error
|
|
260
|
+
? settled.reason.message
|
|
261
|
+
: String(settled.reason);
|
|
262
|
+
results.push(createRejectedResult(tc.id, String(tc.name), errorMessage));
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (settled.value) {
|
|
266
|
+
results.push(settled.value);
|
|
252
267
|
}
|
|
253
268
|
}
|
|
254
269
|
return results;
|
|
@@ -291,31 +306,26 @@ export class ModelResult {
|
|
|
291
306
|
return true; // Pause for approval
|
|
292
307
|
}
|
|
293
308
|
/**
|
|
294
|
-
* Execute all tools in a single round.
|
|
295
|
-
*
|
|
296
|
-
* Emits tool.result events after each tool execution completes.
|
|
309
|
+
* Execute all tools in a single round in parallel.
|
|
310
|
+
* Emits tool.result events after tool execution completes.
|
|
297
311
|
*
|
|
298
312
|
* @param toolCalls - The tool calls to execute
|
|
299
313
|
* @param turnContext - The current turn context
|
|
300
314
|
* @returns Array of function call outputs formatted for the API
|
|
301
315
|
*/
|
|
302
316
|
async executeToolRound(toolCalls, turnContext) {
|
|
303
|
-
const
|
|
304
|
-
for (const toolCall of toolCalls) {
|
|
317
|
+
const toolCallPromises = toolCalls.map(async (toolCall) => {
|
|
305
318
|
const tool = this.options.tools?.find((t) => t.function.name === toolCall.name);
|
|
306
|
-
if (!tool || !hasExecuteFunction(tool))
|
|
307
|
-
|
|
319
|
+
if (!tool || !hasExecuteFunction(tool)) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
308
322
|
// Check if arguments failed to parse (remained as string instead of object)
|
|
309
|
-
// This happens when the model returns invalid JSON for tool call arguments
|
|
310
|
-
// We use 'unknown' cast because the type system doesn't know arguments can be a string
|
|
311
|
-
// when JSON parsing fails in stream-transformers.ts
|
|
312
323
|
const args = toolCall.arguments;
|
|
313
324
|
if (typeof args === 'string') {
|
|
314
325
|
const rawArgs = args;
|
|
315
326
|
const errorMessage = `Failed to parse tool call arguments for "${toolCall.name}": The model provided invalid JSON. ` +
|
|
316
327
|
`Raw arguments received: "${rawArgs}". ` +
|
|
317
328
|
`Please provide valid JSON arguments for this tool call.`;
|
|
318
|
-
// Emit error event if broadcaster exists
|
|
319
329
|
if (this.toolEventBroadcaster) {
|
|
320
330
|
this.toolEventBroadcaster.push({
|
|
321
331
|
type: 'tool_result',
|
|
@@ -323,23 +333,22 @@ export class ModelResult {
|
|
|
323
333
|
result: { error: errorMessage },
|
|
324
334
|
});
|
|
325
335
|
}
|
|
326
|
-
|
|
327
|
-
type: '
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
336
|
+
return {
|
|
337
|
+
type: 'parse_error',
|
|
338
|
+
toolCall,
|
|
339
|
+
output: {
|
|
340
|
+
type: 'function_call_output',
|
|
341
|
+
id: `output_${toolCall.id}`,
|
|
342
|
+
callId: toolCall.id,
|
|
343
|
+
output: JSON.stringify({ error: errorMessage }),
|
|
344
|
+
},
|
|
345
|
+
};
|
|
333
346
|
}
|
|
334
|
-
// Track preliminary results for this specific tool call
|
|
335
347
|
const preliminaryResultsForCall = [];
|
|
336
|
-
// Create callback for real-time preliminary results
|
|
337
348
|
const onPreliminaryResult = this.toolEventBroadcaster
|
|
338
349
|
? (callId, resultValue) => {
|
|
339
|
-
// Track preliminary results for the tool.result event
|
|
340
350
|
const typedResult = resultValue;
|
|
341
351
|
preliminaryResultsForCall.push(typedResult);
|
|
342
|
-
// Emit preliminary result event
|
|
343
352
|
this.toolEventBroadcaster?.push({
|
|
344
353
|
type: 'preliminary_result',
|
|
345
354
|
toolCallId: callId,
|
|
@@ -348,23 +357,66 @@ export class ModelResult {
|
|
|
348
357
|
}
|
|
349
358
|
: undefined;
|
|
350
359
|
const result = await executeTool(tool, toolCall, turnContext, onPreliminaryResult);
|
|
351
|
-
|
|
360
|
+
return {
|
|
361
|
+
type: 'execution',
|
|
362
|
+
toolCall,
|
|
363
|
+
tool,
|
|
364
|
+
result,
|
|
365
|
+
preliminaryResultsForCall,
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
const settledResults = await Promise.allSettled(toolCallPromises);
|
|
369
|
+
const toolResults = [];
|
|
370
|
+
for (let i = 0; i < settledResults.length; i++) {
|
|
371
|
+
const settled = settledResults[i];
|
|
372
|
+
const originalToolCall = toolCalls[i];
|
|
373
|
+
if (!settled || !originalToolCall)
|
|
374
|
+
continue;
|
|
375
|
+
if (settled.status === 'rejected') {
|
|
376
|
+
const errorMessage = settled.reason instanceof Error
|
|
377
|
+
? settled.reason.message
|
|
378
|
+
: String(settled.reason);
|
|
379
|
+
if (this.toolEventBroadcaster) {
|
|
380
|
+
this.toolEventBroadcaster.push({
|
|
381
|
+
type: 'tool_result',
|
|
382
|
+
toolCallId: originalToolCall.id,
|
|
383
|
+
result: { error: errorMessage },
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
toolResults.push({
|
|
387
|
+
type: 'function_call_output',
|
|
388
|
+
id: `output_${originalToolCall.id}`,
|
|
389
|
+
callId: originalToolCall.id,
|
|
390
|
+
output: JSON.stringify({ error: errorMessage }),
|
|
391
|
+
});
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const value = settled.value;
|
|
395
|
+
if (!value)
|
|
396
|
+
continue;
|
|
397
|
+
if (value.type === 'parse_error') {
|
|
398
|
+
toolResults.push(value.output);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
352
401
|
if (this.toolEventBroadcaster) {
|
|
353
|
-
|
|
402
|
+
this.toolEventBroadcaster.push({
|
|
354
403
|
type: 'tool_result',
|
|
355
|
-
toolCallId: toolCall.id,
|
|
356
|
-
result: (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
404
|
+
toolCallId: value.toolCall.id,
|
|
405
|
+
result: (value.result.error
|
|
406
|
+
? { error: value.result.error.message }
|
|
407
|
+
: value.result.result),
|
|
408
|
+
...(value.preliminaryResultsForCall.length > 0 && {
|
|
409
|
+
preliminaryResults: value.preliminaryResultsForCall,
|
|
410
|
+
}),
|
|
411
|
+
});
|
|
360
412
|
}
|
|
361
413
|
toolResults.push({
|
|
362
414
|
type: 'function_call_output',
|
|
363
|
-
id: `output_${toolCall.id}`,
|
|
364
|
-
callId: toolCall.id,
|
|
365
|
-
output: result.error
|
|
366
|
-
? JSON.stringify({ error: result.error.message })
|
|
367
|
-
: JSON.stringify(result.result),
|
|
415
|
+
id: `output_${value.toolCall.id}`,
|
|
416
|
+
callId: value.toolCall.id,
|
|
417
|
+
output: value.result.error
|
|
418
|
+
? JSON.stringify({ error: value.result.error.message })
|
|
419
|
+
: JSON.stringify(value.result.result),
|
|
368
420
|
});
|
|
369
421
|
}
|
|
370
422
|
return toolResults;
|
|
@@ -437,7 +489,7 @@ export class ModelResult {
|
|
|
437
489
|
...this.resolvedRequest,
|
|
438
490
|
stream: false,
|
|
439
491
|
};
|
|
440
|
-
const newResult = await betaResponsesSend(this.options.client, newRequest, this.options.options);
|
|
492
|
+
const newResult = await betaResponsesSend(this.options.client, { openResponsesRequest: newRequest }, this.options.options);
|
|
441
493
|
if (!newResult.ok) {
|
|
442
494
|
throw newResult.error;
|
|
443
495
|
}
|
|
@@ -590,7 +642,7 @@ export class ModelResult {
|
|
|
590
642
|
// Force stream mode for initial request
|
|
591
643
|
const request = this.resolvedRequest;
|
|
592
644
|
// Make the API request
|
|
593
|
-
const apiResult = await betaResponsesSend(this.options.client, request, this.options.options);
|
|
645
|
+
const apiResult = await betaResponsesSend(this.options.client, { openResponsesRequest: request }, this.options.options);
|
|
594
646
|
if (!apiResult.ok) {
|
|
595
647
|
throw apiResult.error;
|
|
596
648
|
}
|
|
@@ -713,7 +765,7 @@ export class ModelResult {
|
|
|
713
765
|
};
|
|
714
766
|
this.resolvedRequest = request;
|
|
715
767
|
// Make the API request
|
|
716
|
-
const apiResult = await betaResponsesSend(this.options.client, request, this.options.options);
|
|
768
|
+
const apiResult = await betaResponsesSend(this.options.client, { openResponsesRequest: request }, this.options.options);
|
|
717
769
|
if (!apiResult.ok) {
|
|
718
770
|
throw apiResult.error;
|
|
719
771
|
}
|
|
@@ -1,66 +1,77 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
2
3
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { AssistantMessageImages, AssistantMessageImages$Outbound } from "./assistantmessageimages.js";
|
|
3
5
|
import { ChatMessageContentItem, ChatMessageContentItem$Outbound } from "./chatmessagecontentitem.js";
|
|
4
6
|
import { ChatMessageToolCall, ChatMessageToolCall$Outbound } from "./chatmessagetoolcall.js";
|
|
5
7
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
6
|
-
import {
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
url: string;
|
|
10
|
-
};
|
|
11
|
-
export type Image = {
|
|
12
|
-
imageUrl: AssistantMessageImageUrl;
|
|
8
|
+
import { ReasoningDetailUnion, ReasoningDetailUnion$Outbound } from "./reasoningdetailunion.js";
|
|
9
|
+
export declare const AssistantMessageRole: {
|
|
10
|
+
readonly Assistant: "assistant";
|
|
13
11
|
};
|
|
12
|
+
export type AssistantMessageRole = ClosedEnum<typeof AssistantMessageRole>;
|
|
13
|
+
/**
|
|
14
|
+
* Assistant message content
|
|
15
|
+
*/
|
|
16
|
+
export type AssistantMessageContent = string | Array<ChatMessageContentItem> | any;
|
|
17
|
+
/**
|
|
18
|
+
* Assistant message for requests and responses
|
|
19
|
+
*/
|
|
14
20
|
export type AssistantMessage = {
|
|
15
|
-
role:
|
|
16
|
-
|
|
21
|
+
role: AssistantMessageRole;
|
|
22
|
+
/**
|
|
23
|
+
* Assistant message content
|
|
24
|
+
*/
|
|
25
|
+
content?: string | Array<ChatMessageContentItem> | any | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Optional name for the assistant
|
|
28
|
+
*/
|
|
17
29
|
name?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Tool calls made by the assistant
|
|
32
|
+
*/
|
|
18
33
|
toolCalls?: Array<ChatMessageToolCall> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Refusal message if content was refused
|
|
36
|
+
*/
|
|
19
37
|
refusal?: string | null | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Reasoning output
|
|
40
|
+
*/
|
|
20
41
|
reasoning?: string | null | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Reasoning details for extended thinking models
|
|
44
|
+
*/
|
|
45
|
+
reasoningDetails?: Array<ReasoningDetailUnion> | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Generated images from image generation models
|
|
48
|
+
*/
|
|
49
|
+
images?: Array<AssistantMessageImages> | undefined;
|
|
23
50
|
};
|
|
24
51
|
/** @internal */
|
|
52
|
+
export declare const AssistantMessageRole$inboundSchema: z.ZodEnum<typeof AssistantMessageRole>;
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare const AssistantMessageRole$outboundSchema: z.ZodEnum<typeof AssistantMessageRole>;
|
|
55
|
+
/** @internal */
|
|
25
56
|
export declare const AssistantMessageContent$inboundSchema: z.ZodType<AssistantMessageContent, unknown>;
|
|
26
57
|
/** @internal */
|
|
27
|
-
export type AssistantMessageContent$Outbound = string | Array<ChatMessageContentItem$Outbound
|
|
58
|
+
export type AssistantMessageContent$Outbound = string | Array<ChatMessageContentItem$Outbound> | any;
|
|
28
59
|
/** @internal */
|
|
29
60
|
export declare const AssistantMessageContent$outboundSchema: z.ZodType<AssistantMessageContent$Outbound, AssistantMessageContent>;
|
|
30
61
|
export declare function assistantMessageContentToJSON(assistantMessageContent: AssistantMessageContent): string;
|
|
31
62
|
export declare function assistantMessageContentFromJSON(jsonString: string): SafeParseResult<AssistantMessageContent, SDKValidationError>;
|
|
32
63
|
/** @internal */
|
|
33
|
-
export declare const AssistantMessageImageUrl$inboundSchema: z.ZodType<AssistantMessageImageUrl, unknown>;
|
|
34
|
-
/** @internal */
|
|
35
|
-
export type AssistantMessageImageUrl$Outbound = {
|
|
36
|
-
url: string;
|
|
37
|
-
};
|
|
38
|
-
/** @internal */
|
|
39
|
-
export declare const AssistantMessageImageUrl$outboundSchema: z.ZodType<AssistantMessageImageUrl$Outbound, AssistantMessageImageUrl>;
|
|
40
|
-
export declare function assistantMessageImageUrlToJSON(assistantMessageImageUrl: AssistantMessageImageUrl): string;
|
|
41
|
-
export declare function assistantMessageImageUrlFromJSON(jsonString: string): SafeParseResult<AssistantMessageImageUrl, SDKValidationError>;
|
|
42
|
-
/** @internal */
|
|
43
|
-
export declare const Image$inboundSchema: z.ZodType<Image, unknown>;
|
|
44
|
-
/** @internal */
|
|
45
|
-
export type Image$Outbound = {
|
|
46
|
-
image_url: AssistantMessageImageUrl$Outbound;
|
|
47
|
-
};
|
|
48
|
-
/** @internal */
|
|
49
|
-
export declare const Image$outboundSchema: z.ZodType<Image$Outbound, Image>;
|
|
50
|
-
export declare function imageToJSON(image: Image): string;
|
|
51
|
-
export declare function imageFromJSON(jsonString: string): SafeParseResult<Image, SDKValidationError>;
|
|
52
|
-
/** @internal */
|
|
53
64
|
export declare const AssistantMessage$inboundSchema: z.ZodType<AssistantMessage, unknown>;
|
|
54
65
|
/** @internal */
|
|
55
66
|
export type AssistantMessage$Outbound = {
|
|
56
|
-
role:
|
|
57
|
-
content?: string | Array<ChatMessageContentItem$Outbound> | null | undefined;
|
|
67
|
+
role: string;
|
|
68
|
+
content?: string | Array<ChatMessageContentItem$Outbound> | any | null | undefined;
|
|
58
69
|
name?: string | undefined;
|
|
59
70
|
tool_calls?: Array<ChatMessageToolCall$Outbound> | undefined;
|
|
60
71
|
refusal?: string | null | undefined;
|
|
61
72
|
reasoning?: string | null | undefined;
|
|
62
|
-
reasoning_details?: Array<
|
|
63
|
-
images?: Array<
|
|
73
|
+
reasoning_details?: Array<ReasoningDetailUnion$Outbound> | undefined;
|
|
74
|
+
images?: Array<AssistantMessageImages$Outbound> | undefined;
|
|
64
75
|
};
|
|
65
76
|
/** @internal */
|
|
66
77
|
export declare const AssistantMessage$outboundSchema: z.ZodType<AssistantMessage$Outbound, AssistantMessage>;
|