@openrouter/sdk 1.3.4 → 1.3.6

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.
@@ -15,5 +15,5 @@ import { Result } from "../types/fp.js";
15
15
  * @remarks
16
16
  * Update an existing bring-your-own-key (BYOK) provider credential by its `id`. Include the `key` field to rotate the raw provider API key in-place (the previous key material is overwritten). Use `allowed_api_key_hashes` to restrict the credential to specific OpenRouter API keys (`null` clears the restriction). [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
17
  */
18
- export declare function byokUpdate(client: OpenRouterCore, request: operations.UpdateBYOKKeyRequest, options?: RequestOptions): APIPromise<Result<models.UpdateBYOKKeyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
+ export declare function byokUpdate(client: OpenRouterCore, request: operations.UpdateBYOKKeyRequest, options?: RequestOptions): APIPromise<Result<models.UpdateBYOKKeyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
19
  //# sourceMappingURL=byokUpdate.d.ts.map
@@ -97,7 +97,7 @@ async function $do(client, request, options) {
97
97
  const responseFields = {
98
98
  HttpMeta: { Response: response, Request: req },
99
99
  };
100
- const [result] = await M.match(M.json(200, models.UpdateBYOKKeyResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
100
+ const [result] = await M.match(M.json(200, models.UpdateBYOKKeyResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
101
101
  if (!result.ok) {
102
102
  return [result, { status: "complete", request: req, response }];
103
103
  }
@@ -13,7 +13,7 @@ import { Result } from "../types/fp.js";
13
13
  * Delete an intern
14
14
  *
15
15
  * @remarks
16
- * Starts safe teardown of the intern, its runtime and its private vault. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
16
+ * Starts safe teardown of the intern, its runtime and its private vault. The body is optional. Send `{"acknowledge_workspace_loss": true}` to delete a `destroy_failed` intern whose `last_failure_message` names `workspace_archive_failed`, accepting that its workspace is not backed up. The request body is capped at 1048576 bytes and a larger body is refused with 413. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
17
17
  *
18
18
  * If set, this operation will use {@link Security.apiKey} from the global security.
19
19
  */
@@ -2,7 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 7eb35f20da18
4
4
  */
5
- import { encodeSimple } from "../lib/encodings.js";
5
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
6
6
  import { matchStatusCode } from "../lib/http.js";
7
7
  import * as M from "../lib/matchers.js";
8
8
  import { compactMap } from "../lib/primitives.js";
@@ -17,7 +17,7 @@ import { APIPromise } from "../types/async.js";
17
17
  * Delete an intern
18
18
  *
19
19
  * @remarks
20
- * Starts safe teardown of the intern, its runtime and its private vault. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
20
+ * Starts safe teardown of the intern, its runtime and its private vault. The body is optional. Send `{"acknowledge_workspace_loss": true}` to delete a `destroy_failed` intern whose `last_failure_message` names `workspace_archive_failed`, accepting that its workspace is not backed up. The request body is capped at 1048576 bytes and a larger body is refused with 413. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
21
21
  *
22
22
  * If set, this operation will use {@link Security.apiKey} from the global security.
23
23
  */
@@ -30,7 +30,9 @@ async function $do(client, request, options) {
30
30
  return [parsed, { status: "invalid" }];
31
31
  }
32
32
  const payload = parsed.value;
33
- const body = null;
33
+ const body = encodeJSON("body", payload.DeleteInternRequest, {
34
+ explode: true,
35
+ });
34
36
  const pathParams = {
35
37
  internId: encodeSimple("internId", payload.internId, {
36
38
  explode: false,
@@ -39,6 +41,7 @@ async function $do(client, request, options) {
39
41
  };
40
42
  const path = pathToFunc("/interns/{internId}")(pathParams);
41
43
  const headers = new Headers(compactMap({
44
+ "Content-Type": "application/json",
42
45
  Accept: "application/json",
43
46
  "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
44
47
  "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
@@ -96,7 +99,7 @@ async function $do(client, request, options) {
96
99
  const responseFields = {
97
100
  HttpMeta: { Response: response, Request: req },
98
101
  };
99
- const [result] = await M.match(M.json(202, models.DeleteInternResponse$inboundSchema), M.jsonErr([401, 403, 404, 408, 409], errors.InternLifecycleError$inboundSchema), M.jsonErr([500, 502], errors.InternLifecycleError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
102
+ const [result] = await M.match(M.json(202, models.DeleteInternResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 408, 409, 413], errors.InternLifecycleError$inboundSchema), M.jsonErr([500, 502], errors.InternLifecycleError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
100
103
  if (!result.ok) {
101
104
  return [result, { status: "complete", request: req, response }];
102
105
  }
@@ -36,6 +36,7 @@ async function $do(client, request, options) {
36
36
  "status": payload?.status,
37
37
  }, { explode: false }), encodeFormQuery({
38
38
  "limit": payload?.limit,
39
+ "starting_after": payload?.starting_after,
39
40
  "workspace_id": payload?.workspace_id,
40
41
  }));
41
42
  const headers = new Headers(compactMap({
@@ -50,8 +50,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
50
50
  export declare const SDK_METADATA: {
51
51
  readonly language: "typescript";
52
52
  readonly openapiDocVersion: "1.0.0";
53
- readonly sdkVersion: "1.3.4";
53
+ readonly sdkVersion: "1.3.6";
54
54
  readonly genVersion: "2.914.0";
55
- readonly userAgent: "speakeasy-sdk/typescript 1.3.4 2.914.0 1.0.0 @openrouter/sdk";
55
+ readonly userAgent: "speakeasy-sdk/typescript 1.3.6 2.914.0 1.0.0 @openrouter/sdk";
56
56
  };
57
57
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -29,8 +29,8 @@ export function serverURLFromOptions(options) {
29
29
  export const SDK_METADATA = {
30
30
  language: "typescript",
31
31
  openapiDocVersion: "1.0.0",
32
- sdkVersion: "1.3.4",
32
+ sdkVersion: "1.3.6",
33
33
  genVersion: "2.914.0",
34
- userAgent: "speakeasy-sdk/typescript 1.3.4 2.914.0 1.0.0 @openrouter/sdk",
34
+ userAgent: "speakeasy-sdk/typescript 1.3.6 2.914.0 1.0.0 @openrouter/sdk",
35
35
  };
36
36
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,18 @@
1
+ import * as z from "zod/v4";
2
+ /**
3
+ * Optional consent for a teardown that discards the workspace.
4
+ */
5
+ export type DeleteInternRequest = {
6
+ /**
7
+ * Delete even though the workspace backup was not confirmed. Defaults to false, which refuses the teardown when a workspace archive is missing.
8
+ */
9
+ acknowledgeWorkspaceLoss?: boolean | undefined;
10
+ };
11
+ /** @internal */
12
+ export type DeleteInternRequest$Outbound = {
13
+ acknowledge_workspace_loss: boolean;
14
+ };
15
+ /** @internal */
16
+ export declare const DeleteInternRequest$outboundSchema: z.ZodType<DeleteInternRequest$Outbound, DeleteInternRequest>;
17
+ export declare function deleteInternRequestToJSON(deleteInternRequest: DeleteInternRequest): string;
18
+ //# sourceMappingURL=deleteinternrequest.d.ts.map
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 732bd4f781c2
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../lib/primitives.js";
7
+ /** @internal */
8
+ export const DeleteInternRequest$outboundSchema = z.object({
9
+ acknowledgeWorkspaceLoss: z.boolean().default(false),
10
+ }).transform((v) => {
11
+ return remap$(v, {
12
+ acknowledgeWorkspaceLoss: "acknowledge_workspace_loss",
13
+ });
14
+ });
15
+ export function deleteInternRequestToJSON(deleteInternRequest) {
16
+ return JSON.stringify(DeleteInternRequest$outboundSchema.parse(deleteInternRequest));
17
+ }
18
+ //# sourceMappingURL=deleteinternrequest.js.map
@@ -209,6 +209,7 @@ export * from "./decisionsscorequestion.js";
209
209
  export * from "./defaultparameters.js";
210
210
  export * from "./deletebyokkeyresponse.js";
211
211
  export * from "./deleteguardrailresponse.js";
212
+ export * from "./deleteinternrequest.js";
212
213
  export * from "./deleteinternresponse.js";
213
214
  export * from "./deleteobservabilitydestinationresponse.js";
214
215
  export * from "./deletescimgroupmappingresponse.js";
@@ -213,6 +213,7 @@ export * from "./decisionsscorequestion.js";
213
213
  export * from "./defaultparameters.js";
214
214
  export * from "./deletebyokkeyresponse.js";
215
215
  export * from "./deleteguardrailresponse.js";
216
+ export * from "./deleteinternrequest.js";
216
217
  export * from "./deleteinternresponse.js";
217
218
  export * from "./deleteobservabilitydestinationresponse.js";
218
219
  export * from "./deletescimgroupmappingresponse.js";
@@ -27,12 +27,12 @@ export type InternChatCompletionChunk = {
27
27
  */
28
28
  id: string;
29
29
  /**
30
- * The request `model` when given, or `openrouter/intern`. The final chunk may carry the model the intern reported for the run instead.
30
+ * The runtime's identifier for the model the intern is running, as the intern reports it. Each chunk carries the model from the event behind it: `openrouter/intern` on chunks emitted before the intern has reported one and on chunks the API emits itself (timeout, run-ended and severed-stream errors and their final usage chunk), even after an earlier chunk named a model. It can change within a stream. It is not an OpenRouter model slug, and the request `model` is never used.
31
31
  */
32
32
  model: string;
33
33
  object: InternChatCompletionChunkObject;
34
34
  /**
35
- * On the final chunk of every response, the daemon session to continue with, or `null` when the run failed before the intern reported one. Send it as `session_id` on the next request, including the `tool` reply to an interaction.
35
+ * On the final chunk of every response, the daemon session to continue with, or `null` when the run failed before the intern reported one. Send it as `session_id` on the next request, including the `tool` reply to an interaction. Session ids are client-visible and scoped to the intern's own daemon.
36
36
  */
37
37
  sessionId?: string | null | undefined;
38
38
  /**
@@ -14,15 +14,15 @@ export type InternChatCompletionRequest = {
14
14
  */
15
15
  messages: Array<InternChatMessage>;
16
16
  /**
17
- * Accepted for OpenAI compatibility and ignored. Streamed chunks report the model the intern actually used, or `openrouter/intern` when it did not report one.
17
+ * Accepted for OpenAI compatibility and never used. The intern runs the model configured on it (`PATCH` the intern to change it). Streamed chunks report the runtime's identifier for that model as the intern reports it, or `openrouter/intern` on chunks whose event carries no model (before the intern reports one, and on the chunks the API emits itself: the timeout, run-ended and severed-stream error chunks, the stop chunk of a replay that ends without a terminal daemon event, and the final usage chunk after any of them). A usage chunk that follows a daemon completion event carries the model the intern reported.
18
18
  */
19
19
  model?: string | undefined;
20
20
  /**
21
- * The daemon session to continue, as returned in `session_id` on the final chunk of an earlier response. Omit it to start a new session. Required when the last message has role `tool`.
21
+ * The daemon session to continue, as returned in `session_id` on the final chunk of an earlier response. Omit it to start a new session. An id the intern has not seen before is not an error: it starts a new session under that id, so a mistyped id forks the conversation. Sessions are scoped to the intern's own daemon. Required when the last message has role `tool`.
22
22
  */
23
23
  sessionId?: string | undefined;
24
24
  /**
25
- * Must be `true`. This endpoint only streams.
25
+ * Must be `true`. This endpoint only streams. `false` or an omitted `stream` is refused with `400` and reason `bad_request`.
26
26
  */
27
27
  stream: true;
28
28
  };
@@ -11,6 +11,10 @@ export type InternListResponse = {
11
11
  * True when more interns match the current filters.
12
12
  */
13
13
  hasMore: boolean;
14
+ /**
15
+ * Opaque cursor, present when `has_more` is true. Pass it as `starting_after` to fetch the next page.
16
+ */
17
+ nextCursor?: string | undefined;
14
18
  };
15
19
  /** @internal */
16
20
  export declare const InternListResponse$inboundSchema: z.ZodType<InternListResponse, unknown>;
@@ -10,9 +10,11 @@ import { Intern$inboundSchema } from "./intern.js";
10
10
  export const InternListResponse$inboundSchema = z.object({
11
11
  data: z.array(Intern$inboundSchema),
12
12
  has_more: z.boolean(),
13
+ next_cursor: z.string().optional(),
13
14
  }).transform((v) => {
14
15
  return remap$(v, {
15
16
  "has_more": "hasMore",
17
+ "next_cursor": "nextCursor",
16
18
  });
17
19
  });
18
20
  export function internListResponseFromJSON(jsonString) {
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod/v4";
2
+ import * as models from "../index.js";
2
3
  export type DeleteInternGlobals = {
3
4
  /**
4
5
  * The app identifier should be your app's URL and is used as the primary identifier for rankings.
@@ -44,6 +45,7 @@ export type DeleteInternRequest = {
44
45
  * ID of an intern visible to the authenticated API key.
45
46
  */
46
47
  internId: string;
48
+ deleteInternRequest: models.DeleteInternRequest;
47
49
  };
48
50
  /** @internal */
49
51
  export type DeleteInternRequest$Outbound = {
@@ -51,6 +53,7 @@ export type DeleteInternRequest$Outbound = {
51
53
  appTitle?: string | undefined;
52
54
  appCategories?: string | undefined;
53
55
  internId: string;
56
+ DeleteInternRequest: models.DeleteInternRequest$Outbound;
54
57
  };
55
58
  /** @internal */
56
59
  export declare const DeleteInternRequest$outboundSchema: z.ZodType<DeleteInternRequest$Outbound, DeleteInternRequest>;
@@ -4,15 +4,18 @@
4
4
  */
5
5
  import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
+ import * as models from "../index.js";
7
8
  /** @internal */
8
9
  export const DeleteInternRequest$outboundSchema = z.object({
9
10
  httpReferer: z.string().optional(),
10
11
  appTitle: z.string().optional(),
11
12
  appCategories: z.string().optional(),
12
13
  internId: z.string(),
14
+ deleteInternRequest: models.DeleteInternRequest$outboundSchema,
13
15
  }).transform((v) => {
14
16
  return remap$(v, {
15
17
  httpReferer: "HTTP-Referer",
18
+ deleteInternRequest: "DeleteInternRequest",
16
19
  });
17
20
  });
18
21
  export function deleteInternRequestToJSON(deleteInternRequest) {
@@ -60,6 +60,10 @@ export type ListInternsRequest = {
60
60
  * Comma-separated lifecycle statuses to include.
61
61
  */
62
62
  status?: Array<Status> | undefined;
63
+ /**
64
+ * The opaque `next_cursor` of the previous page. Returns the interns that come after it in the newest-first order. A malformed cursor is a 400.
65
+ */
66
+ startingAfter?: string | undefined;
63
67
  /**
64
68
  * Only return interns in this workspace. It must match the API key workspace.
65
69
  */
@@ -74,6 +78,7 @@ export type ListInternsRequest$Outbound = {
74
78
  appCategories?: string | undefined;
75
79
  limit?: number | undefined;
76
80
  status?: Array<string> | undefined;
81
+ starting_after?: string | undefined;
77
82
  workspace_id?: string | undefined;
78
83
  };
79
84
  /** @internal */
@@ -25,10 +25,12 @@ export const ListInternsRequest$outboundSchema = z.object({
25
25
  appCategories: z.string().optional(),
26
26
  limit: z.int().optional(),
27
27
  status: z.array(Status$outboundSchema).optional(),
28
+ startingAfter: z.string().optional(),
28
29
  workspaceId: z.string().optional(),
29
30
  }).transform((v) => {
30
31
  return remap$(v, {
31
32
  httpReferer: "HTTP-Referer",
33
+ startingAfter: "starting_after",
32
34
  workspaceId: "workspace_id",
33
35
  });
34
36
  });
@@ -12,7 +12,7 @@ export type UpdateInternRequest = {
12
12
  */
13
13
  instructions?: string | null | undefined;
14
14
  /**
15
- * New OpenRouter model slug. Null restores the workspace default.
15
+ * New OpenRouter model slug in `author/slug` form (an optional `:variant` suffix is accepted). Other shapes are refused with 400. Null restores the workspace default. Takes effect on the next provision: until then `GET` shows this configured model while chat chunks show the model the running intern reports.
16
16
  */
17
17
  model?: string | null | undefined;
18
18
  /**
@@ -21,7 +21,7 @@ export declare class Interns extends ClientSDK {
21
21
  * Delete an intern
22
22
  *
23
23
  * @remarks
24
- * Starts safe teardown of the intern, its runtime and its private vault. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
24
+ * Starts safe teardown of the intern, its runtime and its private vault. The body is optional. Send `{"acknowledge_workspace_loss": true}` to delete a `destroy_failed` intern whose `last_failure_message` names `workspace_archive_failed`, accepting that its workspace is not backed up. The request body is capped at 1048576 bytes and a larger body is refused with 413. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
25
25
  */
26
26
  deleteIntern(request: operations.DeleteInternRequest, options?: RequestOptions): Promise<models.DeleteInternResponse>;
27
27
  /**
@@ -35,7 +35,7 @@ export class Interns extends ClientSDK {
35
35
  * Delete an intern
36
36
  *
37
37
  * @remarks
38
- * Starts safe teardown of the intern, its runtime and its private vault. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
38
+ * Starts safe teardown of the intern, its runtime and its private vault. The body is optional. Send `{"acknowledge_workspace_loss": true}` to delete a `destroy_failed` intern whose `last_failure_message` names `workspace_archive_failed`, accepting that its workspace is not backed up. The request body is capped at 1048576 bytes and a larger body is refused with 413. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
39
39
  */
40
40
  async deleteIntern(request, options) {
41
41
  return unwrapAsync(internsDeleteIntern(this, request, options));
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.3.4",
5
+ "version": "1.3.6",
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.3.4",
3
+ "version": "1.3.6",
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
- "test:watch": "vitest --watch --project unit",
77
- "typecheck:transit": "exit 0",
78
- "prepare": "npm run build",
79
- "test": "vitest --run --project unit",
80
- "test:transit": "exit 0",
81
- "typecheck": "tsc --noEmit",
82
76
  "compile": "tsc",
83
77
  "postinstall": "node scripts/check-types.js || true",
84
- "test:e2e": "vitest --run --project e2e"
78
+ "prepare": "npm run build",
79
+ "test:e2e": "vitest --run --project e2e",
80
+ "test:transit": "exit 0",
81
+ "typecheck:transit": "exit 0",
82
+ "test": "vitest --run --project unit",
83
+ "test:watch": "vitest --watch --project unit",
84
+ "typecheck": "tsc --noEmit"
85
85
  },
86
86
  "peerDependencies": {},
87
87
  "devDependencies": {