@openrouter/sdk 0.3.12 → 0.3.15
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/esm/funcs/analyticsGetUserActivity.d.ts +1 -1
- package/esm/funcs/analyticsGetUserActivity.js +1 -1
- package/esm/funcs/apiKeysCreate.d.ts +3 -0
- package/esm/funcs/apiKeysCreate.js +3 -0
- package/esm/funcs/apiKeysDelete.d.ts +3 -0
- package/esm/funcs/apiKeysDelete.js +3 -0
- package/esm/funcs/apiKeysGet.d.ts +3 -0
- package/esm/funcs/apiKeysGet.js +3 -0
- package/esm/funcs/apiKeysList.d.ts +3 -0
- package/esm/funcs/apiKeysList.js +3 -0
- package/esm/funcs/apiKeysUpdate.d.ts +3 -0
- package/esm/funcs/apiKeysUpdate.js +3 -0
- package/esm/funcs/call-model.js +9 -6
- package/esm/funcs/creditsGetCredits.d.ts +1 -1
- package/esm/funcs/creditsGetCredits.js +1 -1
- package/esm/funcs/guardrailsBulkAssignKeys.d.ts +18 -0
- package/esm/funcs/guardrailsBulkAssignKeys.js +89 -0
- package/esm/funcs/guardrailsBulkAssignMembers.d.ts +18 -0
- package/esm/funcs/guardrailsBulkAssignMembers.js +89 -0
- package/esm/funcs/guardrailsBulkUnassignKeys.d.ts +18 -0
- package/esm/funcs/guardrailsBulkUnassignKeys.js +89 -0
- package/esm/funcs/guardrailsBulkUnassignMembers.d.ts +18 -0
- package/esm/funcs/guardrailsBulkUnassignMembers.js +89 -0
- package/esm/funcs/guardrailsCreate.d.ts +18 -0
- package/esm/funcs/guardrailsCreate.js +83 -0
- package/esm/funcs/guardrailsDelete.d.ts +18 -0
- package/esm/funcs/guardrailsDelete.js +88 -0
- package/esm/funcs/{parametersGetParameters.d.ts → guardrailsGet.d.ts} +6 -3
- package/esm/funcs/guardrailsGet.js +88 -0
- package/esm/funcs/guardrailsList.d.ts +18 -0
- package/esm/funcs/guardrailsList.js +87 -0
- package/esm/funcs/guardrailsListGuardrailKeyAssignments.d.ts +18 -0
- package/esm/funcs/guardrailsListGuardrailKeyAssignments.js +93 -0
- package/esm/funcs/guardrailsListGuardrailMemberAssignments.d.ts +18 -0
- package/esm/funcs/guardrailsListGuardrailMemberAssignments.js +93 -0
- package/esm/funcs/guardrailsListKeyAssignments.d.ts +18 -0
- package/esm/funcs/guardrailsListKeyAssignments.js +87 -0
- package/esm/funcs/guardrailsListMemberAssignments.d.ts +18 -0
- package/esm/funcs/guardrailsListMemberAssignments.js +87 -0
- package/esm/funcs/guardrailsUpdate.d.ts +18 -0
- package/esm/funcs/{parametersGetParameters.js → guardrailsUpdate.js} +24 -32
- package/esm/index.d.ts +4 -3
- package/esm/index.js +3 -1
- package/esm/lib/anthropic-compat.test.js +3 -0
- package/esm/lib/async-params.d.ts +46 -6
- package/esm/lib/async-params.js +10 -2
- package/esm/lib/chat-compat.test.js +3 -0
- package/esm/lib/config.d.ts +2 -4
- package/esm/lib/config.js +2 -2
- package/esm/lib/conversation-state.d.ts +61 -0
- package/esm/lib/conversation-state.js +207 -0
- package/esm/lib/model-result.d.ts +175 -2
- package/esm/lib/model-result.js +678 -181
- package/esm/lib/tool-types.d.ts +109 -1
- package/esm/lib/tool-types.js +13 -0
- package/esm/lib/tool.d.ts +21 -1
- package/esm/lib/tool.js +7 -0
- package/esm/models/assistantmessage.d.ts +31 -0
- package/esm/models/assistantmessage.js +43 -0
- package/esm/models/chatgenerationparams.d.ts +93 -12
- package/esm/models/chatgenerationparams.js +75 -6
- package/esm/models/chatgenerationtokenusage.d.ts +1 -0
- package/esm/models/chatgenerationtokenusage.js +2 -0
- package/esm/models/chatmessagecontentitemimage.d.ts +8 -8
- package/esm/models/chatmessagecontentitemimage.js +8 -9
- package/esm/models/chatmessagetokenlogprob.d.ts +4 -4
- package/esm/models/chatmessagetokenlogprob.js +4 -5
- package/esm/models/chatresponsechoice.d.ts +0 -2
- package/esm/models/chatresponsechoice.js +0 -3
- package/esm/models/chatstreamingmessagechunk.d.ts +2 -2
- package/esm/models/chatstreamingmessagechunk.js +2 -2
- package/esm/models/index.d.ts +8 -1
- package/esm/models/index.js +8 -1
- package/esm/models/model.d.ts +4 -0
- package/esm/models/model.js +2 -0
- package/esm/models/openairesponsesinputunion.d.ts +15 -5
- package/esm/models/openairesponsesinputunion.js +5 -5
- package/esm/models/openresponseseasyinputmessage.d.ts +41 -16
- package/esm/models/openresponseseasyinputmessage.js +38 -13
- package/esm/models/openresponsesinputmessageitem.d.ts +37 -12
- package/esm/models/openresponsesinputmessageitem.js +33 -9
- package/esm/models/openresponsesnonstreamingresponse.d.ts +5 -2
- package/esm/models/openresponsesnonstreamingresponse.js +8 -2
- package/esm/models/openresponsesreasoning.d.ts +1 -0
- package/esm/models/openresponsesreasoning.js +1 -0
- package/esm/models/openresponsesrequest.d.ts +61 -24
- package/esm/models/openresponsesrequest.js +39 -6
- package/esm/models/operations/bulkassignkeystoguardrail.d.ts +44 -0
- package/esm/models/operations/bulkassignkeystoguardrail.js +42 -0
- package/esm/models/operations/bulkassignmemberstoguardrail.d.ts +44 -0
- package/esm/models/operations/bulkassignmemberstoguardrail.js +42 -0
- package/esm/models/operations/bulkunassignkeysfromguardrail.d.ts +44 -0
- package/esm/models/operations/bulkunassignkeysfromguardrail.js +42 -0
- package/esm/models/operations/bulkunassignmembersfromguardrail.d.ts +44 -0
- package/esm/models/operations/bulkunassignmembersfromguardrail.js +42 -0
- package/esm/models/operations/createguardrail.d.ts +136 -0
- package/esm/models/operations/createguardrail.js +85 -0
- package/esm/models/operations/deleteguardrail.d.ts +29 -0
- package/esm/models/operations/deleteguardrail.js +21 -0
- package/esm/models/operations/getgeneration.d.ts +4 -0
- package/esm/models/operations/getgeneration.js +1 -0
- package/esm/models/operations/getguardrail.d.ts +92 -0
- package/esm/models/operations/getguardrail.js +60 -0
- package/esm/models/operations/getmodels.d.ts +28 -1
- package/esm/models/operations/getmodels.js +22 -1
- package/esm/models/operations/index.d.ts +13 -1
- package/esm/models/operations/index.js +13 -1
- package/esm/models/operations/listguardrailkeyassignments.d.ts +76 -0
- package/esm/models/operations/listguardrailkeyassignments.js +51 -0
- package/esm/models/operations/listguardrailmemberassignments.d.ts +72 -0
- package/esm/models/operations/listguardrailmemberassignments.js +49 -0
- package/esm/models/operations/listguardrails.d.ts +98 -0
- package/esm/models/operations/listguardrails.js +66 -0
- package/esm/models/operations/listkeyassignments.d.ts +71 -0
- package/esm/models/operations/listkeyassignments.js +50 -0
- package/esm/models/operations/listmemberassignments.d.ts +67 -0
- package/esm/models/operations/listmemberassignments.js +48 -0
- package/esm/models/operations/updateguardrail.d.ts +151 -0
- package/esm/models/operations/updateguardrail.js +97 -0
- package/esm/models/percentilelatencycutoffs.d.ts +33 -0
- package/esm/models/percentilelatencycutoffs.js +16 -0
- package/esm/models/percentilestats.d.ts +28 -0
- package/esm/models/percentilestats.js +17 -0
- package/esm/models/percentilethroughputcutoffs.d.ts +33 -0
- package/esm/models/percentilethroughputcutoffs.js +16 -0
- package/esm/models/preferredmaxlatency.d.ts +12 -0
- package/esm/models/preferredmaxlatency.js +12 -0
- package/esm/models/preferredminthroughput.d.ts +12 -0
- package/esm/models/preferredminthroughput.js +12 -0
- package/esm/models/providername.d.ts +3 -2
- package/esm/models/providername.js +3 -2
- package/esm/models/providerpreferences.d.ts +8 -20
- package/esm/models/providerpreferences.js +6 -6
- package/esm/models/publicendpoint.d.ts +6 -0
- package/esm/models/publicendpoint.js +5 -0
- package/esm/models/responseinputimage.d.ts +11 -3
- package/esm/models/responseinputimage.js +9 -2
- package/esm/models/responseinputvideo.d.ts +20 -0
- package/esm/models/responseinputvideo.js +19 -0
- package/esm/models/responseoutputtext.d.ts +38 -0
- package/esm/models/responseoutputtext.js +50 -0
- package/esm/models/responsesoutputitemreasoning.d.ts +30 -1
- package/esm/models/responsesoutputitemreasoning.js +22 -0
- package/esm/models/responsesoutputmodality.d.ts +10 -0
- package/esm/models/responsesoutputmodality.js +12 -0
- package/esm/models/schema0.d.ts +3 -2
- package/esm/models/schema0.js +3 -2
- package/esm/models/schema2.d.ts +92 -0
- package/esm/models/schema2.js +109 -0
- package/esm/sdk/analytics.d.ts +1 -1
- package/esm/sdk/analytics.js +1 -1
- package/esm/sdk/apikeys.d.ts +15 -0
- package/esm/sdk/apikeys.js +15 -0
- package/esm/sdk/credits.d.ts +1 -1
- package/esm/sdk/credits.js +1 -1
- package/esm/sdk/guardrails.d.ts +96 -0
- package/esm/sdk/guardrails.js +139 -0
- package/esm/sdk/sdk.d.ts +3 -3
- package/esm/sdk/sdk.js +4 -4
- package/esm/types/index.d.ts +2 -0
- package/esm/types/index.js +1 -0
- package/esm/types/models.d.ts +25 -0
- package/esm/types/models.js +10 -0
- package/jsr.json +1 -1
- package/package.json +12 -10
- package/scripts/check-types.js +127 -0
- package/esm/models/operations/getparameters.d.ts +0 -87
- package/esm/models/operations/getparameters.js +0 -73
- package/esm/models/schema3.d.ts +0 -50
- package/esm/models/schema3.js +0 -61
- package/esm/sdk/parameters.d.ts +0 -9
- package/esm/sdk/parameters.js +0 -16
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
|
+
import * as operations from "../models/operations/index.js";
|
|
3
|
+
export declare class Guardrails extends ClientSDK {
|
|
4
|
+
/**
|
|
5
|
+
* List guardrails
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* List all guardrails for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
9
|
+
*/
|
|
10
|
+
list(request?: operations.ListGuardrailsRequest | undefined, options?: RequestOptions): Promise<operations.ListGuardrailsResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Create a guardrail
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Create a new guardrail for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
16
|
+
*/
|
|
17
|
+
create(request: operations.CreateGuardrailRequest, options?: RequestOptions): Promise<operations.CreateGuardrailResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Get a guardrail
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Get a single guardrail by ID. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
23
|
+
*/
|
|
24
|
+
get(request: operations.GetGuardrailRequest, options?: RequestOptions): Promise<operations.GetGuardrailResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Update a guardrail
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Update an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
30
|
+
*/
|
|
31
|
+
update(request: operations.UpdateGuardrailRequest, options?: RequestOptions): Promise<operations.UpdateGuardrailResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Delete a guardrail
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Delete an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
37
|
+
*/
|
|
38
|
+
delete(request: operations.DeleteGuardrailRequest, options?: RequestOptions): Promise<operations.DeleteGuardrailResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* List all key assignments
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* List all API key guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
44
|
+
*/
|
|
45
|
+
listKeyAssignments(request?: operations.ListKeyAssignmentsRequest | undefined, options?: RequestOptions): Promise<operations.ListKeyAssignmentsResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* List all member assignments
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* List all organization member guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
51
|
+
*/
|
|
52
|
+
listMemberAssignments(request?: operations.ListMemberAssignmentsRequest | undefined, options?: RequestOptions): Promise<operations.ListMemberAssignmentsResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* List key assignments for a guardrail
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* List all API key assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
58
|
+
*/
|
|
59
|
+
listGuardrailKeyAssignments(request: operations.ListGuardrailKeyAssignmentsRequest, options?: RequestOptions): Promise<operations.ListGuardrailKeyAssignmentsResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Bulk assign keys to a guardrail
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* Assign multiple API keys to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
65
|
+
*/
|
|
66
|
+
bulkAssignKeys(request: operations.BulkAssignKeysToGuardrailRequest, options?: RequestOptions): Promise<operations.BulkAssignKeysToGuardrailResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* List member assignments for a guardrail
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* List all organization member assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
72
|
+
*/
|
|
73
|
+
listGuardrailMemberAssignments(request: operations.ListGuardrailMemberAssignmentsRequest, options?: RequestOptions): Promise<operations.ListGuardrailMemberAssignmentsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Bulk assign members to a guardrail
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Assign multiple organization members to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
79
|
+
*/
|
|
80
|
+
bulkAssignMembers(request: operations.BulkAssignMembersToGuardrailRequest, options?: RequestOptions): Promise<operations.BulkAssignMembersToGuardrailResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Bulk unassign keys from a guardrail
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* Unassign multiple API keys from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
86
|
+
*/
|
|
87
|
+
bulkUnassignKeys(request: operations.BulkUnassignKeysFromGuardrailRequest, options?: RequestOptions): Promise<operations.BulkUnassignKeysFromGuardrailResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Bulk unassign members from a guardrail
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Unassign multiple organization members from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
93
|
+
*/
|
|
94
|
+
bulkUnassignMembers(request: operations.BulkUnassignMembersFromGuardrailRequest, options?: RequestOptions): Promise<operations.BulkUnassignMembersFromGuardrailResponse>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=guardrails.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: c4e976dbf057
|
|
4
|
+
*/
|
|
5
|
+
import { guardrailsBulkAssignKeys } from "../funcs/guardrailsBulkAssignKeys.js";
|
|
6
|
+
import { guardrailsBulkAssignMembers } from "../funcs/guardrailsBulkAssignMembers.js";
|
|
7
|
+
import { guardrailsBulkUnassignKeys } from "../funcs/guardrailsBulkUnassignKeys.js";
|
|
8
|
+
import { guardrailsBulkUnassignMembers } from "../funcs/guardrailsBulkUnassignMembers.js";
|
|
9
|
+
import { guardrailsCreate } from "../funcs/guardrailsCreate.js";
|
|
10
|
+
import { guardrailsDelete } from "../funcs/guardrailsDelete.js";
|
|
11
|
+
import { guardrailsGet } from "../funcs/guardrailsGet.js";
|
|
12
|
+
import { guardrailsList } from "../funcs/guardrailsList.js";
|
|
13
|
+
import { guardrailsListGuardrailKeyAssignments } from "../funcs/guardrailsListGuardrailKeyAssignments.js";
|
|
14
|
+
import { guardrailsListGuardrailMemberAssignments } from "../funcs/guardrailsListGuardrailMemberAssignments.js";
|
|
15
|
+
import { guardrailsListKeyAssignments } from "../funcs/guardrailsListKeyAssignments.js";
|
|
16
|
+
import { guardrailsListMemberAssignments } from "../funcs/guardrailsListMemberAssignments.js";
|
|
17
|
+
import { guardrailsUpdate } from "../funcs/guardrailsUpdate.js";
|
|
18
|
+
import { ClientSDK } from "../lib/sdks.js";
|
|
19
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
20
|
+
export class Guardrails extends ClientSDK {
|
|
21
|
+
/**
|
|
22
|
+
* List guardrails
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* List all guardrails for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
26
|
+
*/
|
|
27
|
+
async list(request, options) {
|
|
28
|
+
return unwrapAsync(guardrailsList(this, request, options));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a guardrail
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Create a new guardrail for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
35
|
+
*/
|
|
36
|
+
async create(request, options) {
|
|
37
|
+
return unwrapAsync(guardrailsCreate(this, request, options));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a guardrail
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Get a single guardrail by ID. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
44
|
+
*/
|
|
45
|
+
async get(request, options) {
|
|
46
|
+
return unwrapAsync(guardrailsGet(this, request, options));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update a guardrail
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Update an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
53
|
+
*/
|
|
54
|
+
async update(request, options) {
|
|
55
|
+
return unwrapAsync(guardrailsUpdate(this, request, options));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Delete a guardrail
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Delete an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
62
|
+
*/
|
|
63
|
+
async delete(request, options) {
|
|
64
|
+
return unwrapAsync(guardrailsDelete(this, request, options));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* List all key assignments
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* List all API key guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
71
|
+
*/
|
|
72
|
+
async listKeyAssignments(request, options) {
|
|
73
|
+
return unwrapAsync(guardrailsListKeyAssignments(this, request, options));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* List all member assignments
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* List all organization member guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
80
|
+
*/
|
|
81
|
+
async listMemberAssignments(request, options) {
|
|
82
|
+
return unwrapAsync(guardrailsListMemberAssignments(this, request, options));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* List key assignments for a guardrail
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* List all API key assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
89
|
+
*/
|
|
90
|
+
async listGuardrailKeyAssignments(request, options) {
|
|
91
|
+
return unwrapAsync(guardrailsListGuardrailKeyAssignments(this, request, options));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Bulk assign keys to a guardrail
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Assign multiple API keys to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
98
|
+
*/
|
|
99
|
+
async bulkAssignKeys(request, options) {
|
|
100
|
+
return unwrapAsync(guardrailsBulkAssignKeys(this, request, options));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* List member assignments for a guardrail
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* List all organization member assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
107
|
+
*/
|
|
108
|
+
async listGuardrailMemberAssignments(request, options) {
|
|
109
|
+
return unwrapAsync(guardrailsListGuardrailMemberAssignments(this, request, options));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bulk assign members to a guardrail
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Assign multiple organization members to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
116
|
+
*/
|
|
117
|
+
async bulkAssignMembers(request, options) {
|
|
118
|
+
return unwrapAsync(guardrailsBulkAssignMembers(this, request, options));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Bulk unassign keys from a guardrail
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Unassign multiple API keys from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
125
|
+
*/
|
|
126
|
+
async bulkUnassignKeys(request, options) {
|
|
127
|
+
return unwrapAsync(guardrailsBulkUnassignKeys(this, request, options));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Bulk unassign members from a guardrail
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* Unassign multiple organization members from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
|
|
134
|
+
*/
|
|
135
|
+
async bulkUnassignMembers(request, options) {
|
|
136
|
+
return unwrapAsync(guardrailsBulkUnassignMembers(this, request, options));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=guardrails.js.map
|
package/esm/sdk/sdk.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import { Credits } from "./credits.js";
|
|
|
8
8
|
import { Embeddings } from "./embeddings.js";
|
|
9
9
|
import { Endpoints } from "./endpoints.js";
|
|
10
10
|
import { Generations } from "./generations.js";
|
|
11
|
+
import { Guardrails } from "./guardrails.js";
|
|
11
12
|
import { Models } from "./models.js";
|
|
12
13
|
import { OAuth } from "./oauth.js";
|
|
13
|
-
import { ParametersT } from "./parameters.js";
|
|
14
14
|
import { Providers } from "./providers.js";
|
|
15
15
|
import { type CallModelInput } from "../funcs/call-model.js";
|
|
16
16
|
import type { ModelResult } from "../lib/model-result.js";
|
|
@@ -32,12 +32,12 @@ export declare class OpenRouter extends ClientSDK {
|
|
|
32
32
|
get models(): Models;
|
|
33
33
|
private _endpoints?;
|
|
34
34
|
get endpoints(): Endpoints;
|
|
35
|
-
private _parameters?;
|
|
36
|
-
get parameters(): ParametersT;
|
|
37
35
|
private _providers?;
|
|
38
36
|
get providers(): Providers;
|
|
39
37
|
private _apiKeys?;
|
|
40
38
|
get apiKeys(): APIKeys;
|
|
39
|
+
private _guardrails?;
|
|
40
|
+
get guardrails(): Guardrails;
|
|
41
41
|
private _oAuth?;
|
|
42
42
|
get oAuth(): OAuth;
|
|
43
43
|
private _chat?;
|
package/esm/sdk/sdk.js
CHANGED
|
@@ -12,9 +12,9 @@ import { Credits } from "./credits.js";
|
|
|
12
12
|
import { Embeddings } from "./embeddings.js";
|
|
13
13
|
import { Endpoints } from "./endpoints.js";
|
|
14
14
|
import { Generations } from "./generations.js";
|
|
15
|
+
import { Guardrails } from "./guardrails.js";
|
|
15
16
|
import { Models } from "./models.js";
|
|
16
17
|
import { OAuth } from "./oauth.js";
|
|
17
|
-
import { ParametersT } from "./parameters.js";
|
|
18
18
|
import { Providers } from "./providers.js";
|
|
19
19
|
// #region imports
|
|
20
20
|
import { callModel as callModelFunc, } from "../funcs/call-model.js";
|
|
@@ -43,15 +43,15 @@ export class OpenRouter extends ClientSDK {
|
|
|
43
43
|
get endpoints() {
|
|
44
44
|
return (this._endpoints ?? (this._endpoints = new Endpoints(this._options)));
|
|
45
45
|
}
|
|
46
|
-
get parameters() {
|
|
47
|
-
return (this._parameters ?? (this._parameters = new ParametersT(this._options)));
|
|
48
|
-
}
|
|
49
46
|
get providers() {
|
|
50
47
|
return (this._providers ?? (this._providers = new Providers(this._options)));
|
|
51
48
|
}
|
|
52
49
|
get apiKeys() {
|
|
53
50
|
return (this._apiKeys ?? (this._apiKeys = new APIKeys(this._options)));
|
|
54
51
|
}
|
|
52
|
+
get guardrails() {
|
|
53
|
+
return (this._guardrails ?? (this._guardrails = new Guardrails(this._options)));
|
|
54
|
+
}
|
|
55
55
|
get oAuth() {
|
|
56
56
|
return (this._oAuth ?? (this._oAuth = new OAuth(this._options)));
|
|
57
57
|
}
|
package/esm/types/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export type { PageIterator, Paginator } from "./operations.js";
|
|
|
5
5
|
export { createPageIterator } from "./operations.js";
|
|
6
6
|
export { RFCDate } from "./rfcdate.js";
|
|
7
7
|
export * from "./unrecognized.js";
|
|
8
|
+
export type { ModelId, Variant, StaticVariant, VirtualVariant } from "./models.js";
|
|
9
|
+
export { MODEL_HASH } from "./models.js";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/types/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Union type of all available model IDs on OpenRouter.
|
|
3
|
+
* Includes base models and their variants (e.g., ":free", ":nitro").
|
|
4
|
+
*/
|
|
5
|
+
export type ModelId = 'ai21/jamba-large-1.7' | 'ai21/jamba-mini-1.7' | 'aion-labs/aion-1.0' | 'aion-labs/aion-1.0-mini' | 'aion-labs/aion-rp-llama-3.1-8b' | 'alfredpros/codellama-7b-instruct-solidity' | 'alibaba/tongyi-deepresearch-30b-a3b' | 'alibaba/tongyi-deepresearch-30b-a3b:free' | 'allenai/olmo-2-0325-32b-instruct' | 'allenai/olmo-3-32b-think:free' | 'allenai/olmo-3-7b-instruct' | 'allenai/olmo-3-7b-think' | 'allenai/olmo-3.1-32b-think:free' | 'alpindale/goliath-120b' | 'amazon/nova-2-lite-v1' | 'amazon/nova-lite-v1' | 'amazon/nova-micro-v1' | 'amazon/nova-premier-v1' | 'amazon/nova-pro-v1' | 'anthracite-org/magnum-v4-72b' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-haiku-20241022' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-3.7-sonnet:thinking' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/coder-large' | 'arcee-ai/maestro-reasoning' | 'arcee-ai/spotlight' | 'arcee-ai/trinity-mini' | 'arcee-ai/trinity-mini:free' | 'arcee-ai/virtuoso-large' | 'arliai/qwq-32b-arliai-rpr-v1' | 'baidu/ernie-4.5-21b-a3b' | 'baidu/ernie-4.5-21b-a3b-thinking' | 'baidu/ernie-4.5-300b-a47b' | 'baidu/ernie-4.5-vl-28b-a3b' | 'baidu/ernie-4.5-vl-424b-a47b' | 'bytedance/ui-tars-1.5-7b' | 'cognitivecomputations/dolphin-mistral-24b-venice-edition:free' | 'cohere/command-a' | 'cohere/command-r-08-2024' | 'cohere/command-r-plus-08-2024' | 'cohere/command-r7b-12-2024' | 'deepcogito/cogito-v2-preview-llama-109b-moe' | 'deepcogito/cogito-v2-preview-llama-405b' | 'deepcogito/cogito-v2-preview-llama-70b' | 'deepcogito/cogito-v2.1-671b' | 'deepseek/deepseek-chat' | 'deepseek/deepseek-chat-v3-0324' | 'deepseek/deepseek-chat-v3.1' | 'deepseek/deepseek-prover-v2' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-r1-0528' | 'deepseek/deepseek-r1-0528-qwen3-8b' | 'deepseek/deepseek-r1-0528:free' | 'deepseek/deepseek-r1-distill-llama-70b' | 'deepseek/deepseek-r1-distill-qwen-14b' | 'deepseek/deepseek-r1-distill-qwen-32b' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.1-terminus:exacto' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-speciale' | 'eleutherai/llemma_7b' | 'essentialai/rnj-1-instruct' | 'google/gemini-2.0-flash-001' | 'google/gemini-2.0-flash-exp:free' | 'google/gemini-2.0-flash-lite-001' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-2.5-pro-preview' | 'google/gemini-2.5-pro-preview-05-06' | 'google/gemini-3-flash-preview' | 'google/gemini-3-pro-image-preview' | 'google/gemini-3-pro-preview' | 'google/gemma-2-27b-it' | 'google/gemma-2-9b-it' | 'google/gemma-3-12b-it' | 'google/gemma-3-12b-it:free' | 'google/gemma-3-27b-it' | 'google/gemma-3-27b-it:free' | 'google/gemma-3-4b-it' | 'google/gemma-3-4b-it:free' | 'google/gemma-3n-e2b-it:free' | 'google/gemma-3n-e4b-it' | 'google/gemma-3n-e4b-it:free' | 'gryphe/mythomax-l2-13b' | 'ibm-granite/granite-4.0-h-micro' | 'inception/mercury' | 'inception/mercury-coder' | 'inflection/inflection-3-pi' | 'inflection/inflection-3-productivity' | 'kwaipilot/kat-coder-pro:free' | 'liquid/lfm-2.2-6b' | 'liquid/lfm2-8b-a1b' | 'mancer/weaver' | 'meituan/longcat-flash-chat' | 'meta-llama/llama-3-70b-instruct' | 'meta-llama/llama-3-8b-instruct' | 'meta-llama/llama-3.1-405b' | 'meta-llama/llama-3.1-405b-instruct' | 'meta-llama/llama-3.1-405b-instruct:free' | 'meta-llama/llama-3.1-70b-instruct' | 'meta-llama/llama-3.1-8b-instruct' | 'meta-llama/llama-3.2-11b-vision-instruct' | 'meta-llama/llama-3.2-1b-instruct' | 'meta-llama/llama-3.2-3b-instruct' | 'meta-llama/llama-3.2-3b-instruct:free' | 'meta-llama/llama-3.2-90b-vision-instruct' | 'meta-llama/llama-3.3-70b-instruct' | 'meta-llama/llama-3.3-70b-instruct:free' | 'meta-llama/llama-4-maverick' | 'meta-llama/llama-4-scout' | 'meta-llama/llama-guard-2-8b' | 'meta-llama/llama-guard-3-8b' | 'meta-llama/llama-guard-4-12b' | 'microsoft/phi-3-medium-128k-instruct' | 'microsoft/phi-3-mini-128k-instruct' | 'microsoft/phi-3.5-mini-128k-instruct' | 'microsoft/phi-4' | 'microsoft/phi-4-multimodal-instruct' | 'microsoft/phi-4-reasoning-plus' | 'microsoft/wizardlm-2-8x22b' | 'minimax/minimax-01' | 'minimax/minimax-m1' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'mistralai/codestral-2508' | 'mistralai/devstral-2512' | 'mistralai/devstral-2512:free' | 'mistralai/devstral-medium' | 'mistralai/devstral-small' | 'mistralai/devstral-small-2505' | 'mistralai/ministral-14b-2512' | 'mistralai/ministral-3b' | 'mistralai/ministral-3b-2512' | 'mistralai/ministral-8b' | 'mistralai/ministral-8b-2512' | 'mistralai/mistral-7b-instruct' | 'mistralai/mistral-7b-instruct-v0.1' | 'mistralai/mistral-7b-instruct-v0.2' | 'mistralai/mistral-7b-instruct-v0.3' | 'mistralai/mistral-7b-instruct:free' | 'mistralai/mistral-large' | 'mistralai/mistral-large-2407' | 'mistralai/mistral-large-2411' | 'mistralai/mistral-large-2512' | 'mistralai/mistral-medium-3' | 'mistralai/mistral-medium-3.1' | 'mistralai/mistral-nemo' | 'mistralai/mistral-saba' | 'mistralai/mistral-small-24b-instruct-2501' | 'mistralai/mistral-small-3.1-24b-instruct' | 'mistralai/mistral-small-3.1-24b-instruct:free' | 'mistralai/mistral-small-3.2-24b-instruct' | 'mistralai/mistral-small-creative' | 'mistralai/mistral-tiny' | 'mistralai/mixtral-8x22b-instruct' | 'mistralai/mixtral-8x7b-instruct' | 'mistralai/pixtral-12b' | 'mistralai/pixtral-large-2411' | 'mistralai/voxtral-small-24b-2507' | 'moonshotai/kimi-dev-72b' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-0905:exacto' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2:free' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'neversleep/llama-3.1-lumimaid-8b' | 'neversleep/noromaid-20b' | 'nex-agi/deepseek-v3.1-nex-n1:free' | 'nousresearch/deephermes-3-mistral-24b-preview' | 'nousresearch/hermes-2-pro-llama-3-8b' | 'nousresearch/hermes-3-llama-3.1-405b' | 'nousresearch/hermes-3-llama-3.1-405b:free' | 'nousresearch/hermes-3-llama-3.1-70b' | 'nousresearch/hermes-4-405b' | 'nousresearch/hermes-4-70b' | 'nvidia/llama-3.1-nemotron-70b-instruct' | 'nvidia/llama-3.1-nemotron-ultra-253b-v1' | 'nvidia/llama-3.3-nemotron-super-49b-v1.5' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-3-nano-30b-a3b:free' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-12b-v2-vl:free' | 'nvidia/nemotron-nano-9b-v2' | 'nvidia/nemotron-nano-9b-v2:free' | 'openai/chatgpt-4o-latest' | 'openai/codex-mini' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-0613' | 'openai/gpt-3.5-turbo-16k' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4' | 'openai/gpt-4-0314' | 'openai/gpt-4-1106-preview' | 'openai/gpt-4-turbo' | 'openai/gpt-4-turbo-preview' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-2024-05-13' | 'openai/gpt-4o-2024-08-06' | 'openai/gpt-4o-2024-11-20' | 'openai/gpt-4o-audio-preview' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-2024-07-18' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-4o-search-preview' | 'openai/gpt-4o:extended' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-image' | 'openai/gpt-5-image-mini' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1' | 'openai/gpt-5.1-chat' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-120b:exacto' | 'openai/gpt-oss-120b:free' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-20b:free' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o1-pro' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-mini-high' | 'openai/o3-pro' | 'openai/o4-mini' | 'openai/o4-mini-deep-research' | 'openai/o4-mini-high' | 'opengvlab/internvl3-78b' | 'openrouter/auto' | 'openrouter/bodybuilder' | 'perplexity/sonar' | 'perplexity/sonar-deep-research' | 'perplexity/sonar-pro' | 'perplexity/sonar-pro-search' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'qwen/qwen-2.5-72b-instruct' | 'qwen/qwen-2.5-7b-instruct' | 'qwen/qwen-2.5-coder-32b-instruct' | 'qwen/qwen-2.5-vl-7b-instruct' | 'qwen/qwen-2.5-vl-7b-instruct:free' | 'qwen/qwen-max' | 'qwen/qwen-plus' | 'qwen/qwen-plus-2025-07-28' | 'qwen/qwen-plus-2025-07-28:thinking' | 'qwen/qwen-turbo' | 'qwen/qwen-vl-max' | 'qwen/qwen-vl-plus' | 'qwen/qwen2.5-coder-7b-instruct' | 'qwen/qwen2.5-vl-32b-instruct' | 'qwen/qwen2.5-vl-72b-instruct' | 'qwen/qwen3-14b' | 'qwen/qwen3-235b-a22b' | 'qwen/qwen3-235b-a22b-2507' | 'qwen/qwen3-235b-a22b-thinking-2507' | 'qwen/qwen3-30b-a3b' | 'qwen/qwen3-30b-a3b-instruct-2507' | 'qwen/qwen3-30b-a3b-thinking-2507' | 'qwen/qwen3-32b' | 'qwen/qwen3-4b:free' | 'qwen/qwen3-8b' | 'qwen/qwen3-coder' | 'qwen/qwen3-coder-30b-a3b-instruct' | 'qwen/qwen3-coder-flash' | 'qwen/qwen3-coder-plus' | 'qwen/qwen3-coder:exacto' | 'qwen/qwen3-coder:free' | 'qwen/qwen3-max' | 'qwen/qwen3-next-80b-a3b-instruct' | 'qwen/qwen3-next-80b-a3b-thinking' | 'qwen/qwen3-vl-235b-a22b-instruct' | 'qwen/qwen3-vl-235b-a22b-thinking' | 'qwen/qwen3-vl-30b-a3b-instruct' | 'qwen/qwen3-vl-30b-a3b-thinking' | 'qwen/qwen3-vl-32b-instruct' | 'qwen/qwen3-vl-8b-instruct' | 'qwen/qwen3-vl-8b-thinking' | 'qwen/qwq-32b' | 'raifle/sorcererlm-8x22b' | 'relace/relace-apply-3' | 'relace/relace-search' | 'sao10k/l3-euryale-70b' | 'sao10k/l3-lunaris-8b' | 'sao10k/l3.1-70b-hanami-x1' | 'sao10k/l3.1-euryale-70b' | 'sao10k/l3.3-euryale-70b' | 'stepfun-ai/step3' | 'switchpoint/router' | 'tencent/hunyuan-a13b-instruct' | 'thedrummer/cydonia-24b-v4.1' | 'thedrummer/rocinante-12b' | 'thedrummer/skyfall-36b-v2' | 'thedrummer/unslopnemo-12b' | 'thudm/glm-4.1v-9b-thinking' | 'tngtech/deepseek-r1t-chimera' | 'tngtech/deepseek-r1t-chimera:free' | 'tngtech/deepseek-r1t2-chimera' | 'tngtech/deepseek-r1t2-chimera:free' | 'tngtech/tng-r1t-chimera' | 'tngtech/tng-r1t-chimera:free' | 'undi95/remm-slerp-l2-13b' | 'x-ai/grok-3' | 'x-ai/grok-3-beta' | 'x-ai/grok-3-mini' | 'x-ai/grok-3-mini-beta' | 'x-ai/grok-4' | 'x-ai/grok-4-fast' | 'x-ai/grok-4.1-fast' | 'x-ai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash:free' | 'z-ai/glm-4-32b' | 'z-ai/glm-4.5' | 'z-ai/glm-4.5-air' | 'z-ai/glm-4.5-air:free' | 'z-ai/glm-4.5v' | 'z-ai/glm-4.6' | 'z-ai/glm-4.6:exacto' | 'z-ai/glm-4.6v' | 'z-ai/glm-4.7';
|
|
6
|
+
/**
|
|
7
|
+
* Static variants that create distinct model IDs.
|
|
8
|
+
* These are already present in the API response (e.g., "openai/gpt-4:free").
|
|
9
|
+
*/
|
|
10
|
+
export type StaticVariant = 'free' | 'extended' | 'exacto' | 'thinking';
|
|
11
|
+
/**
|
|
12
|
+
* Virtual variants used for routing hints.
|
|
13
|
+
* These do not create distinct model IDs but affect routing behavior.
|
|
14
|
+
*/
|
|
15
|
+
export type VirtualVariant = 'all' | 'online' | 'nitro' | 'floor';
|
|
16
|
+
/**
|
|
17
|
+
* All available variants.
|
|
18
|
+
*/
|
|
19
|
+
export type Variant = StaticVariant | VirtualVariant;
|
|
20
|
+
/**
|
|
21
|
+
* Hash of model IDs for staleness checking.
|
|
22
|
+
* Used by postinstall script to detect outdated types.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MODEL_HASH = "986e77d89072f654";
|
|
25
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Auto-generated by @openrouter/cli types
|
|
2
|
+
// Run `npx @openrouter/cli types` to regenerate
|
|
3
|
+
// Generated: 2025-12-23T14:49:53.976Z
|
|
4
|
+
// Model count: 351
|
|
5
|
+
/**
|
|
6
|
+
* Hash of model IDs for staleness checking.
|
|
7
|
+
* Used by postinstall script to detect outdated types.
|
|
8
|
+
*/
|
|
9
|
+
export const MODEL_HASH = '986e77d89072f654';
|
|
10
|
+
//# sourceMappingURL=models.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.",
|
|
6
6
|
"keywords": [
|
|
@@ -64,15 +64,17 @@
|
|
|
64
64
|
"type": "git",
|
|
65
65
|
"url": "https://github.com/OpenRouterTeam/typescript-sdk.git"
|
|
66
66
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
"scripts": {
|
|
68
|
+
"lint": "eslint --cache --max-warnings=0 src",
|
|
69
|
+
"build": "tsc",
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"prepublishOnly": "npm run build",
|
|
72
|
+
"postinstall": "node scripts/check-types.js || true",
|
|
73
|
+
"test": "vitest --run --project unit",
|
|
74
|
+
"test:e2e": "vitest --run --project e2e",
|
|
75
|
+
"test:watch": "vitest --watch --project unit"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {},
|
|
76
78
|
"devDependencies": {
|
|
77
79
|
"@eslint/js": "^9.19.0",
|
|
78
80
|
"@types/node": "^22.13.12",
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script to check if model types are stale.
|
|
4
|
+
* Similar to update-browserslist-db, this warns users when their
|
|
5
|
+
* generated types are outdated.
|
|
6
|
+
*
|
|
7
|
+
* This script:
|
|
8
|
+
* 1. Reads the MODEL_HASH from the generated types file
|
|
9
|
+
* 2. Fetches current models from the OpenRouter API
|
|
10
|
+
* 3. Computes a hash of the current models
|
|
11
|
+
* 4. Warns to stderr if the hashes don't match
|
|
12
|
+
*
|
|
13
|
+
* Exit codes:
|
|
14
|
+
* - 0: Types are up to date OR check was skipped
|
|
15
|
+
* - Does NOT fail on stale types (to avoid breaking installs)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { createHash } from 'node:crypto';
|
|
19
|
+
import { readFile } from 'node:fs/promises';
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { dirname, resolve } from 'node:path';
|
|
22
|
+
|
|
23
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
24
|
+
const __dirname = dirname(__filename);
|
|
25
|
+
|
|
26
|
+
const TYPES_FILE_PATH = resolve(__dirname, '../src/types/models.ts');
|
|
27
|
+
const API_URL = 'https://openrouter.ai/api/v1/models';
|
|
28
|
+
const TIMEOUT_MS = 5000;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Type guard for Node.js errors with error codes
|
|
32
|
+
* @param {unknown} error
|
|
33
|
+
* @returns {error is NodeJS.ErrnoException}
|
|
34
|
+
*/
|
|
35
|
+
function isNodeError(error) {
|
|
36
|
+
return error instanceof Error && 'code' in error;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Compute SHA-256 hash of sorted model IDs (first 16 chars)
|
|
41
|
+
* @param {string[]} modelIds
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
function computeHash(modelIds) {
|
|
45
|
+
const sorted = [...modelIds].sort();
|
|
46
|
+
const content = sorted.join('\n');
|
|
47
|
+
const hash = createHash('sha256').update(content).digest('hex');
|
|
48
|
+
return hash.substring(0, 16);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Extract MODEL_HASH from types file content
|
|
53
|
+
* @param {string} content
|
|
54
|
+
* @returns {string | null}
|
|
55
|
+
*/
|
|
56
|
+
function extractHash(content) {
|
|
57
|
+
const match = content.match(/export const MODEL_HASH = '([a-f0-9]+)'/);
|
|
58
|
+
return match ? match[1] : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fetch models from API with timeout
|
|
63
|
+
* @returns {Promise<string[]>}
|
|
64
|
+
*/
|
|
65
|
+
async function fetchModels() {
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timeout = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const response = await fetch(API_URL, { signal: controller.signal });
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new Error(`HTTP ${response.status}`);
|
|
73
|
+
}
|
|
74
|
+
const data = await response.json();
|
|
75
|
+
if (!data?.data || !Array.isArray(data.data)) {
|
|
76
|
+
throw new Error('Invalid API response structure');
|
|
77
|
+
}
|
|
78
|
+
return data.data.map((m) => m.id);
|
|
79
|
+
} finally {
|
|
80
|
+
clearTimeout(timeout);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function main() {
|
|
85
|
+
if (process.env.CI) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (process.env.OPENROUTER_SKIP_TYPE_CHECK) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
/** @type {string | null} */
|
|
95
|
+
let existingHash;
|
|
96
|
+
try {
|
|
97
|
+
const content = await readFile(TYPES_FILE_PATH, 'utf-8');
|
|
98
|
+
existingHash = extractHash(content);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (isNodeError(error) && error.code === 'ENOENT') {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!existingHash) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const modelIds = await fetchModels();
|
|
111
|
+
const currentHash = computeHash(modelIds);
|
|
112
|
+
|
|
113
|
+
if (existingHash !== currentHash) {
|
|
114
|
+
process.stderr.write(
|
|
115
|
+
'\n' +
|
|
116
|
+
'\x1b[33m' +
|
|
117
|
+
'OpenRouter model types are outdated.\n' +
|
|
118
|
+
'Run: npx @openrouter/cli types\n' +
|
|
119
|
+
'\x1b[0m',
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
} catch {
|
|
123
|
+
// Silently ignore errors - we don't want to break installs
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main();
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v4";
|
|
2
|
-
import { OpenEnum } from "../../types/enums.js";
|
|
3
|
-
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
4
|
-
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
5
|
-
import * as models from "../index.js";
|
|
6
|
-
export type GetParametersSecurity = {
|
|
7
|
-
bearer: string;
|
|
8
|
-
};
|
|
9
|
-
export type GetParametersRequest = {
|
|
10
|
-
author: string;
|
|
11
|
-
slug: string;
|
|
12
|
-
provider?: models.ProviderName | undefined;
|
|
13
|
-
};
|
|
14
|
-
export declare const SupportedParameter: {
|
|
15
|
-
readonly Temperature: "temperature";
|
|
16
|
-
readonly TopP: "top_p";
|
|
17
|
-
readonly TopK: "top_k";
|
|
18
|
-
readonly MinP: "min_p";
|
|
19
|
-
readonly TopA: "top_a";
|
|
20
|
-
readonly FrequencyPenalty: "frequency_penalty";
|
|
21
|
-
readonly PresencePenalty: "presence_penalty";
|
|
22
|
-
readonly RepetitionPenalty: "repetition_penalty";
|
|
23
|
-
readonly MaxTokens: "max_tokens";
|
|
24
|
-
readonly LogitBias: "logit_bias";
|
|
25
|
-
readonly Logprobs: "logprobs";
|
|
26
|
-
readonly TopLogprobs: "top_logprobs";
|
|
27
|
-
readonly Seed: "seed";
|
|
28
|
-
readonly ResponseFormat: "response_format";
|
|
29
|
-
readonly StructuredOutputs: "structured_outputs";
|
|
30
|
-
readonly Stop: "stop";
|
|
31
|
-
readonly Tools: "tools";
|
|
32
|
-
readonly ToolChoice: "tool_choice";
|
|
33
|
-
readonly ParallelToolCalls: "parallel_tool_calls";
|
|
34
|
-
readonly IncludeReasoning: "include_reasoning";
|
|
35
|
-
readonly Reasoning: "reasoning";
|
|
36
|
-
readonly ReasoningEffort: "reasoning_effort";
|
|
37
|
-
readonly WebSearchOptions: "web_search_options";
|
|
38
|
-
readonly Verbosity: "verbosity";
|
|
39
|
-
};
|
|
40
|
-
export type SupportedParameter = OpenEnum<typeof SupportedParameter>;
|
|
41
|
-
/**
|
|
42
|
-
* Parameter analytics data
|
|
43
|
-
*/
|
|
44
|
-
export type GetParametersData = {
|
|
45
|
-
/**
|
|
46
|
-
* Model identifier
|
|
47
|
-
*/
|
|
48
|
-
model: string;
|
|
49
|
-
/**
|
|
50
|
-
* List of parameters supported by this model
|
|
51
|
-
*/
|
|
52
|
-
supportedParameters: Array<SupportedParameter>;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Returns the parameters for the specified model
|
|
56
|
-
*/
|
|
57
|
-
export type GetParametersResponse = {
|
|
58
|
-
/**
|
|
59
|
-
* Parameter analytics data
|
|
60
|
-
*/
|
|
61
|
-
data: GetParametersData;
|
|
62
|
-
};
|
|
63
|
-
/** @internal */
|
|
64
|
-
export type GetParametersSecurity$Outbound = {
|
|
65
|
-
bearer: string;
|
|
66
|
-
};
|
|
67
|
-
/** @internal */
|
|
68
|
-
export declare const GetParametersSecurity$outboundSchema: z.ZodType<GetParametersSecurity$Outbound, GetParametersSecurity>;
|
|
69
|
-
export declare function getParametersSecurityToJSON(getParametersSecurity: GetParametersSecurity): string;
|
|
70
|
-
/** @internal */
|
|
71
|
-
export type GetParametersRequest$Outbound = {
|
|
72
|
-
author: string;
|
|
73
|
-
slug: string;
|
|
74
|
-
provider?: string | undefined;
|
|
75
|
-
};
|
|
76
|
-
/** @internal */
|
|
77
|
-
export declare const GetParametersRequest$outboundSchema: z.ZodType<GetParametersRequest$Outbound, GetParametersRequest>;
|
|
78
|
-
export declare function getParametersRequestToJSON(getParametersRequest: GetParametersRequest): string;
|
|
79
|
-
/** @internal */
|
|
80
|
-
export declare const SupportedParameter$inboundSchema: z.ZodType<SupportedParameter, unknown>;
|
|
81
|
-
/** @internal */
|
|
82
|
-
export declare const GetParametersData$inboundSchema: z.ZodType<GetParametersData, unknown>;
|
|
83
|
-
export declare function getParametersDataFromJSON(jsonString: string): SafeParseResult<GetParametersData, SDKValidationError>;
|
|
84
|
-
/** @internal */
|
|
85
|
-
export declare const GetParametersResponse$inboundSchema: z.ZodType<GetParametersResponse, unknown>;
|
|
86
|
-
export declare function getParametersResponseFromJSON(jsonString: string): SafeParseResult<GetParametersResponse, SDKValidationError>;
|
|
87
|
-
//# sourceMappingURL=getparameters.d.ts.map
|