@thinkai/tai-api-contract 2.240.0 → 2.241.0

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.
@@ -1,7 +1,7 @@
1
1
  openapi: 3.0.3
2
2
  info:
3
3
  title: ThinkAI API
4
- version: 2.240.0
4
+ version: 2.241.0
5
5
  description: >
6
6
  Contract surface for the AI Driven SDLC backend used by ThinkAI.
7
7
  Workspace-scoped routes use `/workspaces/{workspaceId}/...`.
@@ -1141,6 +1141,81 @@ paths:
1141
1141
  error: Forbidden
1142
1142
  code: forbidden
1143
1143
 
1144
+ /admin/ecg-platform-cost/summary:
1145
+ get:
1146
+ tags: [PlatformAdmin]
1147
+ summary: ECG spend on ThinkAI-held keys (embeddings, rerank) by workspace
1148
+ operationId: adminGetEcgPlatformCostSummary
1149
+ description: >
1150
+ Rolls up embedding and rerank usage that ThinkAI pays for (the platform keys, not the
1151
+ workspace's own model key) for the given UTC range, defaulting to the current UTC
1152
+ calendar month. Tokens are what the provider reported; calls where it reported nothing
1153
+ are estimated from the characters sent and counted in `estimatedCalls`.
1154
+ `byWorkspace` lists the highest-spending workspaces up to `workspaceLimit`;
1155
+ `otherWorkspaces` is the remainder, so the rows shown plus `otherWorkspaces` always
1156
+ equal `totals`. A deleted workspace's spend is kept and reported with a null workspace.
1157
+
1158
+ **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`.
1159
+ This is ThinkAI's cost and is never returned to workspace members.
1160
+ parameters:
1161
+ - name: from
1162
+ in: query
1163
+ required: false
1164
+ schema:
1165
+ type: string
1166
+ format: date-time
1167
+ description: Inclusive start (ISO-8601). Defaults to start of current UTC month.
1168
+ - name: to
1169
+ in: query
1170
+ required: false
1171
+ schema:
1172
+ type: string
1173
+ format: date-time
1174
+ description: Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days.
1175
+ - name: workspaceLimit
1176
+ in: query
1177
+ required: false
1178
+ schema:
1179
+ type: integer
1180
+ minimum: 1
1181
+ maximum: 100
1182
+ default: 25
1183
+ description: How many workspaces to list in `byWorkspace`.
1184
+ responses:
1185
+ "200":
1186
+ description: Totals and splits (zeros and empty lists when nothing was spent).
1187
+ content:
1188
+ application/json:
1189
+ schema:
1190
+ $ref: "#/components/schemas/PlatformEcgSpendSummaryDto"
1191
+ "400":
1192
+ description: Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range.
1193
+ content:
1194
+ application/json:
1195
+ schema:
1196
+ $ref: "#/components/schemas/ErrorMessageDto"
1197
+ "401":
1198
+ description: Missing or invalid JWT.
1199
+ content:
1200
+ application/json:
1201
+ schema:
1202
+ $ref: "#/components/schemas/ErrorMessageDto"
1203
+ "403":
1204
+ description: Caller is not a platform admin.
1205
+ content:
1206
+ application/json:
1207
+ schema:
1208
+ $ref: "#/components/schemas/ErrorMessageDto"
1209
+ example:
1210
+ error: Forbidden
1211
+ code: forbidden
1212
+ "503":
1213
+ description: The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance.
1214
+ content:
1215
+ application/json:
1216
+ schema:
1217
+ $ref: "#/components/schemas/ErrorMessageDto"
1218
+
1144
1219
  /admin/workspaces/{workspaceId}/automation-cost/budget:
1145
1220
  get:
1146
1221
  tags: [PlatformAdmin]
@@ -31530,6 +31605,82 @@ components:
31530
31605
  invocationCount:
31531
31606
  type: integer
31532
31607
 
31608
+ PlatformEcgSpendBucketDto:
31609
+ type: object
31610
+ required: [calls, tokens, estimatedCalls]
31611
+ properties:
31612
+ calls:
31613
+ type: integer
31614
+ format: int64
31615
+ tokens:
31616
+ type: integer
31617
+ format: int64
31618
+ estimatedCalls:
31619
+ type: integer
31620
+ format: int64
31621
+ description: Calls whose token count was estimated because the provider reported none.
31622
+
31623
+ PlatformEcgSpendSummaryDto:
31624
+ type: object
31625
+ required: [from, to, totals, byKind, byChannel, byWorkspace, otherWorkspaces]
31626
+ properties:
31627
+ from:
31628
+ type: string
31629
+ format: date-time
31630
+ to:
31631
+ type: string
31632
+ format: date-time
31633
+ totals:
31634
+ $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31635
+ byKind:
31636
+ type: array
31637
+ items:
31638
+ allOf:
31639
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31640
+ - type: object
31641
+ required: [kind]
31642
+ properties:
31643
+ kind:
31644
+ type: string
31645
+ enum: [embed, rerank]
31646
+ byChannel:
31647
+ type: array
31648
+ items:
31649
+ allOf:
31650
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31651
+ - type: object
31652
+ required: [channel]
31653
+ properties:
31654
+ channel:
31655
+ type: string
31656
+ enum: [web_chat, mcp, background]
31657
+ byWorkspace:
31658
+ type: array
31659
+ description: Highest token spend first, at most `workspaceLimit` rows.
31660
+ items:
31661
+ allOf:
31662
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31663
+ - type: object
31664
+ required: [workspaceId, workspaceName]
31665
+ properties:
31666
+ workspaceId:
31667
+ type: string
31668
+ format: uuid
31669
+ nullable: true
31670
+ description: Null for spend of a workspace that has since been deleted.
31671
+ workspaceName:
31672
+ type: string
31673
+ nullable: true
31674
+ otherWorkspaces:
31675
+ description: Spend of the workspaces not listed in `byWorkspace`.
31676
+ allOf:
31677
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31678
+ - type: object
31679
+ required: [count]
31680
+ properties:
31681
+ count:
31682
+ type: integer
31683
+
31533
31684
  AutomationCostSummaryDto:
31534
31685
  type: object
31535
31686
  required: [rows, totals]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkai/tai-api-contract",
3
- "version": "2.240.0",
3
+ "version": "2.241.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -243,6 +243,27 @@ export interface paths {
243
243
  patch?: never;
244
244
  trace?: never;
245
245
  };
246
+ "/admin/ecg-platform-cost/summary": {
247
+ parameters: {
248
+ query?: never;
249
+ header?: never;
250
+ path?: never;
251
+ cookie?: never;
252
+ };
253
+ /**
254
+ * ECG spend on ThinkAI-held keys (embeddings, rerank) by workspace
255
+ * @description Rolls up embedding and rerank usage that ThinkAI pays for (the platform keys, not the workspace's own model key) for the given UTC range, defaulting to the current UTC calendar month. Tokens are what the provider reported; calls where it reported nothing are estimated from the characters sent and counted in `estimatedCalls`. `byWorkspace` lists the highest-spending workspaces up to `workspaceLimit`; `otherWorkspaces` is the remainder, so the rows shown plus `otherWorkspaces` always equal `totals`. A deleted workspace's spend is kept and reported with a null workspace.
256
+ * **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`. This is ThinkAI's cost and is never returned to workspace members.
257
+ */
258
+ get: operations["adminGetEcgPlatformCostSummary"];
259
+ put?: never;
260
+ post?: never;
261
+ delete?: never;
262
+ options?: never;
263
+ head?: never;
264
+ patch?: never;
265
+ trace?: never;
266
+ };
246
267
  "/admin/workspaces/{workspaceId}/automation-cost/budget": {
247
268
  parameters: {
248
269
  query?: never;
@@ -13091,6 +13112,45 @@ export interface components {
13091
13112
  estimatedSpendCents: number;
13092
13113
  invocationCount: number;
13093
13114
  };
13115
+ PlatformEcgSpendBucketDto: {
13116
+ /** Format: int64 */
13117
+ calls: number;
13118
+ /** Format: int64 */
13119
+ tokens: number;
13120
+ /**
13121
+ * Format: int64
13122
+ * @description Calls whose token count was estimated because the provider reported none.
13123
+ */
13124
+ estimatedCalls: number;
13125
+ };
13126
+ PlatformEcgSpendSummaryDto: {
13127
+ /** Format: date-time */
13128
+ from: string;
13129
+ /** Format: date-time */
13130
+ to: string;
13131
+ totals: components["schemas"]["PlatformEcgSpendBucketDto"];
13132
+ byKind: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13133
+ /** @enum {string} */
13134
+ kind: "embed" | "rerank";
13135
+ })[];
13136
+ byChannel: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13137
+ /** @enum {string} */
13138
+ channel: "web_chat" | "mcp" | "background";
13139
+ })[];
13140
+ /** @description Highest token spend first, at most `workspaceLimit` rows. */
13141
+ byWorkspace: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13142
+ /**
13143
+ * Format: uuid
13144
+ * @description Null for spend of a workspace that has since been deleted.
13145
+ */
13146
+ workspaceId: string | null;
13147
+ workspaceName: string | null;
13148
+ })[];
13149
+ /** @description Spend of the workspaces not listed in `byWorkspace`. */
13150
+ otherWorkspaces: components["schemas"]["PlatformEcgSpendBucketDto"] & {
13151
+ count: number;
13152
+ };
13153
+ };
13094
13154
  AutomationCostSummaryDto: {
13095
13155
  rows: components["schemas"]["AutomationCostSummaryRowDto"][];
13096
13156
  totals: components["schemas"]["AutomationCostSummaryTotalsDto"];
@@ -16250,6 +16310,8 @@ export type ActivityLogPageDto = components['schemas']['ActivityLogPageDto'];
16250
16310
  export type AutomationCostOperationDto = components['schemas']['AutomationCostOperationDto'];
16251
16311
  export type AutomationCostSummaryRowDto = components['schemas']['AutomationCostSummaryRowDto'];
16252
16312
  export type AutomationCostSummaryTotalsDto = components['schemas']['AutomationCostSummaryTotalsDto'];
16313
+ export type PlatformEcgSpendBucketDto = components['schemas']['PlatformEcgSpendBucketDto'];
16314
+ export type PlatformEcgSpendSummaryDto = components['schemas']['PlatformEcgSpendSummaryDto'];
16253
16315
  export type AutomationCostSummaryDto = components['schemas']['AutomationCostSummaryDto'];
16254
16316
  export type AutomationCostBudgetStatusDto = components['schemas']['AutomationCostBudgetStatusDto'];
16255
16317
  export type AutomationCostBudgetViewDto = components['schemas']['AutomationCostBudgetViewDto'];
@@ -17389,6 +17451,75 @@ export interface operations {
17389
17451
  };
17390
17452
  };
17391
17453
  };
17454
+ adminGetEcgPlatformCostSummary: {
17455
+ parameters: {
17456
+ query?: {
17457
+ /** @description Inclusive start (ISO-8601). Defaults to start of current UTC month. */
17458
+ from?: string;
17459
+ /** @description Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days. */
17460
+ to?: string;
17461
+ /** @description How many workspaces to list in `byWorkspace`. */
17462
+ workspaceLimit?: number;
17463
+ };
17464
+ header?: never;
17465
+ path?: never;
17466
+ cookie?: never;
17467
+ };
17468
+ requestBody?: never;
17469
+ responses: {
17470
+ /** @description Totals and splits (zeros and empty lists when nothing was spent). */
17471
+ 200: {
17472
+ headers: {
17473
+ [name: string]: unknown;
17474
+ };
17475
+ content: {
17476
+ "application/json": components["schemas"]["PlatformEcgSpendSummaryDto"];
17477
+ };
17478
+ };
17479
+ /** @description Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range. */
17480
+ 400: {
17481
+ headers: {
17482
+ [name: string]: unknown;
17483
+ };
17484
+ content: {
17485
+ "application/json": components["schemas"]["ErrorMessageDto"];
17486
+ };
17487
+ };
17488
+ /** @description Missing or invalid JWT. */
17489
+ 401: {
17490
+ headers: {
17491
+ [name: string]: unknown;
17492
+ };
17493
+ content: {
17494
+ "application/json": components["schemas"]["ErrorMessageDto"];
17495
+ };
17496
+ };
17497
+ /** @description Caller is not a platform admin. */
17498
+ 403: {
17499
+ headers: {
17500
+ [name: string]: unknown;
17501
+ };
17502
+ content: {
17503
+ /**
17504
+ * @example {
17505
+ * "error": "Forbidden",
17506
+ * "code": "forbidden"
17507
+ * }
17508
+ */
17509
+ "application/json": components["schemas"]["ErrorMessageDto"];
17510
+ };
17511
+ };
17512
+ /** @description The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance. */
17513
+ 503: {
17514
+ headers: {
17515
+ [name: string]: unknown;
17516
+ };
17517
+ content: {
17518
+ "application/json": components["schemas"]["ErrorMessageDto"];
17519
+ };
17520
+ };
17521
+ };
17522
+ };
17392
17523
  adminGetAutomationCostBudget: {
17393
17524
  parameters: {
17394
17525
  query?: {