@openrouter/sdk 1.5.136 → 1.5.137

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.
@@ -0,0 +1,24 @@
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 { BatchResult } from "./batchresult.js";
5
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
6
+ export declare const BatchResultsPageResponseObject: {
7
+ readonly List: "list";
8
+ };
9
+ export type BatchResultsPageResponseObject = ClosedEnum<typeof BatchResultsPageResponseObject>;
10
+ /**
11
+ * A cursor-paginated page of normalized batch result rows.
12
+ */
13
+ export type BatchResultsPageResponse = {
14
+ data: Array<BatchResult>;
15
+ hasMore: boolean;
16
+ nextCursor: string | null;
17
+ object: BatchResultsPageResponseObject;
18
+ };
19
+ /** @internal */
20
+ export declare const BatchResultsPageResponseObject$inboundSchema: z.ZodEnum<typeof BatchResultsPageResponseObject>;
21
+ /** @internal */
22
+ export declare const BatchResultsPageResponse$inboundSchema: z.ZodType<BatchResultsPageResponse, unknown>;
23
+ export declare function batchResultsPageResponseFromJSON(jsonString: string): SafeParseResult<BatchResultsPageResponse, SDKValidationError>;
24
+ //# sourceMappingURL=batchresultspageresponse.d.ts.map
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import * as z from "zod/v4";
5
+ import { remap as remap$ } from "../lib/primitives.js";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { BatchResult$inboundSchema } from "./batchresult.js";
8
+ export const BatchResultsPageResponseObject = {
9
+ List: "list",
10
+ };
11
+ /** @internal */
12
+ export const BatchResultsPageResponseObject$inboundSchema = z.enum(BatchResultsPageResponseObject);
13
+ /** @internal */
14
+ export const BatchResultsPageResponse$inboundSchema = z.object({
15
+ data: z.array(BatchResult$inboundSchema),
16
+ has_more: z.boolean(),
17
+ next_cursor: z.nullable(z.string()),
18
+ object: BatchResultsPageResponseObject$inboundSchema,
19
+ }).transform((v) => {
20
+ return remap$(v, {
21
+ "has_more": "hasMore",
22
+ "next_cursor": "nextCursor",
23
+ });
24
+ });
25
+ export function batchResultsPageResponseFromJSON(jsonString) {
26
+ return safeParse(jsonString, (x) => BatchResultsPageResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchResultsPageResponse' from JSON`);
27
+ }
28
+ //# sourceMappingURL=batchresultspageresponse.js.map
@@ -170,6 +170,8 @@ export * from "./batchobject.js";
170
170
  export * from "./batchoutputreference.js";
171
171
  export * from "./batchpaymentrequiredresponseerror.js";
172
172
  export * from "./batchproviderpreferences.js";
173
+ export * from "./batchresult.js";
174
+ export * from "./batchresultspageresponse.js";
173
175
  export * from "./batchsubmitbody.js";
174
176
  export * from "./booleancapability.js";
175
177
  export * from "./budgetaccountguardrailpolicy.js";
@@ -173,6 +173,8 @@ export * from "./batchobject.js";
173
173
  export * from "./batchoutputreference.js";
174
174
  export * from "./batchpaymentrequiredresponseerror.js";
175
175
  export * from "./batchproviderpreferences.js";
176
+ export * from "./batchresult.js";
177
+ export * from "./batchresultspageresponse.js";
176
178
  export * from "./batchsubmitbody.js";
177
179
  export * from "./booleancapability.js";
178
180
  export * from "./budgetaccountguardrailpolicy.js";
@@ -0,0 +1,77 @@
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 * as models from "../index.js";
5
+ export type GetBatchResultsGlobals = {
6
+ /**
7
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
8
+ *
9
+ * @remarks
10
+ * This is used to track API usage per application.
11
+ */
12
+ httpReferer?: string | undefined;
13
+ /**
14
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
15
+ *
16
+ * @remarks
17
+ */
18
+ appTitle?: string | undefined;
19
+ /**
20
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
21
+ *
22
+ * @remarks
23
+ */
24
+ appCategories?: string | undefined;
25
+ };
26
+ export type GetBatchResultsRequest = {
27
+ /**
28
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
29
+ *
30
+ * @remarks
31
+ * This is used to track API usage per application.
32
+ */
33
+ httpReferer?: string | undefined;
34
+ /**
35
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
36
+ *
37
+ * @remarks
38
+ */
39
+ appTitle?: string | undefined;
40
+ /**
41
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
42
+ *
43
+ * @remarks
44
+ */
45
+ appCategories?: string | undefined;
46
+ /**
47
+ * The batch job id returned from submit.
48
+ */
49
+ id: string;
50
+ /**
51
+ * Maximum number of result items to return, from 1 through 1000.
52
+ */
53
+ limit?: number | undefined;
54
+ /**
55
+ * Opaque pagination cursor from the previous page's `next_cursor`. Omit for the first page.
56
+ */
57
+ cursor?: string | undefined;
58
+ };
59
+ export type GetBatchResultsResponse = {
60
+ result: models.BatchResultsPageResponse;
61
+ };
62
+ /** @internal */
63
+ export type GetBatchResultsRequest$Outbound = {
64
+ "HTTP-Referer"?: string | undefined;
65
+ appTitle?: string | undefined;
66
+ appCategories?: string | undefined;
67
+ id: string;
68
+ limit?: number | undefined;
69
+ cursor?: string | undefined;
70
+ };
71
+ /** @internal */
72
+ export declare const GetBatchResultsRequest$outboundSchema: z.ZodType<GetBatchResultsRequest$Outbound, GetBatchResultsRequest>;
73
+ export declare function getBatchResultsRequestToJSON(getBatchResultsRequest: GetBatchResultsRequest): string;
74
+ /** @internal */
75
+ export declare const GetBatchResultsResponse$inboundSchema: z.ZodType<GetBatchResultsResponse, unknown>;
76
+ export declare function getBatchResultsResponseFromJSON(jsonString: string): SafeParseResult<GetBatchResultsResponse, SDKValidationError>;
77
+ //# sourceMappingURL=getbatchresults.d.ts.map
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import * as z from "zod/v4";
5
+ import { remap as remap$ } from "../../lib/primitives.js";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { BatchResultsPageResponse$inboundSchema as models_BatchResultsPageResponse$inboundSchema } from "../batchresultspageresponse.js";
8
+ /** @internal */
9
+ export const GetBatchResultsRequest$outboundSchema = z.object({
10
+ httpReferer: z.string().optional(),
11
+ appTitle: z.string().optional(),
12
+ appCategories: z.string().optional(),
13
+ id: z.string(),
14
+ limit: z.int().optional(),
15
+ cursor: z.string().optional(),
16
+ }).transform((v) => {
17
+ return remap$(v, {
18
+ httpReferer: "HTTP-Referer",
19
+ });
20
+ });
21
+ export function getBatchResultsRequestToJSON(getBatchResultsRequest) {
22
+ return JSON.stringify(GetBatchResultsRequest$outboundSchema.parse(getBatchResultsRequest));
23
+ }
24
+ /** @internal */
25
+ export const GetBatchResultsResponse$inboundSchema = z.object({
26
+ Result: models_BatchResultsPageResponse$inboundSchema,
27
+ }).transform((v) => {
28
+ return remap$(v, {
29
+ "Result": "result",
30
+ });
31
+ });
32
+ export function getBatchResultsResponseFromJSON(jsonString) {
33
+ return safeParse(jsonString, (x) => GetBatchResultsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetBatchResultsResponse' from JSON`);
34
+ }
35
+ //# sourceMappingURL=getbatchresults.js.map
@@ -67,6 +67,7 @@ export * from "./getanalyticsmeta.js";
67
67
  export * from "./getapikeypolicyassignment.js";
68
68
  export * from "./getapprankings.js";
69
69
  export * from "./getbatches.js";
70
+ export * from "./getbatchresults.js";
70
71
  export * from "./getbenchmarks.js";
71
72
  export * from "./getbudgetpolicy.js";
72
73
  export * from "./getbyokkey.js";
@@ -70,6 +70,7 @@ export * from "./getanalyticsmeta.js";
70
70
  export * from "./getapikeypolicyassignment.js";
71
71
  export * from "./getapprankings.js";
72
72
  export * from "./getbatches.js";
73
+ export * from "./getbatchresults.js";
73
74
  export * from "./getbenchmarks.js";
74
75
  export * from "./getbudgetpolicy.js";
75
76
  export * from "./getbyokkey.js";
@@ -33,5 +33,14 @@ export declare class Batch extends ClientSDK {
33
33
  * Returns a batch with its status and request counts. Batches in a terminal status include `results`. Failed batches report the reason in `error.message`. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart).
34
34
  */
35
35
  getBatches(request: operations.GetBatchesRequest, options?: RequestOptions): Promise<models.BatchObject>;
36
+ /**
37
+ * Get batch results
38
+ *
39
+ * @remarks
40
+ * Returns a cursor-paginated page of normalized OpenRouter-format results for a finished batch. Pass the previous page's `next_cursor` as `cursor` to read the next page. Pages are stable across retries for the 30-day artifact retention window. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart).
41
+ */
42
+ getResults(request: operations.GetBatchResultsRequest, options?: RequestOptions): Promise<PageIterator<operations.GetBatchResultsResponse, {
43
+ cursor: string;
44
+ }>>;
36
45
  }
37
46
  //# sourceMappingURL=batch.d.ts.map
package/esm/sdk/batch.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { batchCreateBatches } from "../funcs/batchCreateBatches.js";
5
5
  import { batchDelete } from "../funcs/batchDelete.js";
6
6
  import { batchGetBatches } from "../funcs/batchGetBatches.js";
7
+ import { batchGetResults } from "../funcs/batchGetResults.js";
7
8
  import { batchList } from "../funcs/batchList.js";
8
9
  import { ClientSDK } from "../lib/sdks.js";
9
10
  import { unwrapAsync } from "../types/fp.js";
@@ -45,5 +46,14 @@ export class Batch extends ClientSDK {
45
46
  async getBatches(request, options) {
46
47
  return unwrapAsync(batchGetBatches(this, request, options));
47
48
  }
49
+ /**
50
+ * Get batch results
51
+ *
52
+ * @remarks
53
+ * Returns a cursor-paginated page of normalized OpenRouter-format results for a finished batch. Pass the previous page's `next_cursor` as `cursor` to read the next page. Pages are stable across retries for the 30-day artifact retention window. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart).
54
+ */
55
+ async getResults(request, options) {
56
+ return unwrapResultIterator(batchGetResults(this, request, options));
57
+ }
48
58
  }
49
59
  //# sourceMappingURL=batch.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.5.136",
5
+ "version": "1.5.137",
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": "1.5.136",
3
+ "version": "1.5.137",
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": [
@@ -74,14 +74,14 @@
74
74
  "build": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js",
75
75
  "prepublishOnly": "npm run build",
76
76
  "compile": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js",
77
+ "postinstall": "node scripts/check-types.js || true",
78
+ "prepare": "npm run build",
77
79
  "test": "vitest --run --project unit",
78
80
  "test:e2e": "vitest --run --project e2e",
79
81
  "test:transit": "exit 0",
82
+ "test:watch": "vitest --watch --project unit",
80
83
  "typecheck": "tsc --noEmit",
81
- "typecheck:transit": "exit 0",
82
- "postinstall": "node scripts/check-types.js || true",
83
- "prepare": "npm run build",
84
- "test:watch": "vitest --watch --project unit"
84
+ "typecheck:transit": "exit 0"
85
85
  },
86
86
  "peerDependencies": {
87
87