@openrouter/sdk 1.2.4 → 1.2.5

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.
@@ -13,7 +13,7 @@ import { Result } from "../types/fp.js";
13
13
  * Get user activity grouped by endpoint
14
14
  *
15
15
  * @remarks
16
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required.
16
+ * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
17
  */
18
18
  export declare function analyticsGetUserActivity(client: OpenRouterCore, request?: operations.GetUserActivityRequest | undefined, options?: RequestOptions): APIPromise<Result<models.ActivityResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
19
  //# sourceMappingURL=analyticsGetUserActivity.d.ts.map
@@ -17,7 +17,7 @@ import { APIPromise } from "../types/async.js";
17
17
  * Get user activity grouped by endpoint
18
18
  *
19
19
  * @remarks
20
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required.
20
+ * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required.
21
21
  */
22
22
  export function analyticsGetUserActivity(client, request, options) {
23
23
  return new APIPromise($do(client, request, options));
@@ -33,7 +33,9 @@ async function $do(client, request, options) {
33
33
  const query = encodeFormQuery({
34
34
  "api_key_hash": payload?.api_key_hash,
35
35
  "date": payload?.date,
36
+ "group_by": payload?.group_by,
36
37
  "user_id": payload?.user_id,
38
+ "workspace_id": payload?.workspace_id,
37
39
  });
38
40
  const headers = new Headers(compactMap({
39
41
  Accept: "application/json",
@@ -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: "1.2.4";
52
+ readonly sdkVersion: "1.2.5";
53
53
  readonly genVersion: "2.914.0";
54
- readonly userAgent: "speakeasy-sdk/typescript 1.2.4 2.914.0 1.0.0 @openrouter/sdk";
54
+ readonly userAgent: "speakeasy-sdk/typescript 1.2.5 2.914.0 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: "1.2.4",
29
+ sdkVersion: "1.2.5",
30
30
  genVersion: "2.914.0",
31
- userAgent: "speakeasy-sdk/typescript 1.2.4 2.914.0 1.0.0 @openrouter/sdk",
31
+ userAgent: "speakeasy-sdk/typescript 1.2.5 2.914.0 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map
@@ -46,6 +46,10 @@ export type ActivityItem = {
46
46
  * Total cost in USD (OpenRouter credits spent)
47
47
  */
48
48
  usage: number;
49
+ /**
50
+ * ID of the workspace this activity is attributed to. Only present when `group_by=workspace` is passed; the response is then split per workspace. Activity recorded before workspace resolution existed is attributed to the account default workspace.
51
+ */
52
+ workspaceId?: string | undefined;
49
53
  };
50
54
  /** @internal */
51
55
  export declare const ActivityItem$inboundSchema: z.ZodType<ActivityItem, unknown>;
@@ -19,6 +19,7 @@ export const ActivityItem$inboundSchema = z
19
19
  reasoning_tokens: z.int(),
20
20
  requests: z.int(),
21
21
  usage: z.number(),
22
+ workspace_id: z.string().optional(),
22
23
  }).transform((v) => {
23
24
  return remap$(v, {
24
25
  "byok_usage_inference": "byokUsageInference",
@@ -28,6 +29,7 @@ export const ActivityItem$inboundSchema = z
28
29
  "prompt_tokens": "promptTokens",
29
30
  "provider_name": "providerName",
30
31
  "reasoning_tokens": "reasoningTokens",
32
+ "workspace_id": "workspaceId",
31
33
  });
32
34
  });
33
35
  export function activityItemFromJSON(jsonString) {
@@ -211,6 +211,10 @@ export type GenerationResponseData = {
211
211
  * The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)
212
212
  */
213
213
  webSearchEngine: string | null;
214
+ /**
215
+ * ID of the workspace this generation is attributed to. Null for accounts without workspaces. Generations created before workspace resolution existed are attributed to the account default workspace.
216
+ */
217
+ workspaceId: string | null;
214
218
  };
215
219
  /**
216
220
  * Generation response
@@ -78,6 +78,7 @@ export const GenerationResponseData$inboundSchema = z.object({
78
78
  usage: z.number(),
79
79
  user_agent: z.nullable(z.string()),
80
80
  web_search_engine: z.nullable(z.string()),
81
+ workspace_id: z.nullable(z.string()),
81
82
  }).transform((v) => {
82
83
  return remap$(v, {
83
84
  "api_type": "apiType",
@@ -116,6 +117,7 @@ export const GenerationResponseData$inboundSchema = z.object({
116
117
  "upstream_inference_cost": "upstreamInferenceCost",
117
118
  "user_agent": "userAgent",
118
119
  "web_search_engine": "webSearchEngine",
120
+ "workspace_id": "workspaceId",
119
121
  });
120
122
  });
121
123
  export function generationResponseDataFromJSON(jsonString) {
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../../types/enums.js";
2
3
  export type GetUserActivityGlobals = {
3
4
  /**
4
5
  * The app identifier should be your app's URL and is used as the primary identifier for rankings.
@@ -20,6 +21,16 @@ export type GetUserActivityGlobals = {
20
21
  */
21
22
  appCategories?: string | undefined;
22
23
  };
24
+ /**
25
+ * Set to 'workspace' to split each row per workspace and include `workspace_id` on every item. Omitted by default, in which case rows are aggregated across workspaces (by date, model, and endpoint) and `workspace_id` is not returned — preserving the historical response shape.
26
+ */
27
+ export declare const GroupBy: {
28
+ readonly Workspace: "workspace";
29
+ };
30
+ /**
31
+ * Set to 'workspace' to split each row per workspace and include `workspace_id` on every item. Omitted by default, in which case rows are aggregated across workspaces (by date, model, and endpoint) and `workspace_id` is not returned — preserving the historical response shape.
32
+ */
33
+ export type GroupBy = ClosedEnum<typeof GroupBy>;
23
34
  export type GetUserActivityRequest = {
24
35
  /**
25
36
  * The app identifier should be your app's URL and is used as the primary identifier for rankings.
@@ -52,8 +63,18 @@ export type GetUserActivityRequest = {
52
63
  * Filter by org member user ID. Only applicable for organization accounts.
53
64
  */
54
65
  userId?: string | undefined;
66
+ /**
67
+ * Set to 'workspace' to split each row per workspace and include `workspace_id` on every item. Omitted by default, in which case rows are aggregated across workspaces (by date, model, and endpoint) and `workspace_id` is not returned — preserving the historical response shape.
68
+ */
69
+ groupBy?: GroupBy | undefined;
70
+ /**
71
+ * Filter by workspace ID (UUID). Returns only activity attributed to that workspace. The workspace must belong to the authenticated account.
72
+ */
73
+ workspaceId?: string | undefined;
55
74
  };
56
75
  /** @internal */
76
+ export declare const GroupBy$outboundSchema: z.ZodEnum<typeof GroupBy>;
77
+ /** @internal */
57
78
  export type GetUserActivityRequest$Outbound = {
58
79
  "HTTP-Referer"?: string | undefined;
59
80
  appTitle?: string | undefined;
@@ -61,6 +82,8 @@ export type GetUserActivityRequest$Outbound = {
61
82
  date?: string | undefined;
62
83
  api_key_hash?: string | undefined;
63
84
  user_id?: string | undefined;
85
+ group_by?: string | undefined;
86
+ workspace_id?: string | undefined;
64
87
  };
65
88
  /** @internal */
66
89
  export declare const GetUserActivityRequest$outboundSchema: z.ZodType<GetUserActivityRequest$Outbound, GetUserActivityRequest>;
@@ -4,6 +4,14 @@
4
4
  */
5
5
  import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
+ /**
8
+ * Set to 'workspace' to split each row per workspace and include `workspace_id` on every item. Omitted by default, in which case rows are aggregated across workspaces (by date, model, and endpoint) and `workspace_id` is not returned — preserving the historical response shape.
9
+ */
10
+ export const GroupBy = {
11
+ Workspace: "workspace",
12
+ };
13
+ /** @internal */
14
+ export const GroupBy$outboundSchema = z.enum(GroupBy);
7
15
  /** @internal */
8
16
  export const GetUserActivityRequest$outboundSchema = z.object({
9
17
  httpReferer: z.string().optional(),
@@ -12,11 +20,15 @@ export const GetUserActivityRequest$outboundSchema = z.object({
12
20
  date: z.string().optional(),
13
21
  apiKeyHash: z.string().optional(),
14
22
  userId: z.string().optional(),
23
+ groupBy: GroupBy$outboundSchema.optional(),
24
+ workspaceId: z.string().optional(),
15
25
  }).transform((v) => {
16
26
  return remap$(v, {
17
27
  httpReferer: "HTTP-Referer",
18
28
  apiKeyHash: "api_key_hash",
19
29
  userId: "user_id",
30
+ groupBy: "group_by",
31
+ workspaceId: "workspace_id",
20
32
  });
21
33
  });
22
34
  export function getUserActivityRequestToJSON(getUserActivityRequest) {
@@ -68,7 +68,7 @@ export type ClassifierFilters = {
68
68
  };
69
69
  export type Value2 = string | number;
70
70
  /**
71
- * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name; `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned.
71
+ * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned.
72
72
  */
73
73
  export type Value1 = string | number | Array<string | number>;
74
74
  export type Filter = {
@@ -81,7 +81,7 @@ export type Filter = {
81
81
  */
82
82
  operator: string;
83
83
  /**
84
- * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name; `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned.
84
+ * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned.
85
85
  */
86
86
  value: string | number | Array<string | number>;
87
87
  };
@@ -6,7 +6,7 @@ export declare class Analytics extends ClientSDK {
6
6
  * Get user activity grouped by endpoint
7
7
  *
8
8
  * @remarks
9
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required.
9
+ * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required.
10
10
  */
11
11
  getUserActivity(request?: operations.GetUserActivityRequest | undefined, options?: RequestOptions): Promise<models.ActivityResponse>;
12
12
  }
@@ -10,7 +10,7 @@ export class Analytics extends ClientSDK {
10
10
  * Get user activity grouped by endpoint
11
11
  *
12
12
  * @remarks
13
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required.
13
+ * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required.
14
14
  */
15
15
  async getUserActivity(request, options) {
16
16
  return unwrapAsync(analyticsGetUserActivity(this, request, options));
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.2.4",
5
+ "version": "1.2.5",
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.2.4",
3
+ "version": "1.2.5",
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": "tsc",
75
75
  "prepublishOnly": "npm run build",
76
76
  "postinstall": "node scripts/check-types.js || true",
77
+ "prepare": "npm run build",
78
+ "test": "vitest --run --project unit",
79
+ "test:watch": "vitest --watch --project unit",
77
80
  "typecheck": "tsc --noEmit",
78
81
  "typecheck:transit": "exit 0",
79
82
  "compile": "tsc",
80
- "prepare": "npm run build",
81
- "test": "vitest --run --project unit",
82
83
  "test:e2e": "vitest --run --project e2e",
83
- "test:transit": "exit 0",
84
- "test:watch": "vitest --watch --project unit"
84
+ "test:transit": "exit 0"
85
85
  },
86
86
  "peerDependencies": {},
87
87
  "devDependencies": {