@deeprelay/sdk 0.1.0 → 0.1.2

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.
Files changed (71) hide show
  1. package/.openapi-generator/FILES +14 -0
  2. package/README.md +13 -2
  3. package/dist/apis/BillingApi.d.ts +53 -0
  4. package/dist/apis/BillingApi.js +141 -0
  5. package/dist/apis/InferenceApi.d.ts +18 -0
  6. package/dist/apis/InferenceApi.js +51 -0
  7. package/dist/esm/apis/BillingApi.d.ts +53 -0
  8. package/dist/esm/apis/BillingApi.js +141 -0
  9. package/dist/esm/apis/InferenceApi.d.ts +18 -0
  10. package/dist/esm/apis/InferenceApi.js +51 -0
  11. package/dist/esm/models/InferencePreflight.d.ts +92 -0
  12. package/dist/esm/models/InferencePreflight.js +86 -0
  13. package/dist/esm/models/RefereeStatus.d.ts +79 -0
  14. package/dist/esm/models/RefereeStatus.js +70 -0
  15. package/dist/esm/models/Referral.d.ts +94 -0
  16. package/dist/esm/models/Referral.js +82 -0
  17. package/dist/esm/models/SubscriptionCheckoutRequest.d.ts +45 -0
  18. package/dist/esm/models/SubscriptionCheckoutRequest.js +45 -0
  19. package/dist/esm/models/SubscriptionCheckoutSession.d.ts +45 -0
  20. package/dist/esm/models/SubscriptionCheckoutSession.js +52 -0
  21. package/dist/esm/models/SubscriptionPortalRequest.d.ts +32 -0
  22. package/dist/esm/models/SubscriptionPortalRequest.js +41 -0
  23. package/dist/esm/models/SubscriptionPortalSession.d.ts +32 -0
  24. package/dist/esm/models/SubscriptionPortalSession.js +43 -0
  25. package/dist/esm/models/VideoJob.d.ts +6 -0
  26. package/dist/esm/models/VideoJob.js +2 -0
  27. package/dist/esm/models/index.d.ts +7 -0
  28. package/dist/esm/models/index.js +7 -0
  29. package/dist/esm/runtime.js +1 -1
  30. package/dist/models/InferencePreflight.d.ts +92 -0
  31. package/dist/models/InferencePreflight.js +94 -0
  32. package/dist/models/RefereeStatus.d.ts +79 -0
  33. package/dist/models/RefereeStatus.js +78 -0
  34. package/dist/models/Referral.d.ts +94 -0
  35. package/dist/models/Referral.js +89 -0
  36. package/dist/models/SubscriptionCheckoutRequest.d.ts +45 -0
  37. package/dist/models/SubscriptionCheckoutRequest.js +52 -0
  38. package/dist/models/SubscriptionCheckoutSession.d.ts +45 -0
  39. package/dist/models/SubscriptionCheckoutSession.js +59 -0
  40. package/dist/models/SubscriptionPortalRequest.d.ts +32 -0
  41. package/dist/models/SubscriptionPortalRequest.js +48 -0
  42. package/dist/models/SubscriptionPortalSession.d.ts +32 -0
  43. package/dist/models/SubscriptionPortalSession.js +50 -0
  44. package/dist/models/VideoJob.d.ts +6 -0
  45. package/dist/models/VideoJob.js +2 -0
  46. package/dist/models/index.d.ts +7 -0
  47. package/dist/models/index.js +7 -0
  48. package/dist/runtime.js +1 -1
  49. package/docs/BillingApi.md +220 -0
  50. package/docs/InferenceApi.md +74 -0
  51. package/docs/InferencePreflight.md +47 -0
  52. package/docs/RefereeStatus.md +47 -0
  53. package/docs/Referral.md +55 -0
  54. package/docs/SubscriptionCheckoutRequest.md +39 -0
  55. package/docs/SubscriptionCheckoutSession.md +38 -0
  56. package/docs/SubscriptionPortalRequest.md +35 -0
  57. package/docs/SubscriptionPortalSession.md +34 -0
  58. package/docs/VideoJob.md +2 -0
  59. package/package.json +1 -1
  60. package/src/apis/BillingApi.ts +180 -0
  61. package/src/apis/InferenceApi.ts +67 -0
  62. package/src/models/InferencePreflight.ts +147 -0
  63. package/src/models/RefereeStatus.ts +131 -0
  64. package/src/models/Referral.ts +164 -0
  65. package/src/models/SubscriptionCheckoutRequest.ts +82 -0
  66. package/src/models/SubscriptionCheckoutSession.ts +92 -0
  67. package/src/models/SubscriptionPortalRequest.ts +65 -0
  68. package/src/models/SubscriptionPortalSession.ts +66 -0
  69. package/src/models/VideoJob.ts +8 -0
  70. package/src/models/index.ts +7 -0
  71. package/src/runtime.ts +1 -1
@@ -25,8 +25,13 @@ import { BalanceFromJSON, } from '../models/Balance';
25
25
  import { CreateCryptoDepositRequestToJSON, } from '../models/CreateCryptoDepositRequest';
26
26
  import { CryptoDepositFromJSON, } from '../models/CryptoDeposit';
27
27
  import { ListDeposits200ResponseFromJSON, } from '../models/ListDeposits200Response';
28
+ import { ReferralFromJSON, } from '../models/Referral';
28
29
  import { SpendingLimitFromJSON, } from '../models/SpendingLimit';
29
30
  import { SubscriptionFromJSON, } from '../models/Subscription';
31
+ import { SubscriptionCheckoutRequestToJSON, } from '../models/SubscriptionCheckoutRequest';
32
+ import { SubscriptionCheckoutSessionFromJSON, } from '../models/SubscriptionCheckoutSession';
33
+ import { SubscriptionPortalRequestToJSON, } from '../models/SubscriptionPortalRequest';
34
+ import { SubscriptionPortalSessionFromJSON, } from '../models/SubscriptionPortalSession';
30
35
  import { UpdateSpendingLimitRequestToJSON, } from '../models/UpdateSpendingLimitRequest';
31
36
  /**
32
37
  *
@@ -81,6 +86,98 @@ export class BillingApi extends runtime.BaseAPI {
81
86
  return yield response.value();
82
87
  });
83
88
  }
89
+ /**
90
+ * Creates request options for createSubscriptionCheckout without sending the request
91
+ */
92
+ createSubscriptionCheckoutRequestOpts(requestParameters) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const queryParameters = {};
95
+ const headerParameters = {};
96
+ headerParameters['Content-Type'] = 'application/json';
97
+ if (this.configuration && this.configuration.accessToken) {
98
+ const token = this.configuration.accessToken;
99
+ const tokenString = yield token("bearerAuth", []);
100
+ if (tokenString) {
101
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
102
+ }
103
+ }
104
+ let urlPath = `/billing/subscription/checkout`;
105
+ return {
106
+ path: urlPath,
107
+ method: 'POST',
108
+ headers: headerParameters,
109
+ query: queryParameters,
110
+ body: SubscriptionCheckoutRequestToJSON(requestParameters['subscriptionCheckoutRequest']),
111
+ };
112
+ });
113
+ }
114
+ /**
115
+ * Opens a hosted checkout session for the flat tier and returns its URL. Requires the `billing:write` scope AND organization-admin privileges — subscribing spends organization money. This endpoint does NOT subscribe anyone. Checkout is a hosted page that needs a browser and a card, so the caller\'s job is to put the returned URL in front of a human. The subscription becomes active when payment completes, which is not synchronous with this call: poll `/billing/subscription` to confirm. `success_url` and `cancel_url` are optional and fall back to the deployment\'s configured redirects, which is what lets a command-line client start a purchase without having any URLs of its own. An empty request body is valid and means \"use every default\". `plan_key`, when sent, pins the plan the client DISPLAYED: an unknown key is a 400 rather than a silent purchase of a different tier. Today there is one tier, so the only accepted value is its key — but sending it is the forward-compatible choice. One flat tier means at most one subscription per organization: a second checkout while an entitling subscription exists is a 409.
116
+ * Start a subscription checkout session
117
+ */
118
+ createSubscriptionCheckoutRaw(requestParameters, initOverrides) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const requestOptions = yield this.createSubscriptionCheckoutRequestOpts(requestParameters);
121
+ const response = yield this.request(requestOptions, initOverrides);
122
+ return new runtime.JSONApiResponse(response, (jsonValue) => SubscriptionCheckoutSessionFromJSON(jsonValue));
123
+ });
124
+ }
125
+ /**
126
+ * Opens a hosted checkout session for the flat tier and returns its URL. Requires the `billing:write` scope AND organization-admin privileges — subscribing spends organization money. This endpoint does NOT subscribe anyone. Checkout is a hosted page that needs a browser and a card, so the caller\'s job is to put the returned URL in front of a human. The subscription becomes active when payment completes, which is not synchronous with this call: poll `/billing/subscription` to confirm. `success_url` and `cancel_url` are optional and fall back to the deployment\'s configured redirects, which is what lets a command-line client start a purchase without having any URLs of its own. An empty request body is valid and means \"use every default\". `plan_key`, when sent, pins the plan the client DISPLAYED: an unknown key is a 400 rather than a silent purchase of a different tier. Today there is one tier, so the only accepted value is its key — but sending it is the forward-compatible choice. One flat tier means at most one subscription per organization: a second checkout while an entitling subscription exists is a 409.
127
+ * Start a subscription checkout session
128
+ */
129
+ createSubscriptionCheckout() {
130
+ return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) {
131
+ const response = yield this.createSubscriptionCheckoutRaw(requestParameters, initOverrides);
132
+ return yield response.value();
133
+ });
134
+ }
135
+ /**
136
+ * Creates request options for createSubscriptionPortal without sending the request
137
+ */
138
+ createSubscriptionPortalRequestOpts(requestParameters) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const queryParameters = {};
141
+ const headerParameters = {};
142
+ headerParameters['Content-Type'] = 'application/json';
143
+ if (this.configuration && this.configuration.accessToken) {
144
+ const token = this.configuration.accessToken;
145
+ const tokenString = yield token("bearerAuth", []);
146
+ if (tokenString) {
147
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
148
+ }
149
+ }
150
+ let urlPath = `/billing/subscription/portal`;
151
+ return {
152
+ path: urlPath,
153
+ method: 'POST',
154
+ headers: headerParameters,
155
+ query: queryParameters,
156
+ body: SubscriptionPortalRequestToJSON(requestParameters['subscriptionPortalRequest']),
157
+ };
158
+ });
159
+ }
160
+ /**
161
+ * Returns a URL for the hosted billing portal: where a customer cancels the subscription, resumes one they cancelled, changes payment method, or downloads invoices. Requires the `billing:write` scope AND organization-admin privileges. Cancellation lives here rather than on its own endpoint because it is one surface with the rest of the billing lifecycle. The common reason a subscription is about to lapse is a declined card, and the fix for that is a new card, not a cancellation — sending a customer somewhere that can only cancel would lose renewals. Cancelling in the portal ends the subscription at the close of the current period; coverage continues until then and `/billing/subscription` reports `cancel_at_period_end: true`. An organization that has never paid for anything gets 404: there is no billing account to manage, and this endpoint deliberately does not create one as a side effect of looking.
162
+ * Open the billing portal to cancel or manage the subscription
163
+ */
164
+ createSubscriptionPortalRaw(requestParameters, initOverrides) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const requestOptions = yield this.createSubscriptionPortalRequestOpts(requestParameters);
167
+ const response = yield this.request(requestOptions, initOverrides);
168
+ return new runtime.JSONApiResponse(response, (jsonValue) => SubscriptionPortalSessionFromJSON(jsonValue));
169
+ });
170
+ }
171
+ /**
172
+ * Returns a URL for the hosted billing portal: where a customer cancels the subscription, resumes one they cancelled, changes payment method, or downloads invoices. Requires the `billing:write` scope AND organization-admin privileges. Cancellation lives here rather than on its own endpoint because it is one surface with the rest of the billing lifecycle. The common reason a subscription is about to lapse is a declined card, and the fix for that is a new card, not a cancellation — sending a customer somewhere that can only cancel would lose renewals. Cancelling in the portal ends the subscription at the close of the current period; coverage continues until then and `/billing/subscription` reports `cancel_at_period_end: true`. An organization that has never paid for anything gets 404: there is no billing account to manage, and this endpoint deliberately does not create one as a side effect of looking.
173
+ * Open the billing portal to cancel or manage the subscription
174
+ */
175
+ createSubscriptionPortal() {
176
+ return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) {
177
+ const response = yield this.createSubscriptionPortalRaw(requestParameters, initOverrides);
178
+ return yield response.value();
179
+ });
180
+ }
84
181
  /**
85
182
  * Creates request options for getBalance without sending the request
86
183
  */
@@ -173,6 +270,50 @@ export class BillingApi extends runtime.BaseAPI {
173
270
  return yield response.value();
174
271
  });
175
272
  }
273
+ /**
274
+ * Creates request options for getReferral without sending the request
275
+ */
276
+ getReferralRequestOpts() {
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ const queryParameters = {};
279
+ const headerParameters = {};
280
+ if (this.configuration && this.configuration.accessToken) {
281
+ const token = this.configuration.accessToken;
282
+ const tokenString = yield token("bearerAuth", []);
283
+ if (tokenString) {
284
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
285
+ }
286
+ }
287
+ let urlPath = `/referrals`;
288
+ return {
289
+ path: urlPath,
290
+ method: 'GET',
291
+ headers: headerParameters,
292
+ query: queryParameters,
293
+ };
294
+ });
295
+ }
296
+ /**
297
+ * Returns the organization\'s shareable referral code and invite link (minting the code on first read), the program terms, the referrer\'s stats, and — when this organization itself signed up through someone else\'s link — its own progress toward the referee reward. Requires the `billing:read` scope. The organization is taken from the authenticated API key, never from a parameter. The program: share the invite link; when a friend signs up through it and spends `qualify_spend_cents` on inference, the referrer receives `reward_cents` and the friend receives `referee_reward_cents`, both as non-withdrawable credit, after a `hold_days` chargeback hold. The terms ride on the wire so a client never hard-codes the amounts. `referred` is ABSENT (not null) for an organization nobody referred — key on its presence. This is the same contract the dashboard\'s referral card reads.
298
+ * Get the org referral code, invite link, terms and stats
299
+ */
300
+ getReferralRaw(initOverrides) {
301
+ return __awaiter(this, void 0, void 0, function* () {
302
+ const requestOptions = yield this.getReferralRequestOpts();
303
+ const response = yield this.request(requestOptions, initOverrides);
304
+ return new runtime.JSONApiResponse(response, (jsonValue) => ReferralFromJSON(jsonValue));
305
+ });
306
+ }
307
+ /**
308
+ * Returns the organization\'s shareable referral code and invite link (minting the code on first read), the program terms, the referrer\'s stats, and — when this organization itself signed up through someone else\'s link — its own progress toward the referee reward. Requires the `billing:read` scope. The organization is taken from the authenticated API key, never from a parameter. The program: share the invite link; when a friend signs up through it and spends `qualify_spend_cents` on inference, the referrer receives `reward_cents` and the friend receives `referee_reward_cents`, both as non-withdrawable credit, after a `hold_days` chargeback hold. The terms ride on the wire so a client never hard-codes the amounts. `referred` is ABSENT (not null) for an organization nobody referred — key on its presence. This is the same contract the dashboard\'s referral card reads.
309
+ * Get the org referral code, invite link, terms and stats
310
+ */
311
+ getReferral(initOverrides) {
312
+ return __awaiter(this, void 0, void 0, function* () {
313
+ const response = yield this.getReferralRaw(initOverrides);
314
+ return yield response.value();
315
+ });
316
+ }
176
317
  /**
177
318
  * Creates request options for getSpendingLimit without sending the request
178
319
  */
@@ -16,6 +16,7 @@ import { type EmbeddingsRequest } from '../models/EmbeddingsRequest';
16
16
  import { type EmbeddingsResponse } from '../models/EmbeddingsResponse';
17
17
  import { type ImagesGenerationsRequest } from '../models/ImagesGenerationsRequest';
18
18
  import { type ImagesResponse } from '../models/ImagesResponse';
19
+ import { type InferencePreflight } from '../models/InferencePreflight';
19
20
  import { type Model } from '../models/Model';
20
21
  import { type ModelList } from '../models/ModelList';
21
22
  import { type VideoCreateRequest } from '../models/VideoCreateRequest';
@@ -47,6 +48,9 @@ export interface GetVideoRequest {
47
48
  export interface GetVideoContentRequest {
48
49
  id: string;
49
50
  }
51
+ export interface InferencePreflightRequest {
52
+ model: string;
53
+ }
50
54
  export interface ListModelsRequest {
51
55
  modality?: ListModelsModalityEnum;
52
56
  }
@@ -162,6 +166,20 @@ export declare class InferenceApi extends runtime.BaseAPI {
162
166
  * Download a completed video artifact
163
167
  */
164
168
  getVideoContent(requestParameters: GetVideoContentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
169
+ /**
170
+ * Creates request options for inferencePreflight without sending the request
171
+ */
172
+ inferencePreflightRequestOpts(requestParameters: InferencePreflightRequest): Promise<runtime.RequestOpts>;
173
+ /**
174
+ * Answers \"what happens if I call this model right now?\" before the call is made: whether the plan covers the model, whether the organization is subscribed, and whether there is credit to pay if it is not covered. Requires the `serverless:read` scope. Nothing is sent, counted, charged, or reserved. The verdict is computed from the state of the SAME gates that judge the real request — plan coverage, subscription entitlement, remaining plan quota, credit balance and self-set spending caps — so the advice cannot drift from enforcement. It is deliberately NOT a dry run: no per-request cost estimate is quoted, because that figure changes with every prompt and quoting it would invite clients to cache it. The gates consulted depend on the model\'s MODALITY, because the endpoints do not all meet the same ones. Chat, embeddings and image requests meet the full gate (balance, then the organization\'s opt-in daily cap, then its monthly cap). Video creation meets only the balance check, so an organization past its own spending cap but holding credit is reported as fundable for video — which is what the video endpoint will in fact do. Predicting the strictest gate rather than the applicable one would make this endpoint refuse requests the API accepts. The same is true of the plan: video creation does not run the subscription gate, so `plan_covered` is false for a video model even if an operator has placed it on the plan\'s covered list. That is a deliberate divergence from the same-named field on `/v1/models`, which reports the platform\'s configuration. Here it means \"the plan covers this REQUEST\" — describing what will happen is the entire job of a preflight. One caveat on \"read-only\": resolving the balance creates the organization\'s balance row if it has never had one (idempotent, org-scoped, and the same row the first real request would create). Nothing else is written. The case this exists for is `warn` / `not_plan_covered`. A subscriber calling a model outside the plan IS served and IS charged pay-as-you-go, and nothing in the response to that request says so — the first signal used to be the invoice. `funded` is a boolean and never a figure. This route is on the inference read scope, so it must not disclose the organization\'s balance; use `/billing/balance` for the number. Failure posture is the opposite of the request gate\'s: any gate that cannot be read degrades the verdict toward `ok`, never toward `block`. A false `block` would stop a customer whose request would have succeeded, while a false `ok` costs them one honest error from the real call.
175
+ * Check whether a model request would be served, and at whose expense
176
+ */
177
+ inferencePreflightRaw(requestParameters: InferencePreflightRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<InferencePreflight>>;
178
+ /**
179
+ * Answers \"what happens if I call this model right now?\" before the call is made: whether the plan covers the model, whether the organization is subscribed, and whether there is credit to pay if it is not covered. Requires the `serverless:read` scope. Nothing is sent, counted, charged, or reserved. The verdict is computed from the state of the SAME gates that judge the real request — plan coverage, subscription entitlement, remaining plan quota, credit balance and self-set spending caps — so the advice cannot drift from enforcement. It is deliberately NOT a dry run: no per-request cost estimate is quoted, because that figure changes with every prompt and quoting it would invite clients to cache it. The gates consulted depend on the model\'s MODALITY, because the endpoints do not all meet the same ones. Chat, embeddings and image requests meet the full gate (balance, then the organization\'s opt-in daily cap, then its monthly cap). Video creation meets only the balance check, so an organization past its own spending cap but holding credit is reported as fundable for video — which is what the video endpoint will in fact do. Predicting the strictest gate rather than the applicable one would make this endpoint refuse requests the API accepts. The same is true of the plan: video creation does not run the subscription gate, so `plan_covered` is false for a video model even if an operator has placed it on the plan\'s covered list. That is a deliberate divergence from the same-named field on `/v1/models`, which reports the platform\'s configuration. Here it means \"the plan covers this REQUEST\" — describing what will happen is the entire job of a preflight. One caveat on \"read-only\": resolving the balance creates the organization\'s balance row if it has never had one (idempotent, org-scoped, and the same row the first real request would create). Nothing else is written. The case this exists for is `warn` / `not_plan_covered`. A subscriber calling a model outside the plan IS served and IS charged pay-as-you-go, and nothing in the response to that request says so — the first signal used to be the invoice. `funded` is a boolean and never a figure. This route is on the inference read scope, so it must not disclose the organization\'s balance; use `/billing/balance` for the number. Failure posture is the opposite of the request gate\'s: any gate that cannot be read degrades the verdict toward `ok`, never toward `block`. A false `block` would stop a customer whose request would have succeeded, while a false `ok` costs them one honest error from the real call.
180
+ * Check whether a model request would be served, and at whose expense
181
+ */
182
+ inferencePreflight(requestParameters: InferencePreflightRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<InferencePreflight>;
165
183
  /**
166
184
  * Creates request options for listModels without sending the request
167
185
  */
@@ -27,6 +27,7 @@ import { EmbeddingsRequestToJSON, } from '../models/EmbeddingsRequest';
27
27
  import { EmbeddingsResponseFromJSON, } from '../models/EmbeddingsResponse';
28
28
  import { ImagesGenerationsRequestToJSON, } from '../models/ImagesGenerationsRequest';
29
29
  import { ImagesResponseFromJSON, } from '../models/ImagesResponse';
30
+ import { InferencePreflightFromJSON, } from '../models/InferencePreflight';
30
31
  import { ModelFromJSON, } from '../models/Model';
31
32
  import { ModelListFromJSON, } from '../models/ModelList';
32
33
  import { VideoCreateRequestToJSON, } from '../models/VideoCreateRequest';
@@ -422,6 +423,56 @@ export class InferenceApi extends runtime.BaseAPI {
422
423
  return yield response.value();
423
424
  });
424
425
  }
426
+ /**
427
+ * Creates request options for inferencePreflight without sending the request
428
+ */
429
+ inferencePreflightRequestOpts(requestParameters) {
430
+ return __awaiter(this, void 0, void 0, function* () {
431
+ if (requestParameters['model'] == null) {
432
+ throw new runtime.RequiredError('model', 'Required parameter "model" was null or undefined when calling inferencePreflight().');
433
+ }
434
+ const queryParameters = {};
435
+ if (requestParameters['model'] != null) {
436
+ queryParameters['model'] = requestParameters['model'];
437
+ }
438
+ const headerParameters = {};
439
+ if (this.configuration && this.configuration.accessToken) {
440
+ const token = this.configuration.accessToken;
441
+ const tokenString = yield token("bearerAuth", []);
442
+ if (tokenString) {
443
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
444
+ }
445
+ }
446
+ let urlPath = `/inference/preflight`;
447
+ return {
448
+ path: urlPath,
449
+ method: 'GET',
450
+ headers: headerParameters,
451
+ query: queryParameters,
452
+ };
453
+ });
454
+ }
455
+ /**
456
+ * Answers \"what happens if I call this model right now?\" before the call is made: whether the plan covers the model, whether the organization is subscribed, and whether there is credit to pay if it is not covered. Requires the `serverless:read` scope. Nothing is sent, counted, charged, or reserved. The verdict is computed from the state of the SAME gates that judge the real request — plan coverage, subscription entitlement, remaining plan quota, credit balance and self-set spending caps — so the advice cannot drift from enforcement. It is deliberately NOT a dry run: no per-request cost estimate is quoted, because that figure changes with every prompt and quoting it would invite clients to cache it. The gates consulted depend on the model\'s MODALITY, because the endpoints do not all meet the same ones. Chat, embeddings and image requests meet the full gate (balance, then the organization\'s opt-in daily cap, then its monthly cap). Video creation meets only the balance check, so an organization past its own spending cap but holding credit is reported as fundable for video — which is what the video endpoint will in fact do. Predicting the strictest gate rather than the applicable one would make this endpoint refuse requests the API accepts. The same is true of the plan: video creation does not run the subscription gate, so `plan_covered` is false for a video model even if an operator has placed it on the plan\'s covered list. That is a deliberate divergence from the same-named field on `/v1/models`, which reports the platform\'s configuration. Here it means \"the plan covers this REQUEST\" — describing what will happen is the entire job of a preflight. One caveat on \"read-only\": resolving the balance creates the organization\'s balance row if it has never had one (idempotent, org-scoped, and the same row the first real request would create). Nothing else is written. The case this exists for is `warn` / `not_plan_covered`. A subscriber calling a model outside the plan IS served and IS charged pay-as-you-go, and nothing in the response to that request says so — the first signal used to be the invoice. `funded` is a boolean and never a figure. This route is on the inference read scope, so it must not disclose the organization\'s balance; use `/billing/balance` for the number. Failure posture is the opposite of the request gate\'s: any gate that cannot be read degrades the verdict toward `ok`, never toward `block`. A false `block` would stop a customer whose request would have succeeded, while a false `ok` costs them one honest error from the real call.
457
+ * Check whether a model request would be served, and at whose expense
458
+ */
459
+ inferencePreflightRaw(requestParameters, initOverrides) {
460
+ return __awaiter(this, void 0, void 0, function* () {
461
+ const requestOptions = yield this.inferencePreflightRequestOpts(requestParameters);
462
+ const response = yield this.request(requestOptions, initOverrides);
463
+ return new runtime.JSONApiResponse(response, (jsonValue) => InferencePreflightFromJSON(jsonValue));
464
+ });
465
+ }
466
+ /**
467
+ * Answers \"what happens if I call this model right now?\" before the call is made: whether the plan covers the model, whether the organization is subscribed, and whether there is credit to pay if it is not covered. Requires the `serverless:read` scope. Nothing is sent, counted, charged, or reserved. The verdict is computed from the state of the SAME gates that judge the real request — plan coverage, subscription entitlement, remaining plan quota, credit balance and self-set spending caps — so the advice cannot drift from enforcement. It is deliberately NOT a dry run: no per-request cost estimate is quoted, because that figure changes with every prompt and quoting it would invite clients to cache it. The gates consulted depend on the model\'s MODALITY, because the endpoints do not all meet the same ones. Chat, embeddings and image requests meet the full gate (balance, then the organization\'s opt-in daily cap, then its monthly cap). Video creation meets only the balance check, so an organization past its own spending cap but holding credit is reported as fundable for video — which is what the video endpoint will in fact do. Predicting the strictest gate rather than the applicable one would make this endpoint refuse requests the API accepts. The same is true of the plan: video creation does not run the subscription gate, so `plan_covered` is false for a video model even if an operator has placed it on the plan\'s covered list. That is a deliberate divergence from the same-named field on `/v1/models`, which reports the platform\'s configuration. Here it means \"the plan covers this REQUEST\" — describing what will happen is the entire job of a preflight. One caveat on \"read-only\": resolving the balance creates the organization\'s balance row if it has never had one (idempotent, org-scoped, and the same row the first real request would create). Nothing else is written. The case this exists for is `warn` / `not_plan_covered`. A subscriber calling a model outside the plan IS served and IS charged pay-as-you-go, and nothing in the response to that request says so — the first signal used to be the invoice. `funded` is a boolean and never a figure. This route is on the inference read scope, so it must not disclose the organization\'s balance; use `/billing/balance` for the number. Failure posture is the opposite of the request gate\'s: any gate that cannot be read degrades the verdict toward `ok`, never toward `block`. A false `block` would stop a customer whose request would have succeeded, while a false `ok` costs them one honest error from the real call.
468
+ * Check whether a model request would be served, and at whose expense
469
+ */
470
+ inferencePreflight(requestParameters, initOverrides) {
471
+ return __awaiter(this, void 0, void 0, function* () {
472
+ const response = yield this.inferencePreflightRaw(requestParameters, initOverrides);
473
+ return yield response.value();
474
+ });
475
+ }
425
476
  /**
426
477
  * Creates request options for listModels without sending the request
427
478
  */
@@ -0,0 +1,92 @@
1
+ /**
2
+ * deeprelay Public Developer API
3
+ * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: support@deeprelay.ai
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ /**
13
+ * The verdict for one (organization, model) pair: what would happen if the model were invoked right now.
14
+ *
15
+ * @export
16
+ * @interface InferencePreflight
17
+ */
18
+ export interface InferencePreflight {
19
+ /**
20
+ * The canonical catalog id the request resolved to.
21
+ * @type {string}
22
+ * @memberof InferencePreflight
23
+ */
24
+ model: string;
25
+ /**
26
+ * `ok` — the request will be served (covered by the plan, or payable). `warn` — it will be served AND charged in a way the caller may not expect. `block` — it will be refused (402 or 429).
27
+ * @type {InferencePreflightVerdictEnum}
28
+ * @memberof InferencePreflight
29
+ */
30
+ verdict: InferencePreflightVerdictEnum;
31
+ /**
32
+ * Stable code explaining the verdict, for clients that need their own wording. Absent on a plain `ok` that needs no explanation.
33
+ * @type {InferencePreflightReasonEnum}
34
+ * @memberof InferencePreflight
35
+ */
36
+ reason?: InferencePreflightReasonEnum;
37
+ /**
38
+ * A ready-to-print sentence, phrased for this exact plan/credit combination. Prefer it over composing one from verdict and reason: it improves without a client release.
39
+ * @type {string}
40
+ * @memberof InferencePreflight
41
+ */
42
+ message: string;
43
+ /**
44
+ * Whether the subscription tier covers this model. A property of the PLATFORM, not of the caller — it stays true for an organization that has no subscription, which is what makes the "this is included in the plan" upsell honest.
45
+ * @type {boolean}
46
+ * @memberof InferencePreflight
47
+ */
48
+ planCovered: boolean;
49
+ /**
50
+ * Whether the organization is entitled to the plan right now.
51
+ * @type {boolean}
52
+ * @memberof InferencePreflight
53
+ */
54
+ subscribed: boolean;
55
+ /**
56
+ * Whether a pay-as-you-go request could be paid for right now: a positive credit balance AND no self-set spending cap already at its limit. A boolean and never a figure — this route is on the inference read scope and must not disclose the balance.
57
+ * @type {boolean}
58
+ * @memberof InferencePreflight
59
+ */
60
+ funded: boolean;
61
+ }
62
+ /**
63
+ * @export
64
+ */
65
+ export declare const InferencePreflightVerdictEnum: {
66
+ readonly Ok: "ok";
67
+ readonly Warn: "warn";
68
+ readonly Block: "block";
69
+ };
70
+ export type InferencePreflightVerdictEnum = typeof InferencePreflightVerdictEnum[keyof typeof InferencePreflightVerdictEnum];
71
+ /**
72
+ * @export
73
+ */
74
+ export declare const InferencePreflightReasonEnum: {
75
+ readonly PlanCovered: "plan_covered";
76
+ readonly Payg: "payg";
77
+ readonly NotPlanCovered: "not_plan_covered";
78
+ readonly SubscriptionQuotaExhausted: "subscription_quota_exhausted";
79
+ readonly InsufficientBalance: "insufficient_balance";
80
+ readonly DailyLimitReached: "daily_limit_reached";
81
+ readonly MonthlyLimitReached: "monthly_limit_reached";
82
+ readonly PreflightUnavailable: "preflight_unavailable";
83
+ };
84
+ export type InferencePreflightReasonEnum = typeof InferencePreflightReasonEnum[keyof typeof InferencePreflightReasonEnum];
85
+ /**
86
+ * Check if a given object implements the InferencePreflight interface.
87
+ */
88
+ export declare function instanceOfInferencePreflight(value: object): value is InferencePreflight;
89
+ export declare function InferencePreflightFromJSON(json: any): InferencePreflight;
90
+ export declare function InferencePreflightFromJSONTyped(json: any, ignoreDiscriminator: boolean): InferencePreflight;
91
+ export declare function InferencePreflightToJSON(json: any): InferencePreflight;
92
+ export declare function InferencePreflightToJSONTyped(value?: InferencePreflight | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,86 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * deeprelay Public Developer API
5
+ * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@deeprelay.ai
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ /**
15
+ * @export
16
+ */
17
+ export const InferencePreflightVerdictEnum = {
18
+ Ok: 'ok',
19
+ Warn: 'warn',
20
+ Block: 'block'
21
+ };
22
+ /**
23
+ * @export
24
+ */
25
+ export const InferencePreflightReasonEnum = {
26
+ PlanCovered: 'plan_covered',
27
+ Payg: 'payg',
28
+ NotPlanCovered: 'not_plan_covered',
29
+ SubscriptionQuotaExhausted: 'subscription_quota_exhausted',
30
+ InsufficientBalance: 'insufficient_balance',
31
+ DailyLimitReached: 'daily_limit_reached',
32
+ MonthlyLimitReached: 'monthly_limit_reached',
33
+ PreflightUnavailable: 'preflight_unavailable'
34
+ };
35
+ /**
36
+ * Check if a given object implements the InferencePreflight interface.
37
+ */
38
+ export function instanceOfInferencePreflight(value) {
39
+ if (!('model' in value) || value['model'] === undefined)
40
+ return false;
41
+ if (!('verdict' in value) || value['verdict'] === undefined)
42
+ return false;
43
+ if (!('message' in value) || value['message'] === undefined)
44
+ return false;
45
+ if ((!('planCovered' in value) && !('plan_covered' in value)) || (value['planCovered'] === undefined && value['plan_covered'] === undefined))
46
+ return false;
47
+ if (!('subscribed' in value) || value['subscribed'] === undefined)
48
+ return false;
49
+ if (!('funded' in value) || value['funded'] === undefined)
50
+ return false;
51
+ return true;
52
+ }
53
+ export function InferencePreflightFromJSON(json) {
54
+ return InferencePreflightFromJSONTyped(json, false);
55
+ }
56
+ export function InferencePreflightFromJSONTyped(json, ignoreDiscriminator) {
57
+ if (json == null) {
58
+ return json;
59
+ }
60
+ return {
61
+ 'model': json['model'],
62
+ 'verdict': json['verdict'],
63
+ 'reason': json['reason'] == null ? undefined : json['reason'],
64
+ 'message': json['message'],
65
+ 'planCovered': json['plan_covered'],
66
+ 'subscribed': json['subscribed'],
67
+ 'funded': json['funded'],
68
+ };
69
+ }
70
+ export function InferencePreflightToJSON(json) {
71
+ return InferencePreflightToJSONTyped(json, false);
72
+ }
73
+ export function InferencePreflightToJSONTyped(value, ignoreDiscriminator = false) {
74
+ if (value == null) {
75
+ return value;
76
+ }
77
+ return {
78
+ 'model': value['model'],
79
+ 'verdict': value['verdict'],
80
+ 'reason': value['reason'],
81
+ 'message': value['message'],
82
+ 'plan_covered': value['planCovered'],
83
+ 'subscribed': value['subscribed'],
84
+ 'funded': value['funded'],
85
+ };
86
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * deeprelay Public Developer API
3
+ * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: support@deeprelay.ai
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ /**
13
+ * Present only when the organization signed up through someone else's invite link: where that referral sits and how far the organization is from unlocking its own reward.
14
+ *
15
+ * @export
16
+ * @interface RefereeStatus
17
+ */
18
+ export interface RefereeStatus {
19
+ /**
20
+ * Lifecycle state. `pending` until the spend gate is met; `qualified` inside the hold; `settled` once paid.
21
+ * @type {RefereeStatusStatusEnum}
22
+ * @memberof RefereeStatus
23
+ */
24
+ status: RefereeStatusStatusEnum;
25
+ /**
26
+ * Cumulative inference spend so far.
27
+ * @type {number}
28
+ * @memberof RefereeStatus
29
+ */
30
+ spentCents: number;
31
+ /**
32
+ * The spend that qualifies the referral.
33
+ * @type {number}
34
+ * @memberof RefereeStatus
35
+ */
36
+ qualifySpendCents: number;
37
+ /**
38
+ * What this organization receives on settlement.
39
+ * @type {number}
40
+ * @memberof RefereeStatus
41
+ */
42
+ rewardCents: number;
43
+ /**
44
+ * When the spend gate was met. Absent while pending.
45
+ * @type {Date}
46
+ * @memberof RefereeStatus
47
+ */
48
+ qualifiedAt?: Date;
49
+ /**
50
+ * When the hold ends and both halves pay out. Absent while pending.
51
+ * @type {Date}
52
+ * @memberof RefereeStatus
53
+ */
54
+ holdUntil?: Date;
55
+ /**
56
+ * When the reward was paid. Absent until settled.
57
+ * @type {Date}
58
+ * @memberof RefereeStatus
59
+ */
60
+ settledAt?: Date;
61
+ }
62
+ /**
63
+ * @export
64
+ */
65
+ export declare const RefereeStatusStatusEnum: {
66
+ readonly Pending: "pending";
67
+ readonly Qualified: "qualified";
68
+ readonly Settled: "settled";
69
+ readonly Rejected: "rejected";
70
+ };
71
+ export type RefereeStatusStatusEnum = typeof RefereeStatusStatusEnum[keyof typeof RefereeStatusStatusEnum];
72
+ /**
73
+ * Check if a given object implements the RefereeStatus interface.
74
+ */
75
+ export declare function instanceOfRefereeStatus(value: object): value is RefereeStatus;
76
+ export declare function RefereeStatusFromJSON(json: any): RefereeStatus;
77
+ export declare function RefereeStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): RefereeStatus;
78
+ export declare function RefereeStatusToJSON(json: any): RefereeStatus;
79
+ export declare function RefereeStatusToJSONTyped(value?: RefereeStatus | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,70 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * deeprelay Public Developer API
5
+ * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@deeprelay.ai
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ /**
15
+ * @export
16
+ */
17
+ export const RefereeStatusStatusEnum = {
18
+ Pending: 'pending',
19
+ Qualified: 'qualified',
20
+ Settled: 'settled',
21
+ Rejected: 'rejected'
22
+ };
23
+ /**
24
+ * Check if a given object implements the RefereeStatus interface.
25
+ */
26
+ export function instanceOfRefereeStatus(value) {
27
+ if (!('status' in value) || value['status'] === undefined)
28
+ return false;
29
+ if ((!('spentCents' in value) && !('spent_cents' in value)) || (value['spentCents'] === undefined && value['spent_cents'] === undefined))
30
+ return false;
31
+ if ((!('qualifySpendCents' in value) && !('qualify_spend_cents' in value)) || (value['qualifySpendCents'] === undefined && value['qualify_spend_cents'] === undefined))
32
+ return false;
33
+ if ((!('rewardCents' in value) && !('reward_cents' in value)) || (value['rewardCents'] === undefined && value['reward_cents'] === undefined))
34
+ return false;
35
+ return true;
36
+ }
37
+ export function RefereeStatusFromJSON(json) {
38
+ return RefereeStatusFromJSONTyped(json, false);
39
+ }
40
+ export function RefereeStatusFromJSONTyped(json, ignoreDiscriminator) {
41
+ if (json == null) {
42
+ return json;
43
+ }
44
+ return {
45
+ 'status': json['status'],
46
+ 'spentCents': json['spent_cents'],
47
+ 'qualifySpendCents': json['qualify_spend_cents'],
48
+ 'rewardCents': json['reward_cents'],
49
+ 'qualifiedAt': json['qualified_at'] == null ? undefined : (new Date(json['qualified_at'])),
50
+ 'holdUntil': json['hold_until'] == null ? undefined : (new Date(json['hold_until'])),
51
+ 'settledAt': json['settled_at'] == null ? undefined : (new Date(json['settled_at'])),
52
+ };
53
+ }
54
+ export function RefereeStatusToJSON(json) {
55
+ return RefereeStatusToJSONTyped(json, false);
56
+ }
57
+ export function RefereeStatusToJSONTyped(value, ignoreDiscriminator = false) {
58
+ if (value == null) {
59
+ return value;
60
+ }
61
+ return {
62
+ 'status': value['status'],
63
+ 'spent_cents': value['spentCents'],
64
+ 'qualify_spend_cents': value['qualifySpendCents'],
65
+ 'reward_cents': value['rewardCents'],
66
+ 'qualified_at': value['qualifiedAt'] == null ? value['qualifiedAt'] : value['qualifiedAt'].toISOString(),
67
+ 'hold_until': value['holdUntil'] == null ? value['holdUntil'] : value['holdUntil'].toISOString(),
68
+ 'settled_at': value['settledAt'] == null ? value['settledAt'] : value['settledAt'].toISOString(),
69
+ };
70
+ }