@openrouter/sdk 1.2.29 → 1.2.31
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/datasetsGetSessionCost.d.ts +27 -0
- package/esm/funcs/datasetsGetSessionCost.js +142 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/index.d.ts +3 -0
- package/esm/models/index.js +3 -0
- package/esm/models/operations/getsessioncost.d.ts +103 -0
- package/esm/models/operations/getsessioncost.js +53 -0
- package/esm/models/operations/index.d.ts +1 -0
- package/esm/models/operations/index.js +1 -0
- package/esm/models/sessioncostitem.d.ts +45 -0
- package/esm/models/sessioncostitem.js +40 -0
- package/esm/models/sessioncostmeta.d.ts +38 -0
- package/esm/models/sessioncostmeta.js +32 -0
- package/esm/models/sessioncostresponse.d.ts +13 -0
- package/esm/models/sessioncostresponse.js +17 -0
- package/esm/sdk/datasets.d.ts +15 -0
- package/esm/sdk/datasets.js +16 -0
- package/jsr.json +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OpenRouterCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { OpenRouterError } from "../models/errors/openroutererror.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
import { PageIterator } from "../types/operations.js";
|
|
12
|
+
/**
|
|
13
|
+
* Cost per session by harness and model
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses.
|
|
17
|
+
* Sessions are never pooled across apps. Medians are of per-session USD spend, and
|
|
18
|
+
* privacy-preserving aggregation never exposes clerk_user_id values or per-session rows.
|
|
19
|
+
*
|
|
20
|
+
* Filter by `app_slug`, `model`, or `turn_range`. Filtering by `model` alone works across apps
|
|
21
|
+
* for harness-vs-harness comparison at a fixed model. Results refresh weekly and include the source snapshot
|
|
22
|
+
* window in `meta`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function datasetsGetSessionCost(client: OpenRouterCore, request?: operations.GetSessionCostRequest | undefined, options?: RequestOptions): APIPromise<PageIterator<Result<operations.GetSessionCostResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>, {
|
|
25
|
+
offset: number;
|
|
26
|
+
}>>;
|
|
27
|
+
//# sourceMappingURL=datasetsGetSessionCost.d.ts.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 3462402e5d7d
|
|
4
|
+
*/
|
|
5
|
+
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
14
|
+
import { APIPromise } from "../types/async.js";
|
|
15
|
+
import { createPageIterator, haltIterator, } from "../types/operations.js";
|
|
16
|
+
/**
|
|
17
|
+
* Cost per session by harness and model
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses.
|
|
21
|
+
* Sessions are never pooled across apps. Medians are of per-session USD spend, and
|
|
22
|
+
* privacy-preserving aggregation never exposes clerk_user_id values or per-session rows.
|
|
23
|
+
*
|
|
24
|
+
* Filter by `app_slug`, `model`, or `turn_range`. Filtering by `model` alone works across apps
|
|
25
|
+
* for harness-vs-harness comparison at a fixed model. Results refresh weekly and include the source snapshot
|
|
26
|
+
* window in `meta`.
|
|
27
|
+
*/
|
|
28
|
+
export function datasetsGetSessionCost(client, request, options) {
|
|
29
|
+
return new APIPromise($do(client, request, options));
|
|
30
|
+
}
|
|
31
|
+
async function $do(client, request, options) {
|
|
32
|
+
const parsed = safeParse(request, (value) => operations.GetSessionCostRequest$outboundSchema.optional().parse(value), "Input validation failed");
|
|
33
|
+
if (!parsed.ok) {
|
|
34
|
+
return [haltIterator(parsed), { status: "invalid" }];
|
|
35
|
+
}
|
|
36
|
+
const payload = parsed.value;
|
|
37
|
+
const body = null;
|
|
38
|
+
const path = pathToFunc("/datasets/session-cost")();
|
|
39
|
+
const query = encodeFormQuery({
|
|
40
|
+
"app_slug": payload?.app_slug,
|
|
41
|
+
"limit": payload?.limit,
|
|
42
|
+
"model": payload?.model,
|
|
43
|
+
"offset": payload?.offset,
|
|
44
|
+
"turn_range": payload?.turn_range,
|
|
45
|
+
});
|
|
46
|
+
const headers = new Headers(compactMap({
|
|
47
|
+
Accept: "application/json",
|
|
48
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
49
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload?.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
50
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload?.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
51
|
+
}));
|
|
52
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
53
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
54
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
55
|
+
const context = {
|
|
56
|
+
options: client._options,
|
|
57
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
58
|
+
operationID: "getSessionCost",
|
|
59
|
+
oAuth2Scopes: null,
|
|
60
|
+
resolvedSecurity: requestSecurity,
|
|
61
|
+
securitySource: client._options.apiKey,
|
|
62
|
+
retryConfig: options?.retries
|
|
63
|
+
|| client._options.retryConfig
|
|
64
|
+
|| {
|
|
65
|
+
strategy: "backoff",
|
|
66
|
+
backoff: {
|
|
67
|
+
initialInterval: 500,
|
|
68
|
+
maxInterval: 60000,
|
|
69
|
+
exponent: 1.5,
|
|
70
|
+
maxElapsedTime: 3600000,
|
|
71
|
+
},
|
|
72
|
+
retryConnectionErrors: true,
|
|
73
|
+
}
|
|
74
|
+
|| { strategy: "none" },
|
|
75
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
76
|
+
};
|
|
77
|
+
const requestRes = client._createRequest(context, {
|
|
78
|
+
security: requestSecurity,
|
|
79
|
+
method: "GET",
|
|
80
|
+
baseURL: options?.serverURL,
|
|
81
|
+
path: path,
|
|
82
|
+
headers: headers,
|
|
83
|
+
query: query,
|
|
84
|
+
body: body,
|
|
85
|
+
userAgent: client._options.userAgent,
|
|
86
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
87
|
+
}, options);
|
|
88
|
+
if (!requestRes.ok) {
|
|
89
|
+
return [haltIterator(requestRes), { status: "invalid" }];
|
|
90
|
+
}
|
|
91
|
+
const req = requestRes.value;
|
|
92
|
+
const doResult = await client._do(req, {
|
|
93
|
+
context,
|
|
94
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
95
|
+
retryConfig: context.retryConfig,
|
|
96
|
+
retryCodes: context.retryCodes,
|
|
97
|
+
});
|
|
98
|
+
if (!doResult.ok) {
|
|
99
|
+
return [haltIterator(doResult), { status: "request-error", request: req }];
|
|
100
|
+
}
|
|
101
|
+
const response = doResult.value;
|
|
102
|
+
const responseFields = {
|
|
103
|
+
HttpMeta: { Response: response, Request: req },
|
|
104
|
+
};
|
|
105
|
+
const [result, raw] = await M.match(M.json(200, operations.GetSessionCostResponse$inboundSchema, {
|
|
106
|
+
key: "Result",
|
|
107
|
+
}), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
108
|
+
if (!result.ok) {
|
|
109
|
+
return [haltIterator(result), {
|
|
110
|
+
status: "complete",
|
|
111
|
+
request: req,
|
|
112
|
+
response,
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
115
|
+
const nextFunc = (responseData) => {
|
|
116
|
+
const offset = request?.offset ?? 0;
|
|
117
|
+
if (!responseData) {
|
|
118
|
+
return { next: () => null };
|
|
119
|
+
}
|
|
120
|
+
const results = responseData.data;
|
|
121
|
+
if (!Array.isArray(results) || !results.length) {
|
|
122
|
+
return { next: () => null };
|
|
123
|
+
}
|
|
124
|
+
const limit = request?.limit ?? 100;
|
|
125
|
+
if (results.length < limit) {
|
|
126
|
+
return { next: () => null };
|
|
127
|
+
}
|
|
128
|
+
const nextOffset = offset + results.length;
|
|
129
|
+
const nextVal = () => datasetsGetSessionCost(client, {
|
|
130
|
+
...request,
|
|
131
|
+
offset: nextOffset,
|
|
132
|
+
}, options);
|
|
133
|
+
return { next: nextVal, "~next": { offset: nextOffset } };
|
|
134
|
+
};
|
|
135
|
+
const page = { ...result, ...nextFunc(raw) };
|
|
136
|
+
return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
|
|
137
|
+
status: "complete",
|
|
138
|
+
request: req,
|
|
139
|
+
response,
|
|
140
|
+
}];
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=datasetsGetSessionCost.js.map
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
49
49
|
export declare const SDK_METADATA: {
|
|
50
50
|
readonly language: "typescript";
|
|
51
51
|
readonly openapiDocVersion: "1.0.0";
|
|
52
|
-
readonly sdkVersion: "1.2.
|
|
52
|
+
readonly sdkVersion: "1.2.31";
|
|
53
53
|
readonly genVersion: "2.914.0";
|
|
54
|
-
readonly userAgent: "speakeasy-sdk/typescript 1.2.
|
|
54
|
+
readonly userAgent: "speakeasy-sdk/typescript 1.2.31 2.914.0 1.0.0 @openrouter/sdk";
|
|
55
55
|
};
|
|
56
56
|
//# 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: "1.2.
|
|
29
|
+
sdkVersion: "1.2.31",
|
|
30
30
|
genVersion: "2.914.0",
|
|
31
|
-
userAgent: "speakeasy-sdk/typescript 1.2.
|
|
31
|
+
userAgent: "speakeasy-sdk/typescript 1.2.31 2.914.0 1.0.0 @openrouter/sdk",
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=config.js.map
|
package/esm/models/index.d.ts
CHANGED
|
@@ -500,6 +500,9 @@ export * from "./searchqualitylevel.js";
|
|
|
500
500
|
export * from "./security.js";
|
|
501
501
|
export * from "./servertoolusedetails.js";
|
|
502
502
|
export * from "./serviceunavailableresponseerrordata.js";
|
|
503
|
+
export * from "./sessioncostitem.js";
|
|
504
|
+
export * from "./sessioncostmeta.js";
|
|
505
|
+
export * from "./sessioncostresponse.js";
|
|
503
506
|
export * from "./shellcallitem.js";
|
|
504
507
|
export * from "./shellcalloutputitem.js";
|
|
505
508
|
export * from "./shellcallstatus.js";
|
package/esm/models/index.js
CHANGED
|
@@ -504,6 +504,9 @@ export * from "./searchqualitylevel.js";
|
|
|
504
504
|
export * from "./security.js";
|
|
505
505
|
export * from "./servertoolusedetails.js";
|
|
506
506
|
export * from "./serviceunavailableresponseerrordata.js";
|
|
507
|
+
export * from "./sessioncostitem.js";
|
|
508
|
+
export * from "./sessioncostmeta.js";
|
|
509
|
+
export * from "./sessioncostresponse.js";
|
|
507
510
|
export * from "./shellcallitem.js";
|
|
508
511
|
export * from "./shellcalloutputitem.js";
|
|
509
512
|
export * from "./shellcallstatus.js";
|
|
@@ -0,0 +1,103 @@
|
|
|
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 GetSessionCostGlobals = {
|
|
7
|
+
/**
|
|
8
|
+
* The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This is used to track API usage per application.
|
|
12
|
+
*/
|
|
13
|
+
httpReferer?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
*/
|
|
19
|
+
appTitle?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
*/
|
|
25
|
+
appCategories?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Filter by the inclusive number of turns in a session.
|
|
29
|
+
*/
|
|
30
|
+
export declare const TurnRange: {
|
|
31
|
+
readonly OneMinusTurn: "1-turn";
|
|
32
|
+
readonly TwoMinus9MinusTurns: "2-9-turns";
|
|
33
|
+
readonly TenMinus49MinusTurns: "10-49-turns";
|
|
34
|
+
readonly FiftyMinusPlusTurns: "50-plus-turns";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Filter by the inclusive number of turns in a session.
|
|
38
|
+
*/
|
|
39
|
+
export type TurnRange = OpenEnum<typeof TurnRange>;
|
|
40
|
+
export type GetSessionCostRequest = {
|
|
41
|
+
/**
|
|
42
|
+
* The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This is used to track API usage per application.
|
|
46
|
+
*/
|
|
47
|
+
httpReferer?: string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
*/
|
|
53
|
+
appTitle?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
*/
|
|
59
|
+
appCategories?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Filter to one published harness slug.
|
|
62
|
+
*/
|
|
63
|
+
appSlug?: string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Exact model permaslug filter. Works across all harness apps.
|
|
66
|
+
*/
|
|
67
|
+
model?: string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Filter by the inclusive number of turns in a session.
|
|
70
|
+
*/
|
|
71
|
+
turnRange?: TurnRange | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum number of cells to return (1-500). Defaults to 100.
|
|
74
|
+
*/
|
|
75
|
+
limit?: number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Number of sorted cells to skip (0-5000). Defaults to 0.
|
|
78
|
+
*/
|
|
79
|
+
offset?: number | null | undefined;
|
|
80
|
+
};
|
|
81
|
+
export type GetSessionCostResponse = {
|
|
82
|
+
result: models.SessionCostResponse;
|
|
83
|
+
};
|
|
84
|
+
/** @internal */
|
|
85
|
+
export declare const TurnRange$outboundSchema: z.ZodType<string, TurnRange>;
|
|
86
|
+
/** @internal */
|
|
87
|
+
export type GetSessionCostRequest$Outbound = {
|
|
88
|
+
"HTTP-Referer"?: string | undefined;
|
|
89
|
+
appTitle?: string | undefined;
|
|
90
|
+
appCategories?: string | undefined;
|
|
91
|
+
app_slug?: string | undefined;
|
|
92
|
+
model?: string | undefined;
|
|
93
|
+
turn_range?: string | undefined;
|
|
94
|
+
limit: number;
|
|
95
|
+
offset: number | null;
|
|
96
|
+
};
|
|
97
|
+
/** @internal */
|
|
98
|
+
export declare const GetSessionCostRequest$outboundSchema: z.ZodType<GetSessionCostRequest$Outbound, GetSessionCostRequest>;
|
|
99
|
+
export declare function getSessionCostRequestToJSON(getSessionCostRequest: GetSessionCostRequest): string;
|
|
100
|
+
/** @internal */
|
|
101
|
+
export declare const GetSessionCostResponse$inboundSchema: z.ZodType<GetSessionCostResponse, unknown>;
|
|
102
|
+
export declare function getSessionCostResponseFromJSON(jsonString: string): SafeParseResult<GetSessionCostResponse, SDKValidationError>;
|
|
103
|
+
//# sourceMappingURL=getsessioncost.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 64d7aeafa13e
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import * as openEnums from "../../types/enums.js";
|
|
9
|
+
import * as models from "../index.js";
|
|
10
|
+
/**
|
|
11
|
+
* Filter by the inclusive number of turns in a session.
|
|
12
|
+
*/
|
|
13
|
+
export const TurnRange = {
|
|
14
|
+
OneMinusTurn: "1-turn",
|
|
15
|
+
TwoMinus9MinusTurns: "2-9-turns",
|
|
16
|
+
TenMinus49MinusTurns: "10-49-turns",
|
|
17
|
+
FiftyMinusPlusTurns: "50-plus-turns",
|
|
18
|
+
};
|
|
19
|
+
/** @internal */
|
|
20
|
+
export const TurnRange$outboundSchema = openEnums
|
|
21
|
+
.outboundSchema(TurnRange);
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const GetSessionCostRequest$outboundSchema = z.object({
|
|
24
|
+
httpReferer: z.string().optional(),
|
|
25
|
+
appTitle: z.string().optional(),
|
|
26
|
+
appCategories: z.string().optional(),
|
|
27
|
+
appSlug: z.string().optional(),
|
|
28
|
+
model: z.string().optional(),
|
|
29
|
+
turnRange: TurnRange$outboundSchema.optional(),
|
|
30
|
+
limit: z.int().default(100),
|
|
31
|
+
offset: z.nullable(z.int().default(0)),
|
|
32
|
+
}).transform((v) => {
|
|
33
|
+
return remap$(v, {
|
|
34
|
+
httpReferer: "HTTP-Referer",
|
|
35
|
+
appSlug: "app_slug",
|
|
36
|
+
turnRange: "turn_range",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
export function getSessionCostRequestToJSON(getSessionCostRequest) {
|
|
40
|
+
return JSON.stringify(GetSessionCostRequest$outboundSchema.parse(getSessionCostRequest));
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
export const GetSessionCostResponse$inboundSchema = z.object({
|
|
44
|
+
Result: models.SessionCostResponse$inboundSchema,
|
|
45
|
+
}).transform((v) => {
|
|
46
|
+
return remap$(v, {
|
|
47
|
+
"Result": "result",
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export function getSessionCostResponseFromJSON(jsonString) {
|
|
51
|
+
return safeParse(jsonString, (x) => GetSessionCostResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSessionCostResponse' from JSON`);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=getsessioncost.js.map
|
|
@@ -49,6 +49,7 @@ export * from "./getpreset.js";
|
|
|
49
49
|
export * from "./getpresetversion.js";
|
|
50
50
|
export * from "./getrankingsdaily.js";
|
|
51
51
|
export * from "./getscimgroupmapping.js";
|
|
52
|
+
export * from "./getsessioncost.js";
|
|
52
53
|
export * from "./gettaskclassifications.js";
|
|
53
54
|
export * from "./getuseractivity.js";
|
|
54
55
|
export * from "./getvideos.js";
|
|
@@ -53,6 +53,7 @@ export * from "./getpreset.js";
|
|
|
53
53
|
export * from "./getpresetversion.js";
|
|
54
54
|
export * from "./getrankingsdaily.js";
|
|
55
55
|
export * from "./getscimgroupmapping.js";
|
|
56
|
+
export * from "./getsessioncost.js";
|
|
56
57
|
export * from "./gettaskclassifications.js";
|
|
57
58
|
export * from "./getuseractivity.js";
|
|
58
59
|
export * from "./getvideos.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Inclusive session turn-count range.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TurnRange: {
|
|
9
|
+
readonly OneMinusTurn: "1-turn";
|
|
10
|
+
readonly TwoMinus9MinusTurns: "2-9-turns";
|
|
11
|
+
readonly TenMinus49MinusTurns: "10-49-turns";
|
|
12
|
+
readonly FiftyMinusPlusTurns: "50-plus-turns";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Inclusive session turn-count range.
|
|
16
|
+
*/
|
|
17
|
+
export type TurnRange = OpenEnum<typeof TurnRange>;
|
|
18
|
+
export type SessionCostItem = {
|
|
19
|
+
/**
|
|
20
|
+
* Published harness display label.
|
|
21
|
+
*/
|
|
22
|
+
appName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Stable public slug of the harness.
|
|
25
|
+
*/
|
|
26
|
+
appSlug: string;
|
|
27
|
+
/**
|
|
28
|
+
* Median USD spend per sampled session.
|
|
29
|
+
*/
|
|
30
|
+
medianSessionCostUsd: number;
|
|
31
|
+
/**
|
|
32
|
+
* Exact model permaslug.
|
|
33
|
+
*/
|
|
34
|
+
modelPermaslug: string;
|
|
35
|
+
/**
|
|
36
|
+
* Inclusive session turn-count range.
|
|
37
|
+
*/
|
|
38
|
+
turnRange: TurnRange;
|
|
39
|
+
};
|
|
40
|
+
/** @internal */
|
|
41
|
+
export declare const TurnRange$inboundSchema: z.ZodType<TurnRange, unknown>;
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const SessionCostItem$inboundSchema: z.ZodType<SessionCostItem, unknown>;
|
|
44
|
+
export declare function sessionCostItemFromJSON(jsonString: string): SafeParseResult<SessionCostItem, SDKValidationError>;
|
|
45
|
+
//# sourceMappingURL=sessioncostitem.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 1767ec935316
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import * as openEnums from "../types/enums.js";
|
|
9
|
+
/**
|
|
10
|
+
* Inclusive session turn-count range.
|
|
11
|
+
*/
|
|
12
|
+
export const TurnRange = {
|
|
13
|
+
OneMinusTurn: "1-turn",
|
|
14
|
+
TwoMinus9MinusTurns: "2-9-turns",
|
|
15
|
+
TenMinus49MinusTurns: "10-49-turns",
|
|
16
|
+
FiftyMinusPlusTurns: "50-plus-turns",
|
|
17
|
+
};
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const TurnRange$inboundSchema = openEnums
|
|
20
|
+
.inboundSchema(TurnRange);
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const SessionCostItem$inboundSchema = z.object({
|
|
23
|
+
app_name: z.string(),
|
|
24
|
+
app_slug: z.string(),
|
|
25
|
+
median_session_cost_usd: z.number(),
|
|
26
|
+
model_permaslug: z.string(),
|
|
27
|
+
turn_range: TurnRange$inboundSchema,
|
|
28
|
+
}).transform((v) => {
|
|
29
|
+
return remap$(v, {
|
|
30
|
+
"app_name": "appName",
|
|
31
|
+
"app_slug": "appSlug",
|
|
32
|
+
"median_session_cost_usd": "medianSessionCostUsd",
|
|
33
|
+
"model_permaslug": "modelPermaslug",
|
|
34
|
+
"turn_range": "turnRange",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
export function sessionCostItemFromJSON(jsonString) {
|
|
38
|
+
return safeParse(jsonString, (x) => SessionCostItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionCostItem' from JSON`);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=sessioncostitem.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
+
/**
|
|
6
|
+
* Dataset version.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SessionCostMetaVersion: {
|
|
9
|
+
readonly V1: "v1";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Dataset version.
|
|
13
|
+
*/
|
|
14
|
+
export type SessionCostMetaVersion = ClosedEnum<typeof SessionCostMetaVersion>;
|
|
15
|
+
export type SessionCostMeta = {
|
|
16
|
+
/**
|
|
17
|
+
* ISO-8601 timestamp when the response was generated.
|
|
18
|
+
*/
|
|
19
|
+
asOf: string;
|
|
20
|
+
/**
|
|
21
|
+
* Dataset version.
|
|
22
|
+
*/
|
|
23
|
+
version: SessionCostMetaVersion;
|
|
24
|
+
/**
|
|
25
|
+
* Number of days in the weekly session sample window, or null when no snapshot is published.
|
|
26
|
+
*/
|
|
27
|
+
windowDays: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* UTC date of the final day in the session sample window, or null when no snapshot is published.
|
|
30
|
+
*/
|
|
31
|
+
windowEndDate: string | null;
|
|
32
|
+
};
|
|
33
|
+
/** @internal */
|
|
34
|
+
export declare const SessionCostMetaVersion$inboundSchema: z.ZodEnum<typeof SessionCostMetaVersion>;
|
|
35
|
+
/** @internal */
|
|
36
|
+
export declare const SessionCostMeta$inboundSchema: z.ZodType<SessionCostMeta, unknown>;
|
|
37
|
+
export declare function sessionCostMetaFromJSON(jsonString: string): SafeParseResult<SessionCostMeta, SDKValidationError>;
|
|
38
|
+
//# sourceMappingURL=sessioncostmeta.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: de705cb6caba
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
/**
|
|
9
|
+
* Dataset version.
|
|
10
|
+
*/
|
|
11
|
+
export const SessionCostMetaVersion = {
|
|
12
|
+
V1: "v1",
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const SessionCostMetaVersion$inboundSchema = z.enum(SessionCostMetaVersion);
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const SessionCostMeta$inboundSchema = z.object({
|
|
18
|
+
as_of: z.string(),
|
|
19
|
+
version: SessionCostMetaVersion$inboundSchema,
|
|
20
|
+
window_days: z.nullable(z.int()),
|
|
21
|
+
window_end_date: z.nullable(z.string()),
|
|
22
|
+
}).transform((v) => {
|
|
23
|
+
return remap$(v, {
|
|
24
|
+
"as_of": "asOf",
|
|
25
|
+
"window_days": "windowDays",
|
|
26
|
+
"window_end_date": "windowEndDate",
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
export function sessionCostMetaFromJSON(jsonString) {
|
|
30
|
+
return safeParse(jsonString, (x) => SessionCostMeta$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionCostMeta' from JSON`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sessioncostmeta.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
|
+
import { SessionCostItem } from "./sessioncostitem.js";
|
|
5
|
+
import { SessionCostMeta } from "./sessioncostmeta.js";
|
|
6
|
+
export type SessionCostResponse = {
|
|
7
|
+
data: Array<SessionCostItem>;
|
|
8
|
+
meta: SessionCostMeta;
|
|
9
|
+
};
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const SessionCostResponse$inboundSchema: z.ZodType<SessionCostResponse, unknown>;
|
|
12
|
+
export declare function sessionCostResponseFromJSON(jsonString: string): SafeParseResult<SessionCostResponse, SDKValidationError>;
|
|
13
|
+
//# sourceMappingURL=sessioncostresponse.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 312132889b9f
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { SessionCostItem$inboundSchema, } from "./sessioncostitem.js";
|
|
8
|
+
import { SessionCostMeta$inboundSchema, } from "./sessioncostmeta.js";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const SessionCostResponse$inboundSchema = z.object({
|
|
11
|
+
data: z.array(SessionCostItem$inboundSchema),
|
|
12
|
+
meta: SessionCostMeta$inboundSchema,
|
|
13
|
+
});
|
|
14
|
+
export function sessionCostResponseFromJSON(jsonString) {
|
|
15
|
+
return safeParse(jsonString, (x) => SessionCostResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionCostResponse' from JSON`);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=sessioncostresponse.js.map
|
package/esm/sdk/datasets.d.ts
CHANGED
|
@@ -66,5 +66,20 @@ export declare class Datasets extends ClientSDK {
|
|
|
66
66
|
* different provider.
|
|
67
67
|
*/
|
|
68
68
|
getRankingsDaily(request?: operations.GetRankingsDailyRequest | undefined, options?: RequestOptions): Promise<models.RankingsDailyResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Cost per session by harness and model
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses.
|
|
74
|
+
* Sessions are never pooled across apps. Medians are of per-session USD spend, and
|
|
75
|
+
* privacy-preserving aggregation never exposes clerk_user_id values or per-session rows.
|
|
76
|
+
*
|
|
77
|
+
* Filter by `app_slug`, `model`, or `turn_range`. Filtering by `model` alone works across apps
|
|
78
|
+
* for harness-vs-harness comparison at a fixed model. Results refresh weekly and include the source snapshot
|
|
79
|
+
* window in `meta`.
|
|
80
|
+
*/
|
|
81
|
+
getSessionCost(request?: operations.GetSessionCostRequest | undefined, options?: RequestOptions): Promise<PageIterator<operations.GetSessionCostResponse, {
|
|
82
|
+
offset: number;
|
|
83
|
+
}>>;
|
|
69
84
|
}
|
|
70
85
|
//# sourceMappingURL=datasets.d.ts.map
|
package/esm/sdk/datasets.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { datasetsGetAppRankings } from "../funcs/datasetsGetAppRankings.js";
|
|
6
6
|
import { datasetsGetRankingsDaily } from "../funcs/datasetsGetRankingsDaily.js";
|
|
7
|
+
import { datasetsGetSessionCost } from "../funcs/datasetsGetSessionCost.js";
|
|
7
8
|
import { ClientSDK } from "../lib/sdks.js";
|
|
8
9
|
import { unwrapAsync } from "../types/fp.js";
|
|
9
10
|
import { unwrapResultIterator } from "../types/operations.js";
|
|
@@ -73,5 +74,20 @@ export class Datasets extends ClientSDK {
|
|
|
73
74
|
async getRankingsDaily(request, options) {
|
|
74
75
|
return unwrapAsync(datasetsGetRankingsDaily(this, request, options));
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Cost per session by harness and model
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses.
|
|
82
|
+
* Sessions are never pooled across apps. Medians are of per-session USD spend, and
|
|
83
|
+
* privacy-preserving aggregation never exposes clerk_user_id values or per-session rows.
|
|
84
|
+
*
|
|
85
|
+
* Filter by `app_slug`, `model`, or `turn_range`. Filtering by `model` alone works across apps
|
|
86
|
+
* for harness-vs-harness comparison at a fixed model. Results refresh weekly and include the source snapshot
|
|
87
|
+
* window in `meta`.
|
|
88
|
+
*/
|
|
89
|
+
async getSessionCost(request, options) {
|
|
90
|
+
return unwrapResultIterator(datasetsGetSessionCost(this, request, options));
|
|
91
|
+
}
|
|
76
92
|
}
|
|
77
93
|
//# sourceMappingURL=datasets.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.31",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.",
|
|
6
6
|
"keywords": [
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"lint": "eslint --cache --max-warnings=0 src",
|
|
74
74
|
"build": "tsc",
|
|
75
75
|
"prepublishOnly": "npm run build",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
76
|
+
"test:transit": "exit 0",
|
|
77
|
+
"compile": "tsc",
|
|
78
78
|
"test": "vitest --run --project unit",
|
|
79
79
|
"test:e2e": "vitest --run --project e2e",
|
|
80
|
-
"compile": "tsc",
|
|
81
|
-
"prepare": "npm run build",
|
|
82
|
-
"test:transit": "exit 0",
|
|
83
80
|
"test:watch": "vitest --watch --project unit",
|
|
84
|
-
"typecheck": "tsc --noEmit"
|
|
81
|
+
"typecheck": "tsc --noEmit",
|
|
82
|
+
"typecheck:transit": "exit 0",
|
|
83
|
+
"postinstall": "node scripts/check-types.js || true",
|
|
84
|
+
"prepare": "npm run build"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {},
|
|
87
87
|
"devDependencies": {
|