@openrouter/sdk 0.12.21 → 0.12.23

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.
@@ -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.21";
52
+ readonly sdkVersion: "0.12.23";
53
53
  readonly genVersion: "2.879.1";
54
- readonly userAgent: "speakeasy-sdk/typescript 0.12.21 2.879.1 1.0.0 @openrouter/sdk";
54
+ readonly userAgent: "speakeasy-sdk/typescript 0.12.23 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.21",
29
+ sdkVersion: "0.12.23",
30
30
  genVersion: "2.879.1",
31
- userAgent: "speakeasy-sdk/typescript 0.12.21 2.879.1 1.0.0 @openrouter/sdk",
31
+ userAgent: "speakeasy-sdk/typescript 0.12.23 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
  */
@@ -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
@@ -11,6 +11,7 @@ export declare const ApiType: {
11
11
  readonly Embeddings: "embeddings";
12
12
  readonly Rerank: "rerank";
13
13
  readonly Tts: "tts";
14
+ readonly Stt: "stt";
14
15
  readonly Video: "video";
15
16
  };
16
17
  /**
@@ -15,6 +15,7 @@ export const ApiType = {
15
15
  Embeddings: "embeddings",
16
16
  Rerank: "rerank",
17
17
  Tts: "tts",
18
+ Stt: "stt",
18
19
  Video: "video",
19
20
  };
20
21
  /** @internal */
@@ -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";
@@ -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";
@@ -8,6 +8,7 @@ export declare const OutputModality: {
8
8
  readonly Video: "video";
9
9
  readonly Rerank: "rerank";
10
10
  readonly Speech: "speech";
11
+ readonly Transcription: "transcription";
11
12
  };
12
13
  export type OutputModality = OpenEnum<typeof OutputModality>;
13
14
  /** @internal */
@@ -11,6 +11,7 @@ export const OutputModality = {
11
11
  Video: "video",
12
12
  Rerank: "rerank",
13
13
  Speech: "speech",
14
+ Transcription: "transcription",
14
15
  };
15
16
  /** @internal */
16
17
  export const OutputModality$inboundSchema = openEnums.inboundSchema(OutputModality);
@@ -12,6 +12,14 @@ export type OutputWebFetchServerToolItemType = ClosedEnum<typeof OutputWebFetchS
12
12
  */
13
13
  export type OutputWebFetchServerToolItem = {
14
14
  content?: string | undefined;
15
+ /**
16
+ * The error message if the fetch failed.
17
+ */
18
+ error?: string | undefined;
19
+ /**
20
+ * The HTTP status code returned by the upstream URL fetch.
21
+ */
22
+ httpStatus?: number | undefined;
15
23
  id?: string | undefined;
16
24
  status: ToolCallStatus;
17
25
  title?: string | undefined;
@@ -27,6 +35,8 @@ export declare const OutputWebFetchServerToolItem$inboundSchema: z.ZodType<Outpu
27
35
  /** @internal */
28
36
  export type OutputWebFetchServerToolItem$Outbound = {
29
37
  content?: string | undefined;
38
+ error?: string | undefined;
39
+ httpStatus?: number | undefined;
30
40
  id?: string | undefined;
31
41
  status: string;
32
42
  title?: string | undefined;
@@ -15,6 +15,8 @@ export const OutputWebFetchServerToolItemType$outboundSchema = OutputWebFetchSer
15
15
  /** @internal */
16
16
  export const OutputWebFetchServerToolItem$inboundSchema = z.object({
17
17
  content: z.string().optional(),
18
+ error: z.string().optional(),
19
+ httpStatus: z.int().optional(),
18
20
  id: z.string().optional(),
19
21
  status: ToolCallStatus$inboundSchema,
20
22
  title: z.string().optional(),
@@ -24,6 +26,8 @@ export const OutputWebFetchServerToolItem$inboundSchema = z.object({
24
26
  /** @internal */
25
27
  export const OutputWebFetchServerToolItem$outboundSchema = z.object({
26
28
  content: z.string().optional(),
29
+ error: z.string().optional(),
30
+ httpStatus: z.int().optional(),
27
31
  id: z.string().optional(),
28
32
  status: ToolCallStatus$outboundSchema,
29
33
  title: z.string().optional(),
@@ -7,7 +7,7 @@ export type InputTokensDetails = {
7
7
  export type OutputTokensDetails = {
8
8
  reasoningTokens: number;
9
9
  };
10
- export type CostDetails = {
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?: CostDetails | undefined;
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 CostDetails$inboundSchema: z.ZodType<CostDetails, unknown>;
42
- export declare function costDetailsFromJSON(jsonString: string): SafeParseResult<CostDetails, SDKValidationError>;
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>;
@@ -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 CostDetails$inboundSchema = z
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 costDetailsFromJSON(jsonString) {
44
- return safeParse(jsonString, (x) => CostDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CostDetails' from JSON`);
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(() => CostDetails$inboundSchema).optional(),
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "0.12.21",
5
+ "version": "0.12.23",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrouter/sdk",
3
- "version": "0.12.21",
3
+ "version": "0.12.23",
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,14 +69,14 @@
69
69
  "lint": "eslint --cache --max-warnings=0 src",
70
70
  "build": "tsc",
71
71
  "prepublishOnly": "npm run build",
72
- "compile": "tsc",
73
72
  "postinstall": "node scripts/check-types.js || true",
73
+ "test": "vitest --run --project unit",
74
74
  "test:e2e": "vitest --run --project e2e",
75
- "test:watch": "vitest --watch --project unit",
75
+ "test:transit": "exit 0",
76
76
  "typecheck": "tsc --noEmit",
77
+ "compile": "tsc",
77
78
  "prepare": "npm run build",
78
- "test": "vitest --run --project unit",
79
- "test:transit": "exit 0",
79
+ "test:watch": "vitest --watch --project unit",
80
80
  "typecheck:transit": "exit 0"
81
81
  },
82
82
  "peerDependencies": {},