@deeprelay/sdk 0.4.1 → 0.4.3

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 (105) hide show
  1. package/.openapi-generator/FILES +4 -0
  2. package/README.md +4 -2
  3. package/dist/apis/ApiKeysApi.d.ts +2 -2
  4. package/dist/apis/ApiKeysApi.js +2 -2
  5. package/dist/apis/BillingApi.d.ts +2 -2
  6. package/dist/apis/BillingApi.js +2 -2
  7. package/dist/apis/InferenceApi.d.ts +3 -2
  8. package/dist/apis/InferenceApi.js +5 -2
  9. package/dist/apis/RequestsApi.d.ts +4 -2
  10. package/dist/apis/RequestsApi.js +8 -2
  11. package/dist/esm/apis/ApiKeysApi.d.ts +2 -2
  12. package/dist/esm/apis/ApiKeysApi.js +2 -2
  13. package/dist/esm/apis/BillingApi.d.ts +2 -2
  14. package/dist/esm/apis/BillingApi.js +2 -2
  15. package/dist/esm/apis/InferenceApi.d.ts +3 -2
  16. package/dist/esm/apis/InferenceApi.js +5 -2
  17. package/dist/esm/apis/RequestsApi.d.ts +4 -2
  18. package/dist/esm/apis/RequestsApi.js +8 -2
  19. package/dist/esm/models/ApiKey.d.ts +19 -0
  20. package/dist/esm/models/ApiKey.js +9 -0
  21. package/dist/esm/models/ApiKeyCreate.d.ts +6 -0
  22. package/dist/esm/models/ApiKeyCreate.js +2 -0
  23. package/dist/esm/models/ApiKeyCreated.d.ts +19 -0
  24. package/dist/esm/models/ApiKeyCreated.js +9 -0
  25. package/dist/esm/models/ApiKeyFallbackEntry.d.ts +65 -0
  26. package/dist/esm/models/ApiKeyFallbackEntry.js +67 -0
  27. package/dist/esm/models/ApiKeyUpdate.d.ts +7 -1
  28. package/dist/esm/models/ApiKeyUpdate.js +2 -0
  29. package/dist/esm/models/ChatCompletionRequest.d.ts +6 -0
  30. package/dist/esm/models/ChatCompletionRequest.js +2 -0
  31. package/dist/esm/models/CreateWebhookEndpointRequest.d.ts +1 -0
  32. package/dist/esm/models/CreateWebhookEndpointRequest.js +2 -1
  33. package/dist/esm/models/RefereeStatus.d.ts +33 -4
  34. package/dist/esm/models/RefereeStatus.js +15 -1
  35. package/dist/esm/models/Referral.d.ts +10 -3
  36. package/dist/esm/models/Referral.js +2 -0
  37. package/dist/esm/models/RequestAttempt.d.ts +71 -0
  38. package/dist/esm/models/RequestAttempt.js +67 -0
  39. package/dist/esm/models/RequestLogEntry.d.ts +25 -0
  40. package/dist/esm/models/RequestLogEntry.js +9 -0
  41. package/dist/esm/models/WebhookEndpoint.d.ts +1 -0
  42. package/dist/esm/models/WebhookEndpoint.js +2 -1
  43. package/dist/esm/models/index.d.ts +2 -0
  44. package/dist/esm/models/index.js +2 -0
  45. package/dist/esm/runtime.js +1 -1
  46. package/dist/models/ApiKey.d.ts +19 -0
  47. package/dist/models/ApiKey.js +9 -0
  48. package/dist/models/ApiKeyCreate.d.ts +6 -0
  49. package/dist/models/ApiKeyCreate.js +2 -0
  50. package/dist/models/ApiKeyCreated.d.ts +19 -0
  51. package/dist/models/ApiKeyCreated.js +9 -0
  52. package/dist/models/ApiKeyFallbackEntry.d.ts +65 -0
  53. package/dist/models/ApiKeyFallbackEntry.js +75 -0
  54. package/dist/models/ApiKeyUpdate.d.ts +7 -1
  55. package/dist/models/ApiKeyUpdate.js +2 -0
  56. package/dist/models/ChatCompletionRequest.d.ts +6 -0
  57. package/dist/models/ChatCompletionRequest.js +2 -0
  58. package/dist/models/CreateWebhookEndpointRequest.d.ts +1 -0
  59. package/dist/models/CreateWebhookEndpointRequest.js +2 -1
  60. package/dist/models/RefereeStatus.d.ts +33 -4
  61. package/dist/models/RefereeStatus.js +16 -2
  62. package/dist/models/Referral.d.ts +10 -3
  63. package/dist/models/Referral.js +2 -0
  64. package/dist/models/RequestAttempt.d.ts +71 -0
  65. package/dist/models/RequestAttempt.js +75 -0
  66. package/dist/models/RequestLogEntry.d.ts +25 -0
  67. package/dist/models/RequestLogEntry.js +9 -0
  68. package/dist/models/WebhookEndpoint.d.ts +1 -0
  69. package/dist/models/WebhookEndpoint.js +2 -1
  70. package/dist/models/index.d.ts +2 -0
  71. package/dist/models/index.js +2 -0
  72. package/dist/runtime.js +1 -1
  73. package/docs/ApiKey.md +6 -0
  74. package/docs/ApiKeyCreate.md +2 -0
  75. package/docs/ApiKeyCreated.md +6 -0
  76. package/docs/ApiKeyFallbackEntry.md +43 -0
  77. package/docs/ApiKeyUpdate.md +3 -1
  78. package/docs/ApiKeysApi.md +1 -1
  79. package/docs/BillingApi.md +1 -1
  80. package/docs/ChatCompletionRequest.md +2 -0
  81. package/docs/InferenceApi.md +29 -26
  82. package/docs/RefereeStatus.md +6 -0
  83. package/docs/Referral.md +2 -0
  84. package/docs/RequestAttempt.md +45 -0
  85. package/docs/RequestLogEntry.md +8 -0
  86. package/docs/RequestsApi.md +9 -3
  87. package/package.json +1 -1
  88. package/src/apis/ApiKeysApi.ts +2 -2
  89. package/src/apis/BillingApi.ts +2 -2
  90. package/src/apis/InferenceApi.ts +7 -2
  91. package/src/apis/RequestsApi.ts +12 -2
  92. package/src/models/ApiKey.ts +32 -0
  93. package/src/models/ApiKeyCreate.ts +8 -0
  94. package/src/models/ApiKeyCreated.ts +32 -0
  95. package/src/models/ApiKeyFallbackEntry.ts +114 -0
  96. package/src/models/ApiKeyUpdate.ts +9 -1
  97. package/src/models/ChatCompletionRequest.ts +8 -0
  98. package/src/models/CreateWebhookEndpointRequest.ts +2 -1
  99. package/src/models/RefereeStatus.ts +41 -5
  100. package/src/models/Referral.ts +12 -3
  101. package/src/models/RequestAttempt.ts +121 -0
  102. package/src/models/RequestLogEntry.ts +40 -0
  103. package/src/models/WebhookEndpoint.ts +2 -1
  104. package/src/models/index.ts +2 -0
  105. package/src/runtime.ts +1 -1
@@ -38,6 +38,7 @@ export interface ExportRequestsRequest {
38
38
  clientRequestId?: string;
39
39
  from?: Date;
40
40
  to?: Date;
41
+ fallback?: boolean;
41
42
  }
42
43
 
43
44
  export interface GetRequestRequest {
@@ -53,6 +54,7 @@ export interface ListRequestsRequest {
53
54
  clientRequestId?: string;
54
55
  from?: Date;
55
56
  to?: Date;
57
+ fallback?: boolean;
56
58
  cursor?: string;
57
59
  limit?: number;
58
60
  }
@@ -100,6 +102,10 @@ export class RequestsApi extends runtime.BaseAPI {
100
102
  queryParameters['to'] = (requestParameters['to'] as any).toISOString();
101
103
  }
102
104
 
105
+ if (requestParameters['fallback'] != null) {
106
+ queryParameters['fallback'] = requestParameters['fallback'];
107
+ }
108
+
103
109
  const headerParameters: runtime.HTTPHeaders = {};
104
110
 
105
111
  if (this.configuration && this.configuration.accessToken) {
@@ -122,7 +128,7 @@ export class RequestsApi extends runtime.BaseAPI {
122
128
  }
123
129
 
124
130
  /**
125
- * Streams every request-log row matching the filters as a CSV attachment, oldest columns first: `request_id, client_request_id, occurred_at, surface, model, key_id, key_name, key_prefix, status, http_status, error_code, finish_reason, prompt_tokens, completion_tokens, cached_tokens, reasoning_tokens, quota_units, cost, plan_covered, ttft_ms, duration_ms, ignored_params`. Takes the same filters and visibility rules as `GET /requests`, without the cursor and limit. The export is counted before anything is written. When the filters match more rows than the export cap, the answer is 422 `export_too_large` and the problem body carries `max_rows`; narrow the time range or add a filter, then export again. Requires the `serverless:read` scope. Exports have their own, tighter per-key rate limit.
131
+ * Streams every request-log row matching the filters as a CSV attachment, oldest columns first: `request_id, client_request_id, occurred_at, surface, model, key_id, key_name, key_prefix, status, http_status, error_code, finish_reason, prompt_tokens, completion_tokens, cached_tokens, reasoning_tokens, quota_units, cost, plan_covered, ttft_ms, duration_ms, ignored_params, requested_model, served_model, fallback_reason`. Takes the same filters and visibility rules as `GET /requests`, without the cursor and limit. The export is counted before anything is written. When the filters match more rows than the export cap, the answer is 422 `export_too_large` and the problem body carries `max_rows`; narrow the time range or add a filter, then export again. Requires the `serverless:read` scope. Exports have their own, tighter per-key rate limit.
126
132
  * Export the request log as CSV
127
133
  */
128
134
  async exportRequestsRaw(requestParameters: ExportRequestsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<string>> {
@@ -137,7 +143,7 @@ export class RequestsApi extends runtime.BaseAPI {
137
143
  }
138
144
 
139
145
  /**
140
- * Streams every request-log row matching the filters as a CSV attachment, oldest columns first: `request_id, client_request_id, occurred_at, surface, model, key_id, key_name, key_prefix, status, http_status, error_code, finish_reason, prompt_tokens, completion_tokens, cached_tokens, reasoning_tokens, quota_units, cost, plan_covered, ttft_ms, duration_ms, ignored_params`. Takes the same filters and visibility rules as `GET /requests`, without the cursor and limit. The export is counted before anything is written. When the filters match more rows than the export cap, the answer is 422 `export_too_large` and the problem body carries `max_rows`; narrow the time range or add a filter, then export again. Requires the `serverless:read` scope. Exports have their own, tighter per-key rate limit.
146
+ * Streams every request-log row matching the filters as a CSV attachment, oldest columns first: `request_id, client_request_id, occurred_at, surface, model, key_id, key_name, key_prefix, status, http_status, error_code, finish_reason, prompt_tokens, completion_tokens, cached_tokens, reasoning_tokens, quota_units, cost, plan_covered, ttft_ms, duration_ms, ignored_params, requested_model, served_model, fallback_reason`. Takes the same filters and visibility rules as `GET /requests`, without the cursor and limit. The export is counted before anything is written. When the filters match more rows than the export cap, the answer is 422 `export_too_large` and the problem body carries `max_rows`; narrow the time range or add a filter, then export again. Requires the `serverless:read` scope. Exports have their own, tighter per-key rate limit.
141
147
  * Export the request log as CSV
142
148
  */
143
149
  async exportRequests(requestParameters: ExportRequestsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string> {
@@ -238,6 +244,10 @@ export class RequestsApi extends runtime.BaseAPI {
238
244
  queryParameters['to'] = (requestParameters['to'] as any).toISOString();
239
245
  }
240
246
 
247
+ if (requestParameters['fallback'] != null) {
248
+ queryParameters['fallback'] = requestParameters['fallback'];
249
+ }
250
+
241
251
  if (requestParameters['cursor'] != null) {
242
252
  queryParameters['cursor'] = requestParameters['cursor'];
243
253
  }
@@ -20,6 +20,13 @@ import {
20
20
  ApiKeyScopesToJSON,
21
21
  ApiKeyScopesToJSONTyped,
22
22
  } from './ApiKeyScopes';
23
+ import type { ApiKeyFallbackEntry } from './ApiKeyFallbackEntry';
24
+ import {
25
+ ApiKeyFallbackEntryFromJSON,
26
+ ApiKeyFallbackEntryFromJSONTyped,
27
+ ApiKeyFallbackEntryToJSON,
28
+ ApiKeyFallbackEntryToJSONTyped,
29
+ } from './ApiKeyFallbackEntry';
23
30
 
24
31
  /**
25
32
  * An API key's metadata and limits. Never carries the secret.
@@ -87,6 +94,24 @@ export interface ApiKey {
87
94
  * @memberof ApiKey
88
95
  */
89
96
  staleModels?: Array<string>;
97
+ /**
98
+ * Backup models in priority order, applied to every model this key calls. Null means model fallback is off (the default). If every provider for the requested model fails before the first token with a temporary error, the next entry is tried. Entries are kept when a model leaves the plan roster or the catalog and are skipped at request time; see `fallback_entries`. Not applied to Liquid.
99
+ * @type {Array<string>}
100
+ * @memberof ApiKey
101
+ */
102
+ fallbackModels: Array<string> | null;
103
+ /**
104
+ * Present when `fallback_models` is set: one entry per backup, in order, explaining it as of now.
105
+ * @type {Array<ApiKeyFallbackEntry>}
106
+ * @memberof ApiKey
107
+ */
108
+ fallbackEntries?: Array<ApiKeyFallbackEntry>;
109
+ /**
110
+ * The model this key requested most over the last 30 days, which `above_primary` is measured against. Present only for a key with `fallback_models` and recent usage.
111
+ * @type {string}
112
+ * @memberof ApiKey
113
+ */
114
+ primaryModel?: string;
90
115
  /**
91
116
  *
92
117
  * @type {number}
@@ -136,6 +161,7 @@ export function instanceOfApiKey(value: object): value is ApiKey {
136
161
  if (!('scopes' in value) || value['scopes'] === undefined) return false;
137
162
  if ((!('budgetCents' in (value as Record<string, any>)) && !('budget_cents' in (value as Record<string, any>))) || ((value as Record<string, any>)['budgetCents'] === undefined && (value as Record<string, any>)['budget_cents'] === undefined)) return false;
138
163
  if ((!('allowedModels' in (value as Record<string, any>)) && !('allowed_models' in (value as Record<string, any>))) || ((value as Record<string, any>)['allowedModels'] === undefined && (value as Record<string, any>)['allowed_models'] === undefined)) return false;
164
+ if ((!('fallbackModels' in (value as Record<string, any>)) && !('fallback_models' in (value as Record<string, any>))) || ((value as Record<string, any>)['fallbackModels'] === undefined && (value as Record<string, any>)['fallback_models'] === undefined)) return false;
139
165
  if ((!('rateLimitRps' in (value as Record<string, any>)) && !('rate_limit_rps' in (value as Record<string, any>))) || ((value as Record<string, any>)['rateLimitRps'] === undefined && (value as Record<string, any>)['rate_limit_rps'] === undefined)) return false;
140
166
  if ((!('rateLimitBurst' in (value as Record<string, any>)) && !('rate_limit_burst' in (value as Record<string, any>))) || ((value as Record<string, any>)['rateLimitBurst'] === undefined && (value as Record<string, any>)['rate_limit_burst'] === undefined)) return false;
141
167
  if ((!('expiresAt' in (value as Record<string, any>)) && !('expires_at' in (value as Record<string, any>))) || ((value as Record<string, any>)['expiresAt'] === undefined && (value as Record<string, any>)['expires_at'] === undefined)) return false;
@@ -164,6 +190,9 @@ export function ApiKeyFromJSONTyped(json: any, ignoreDiscriminator: boolean): Ap
164
190
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
165
191
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
166
192
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
193
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
194
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : ((json['fallback_entries'] as Array<any>).map(ApiKeyFallbackEntryFromJSON)),
195
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
167
196
  'rateLimitRps': json['rate_limit_rps'],
168
197
  'rateLimitBurst': json['rate_limit_burst'],
169
198
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -194,6 +223,9 @@ export function ApiKeyToJSONTyped(value?: ApiKey | null, ignoreDiscriminator: bo
194
223
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
195
224
  'allowed_models': value['allowedModels'],
196
225
  'stale_models': value['staleModels'],
226
+ 'fallback_models': value['fallbackModels'],
227
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : ((value['fallbackEntries'] as Array<any>).map(ApiKeyFallbackEntryToJSON)),
228
+ 'primary_model': value['primaryModel'],
197
229
  'rate_limit_rps': value['rateLimitRps'],
198
230
  'rate_limit_burst': value['rateLimitBurst'],
199
231
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -43,6 +43,12 @@ export interface ApiKeyCreate {
43
43
  * @memberof ApiKeyCreate
44
44
  */
45
45
  allowedModels?: Array<string>;
46
+ /**
47
+ * Backup models in priority order. Omit it to leave model fallback off. Each entry must be a chat model in the catalog and, when the key has `allowed_models`, on that list. Duplicates are removed. An empty array, more than 3 models or an invalid entry is a 422 `validation_failed` naming the `fallback_models` field.
48
+ * @type {Array<string>}
49
+ * @memberof ApiKeyCreate
50
+ */
51
+ fallbackModels?: Array<string>;
46
52
  /**
47
53
  *
48
54
  * @type {number}
@@ -86,6 +92,7 @@ export function ApiKeyCreateFromJSONTyped(json: any, ignoreDiscriminator: boolea
86
92
  'scopes': json['scopes'],
87
93
  'budgetCents': json['budget_cents'] == null ? undefined : json['budget_cents'],
88
94
  'allowedModels': json['allowed_models'] == null ? undefined : json['allowed_models'],
95
+ 'fallbackModels': json['fallback_models'] == null ? undefined : json['fallback_models'],
89
96
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
90
97
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
91
98
  'expiresAt': json['expires_at'] == null ? undefined : (new Date(json['expires_at'])),
@@ -107,6 +114,7 @@ export function ApiKeyCreateToJSONTyped(value?: ApiKeyCreate | null, ignoreDiscr
107
114
  'scopes': value['scopes'],
108
115
  'budget_cents': value['budgetCents'],
109
116
  'allowed_models': value['allowedModels'],
117
+ 'fallback_models': value['fallbackModels'],
110
118
  'rate_limit_rps': value['rateLimitRps'],
111
119
  'rate_limit_burst': value['rateLimitBurst'],
112
120
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -20,6 +20,13 @@ import {
20
20
  ApiKeyScopesToJSON,
21
21
  ApiKeyScopesToJSONTyped,
22
22
  } from './ApiKeyScopes';
23
+ import type { ApiKeyFallbackEntry } from './ApiKeyFallbackEntry';
24
+ import {
25
+ ApiKeyFallbackEntryFromJSON,
26
+ ApiKeyFallbackEntryFromJSONTyped,
27
+ ApiKeyFallbackEntryToJSON,
28
+ ApiKeyFallbackEntryToJSONTyped,
29
+ } from './ApiKeyFallbackEntry';
23
30
 
24
31
  /**
25
32
  * The new key's metadata plus its secret (`key`), returned exactly once. The same fields as `ApiKey`, plus `key`.
@@ -87,6 +94,24 @@ export interface ApiKeyCreated {
87
94
  * @memberof ApiKeyCreated
88
95
  */
89
96
  staleModels?: Array<string>;
97
+ /**
98
+ * Backup models in priority order, applied to every model this key calls. Null means model fallback is off (the default). If every provider for the requested model fails before the first token with a temporary error, the next entry is tried. Entries are kept when a model leaves the plan roster or the catalog and are skipped at request time; see `fallback_entries`. Not applied to Liquid.
99
+ * @type {Array<string>}
100
+ * @memberof ApiKeyCreated
101
+ */
102
+ fallbackModels: Array<string> | null;
103
+ /**
104
+ * Present when `fallback_models` is set: one entry per backup, in order, explaining it as of now.
105
+ * @type {Array<ApiKeyFallbackEntry>}
106
+ * @memberof ApiKeyCreated
107
+ */
108
+ fallbackEntries?: Array<ApiKeyFallbackEntry>;
109
+ /**
110
+ * The model this key requested most over the last 30 days, which `above_primary` is measured against. Present only for a key with `fallback_models` and recent usage.
111
+ * @type {string}
112
+ * @memberof ApiKeyCreated
113
+ */
114
+ primaryModel?: string;
90
115
  /**
91
116
  *
92
117
  * @type {number}
@@ -142,6 +167,7 @@ export function instanceOfApiKeyCreated(value: object): value is ApiKeyCreated {
142
167
  if (!('scopes' in value) || value['scopes'] === undefined) return false;
143
168
  if ((!('budgetCents' in (value as Record<string, any>)) && !('budget_cents' in (value as Record<string, any>))) || ((value as Record<string, any>)['budgetCents'] === undefined && (value as Record<string, any>)['budget_cents'] === undefined)) return false;
144
169
  if ((!('allowedModels' in (value as Record<string, any>)) && !('allowed_models' in (value as Record<string, any>))) || ((value as Record<string, any>)['allowedModels'] === undefined && (value as Record<string, any>)['allowed_models'] === undefined)) return false;
170
+ if ((!('fallbackModels' in (value as Record<string, any>)) && !('fallback_models' in (value as Record<string, any>))) || ((value as Record<string, any>)['fallbackModels'] === undefined && (value as Record<string, any>)['fallback_models'] === undefined)) return false;
145
171
  if ((!('rateLimitRps' in (value as Record<string, any>)) && !('rate_limit_rps' in (value as Record<string, any>))) || ((value as Record<string, any>)['rateLimitRps'] === undefined && (value as Record<string, any>)['rate_limit_rps'] === undefined)) return false;
146
172
  if ((!('rateLimitBurst' in (value as Record<string, any>)) && !('rate_limit_burst' in (value as Record<string, any>))) || ((value as Record<string, any>)['rateLimitBurst'] === undefined && (value as Record<string, any>)['rate_limit_burst'] === undefined)) return false;
147
173
  if ((!('expiresAt' in (value as Record<string, any>)) && !('expires_at' in (value as Record<string, any>))) || ((value as Record<string, any>)['expiresAt'] === undefined && (value as Record<string, any>)['expires_at'] === undefined)) return false;
@@ -171,6 +197,9 @@ export function ApiKeyCreatedFromJSONTyped(json: any, ignoreDiscriminator: boole
171
197
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
172
198
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
173
199
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
200
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
201
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : ((json['fallback_entries'] as Array<any>).map(ApiKeyFallbackEntryFromJSON)),
202
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
174
203
  'rateLimitRps': json['rate_limit_rps'],
175
204
  'rateLimitBurst': json['rate_limit_burst'],
176
205
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -202,6 +231,9 @@ export function ApiKeyCreatedToJSONTyped(value?: ApiKeyCreated | null, ignoreDis
202
231
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
203
232
  'allowed_models': value['allowedModels'],
204
233
  'stale_models': value['staleModels'],
234
+ 'fallback_models': value['fallbackModels'],
235
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : ((value['fallbackEntries'] as Array<any>).map(ApiKeyFallbackEntryToJSON)),
236
+ 'primary_model': value['primaryModel'],
205
237
  'rate_limit_rps': value['rateLimitRps'],
206
238
  'rate_limit_burst': value['rateLimitBurst'],
207
239
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -0,0 +1,114 @@
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. Keys minted from the dashboard or `deeprelay login` belong to the Production server, https://api.deeprelay.ai/v1. The Demo server is an internal staging environment with its own key store. Versioning: `/v1` is the API version. `info.version` is the revision of this `/v1` document, not a separate API. OpenAI compatibility: chat completions follow the OpenAI request and response shapes, but not every OpenAI parameter is carried. Some are rejected with 400 `unsupported_parameter` and any parameter not declared in this spec is accepted and ignored. The full table is at https://deeprelay.ai/docs/api/inference#openai-compatibility.
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
+ import { mapValues } from '../runtime';
16
+ /**
17
+ * One backup model on a key, as it stands now.
18
+ * @export
19
+ * @interface ApiKeyFallbackEntry
20
+ */
21
+ export interface ApiKeyFallbackEntry {
22
+ /**
23
+ *
24
+ * @type {string}
25
+ * @memberof ApiKeyFallbackEntry
26
+ */
27
+ model: string;
28
+ /**
29
+ * `ok`: usable as a backup. `wallet_only`: the model is not on the subscription plan roster, so it backs up only requests billed to the wallet; a plan-covered request skips it. `unavailable`: the model is no longer in the catalog and is always skipped.
30
+ * @type {ApiKeyFallbackEntryStateEnum}
31
+ * @memberof ApiKeyFallbackEntry
32
+ */
33
+ state: ApiKeyFallbackEntryStateEnum;
34
+ /**
35
+ * Current input price per 1M tokens, in micro-cents. 0 when unknown or unavailable.
36
+ * @type {number}
37
+ * @memberof ApiKeyFallbackEntry
38
+ */
39
+ inputPer1mTokensMicrocents: number;
40
+ /**
41
+ * Current output price per 1M tokens, in micro-cents. 0 when unknown or unavailable.
42
+ * @type {number}
43
+ * @memberof ApiKeyFallbackEntry
44
+ */
45
+ outputPer1mTokensMicrocents: number;
46
+ /**
47
+ * True when this backup's input plus output price is above `primary_model`'s. Pricier backups are allowed; a request served by one is billed at its own price, and the key budget is checked at that price.
48
+ * @type {boolean}
49
+ * @memberof ApiKeyFallbackEntry
50
+ */
51
+ abovePrimary: boolean;
52
+ }
53
+
54
+
55
+ /**
56
+ * @export
57
+ */
58
+ export const ApiKeyFallbackEntryStateEnum = {
59
+ Ok: 'ok',
60
+ WalletOnly: 'wallet_only',
61
+ Unavailable: 'unavailable'
62
+ } as const;
63
+ export type ApiKeyFallbackEntryStateEnum = typeof ApiKeyFallbackEntryStateEnum[keyof typeof ApiKeyFallbackEntryStateEnum];
64
+
65
+
66
+ /**
67
+ * Check if a given object implements the ApiKeyFallbackEntry interface.
68
+ */
69
+ export function instanceOfApiKeyFallbackEntry(value: object): value is ApiKeyFallbackEntry {
70
+ if (!('model' in value) || value['model'] === undefined) return false;
71
+ if (!('state' in value) || value['state'] === undefined) return false;
72
+ if ((!('inputPer1mTokensMicrocents' in (value as Record<string, any>)) && !('input_per_1m_tokens_microcents' in (value as Record<string, any>))) || ((value as Record<string, any>)['inputPer1mTokensMicrocents'] === undefined && (value as Record<string, any>)['input_per_1m_tokens_microcents'] === undefined)) return false;
73
+ if ((!('outputPer1mTokensMicrocents' in (value as Record<string, any>)) && !('output_per_1m_tokens_microcents' in (value as Record<string, any>))) || ((value as Record<string, any>)['outputPer1mTokensMicrocents'] === undefined && (value as Record<string, any>)['output_per_1m_tokens_microcents'] === undefined)) return false;
74
+ if ((!('abovePrimary' in (value as Record<string, any>)) && !('above_primary' in (value as Record<string, any>))) || ((value as Record<string, any>)['abovePrimary'] === undefined && (value as Record<string, any>)['above_primary'] === undefined)) return false;
75
+ return true;
76
+ }
77
+
78
+ export function ApiKeyFallbackEntryFromJSON(json: any): ApiKeyFallbackEntry {
79
+ return ApiKeyFallbackEntryFromJSONTyped(json, false);
80
+ }
81
+
82
+ export function ApiKeyFallbackEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApiKeyFallbackEntry {
83
+ if (json == null) {
84
+ return json;
85
+ }
86
+ return {
87
+
88
+ 'model': json['model'],
89
+ 'state': json['state'],
90
+ 'inputPer1mTokensMicrocents': json['input_per_1m_tokens_microcents'],
91
+ 'outputPer1mTokensMicrocents': json['output_per_1m_tokens_microcents'],
92
+ 'abovePrimary': json['above_primary'],
93
+ };
94
+ }
95
+
96
+ export function ApiKeyFallbackEntryToJSON(json: any): ApiKeyFallbackEntry {
97
+ return ApiKeyFallbackEntryToJSONTyped(json, false);
98
+ }
99
+
100
+ export function ApiKeyFallbackEntryToJSONTyped(value?: ApiKeyFallbackEntry | null, ignoreDiscriminator: boolean = false): any {
101
+ if (value == null) {
102
+ return value;
103
+ }
104
+
105
+ return {
106
+
107
+ 'model': value['model'],
108
+ 'state': value['state'],
109
+ 'input_per_1m_tokens_microcents': value['inputPer1mTokensMicrocents'],
110
+ 'output_per_1m_tokens_microcents': value['outputPer1mTokensMicrocents'],
111
+ 'above_primary': value['abovePrimary'],
112
+ };
113
+ }
114
+
@@ -14,7 +14,7 @@
14
14
 
15
15
  import { mapValues } from '../runtime';
16
16
  /**
17
- * Send only the fields to change. `null` clears `budget_cents`, `allowed_models` or `expires_at`. `scopes` cannot be changed.
17
+ * Send only the fields to change. `null` clears `budget_cents`, `allowed_models`, `fallback_models` or `expires_at`. `scopes` cannot be changed.
18
18
  * @export
19
19
  * @interface ApiKeyUpdate
20
20
  */
@@ -37,6 +37,12 @@ export interface ApiKeyUpdate {
37
37
  * @memberof ApiKeyUpdate
38
38
  */
39
39
  allowedModels?: Array<string> | null;
40
+ /**
41
+ * Replace the backup list (priority order), or `null` to turn model fallback off. Same rules as on create, judged against the key's allowlist after this update. An empty array is a 422 `validation_failed`; send `null` instead.
42
+ * @type {Array<string>}
43
+ * @memberof ApiKeyUpdate
44
+ */
45
+ fallbackModels?: Array<string> | null;
40
46
  /**
41
47
  *
42
48
  * @type {number}
@@ -77,6 +83,7 @@ export function ApiKeyUpdateFromJSONTyped(json: any, ignoreDiscriminator: boolea
77
83
  'name': json['name'] == null ? undefined : json['name'],
78
84
  'budgetCents': json['budget_cents'] === undefined ? undefined : json['budget_cents'] === null ? null : json['budget_cents'],
79
85
  'allowedModels': json['allowed_models'] === undefined ? undefined : json['allowed_models'] === null ? null : json['allowed_models'],
86
+ 'fallbackModels': json['fallback_models'] === undefined ? undefined : json['fallback_models'] === null ? null : json['fallback_models'],
80
87
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
81
88
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
82
89
  'expiresAt': json['expires_at'] === undefined ? undefined : json['expires_at'] === null ? null : (new Date(json['expires_at'])),
@@ -97,6 +104,7 @@ export function ApiKeyUpdateToJSONTyped(value?: ApiKeyUpdate | null, ignoreDiscr
97
104
  'name': value['name'],
98
105
  'budget_cents': value['budgetCents'],
99
106
  'allowed_models': value['allowedModels'],
107
+ 'fallback_models': value['fallbackModels'],
100
108
  'rate_limit_rps': value['rateLimitRps'],
101
109
  'rate_limit_burst': value['rateLimitBurst'],
102
110
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -61,6 +61,12 @@ export interface ChatCompletionRequest {
61
61
  * @memberof ChatCompletionRequest
62
62
  */
63
63
  model: string;
64
+ /**
65
+ * OpenRouter-compatible backup models for this request. `model` is the requested model and `models` lists the backups in priority order; when `model` is empty, the first entry of `models` is the requested model. An entry naming the requested model is ignored. At most 3 backups. The list replaces the API key's `fallback_models` for this request, and an empty array turns model fallback off for this request. Each backup must still pass the key's model allowlist, the request's billing mode and its capability needs, or it is skipped. Sending both `models` and the X-Deeprelay-Fallback-Models header is a 400 `invalid_request`. Chat completions only; on `/messages` and `/responses` use the header.
66
+ * @type {Array<string>}
67
+ * @memberof ChatCompletionRequest
68
+ */
69
+ models?: Array<string> | null;
64
70
  /**
65
71
  *
66
72
  * @type {Array<ChatMessage>}
@@ -186,6 +192,7 @@ export function ChatCompletionRequestFromJSONTyped(json: any, ignoreDiscriminato
186
192
  return {
187
193
 
188
194
  'model': json['model'],
195
+ 'models': json['models'] === undefined ? undefined : json['models'] === null ? null : json['models'],
189
196
  'messages': ((json['messages'] as Array<any>).map(ChatMessageFromJSON)),
190
197
  'temperature': json['temperature'] == null ? undefined : json['temperature'],
191
198
  'maxTokens': json['max_tokens'] == null ? undefined : json['max_tokens'],
@@ -217,6 +224,7 @@ export function ChatCompletionRequestToJSONTyped(value?: ChatCompletionRequest |
217
224
  return {
218
225
 
219
226
  'model': value['model'],
227
+ 'models': value['models'],
220
228
  'messages': ((value['messages'] as Array<any>).map(ChatMessageToJSON)),
221
229
  'temperature': value['temperature'],
222
230
  'max_tokens': value['maxTokens'],
@@ -47,7 +47,8 @@ export const CreateWebhookEndpointRequestEventTypesEnum = {
47
47
  BalanceLow: 'balance.low',
48
48
  SubscriptionQuotaThreshold: 'subscription_quota.threshold',
49
49
  ApiKeyBudgetThreshold: 'api_key_budget.threshold',
50
- MemberSpendThreshold: 'member_spend.threshold'
50
+ MemberSpendThreshold: 'member_spend.threshold',
51
+ PlanRosterModelRemoved: 'plan_roster.model_removed'
51
52
  } as const;
52
53
  export type CreateWebhookEndpointRequestEventTypesEnum = typeof CreateWebhookEndpointRequestEventTypesEnum[keyof typeof CreateWebhookEndpointRequestEventTypesEnum];
53
54
 
@@ -21,21 +21,41 @@ import { mapValues } from '../runtime';
21
21
  */
22
22
  export interface RefereeStatus {
23
23
  /**
24
- * Lifecycle state. `pending` until the spend gate is met; `qualified` inside the hold; `settled` once paid.
24
+ * Lifecycle state. `pending` until the gate is met; `qualified` inside the hold; `settled` once paid; `reversed` when the qualifying deposit was refunded after payout and both rewards were taken back.
25
25
  * @type {RefereeStatusStatusEnum}
26
26
  * @memberof RefereeStatus
27
27
  */
28
28
  status: RefereeStatusStatusEnum;
29
29
  /**
30
- * Cumulative inference spend so far.
30
+ * What qualifies this referral. `deposit` (net real deposits) for current referrals; `spend` (inference usage) for referrals made under the earlier program, which keep their original terms.
31
+ * @type {RefereeStatusGateEnum}
32
+ * @memberof RefereeStatus
33
+ */
34
+ gate?: RefereeStatusGateEnum;
35
+ /**
36
+ * Progress toward the gate so far — net deposits for `deposit`, inference spend for `spend`.
37
+ * @type {number}
38
+ * @memberof RefereeStatus
39
+ */
40
+ progressCents?: number;
41
+ /**
42
+ * The amount that qualifies the referral.
43
+ * @type {number}
44
+ * @memberof RefereeStatus
45
+ */
46
+ goalCents?: number;
47
+ /**
48
+ * Deprecated alias of `progress_cents`.
31
49
  * @type {number}
32
50
  * @memberof RefereeStatus
51
+ * @deprecated
33
52
  */
34
53
  spentCents: number;
35
54
  /**
36
- * The spend that qualifies the referral.
55
+ * Deprecated alias of `goal_cents`.
37
56
  * @type {number}
38
57
  * @memberof RefereeStatus
58
+ * @deprecated
39
59
  */
40
60
  qualifySpendCents: number;
41
61
  /**
@@ -45,7 +65,7 @@ export interface RefereeStatus {
45
65
  */
46
66
  rewardCents: number;
47
67
  /**
48
- * When the spend gate was met. Absent while pending.
68
+ * When the gate was met. Absent while pending.
49
69
  * @type {Date}
50
70
  * @memberof RefereeStatus
51
71
  */
@@ -72,10 +92,20 @@ export const RefereeStatusStatusEnum = {
72
92
  Pending: 'pending',
73
93
  Qualified: 'qualified',
74
94
  Settled: 'settled',
75
- Rejected: 'rejected'
95
+ Rejected: 'rejected',
96
+ Reversed: 'reversed'
76
97
  } as const;
77
98
  export type RefereeStatusStatusEnum = typeof RefereeStatusStatusEnum[keyof typeof RefereeStatusStatusEnum];
78
99
 
100
+ /**
101
+ * @export
102
+ */
103
+ export const RefereeStatusGateEnum = {
104
+ Deposit: 'deposit',
105
+ Spend: 'spend'
106
+ } as const;
107
+ export type RefereeStatusGateEnum = typeof RefereeStatusGateEnum[keyof typeof RefereeStatusGateEnum];
108
+
79
109
 
80
110
  /**
81
111
  * Check if a given object implements the RefereeStatus interface.
@@ -99,6 +129,9 @@ export function RefereeStatusFromJSONTyped(json: any, ignoreDiscriminator: boole
99
129
  return {
100
130
 
101
131
  'status': json['status'],
132
+ 'gate': json['gate'] == null ? undefined : json['gate'],
133
+ 'progressCents': json['progress_cents'] == null ? undefined : json['progress_cents'],
134
+ 'goalCents': json['goal_cents'] == null ? undefined : json['goal_cents'],
102
135
  'spentCents': json['spent_cents'],
103
136
  'qualifySpendCents': json['qualify_spend_cents'],
104
137
  'rewardCents': json['reward_cents'],
@@ -120,6 +153,9 @@ export function RefereeStatusToJSONTyped(value?: RefereeStatus | null, ignoreDis
120
153
  return {
121
154
 
122
155
  'status': value['status'],
156
+ 'gate': value['gate'],
157
+ 'progress_cents': value['progressCents'],
158
+ 'goal_cents': value['goalCents'],
123
159
  'spent_cents': value['spentCents'],
124
160
  'qualify_spend_cents': value['qualifySpendCents'],
125
161
  'reward_cents': value['rewardCents'],
@@ -41,13 +41,13 @@ export interface Referral {
41
41
  */
42
42
  inviteUrl: string;
43
43
  /**
44
- * Friends who signed up through the link but have not yet reached the spend gate.
44
+ * Friends who signed up through the link but have not yet reached the qualifying deposit.
45
45
  * @type {number}
46
46
  * @memberof Referral
47
47
  */
48
48
  pending: number;
49
49
  /**
50
- * Friends past the spend gate whose reward is inside the chargeback hold.
50
+ * Friends past the qualifying deposit whose reward is inside the chargeback hold.
51
51
  * @type {number}
52
52
  * @memberof Referral
53
53
  */
@@ -83,10 +83,17 @@ export interface Referral {
83
83
  */
84
84
  refereeRewardCents: number;
85
85
  /**
86
- * The friend's cumulative inference spend that qualifies a referral.
86
+ * The friend's cumulative net real deposits (card, auto-pay and crypto, less refunds) that qualify a referral.
87
87
  * @type {number}
88
88
  * @memberof Referral
89
89
  */
90
+ qualifyDepositCents?: number;
91
+ /**
92
+ * Deprecated — referrals now qualify on deposits. Mirrors `qualify_deposit_cents`.
93
+ * @type {number}
94
+ * @memberof Referral
95
+ * @deprecated
96
+ */
90
97
  qualifySpendCents: number;
91
98
  /**
92
99
  * Days between qualification and payout (chargeback hold).
@@ -146,6 +153,7 @@ export function ReferralFromJSONTyped(json: any, ignoreDiscriminator: boolean):
146
153
  'commissionEarnedCents': json['commission_earned_cents'],
147
154
  'rewardCents': json['reward_cents'],
148
155
  'refereeRewardCents': json['referee_reward_cents'],
156
+ 'qualifyDepositCents': json['qualify_deposit_cents'] == null ? undefined : json['qualify_deposit_cents'],
149
157
  'qualifySpendCents': json['qualify_spend_cents'],
150
158
  'holdDays': json['hold_days'],
151
159
  'commissionPct': json['commission_pct'],
@@ -173,6 +181,7 @@ export function ReferralToJSONTyped(value?: Referral | null, ignoreDiscriminator
173
181
  'commission_earned_cents': value['commissionEarnedCents'],
174
182
  'reward_cents': value['rewardCents'],
175
183
  'referee_reward_cents': value['refereeRewardCents'],
184
+ 'qualify_deposit_cents': value['qualifyDepositCents'],
176
185
  'qualify_spend_cents': value['qualifySpendCents'],
177
186
  'hold_days': value['holdDays'],
178
187
  'commission_pct': value['commissionPct'],