@openrouter/sdk 1.5.135 → 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";
@@ -786,6 +788,7 @@ export * from "./responsehealingplugin.js";
786
788
  export * from "./responseincludesenum.js";
787
789
  export * from "./responseoutputtext.js";
788
790
  export * from "./responsesbadrequestresponseerrordata.js";
791
+ export * from "./responsescontextmanagement.js";
789
792
  export * from "./responsesinputtransformation.js";
790
793
  export * from "./responsesrequest.js";
791
794
  export * from "./responsesstreamingresponse.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";
@@ -789,6 +791,7 @@ export * from "./responsehealingplugin.js";
789
791
  export * from "./responseincludesenum.js";
790
792
  export * from "./responseoutputtext.js";
791
793
  export * from "./responsesbadrequestresponseerrordata.js";
794
+ export * from "./responsescontextmanagement.js";
792
795
  export * from "./responsesinputtransformation.js";
793
796
  export * from "./responsesrequest.js";
794
797
  export * from "./responsesstreamingresponse.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";
@@ -0,0 +1,27 @@
1
+ import * as z from "zod/v4";
2
+ /**
3
+ * A server-side context management entry. With `compaction`, the provider compacts the conversation once input exceeds `compact_threshold` and returns a `compaction` output item; pass that item back in `input` on later turns.
4
+ */
5
+ export type ResponsesContextManagement = {
6
+ /**
7
+ * Input token count at which server-side compaction is triggered.
8
+ */
9
+ compactThreshold?: number | null | undefined;
10
+ /**
11
+ * The context management strategy. Currently only `compaction` is supported.
12
+ */
13
+ type: string;
14
+ additionalProperties?: {
15
+ [k: string]: any;
16
+ } | undefined;
17
+ };
18
+ /** @internal */
19
+ export type ResponsesContextManagement$Outbound = {
20
+ compact_threshold?: number | null | undefined;
21
+ type: string;
22
+ [additionalProperties: string]: unknown;
23
+ };
24
+ /** @internal */
25
+ export declare const ResponsesContextManagement$outboundSchema: z.ZodType<ResponsesContextManagement$Outbound, ResponsesContextManagement>;
26
+ export declare function responsesContextManagementToJSON(responsesContextManagement: ResponsesContextManagement): string;
27
+ //# sourceMappingURL=responsescontextmanagement.d.ts.map
@@ -0,0 +1,23 @@
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
+ /** @internal */
7
+ export const ResponsesContextManagement$outboundSchema = z.object({
8
+ compactThreshold: z.nullable(z.int()).optional(),
9
+ type: z.string(),
10
+ additionalProperties: z.record(z.string(), z.any()).optional(),
11
+ }).transform((v) => {
12
+ return {
13
+ ...v.additionalProperties,
14
+ ...remap$(v, {
15
+ compactThreshold: "compact_threshold",
16
+ additionalProperties: null,
17
+ }),
18
+ };
19
+ });
20
+ export function responsesContextManagementToJSON(responsesContextManagement) {
21
+ return JSON.stringify(ResponsesContextManagement$outboundSchema.parse(responsesContextManagement));
22
+ }
23
+ //# sourceMappingURL=responsescontextmanagement.js.map
@@ -46,6 +46,7 @@ import { ReasoningMode } from "./reasoningmode.js";
46
46
  import { ReasoningSummaryVerbosity } from "./reasoningsummaryverbosity.js";
47
47
  import { ResponseHealingPlugin, ResponseHealingPlugin$Outbound } from "./responsehealingplugin.js";
48
48
  import { ResponseIncludesEnum } from "./responseincludesenum.js";
49
+ import { ResponsesContextManagement, ResponsesContextManagement$Outbound } from "./responsescontextmanagement.js";
49
50
  import { SearchModelsServerToolOpenRouter, SearchModelsServerToolOpenRouter$Outbound } from "./searchmodelsservertoolopenrouter.js";
50
51
  import { ShellServerTool, ShellServerTool$Outbound } from "./shellservertool.js";
51
52
  import { ShellServerToolOpenRouter, ShellServerToolOpenRouter$Outbound } from "./shellservertoolopenrouter.js";
@@ -207,6 +208,10 @@ export type ResponsesRequest = {
207
208
  * Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.
208
209
  */
209
210
  cacheControl?: AnthropicCacheControlDirective | undefined;
211
+ /**
212
+ * Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns.
213
+ */
214
+ contextManagement?: Array<ResponsesContextManagement> | null | undefined;
210
215
  /**
211
216
  * Debug options for inspecting request transformations (streaming only)
212
217
  */
@@ -487,6 +492,7 @@ export type ResponsesRequest$Outbound = {
487
492
  access_programs?: ResponsesRequestAccessPrograms$Outbound | undefined;
488
493
  background?: boolean | null | undefined;
489
494
  cache_control?: AnthropicCacheControlDirective$Outbound | undefined;
495
+ context_management?: Array<ResponsesContextManagement$Outbound> | null | undefined;
490
496
  debug?: ChatDebugOptions$Outbound | undefined;
491
497
  deferred_tools?: DeferredToolsControl$Outbound | undefined;
492
498
  frequency_penalty?: number | null | undefined;
@@ -50,6 +50,7 @@ import { ReasoningMode$outboundSchema, } from "./reasoningmode.js";
50
50
  import { ReasoningSummaryVerbosity$outboundSchema, } from "./reasoningsummaryverbosity.js";
51
51
  import { ResponseHealingPlugin$outboundSchema, } from "./responsehealingplugin.js";
52
52
  import { ResponseIncludesEnum$outboundSchema, } from "./responseincludesenum.js";
53
+ import { ResponsesContextManagement$outboundSchema, } from "./responsescontextmanagement.js";
53
54
  import { SearchModelsServerToolOpenRouter$outboundSchema, } from "./searchmodelsservertoolopenrouter.js";
54
55
  import { ShellServerTool$outboundSchema, } from "./shellservertool.js";
55
56
  import { ShellServerToolOpenRouter$outboundSchema, } from "./shellservertoolopenrouter.js";
@@ -202,6 +203,7 @@ export const ResponsesRequest$outboundSchema = z.object({
202
203
  .optional(),
203
204
  background: z.nullable(z.boolean()).optional(),
204
205
  cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(),
206
+ contextManagement: z.nullable(z.array(ResponsesContextManagement$outboundSchema)).optional(),
205
207
  debug: ChatDebugOptions$outboundSchema.optional(),
206
208
  deferredTools: DeferredToolsControl$outboundSchema.optional(),
207
209
  frequencyPenalty: z.nullable(z.number()).optional(),
@@ -292,6 +294,7 @@ export const ResponsesRequest$outboundSchema = z.object({
292
294
  return remap$(v, {
293
295
  accessPrograms: "access_programs",
294
296
  cacheControl: "cache_control",
297
+ contextManagement: "context_management",
295
298
  deferredTools: "deferred_tools",
296
299
  frequencyPenalty: "frequency_penalty",
297
300
  imageConfig: "image_config",
@@ -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.135",
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.135",
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": [
@@ -73,15 +73,15 @@
73
73
  "lint": "eslint --cache --max-warnings=0 src",
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
- "typecheck": "tsc --noEmit",
77
- "typecheck:transit": "exit 0",
78
- "postinstall": "node scripts/check-types.js || true",
79
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",
80
78
  "prepare": "npm run build",
81
79
  "test": "vitest --run --project unit",
82
80
  "test:e2e": "vitest --run --project e2e",
83
81
  "test:transit": "exit 0",
84
- "test:watch": "vitest --watch --project unit"
82
+ "test:watch": "vitest --watch --project unit",
83
+ "typecheck": "tsc --noEmit",
84
+ "typecheck:transit": "exit 0"
85
85
  },
86
86
  "peerDependencies": {
87
87