@openrouter/sdk 0.12.21 → 0.12.22
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/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/chatusage.d.ts +13 -0
- package/esm/models/chatusage.js +6 -0
- package/esm/models/costdetails.d.ts +15 -0
- package/esm/models/costdetails.js +24 -0
- package/esm/models/generationresponse.d.ts +1 -0
- package/esm/models/generationresponse.js +1 -0
- package/esm/models/index.d.ts +1 -0
- package/esm/models/index.js +1 -0
- package/esm/models/outputmodality.d.ts +1 -0
- package/esm/models/outputmodality.js +1 -0
- package/esm/models/usage.d.ts +4 -4
- package/esm/models/usage.js +4 -5
- package/jsr.json +1 -1
- package/package.json +7 -7
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: "0.12.
|
|
52
|
+
readonly sdkVersion: "0.12.22";
|
|
53
53
|
readonly genVersion: "2.879.1";
|
|
54
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.12.
|
|
54
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.12.22 2.879.1 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: "0.12.
|
|
29
|
+
sdkVersion: "0.12.22",
|
|
30
30
|
genVersion: "2.879.1",
|
|
31
|
-
userAgent: "speakeasy-sdk/typescript 0.12.
|
|
31
|
+
userAgent: "speakeasy-sdk/typescript 0.12.22 2.879.1 1.0.0 @openrouter/sdk",
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=config.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
2
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
+
import { CostDetails } from "./costdetails.js";
|
|
3
4
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
5
|
/**
|
|
5
6
|
* Detailed completion token usage
|
|
@@ -55,6 +56,18 @@ export type ChatUsage = {
|
|
|
55
56
|
* Detailed completion token usage
|
|
56
57
|
*/
|
|
57
58
|
completionTokensDetails?: CompletionTokensDetails | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Cost of the completion
|
|
61
|
+
*/
|
|
62
|
+
cost?: number | null | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Breakdown of upstream inference costs
|
|
65
|
+
*/
|
|
66
|
+
costDetails?: CostDetails | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Whether a request was made using a Bring Your Own Key configuration
|
|
69
|
+
*/
|
|
70
|
+
isByok?: boolean | undefined;
|
|
58
71
|
/**
|
|
59
72
|
* Number of tokens in the prompt
|
|
60
73
|
*/
|
package/esm/models/chatusage.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as z from "zod/v4";
|
|
6
6
|
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
7
|
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import { CostDetails$inboundSchema } from "./costdetails.js";
|
|
8
9
|
/** @internal */
|
|
9
10
|
export const CompletionTokensDetails$inboundSchema = z.object({
|
|
10
11
|
accepted_prediction_tokens: z.nullable(z.int()).optional(),
|
|
@@ -43,6 +44,9 @@ export function promptTokensDetailsFromJSON(jsonString) {
|
|
|
43
44
|
export const ChatUsage$inboundSchema = z.object({
|
|
44
45
|
completion_tokens: z.int(),
|
|
45
46
|
completion_tokens_details: z.nullable(z.lazy(() => CompletionTokensDetails$inboundSchema)).optional(),
|
|
47
|
+
cost: z.nullable(z.number()).optional(),
|
|
48
|
+
cost_details: z.nullable(CostDetails$inboundSchema).optional(),
|
|
49
|
+
is_byok: z.boolean().optional(),
|
|
46
50
|
prompt_tokens: z.int(),
|
|
47
51
|
prompt_tokens_details: z.nullable(z.lazy(() => PromptTokensDetails$inboundSchema)).optional(),
|
|
48
52
|
total_tokens: z.int(),
|
|
@@ -50,6 +54,8 @@ export const ChatUsage$inboundSchema = z.object({
|
|
|
50
54
|
return remap$(v, {
|
|
51
55
|
"completion_tokens": "completionTokens",
|
|
52
56
|
"completion_tokens_details": "completionTokensDetails",
|
|
57
|
+
"cost_details": "costDetails",
|
|
58
|
+
"is_byok": "isByok",
|
|
53
59
|
"prompt_tokens": "promptTokens",
|
|
54
60
|
"prompt_tokens_details": "promptTokensDetails",
|
|
55
61
|
"total_tokens": "totalTokens",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
|
+
/**
|
|
5
|
+
* Breakdown of upstream inference costs
|
|
6
|
+
*/
|
|
7
|
+
export type CostDetails = {
|
|
8
|
+
upstreamInferenceCompletionsCost: number;
|
|
9
|
+
upstreamInferenceCost?: number | null | undefined;
|
|
10
|
+
upstreamInferencePromptCost: number;
|
|
11
|
+
};
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare const CostDetails$inboundSchema: z.ZodType<CostDetails, unknown>;
|
|
14
|
+
export declare function costDetailsFromJSON(jsonString: string): SafeParseResult<CostDetails, SDKValidationError>;
|
|
15
|
+
//# sourceMappingURL=costdetails.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: a9138bf3f716
|
|
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
|
+
/** @internal */
|
|
9
|
+
export const CostDetails$inboundSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
upstream_inference_completions_cost: z.number(),
|
|
12
|
+
upstream_inference_cost: z.nullable(z.number()).optional(),
|
|
13
|
+
upstream_inference_prompt_cost: z.number(),
|
|
14
|
+
}).transform((v) => {
|
|
15
|
+
return remap$(v, {
|
|
16
|
+
"upstream_inference_completions_cost": "upstreamInferenceCompletionsCost",
|
|
17
|
+
"upstream_inference_cost": "upstreamInferenceCost",
|
|
18
|
+
"upstream_inference_prompt_cost": "upstreamInferencePromptCost",
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export function costDetailsFromJSON(jsonString) {
|
|
22
|
+
return safeParse(jsonString, (x) => CostDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CostDetails' from JSON`);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=costdetails.js.map
|
package/esm/models/index.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export * from "./contentpartdoneevent.js";
|
|
|
72
72
|
export * from "./contentpartimage.js";
|
|
73
73
|
export * from "./contextcompressionengine.js";
|
|
74
74
|
export * from "./contextcompressionplugin.js";
|
|
75
|
+
export * from "./costdetails.js";
|
|
75
76
|
export * from "./createguardrailrequest.js";
|
|
76
77
|
export * from "./createguardrailresponse.js";
|
|
77
78
|
export * from "./createworkspacerequest.js";
|
package/esm/models/index.js
CHANGED
|
@@ -76,6 +76,7 @@ export * from "./contentpartdoneevent.js";
|
|
|
76
76
|
export * from "./contentpartimage.js";
|
|
77
77
|
export * from "./contextcompressionengine.js";
|
|
78
78
|
export * from "./contextcompressionplugin.js";
|
|
79
|
+
export * from "./costdetails.js";
|
|
79
80
|
export * from "./createguardrailrequest.js";
|
|
80
81
|
export * from "./createguardrailresponse.js";
|
|
81
82
|
export * from "./createworkspacerequest.js";
|
package/esm/models/usage.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type InputTokensDetails = {
|
|
|
7
7
|
export type OutputTokensDetails = {
|
|
8
8
|
reasoningTokens: number;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
10
|
+
export type UsageCostDetails = {
|
|
11
11
|
upstreamInferenceCost?: number | null | undefined;
|
|
12
12
|
upstreamInferenceInputCost: number;
|
|
13
13
|
upstreamInferenceOutputCost: number;
|
|
@@ -25,7 +25,7 @@ export type Usage = {
|
|
|
25
25
|
* Cost of the completion
|
|
26
26
|
*/
|
|
27
27
|
cost?: number | null | undefined;
|
|
28
|
-
costDetails?:
|
|
28
|
+
costDetails?: UsageCostDetails | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Whether a request was made using a Bring Your Own Key configuration
|
|
31
31
|
*/
|
|
@@ -38,8 +38,8 @@ export declare function inputTokensDetailsFromJSON(jsonString: string): SafePars
|
|
|
38
38
|
export declare const OutputTokensDetails$inboundSchema: z.ZodType<OutputTokensDetails, unknown>;
|
|
39
39
|
export declare function outputTokensDetailsFromJSON(jsonString: string): SafeParseResult<OutputTokensDetails, SDKValidationError>;
|
|
40
40
|
/** @internal */
|
|
41
|
-
export declare const
|
|
42
|
-
export declare function
|
|
41
|
+
export declare const UsageCostDetails$inboundSchema: z.ZodType<UsageCostDetails, unknown>;
|
|
42
|
+
export declare function usageCostDetailsFromJSON(jsonString: string): SafeParseResult<UsageCostDetails, SDKValidationError>;
|
|
43
43
|
/** @internal */
|
|
44
44
|
export declare const Usage$inboundSchema: z.ZodType<Usage, unknown>;
|
|
45
45
|
export declare function usageFromJSON(jsonString: string): SafeParseResult<Usage, SDKValidationError>;
|
package/esm/models/usage.js
CHANGED
|
@@ -28,8 +28,7 @@ export function outputTokensDetailsFromJSON(jsonString) {
|
|
|
28
28
|
return safeParse(jsonString, (x) => OutputTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OutputTokensDetails' from JSON`);
|
|
29
29
|
}
|
|
30
30
|
/** @internal */
|
|
31
|
-
export const
|
|
32
|
-
.object({
|
|
31
|
+
export const UsageCostDetails$inboundSchema = z.object({
|
|
33
32
|
upstream_inference_cost: z.nullable(z.number()).optional(),
|
|
34
33
|
upstream_inference_input_cost: z.number(),
|
|
35
34
|
upstream_inference_output_cost: z.number(),
|
|
@@ -40,8 +39,8 @@ export const CostDetails$inboundSchema = z
|
|
|
40
39
|
"upstream_inference_output_cost": "upstreamInferenceOutputCost",
|
|
41
40
|
});
|
|
42
41
|
});
|
|
43
|
-
export function
|
|
44
|
-
return safeParse(jsonString, (x) =>
|
|
42
|
+
export function usageCostDetailsFromJSON(jsonString) {
|
|
43
|
+
return safeParse(jsonString, (x) => UsageCostDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageCostDetails' from JSON`);
|
|
45
44
|
}
|
|
46
45
|
/** @internal */
|
|
47
46
|
export const Usage$inboundSchema = z.object({
|
|
@@ -51,7 +50,7 @@ export const Usage$inboundSchema = z.object({
|
|
|
51
50
|
output_tokens_details: z.lazy(() => OutputTokensDetails$inboundSchema),
|
|
52
51
|
total_tokens: z.int(),
|
|
53
52
|
cost: z.nullable(z.number()).optional(),
|
|
54
|
-
cost_details: z.lazy(() =>
|
|
53
|
+
cost_details: z.lazy(() => UsageCostDetails$inboundSchema).optional(),
|
|
55
54
|
is_byok: z.boolean().optional(),
|
|
56
55
|
}).transform((v) => {
|
|
57
56
|
return remap$(v, {
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.22",
|
|
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": [
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
"lint": "eslint --cache --max-warnings=0 src",
|
|
70
70
|
"build": "tsc",
|
|
71
71
|
"prepublishOnly": "npm run build",
|
|
72
|
-
"compile": "tsc",
|
|
73
|
-
"postinstall": "node scripts/check-types.js || true",
|
|
74
|
-
"test:e2e": "vitest --run --project e2e",
|
|
75
|
-
"test:watch": "vitest --watch --project unit",
|
|
76
72
|
"typecheck": "tsc --noEmit",
|
|
73
|
+
"postinstall": "node scripts/check-types.js || true",
|
|
77
74
|
"prepare": "npm run build",
|
|
78
|
-
"test": "vitest --run --project unit",
|
|
79
75
|
"test:transit": "exit 0",
|
|
80
|
-
"
|
|
76
|
+
"test:watch": "vitest --watch --project unit",
|
|
77
|
+
"typecheck:transit": "exit 0",
|
|
78
|
+
"compile": "tsc",
|
|
79
|
+
"test": "vitest --run --project unit",
|
|
80
|
+
"test:e2e": "vitest --run --project e2e"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {},
|
|
83
83
|
"devDependencies": {
|