@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
@@ -0,0 +1,67 @@
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
+ * @export
16
+ */
17
+ export const RequestAttemptOutcomeEnum = {
18
+ Ok: 'ok',
19
+ Failed: 'failed',
20
+ Skipped: 'skipped'
21
+ };
22
+ /**
23
+ * Check if a given object implements the RequestAttempt interface.
24
+ */
25
+ export function instanceOfRequestAttempt(value) {
26
+ if (!('model' in value) || value['model'] === undefined)
27
+ return false;
28
+ if (!('outcome' in value) || value['outcome'] === undefined)
29
+ return false;
30
+ if ((!('durationMs' in value) && !('duration_ms' in value)) || (value['durationMs'] === undefined && value['duration_ms'] === undefined))
31
+ return false;
32
+ if (!('tries' in value) || value['tries'] === undefined)
33
+ return false;
34
+ return true;
35
+ }
36
+ export function RequestAttemptFromJSON(json) {
37
+ return RequestAttemptFromJSONTyped(json, false);
38
+ }
39
+ export function RequestAttemptFromJSONTyped(json, ignoreDiscriminator) {
40
+ if (json == null) {
41
+ return json;
42
+ }
43
+ return {
44
+ 'model': json['model'],
45
+ 'outcome': json['outcome'],
46
+ 'reason': json['reason'] == null ? undefined : json['reason'],
47
+ 'durationMs': json['duration_ms'],
48
+ 'ttftMs': json['ttft_ms'] == null ? undefined : json['ttft_ms'],
49
+ 'tries': json['tries'],
50
+ };
51
+ }
52
+ export function RequestAttemptToJSON(json) {
53
+ return RequestAttemptToJSONTyped(json, false);
54
+ }
55
+ export function RequestAttemptToJSONTyped(value, ignoreDiscriminator = false) {
56
+ if (value == null) {
57
+ return value;
58
+ }
59
+ return {
60
+ 'model': value['model'],
61
+ 'outcome': value['outcome'],
62
+ 'reason': value['reason'],
63
+ 'duration_ms': value['durationMs'],
64
+ 'ttft_ms': value['ttftMs'],
65
+ 'tries': value['tries'],
66
+ };
67
+ }
@@ -9,6 +9,7 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
+ import type { RequestAttempt } from './RequestAttempt';
12
13
  /**
13
14
  * One inference call as the request log records it. Never carries prompt or completion content. Optional numeric fields are omitted when they do not apply (for example token counts on a rejected call).
14
15
  * @export
@@ -177,6 +178,30 @@ export interface RequestLogEntry {
177
178
  * @memberof RequestLogEntry
178
179
  */
179
180
  suppressedCount?: number;
181
+ /**
182
+ * The model the request asked for. Always present; equal to `model` unless a backup model was tried.
183
+ * @type {string}
184
+ * @memberof RequestLogEntry
185
+ */
186
+ requestedModel?: string;
187
+ /**
188
+ * The model that produced the response. Omitted when no model served (a failed or rejected call). When a backup served, `model` is this model and the row is billed at its price.
189
+ * @type {string}
190
+ * @memberof RequestLogEntry
191
+ */
192
+ servedModel?: string;
193
+ /**
194
+ * Set when backup models were tried: the requested model's public error code (for example `upstream_timeout`). Rows with it set are the ones `fallback=true` returns.
195
+ * @type {string}
196
+ * @memberof RequestLogEntry
197
+ */
198
+ fallbackReason?: string;
199
+ /**
200
+ * Present when backup models were tried: every model the request went through, in order, including skipped backups. Upstream providers are never named.
201
+ * @type {Array<RequestAttempt>}
202
+ * @memberof RequestLogEntry
203
+ */
204
+ attempts?: Array<RequestAttempt>;
180
205
  }
181
206
  /**
182
207
  * @export
@@ -11,6 +11,7 @@
11
11
  * https://openapi-generator.tech
12
12
  * Do not edit the class manually.
13
13
  */
14
+ import { RequestAttemptFromJSON, RequestAttemptToJSON, } from './RequestAttempt';
14
15
  /**
15
16
  * @export
16
17
  */
@@ -88,6 +89,10 @@ export function RequestLogEntryFromJSONTyped(json, ignoreDiscriminator) {
88
89
  'imageCount': json['image_count'] == null ? undefined : json['image_count'],
89
90
  'videoSeconds': json['video_seconds'] == null ? undefined : json['video_seconds'],
90
91
  'suppressedCount': json['suppressed_count'] == null ? undefined : json['suppressed_count'],
92
+ 'requestedModel': json['requested_model'] == null ? undefined : json['requested_model'],
93
+ 'servedModel': json['served_model'] == null ? undefined : json['served_model'],
94
+ 'fallbackReason': json['fallback_reason'] == null ? undefined : json['fallback_reason'],
95
+ 'attempts': json['attempts'] == null ? undefined : (json['attempts'].map(RequestAttemptFromJSON)),
91
96
  };
92
97
  }
93
98
  export function RequestLogEntryToJSON(json) {
@@ -125,5 +130,9 @@ export function RequestLogEntryToJSONTyped(value, ignoreDiscriminator = false) {
125
130
  'image_count': value['imageCount'],
126
131
  'video_seconds': value['videoSeconds'],
127
132
  'suppressed_count': value['suppressedCount'],
133
+ 'requested_model': value['requestedModel'],
134
+ 'served_model': value['servedModel'],
135
+ 'fallback_reason': value['fallbackReason'],
136
+ 'attempts': value['attempts'] == null ? undefined : (value['attempts'].map(RequestAttemptToJSON)),
128
137
  };
129
138
  }
@@ -66,6 +66,7 @@ export declare const WebhookEndpointEventTypesEnum: {
66
66
  readonly SubscriptionQuotaThreshold: "subscription_quota.threshold";
67
67
  readonly ApiKeyBudgetThreshold: "api_key_budget.threshold";
68
68
  readonly MemberSpendThreshold: "member_spend.threshold";
69
+ readonly PlanRosterModelRemoved: "plan_roster.model_removed";
69
70
  };
70
71
  export type WebhookEndpointEventTypesEnum = typeof WebhookEndpointEventTypesEnum[keyof typeof WebhookEndpointEventTypesEnum];
71
72
  /**
@@ -24,7 +24,8 @@ export const WebhookEndpointEventTypesEnum = {
24
24
  BalanceLow: 'balance.low',
25
25
  SubscriptionQuotaThreshold: 'subscription_quota.threshold',
26
26
  ApiKeyBudgetThreshold: 'api_key_budget.threshold',
27
- MemberSpendThreshold: 'member_spend.threshold'
27
+ MemberSpendThreshold: 'member_spend.threshold',
28
+ PlanRosterModelRemoved: 'plan_roster.model_removed'
28
29
  };
29
30
  /**
30
31
  * Check if a given object implements the WebhookEndpoint interface.
@@ -4,6 +4,7 @@ export * from './AlertSettingsUpdate';
4
4
  export * from './ApiKey';
5
5
  export * from './ApiKeyCreate';
6
6
  export * from './ApiKeyCreated';
7
+ export * from './ApiKeyFallbackEntry';
7
8
  export * from './ApiKeyList';
8
9
  export * from './ApiKeyScopes';
9
10
  export * from './ApiKeyUpdate';
@@ -43,6 +44,7 @@ export * from './PeakWindow';
43
44
  export * from './Problem';
44
45
  export * from './RefereeStatus';
45
46
  export * from './Referral';
47
+ export * from './RequestAttempt';
46
48
  export * from './RequestLogEntry';
47
49
  export * from './RequestLogPage';
48
50
  export * from './ResponseFormatJSONObject';
@@ -6,6 +6,7 @@ export * from './AlertSettingsUpdate';
6
6
  export * from './ApiKey';
7
7
  export * from './ApiKeyCreate';
8
8
  export * from './ApiKeyCreated';
9
+ export * from './ApiKeyFallbackEntry';
9
10
  export * from './ApiKeyList';
10
11
  export * from './ApiKeyScopes';
11
12
  export * from './ApiKeyUpdate';
@@ -45,6 +46,7 @@ export * from './PeakWindow';
45
46
  export * from './Problem';
46
47
  export * from './RefereeStatus';
47
48
  export * from './Referral';
49
+ export * from './RequestAttempt';
48
50
  export * from './RequestLogEntry';
49
51
  export * from './RequestLogPage';
50
52
  export * from './ResponseFormatJSONObject';
@@ -61,7 +61,7 @@ export class Configuration {
61
61
  return undefined;
62
62
  }
63
63
  get headers() {
64
- return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.4.1' }, this.configuration.headers);
64
+ return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.4.3' }, this.configuration.headers);
65
65
  }
66
66
  get credentials() {
67
67
  return this.configuration.credentials;
@@ -10,6 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import type { ApiKeyScopes } from './ApiKeyScopes';
13
+ import type { ApiKeyFallbackEntry } from './ApiKeyFallbackEntry';
13
14
  /**
14
15
  * An API key's metadata and limits. Never carries the secret.
15
16
  * @export
@@ -76,6 +77,24 @@ export interface ApiKey {
76
77
  * @memberof ApiKey
77
78
  */
78
79
  staleModels?: Array<string>;
80
+ /**
81
+ * 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.
82
+ * @type {Array<string>}
83
+ * @memberof ApiKey
84
+ */
85
+ fallbackModels: Array<string> | null;
86
+ /**
87
+ * Present when `fallback_models` is set: one entry per backup, in order, explaining it as of now.
88
+ * @type {Array<ApiKeyFallbackEntry>}
89
+ * @memberof ApiKey
90
+ */
91
+ fallbackEntries?: Array<ApiKeyFallbackEntry>;
92
+ /**
93
+ * 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.
94
+ * @type {string}
95
+ * @memberof ApiKey
96
+ */
97
+ primaryModel?: string;
79
98
  /**
80
99
  *
81
100
  * @type {number}
@@ -19,6 +19,7 @@ exports.ApiKeyFromJSONTyped = ApiKeyFromJSONTyped;
19
19
  exports.ApiKeyToJSON = ApiKeyToJSON;
20
20
  exports.ApiKeyToJSONTyped = ApiKeyToJSONTyped;
21
21
  const ApiKeyScopes_1 = require("./ApiKeyScopes");
22
+ const ApiKeyFallbackEntry_1 = require("./ApiKeyFallbackEntry");
22
23
  /**
23
24
  * Check if a given object implements the ApiKey interface.
24
25
  */
@@ -37,6 +38,8 @@ function instanceOfApiKey(value) {
37
38
  return false;
38
39
  if ((!('allowedModels' in value) && !('allowed_models' in value)) || (value['allowedModels'] === undefined && value['allowed_models'] === undefined))
39
40
  return false;
41
+ if ((!('fallbackModels' in value) && !('fallback_models' in value)) || (value['fallbackModels'] === undefined && value['fallback_models'] === undefined))
42
+ return false;
40
43
  if ((!('rateLimitRps' in value) && !('rate_limit_rps' in value)) || (value['rateLimitRps'] === undefined && value['rate_limit_rps'] === undefined))
41
44
  return false;
42
45
  if ((!('rateLimitBurst' in value) && !('rate_limit_burst' in value)) || (value['rateLimitBurst'] === undefined && value['rate_limit_burst'] === undefined))
@@ -67,6 +70,9 @@ function ApiKeyFromJSONTyped(json, ignoreDiscriminator) {
67
70
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
68
71
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
69
72
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
73
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
74
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : (json['fallback_entries'].map(ApiKeyFallbackEntry_1.ApiKeyFallbackEntryFromJSON)),
75
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
70
76
  'rateLimitRps': json['rate_limit_rps'],
71
77
  'rateLimitBurst': json['rate_limit_burst'],
72
78
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -93,6 +99,9 @@ function ApiKeyToJSONTyped(value, ignoreDiscriminator = false) {
93
99
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
94
100
  'allowed_models': value['allowedModels'],
95
101
  'stale_models': value['staleModels'],
102
+ 'fallback_models': value['fallbackModels'],
103
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : (value['fallbackEntries'].map(ApiKeyFallbackEntry_1.ApiKeyFallbackEntryToJSON)),
104
+ 'primary_model': value['primaryModel'],
96
105
  'rate_limit_rps': value['rateLimitRps'],
97
106
  'rate_limit_burst': value['rateLimitBurst'],
98
107
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -41,6 +41,12 @@ export interface ApiKeyCreate {
41
41
  * @memberof ApiKeyCreate
42
42
  */
43
43
  allowedModels?: Array<string>;
44
+ /**
45
+ * 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.
46
+ * @type {Array<string>}
47
+ * @memberof ApiKeyCreate
48
+ */
49
+ fallbackModels?: Array<string>;
44
50
  /**
45
51
  *
46
52
  * @type {number}
@@ -40,6 +40,7 @@ function ApiKeyCreateFromJSONTyped(json, ignoreDiscriminator) {
40
40
  'scopes': json['scopes'],
41
41
  'budgetCents': json['budget_cents'] == null ? undefined : json['budget_cents'],
42
42
  'allowedModels': json['allowed_models'] == null ? undefined : json['allowed_models'],
43
+ 'fallbackModels': json['fallback_models'] == null ? undefined : json['fallback_models'],
43
44
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
44
45
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
45
46
  'expiresAt': json['expires_at'] == null ? undefined : (new Date(json['expires_at'])),
@@ -57,6 +58,7 @@ function ApiKeyCreateToJSONTyped(value, ignoreDiscriminator = false) {
57
58
  'scopes': value['scopes'],
58
59
  'budget_cents': value['budgetCents'],
59
60
  'allowed_models': value['allowedModels'],
61
+ 'fallback_models': value['fallbackModels'],
60
62
  'rate_limit_rps': value['rateLimitRps'],
61
63
  'rate_limit_burst': value['rateLimitBurst'],
62
64
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -10,6 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import type { ApiKeyScopes } from './ApiKeyScopes';
13
+ import type { ApiKeyFallbackEntry } from './ApiKeyFallbackEntry';
13
14
  /**
14
15
  * The new key's metadata plus its secret (`key`), returned exactly once. The same fields as `ApiKey`, plus `key`.
15
16
  * @export
@@ -76,6 +77,24 @@ export interface ApiKeyCreated {
76
77
  * @memberof ApiKeyCreated
77
78
  */
78
79
  staleModels?: Array<string>;
80
+ /**
81
+ * 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.
82
+ * @type {Array<string>}
83
+ * @memberof ApiKeyCreated
84
+ */
85
+ fallbackModels: Array<string> | null;
86
+ /**
87
+ * Present when `fallback_models` is set: one entry per backup, in order, explaining it as of now.
88
+ * @type {Array<ApiKeyFallbackEntry>}
89
+ * @memberof ApiKeyCreated
90
+ */
91
+ fallbackEntries?: Array<ApiKeyFallbackEntry>;
92
+ /**
93
+ * 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.
94
+ * @type {string}
95
+ * @memberof ApiKeyCreated
96
+ */
97
+ primaryModel?: string;
79
98
  /**
80
99
  *
81
100
  * @type {number}
@@ -19,6 +19,7 @@ exports.ApiKeyCreatedFromJSONTyped = ApiKeyCreatedFromJSONTyped;
19
19
  exports.ApiKeyCreatedToJSON = ApiKeyCreatedToJSON;
20
20
  exports.ApiKeyCreatedToJSONTyped = ApiKeyCreatedToJSONTyped;
21
21
  const ApiKeyScopes_1 = require("./ApiKeyScopes");
22
+ const ApiKeyFallbackEntry_1 = require("./ApiKeyFallbackEntry");
22
23
  /**
23
24
  * Check if a given object implements the ApiKeyCreated interface.
24
25
  */
@@ -37,6 +38,8 @@ function instanceOfApiKeyCreated(value) {
37
38
  return false;
38
39
  if ((!('allowedModels' in value) && !('allowed_models' in value)) || (value['allowedModels'] === undefined && value['allowed_models'] === undefined))
39
40
  return false;
41
+ if ((!('fallbackModels' in value) && !('fallback_models' in value)) || (value['fallbackModels'] === undefined && value['fallback_models'] === undefined))
42
+ return false;
40
43
  if ((!('rateLimitRps' in value) && !('rate_limit_rps' in value)) || (value['rateLimitRps'] === undefined && value['rate_limit_rps'] === undefined))
41
44
  return false;
42
45
  if ((!('rateLimitBurst' in value) && !('rate_limit_burst' in value)) || (value['rateLimitBurst'] === undefined && value['rate_limit_burst'] === undefined))
@@ -69,6 +72,9 @@ function ApiKeyCreatedFromJSONTyped(json, ignoreDiscriminator) {
69
72
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
70
73
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
71
74
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
75
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
76
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : (json['fallback_entries'].map(ApiKeyFallbackEntry_1.ApiKeyFallbackEntryFromJSON)),
77
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
72
78
  'rateLimitRps': json['rate_limit_rps'],
73
79
  'rateLimitBurst': json['rate_limit_burst'],
74
80
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -96,6 +102,9 @@ function ApiKeyCreatedToJSONTyped(value, ignoreDiscriminator = false) {
96
102
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
97
103
  'allowed_models': value['allowedModels'],
98
104
  'stale_models': value['staleModels'],
105
+ 'fallback_models': value['fallbackModels'],
106
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : (value['fallbackEntries'].map(ApiKeyFallbackEntry_1.ApiKeyFallbackEntryToJSON)),
107
+ 'primary_model': value['primaryModel'],
99
108
  'rate_limit_rps': value['rateLimitRps'],
100
109
  'rate_limit_burst': value['rateLimitBurst'],
101
110
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -0,0 +1,65 @@
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. 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.
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
+ * One backup model on a key, as it stands now.
14
+ * @export
15
+ * @interface ApiKeyFallbackEntry
16
+ */
17
+ export interface ApiKeyFallbackEntry {
18
+ /**
19
+ *
20
+ * @type {string}
21
+ * @memberof ApiKeyFallbackEntry
22
+ */
23
+ model: string;
24
+ /**
25
+ * `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.
26
+ * @type {ApiKeyFallbackEntryStateEnum}
27
+ * @memberof ApiKeyFallbackEntry
28
+ */
29
+ state: ApiKeyFallbackEntryStateEnum;
30
+ /**
31
+ * Current input price per 1M tokens, in micro-cents. 0 when unknown or unavailable.
32
+ * @type {number}
33
+ * @memberof ApiKeyFallbackEntry
34
+ */
35
+ inputPer1mTokensMicrocents: number;
36
+ /**
37
+ * Current output price per 1M tokens, in micro-cents. 0 when unknown or unavailable.
38
+ * @type {number}
39
+ * @memberof ApiKeyFallbackEntry
40
+ */
41
+ outputPer1mTokensMicrocents: number;
42
+ /**
43
+ * 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.
44
+ * @type {boolean}
45
+ * @memberof ApiKeyFallbackEntry
46
+ */
47
+ abovePrimary: boolean;
48
+ }
49
+ /**
50
+ * @export
51
+ */
52
+ export declare const ApiKeyFallbackEntryStateEnum: {
53
+ readonly Ok: "ok";
54
+ readonly WalletOnly: "wallet_only";
55
+ readonly Unavailable: "unavailable";
56
+ };
57
+ export type ApiKeyFallbackEntryStateEnum = typeof ApiKeyFallbackEntryStateEnum[keyof typeof ApiKeyFallbackEntryStateEnum];
58
+ /**
59
+ * Check if a given object implements the ApiKeyFallbackEntry interface.
60
+ */
61
+ export declare function instanceOfApiKeyFallbackEntry(value: object): value is ApiKeyFallbackEntry;
62
+ export declare function ApiKeyFallbackEntryFromJSON(json: any): ApiKeyFallbackEntry;
63
+ export declare function ApiKeyFallbackEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApiKeyFallbackEntry;
64
+ export declare function ApiKeyFallbackEntryToJSON(json: any): ApiKeyFallbackEntry;
65
+ export declare function ApiKeyFallbackEntryToJSONTyped(value?: ApiKeyFallbackEntry | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * deeprelay Public Developer API
6
+ * 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.
7
+ *
8
+ * The version of the OpenAPI document: 1.0.0
9
+ * Contact: support@deeprelay.ai
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ApiKeyFallbackEntryStateEnum = void 0;
17
+ exports.instanceOfApiKeyFallbackEntry = instanceOfApiKeyFallbackEntry;
18
+ exports.ApiKeyFallbackEntryFromJSON = ApiKeyFallbackEntryFromJSON;
19
+ exports.ApiKeyFallbackEntryFromJSONTyped = ApiKeyFallbackEntryFromJSONTyped;
20
+ exports.ApiKeyFallbackEntryToJSON = ApiKeyFallbackEntryToJSON;
21
+ exports.ApiKeyFallbackEntryToJSONTyped = ApiKeyFallbackEntryToJSONTyped;
22
+ /**
23
+ * @export
24
+ */
25
+ exports.ApiKeyFallbackEntryStateEnum = {
26
+ Ok: 'ok',
27
+ WalletOnly: 'wallet_only',
28
+ Unavailable: 'unavailable'
29
+ };
30
+ /**
31
+ * Check if a given object implements the ApiKeyFallbackEntry interface.
32
+ */
33
+ function instanceOfApiKeyFallbackEntry(value) {
34
+ if (!('model' in value) || value['model'] === undefined)
35
+ return false;
36
+ if (!('state' in value) || value['state'] === undefined)
37
+ return false;
38
+ if ((!('inputPer1mTokensMicrocents' in value) && !('input_per_1m_tokens_microcents' in value)) || (value['inputPer1mTokensMicrocents'] === undefined && value['input_per_1m_tokens_microcents'] === undefined))
39
+ return false;
40
+ if ((!('outputPer1mTokensMicrocents' in value) && !('output_per_1m_tokens_microcents' in value)) || (value['outputPer1mTokensMicrocents'] === undefined && value['output_per_1m_tokens_microcents'] === undefined))
41
+ return false;
42
+ if ((!('abovePrimary' in value) && !('above_primary' in value)) || (value['abovePrimary'] === undefined && value['above_primary'] === undefined))
43
+ return false;
44
+ return true;
45
+ }
46
+ function ApiKeyFallbackEntryFromJSON(json) {
47
+ return ApiKeyFallbackEntryFromJSONTyped(json, false);
48
+ }
49
+ function ApiKeyFallbackEntryFromJSONTyped(json, ignoreDiscriminator) {
50
+ if (json == null) {
51
+ return json;
52
+ }
53
+ return {
54
+ 'model': json['model'],
55
+ 'state': json['state'],
56
+ 'inputPer1mTokensMicrocents': json['input_per_1m_tokens_microcents'],
57
+ 'outputPer1mTokensMicrocents': json['output_per_1m_tokens_microcents'],
58
+ 'abovePrimary': json['above_primary'],
59
+ };
60
+ }
61
+ function ApiKeyFallbackEntryToJSON(json) {
62
+ return ApiKeyFallbackEntryToJSONTyped(json, false);
63
+ }
64
+ function ApiKeyFallbackEntryToJSONTyped(value, ignoreDiscriminator = false) {
65
+ if (value == null) {
66
+ return value;
67
+ }
68
+ return {
69
+ 'model': value['model'],
70
+ 'state': value['state'],
71
+ 'input_per_1m_tokens_microcents': value['inputPer1mTokensMicrocents'],
72
+ 'output_per_1m_tokens_microcents': value['outputPer1mTokensMicrocents'],
73
+ 'above_primary': value['abovePrimary'],
74
+ };
75
+ }
@@ -10,7 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  /**
13
- * Send only the fields to change. `null` clears `budget_cents`, `allowed_models` or `expires_at`. `scopes` cannot be changed.
13
+ * Send only the fields to change. `null` clears `budget_cents`, `allowed_models`, `fallback_models` or `expires_at`. `scopes` cannot be changed.
14
14
  * @export
15
15
  * @interface ApiKeyUpdate
16
16
  */
@@ -33,6 +33,12 @@ export interface ApiKeyUpdate {
33
33
  * @memberof ApiKeyUpdate
34
34
  */
35
35
  allowedModels?: Array<string> | null;
36
+ /**
37
+ * 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.
38
+ * @type {Array<string>}
39
+ * @memberof ApiKeyUpdate
40
+ */
41
+ fallbackModels?: Array<string> | null;
36
42
  /**
37
43
  *
38
44
  * @type {number}
@@ -35,6 +35,7 @@ function ApiKeyUpdateFromJSONTyped(json, ignoreDiscriminator) {
35
35
  'name': json['name'] == null ? undefined : json['name'],
36
36
  'budgetCents': json['budget_cents'] === undefined ? undefined : json['budget_cents'] === null ? null : json['budget_cents'],
37
37
  'allowedModels': json['allowed_models'] === undefined ? undefined : json['allowed_models'] === null ? null : json['allowed_models'],
38
+ 'fallbackModels': json['fallback_models'] === undefined ? undefined : json['fallback_models'] === null ? null : json['fallback_models'],
38
39
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
39
40
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
40
41
  'expiresAt': json['expires_at'] === undefined ? undefined : json['expires_at'] === null ? null : (new Date(json['expires_at'])),
@@ -51,6 +52,7 @@ function ApiKeyUpdateToJSONTyped(value, ignoreDiscriminator = false) {
51
52
  'name': value['name'],
52
53
  'budget_cents': value['budgetCents'],
53
54
  'allowed_models': value['allowedModels'],
55
+ 'fallback_models': value['fallbackModels'],
54
56
  'rate_limit_rps': value['rateLimitRps'],
55
57
  'rate_limit_burst': value['rateLimitBurst'],
56
58
  'expires_at': value['expiresAt'] == null ? value['expiresAt'] : value['expiresAt'].toISOString(),
@@ -26,6 +26,12 @@ export interface ChatCompletionRequest {
26
26
  * @memberof ChatCompletionRequest
27
27
  */
28
28
  model: string;
29
+ /**
30
+ * 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.
31
+ * @type {Array<string>}
32
+ * @memberof ChatCompletionRequest
33
+ */
34
+ models?: Array<string> | null;
29
35
  /**
30
36
  *
31
37
  * @type {Array<ChatMessage>}
@@ -42,6 +42,7 @@ function ChatCompletionRequestFromJSONTyped(json, ignoreDiscriminator) {
42
42
  }
43
43
  return {
44
44
  'model': json['model'],
45
+ 'models': json['models'] === undefined ? undefined : json['models'] === null ? null : json['models'],
45
46
  'messages': (json['messages'].map(ChatMessage_1.ChatMessageFromJSON)),
46
47
  'temperature': json['temperature'] == null ? undefined : json['temperature'],
47
48
  'maxTokens': json['max_tokens'] == null ? undefined : json['max_tokens'],
@@ -69,6 +70,7 @@ function ChatCompletionRequestToJSONTyped(value, ignoreDiscriminator = false) {
69
70
  }
70
71
  return {
71
72
  'model': value['model'],
73
+ 'models': value['models'],
72
74
  'messages': (value['messages'].map(ChatMessage_1.ChatMessageToJSON)),
73
75
  'temperature': value['temperature'],
74
76
  'max_tokens': value['maxTokens'],
@@ -42,6 +42,7 @@ export declare const CreateWebhookEndpointRequestEventTypesEnum: {
42
42
  readonly SubscriptionQuotaThreshold: "subscription_quota.threshold";
43
43
  readonly ApiKeyBudgetThreshold: "api_key_budget.threshold";
44
44
  readonly MemberSpendThreshold: "member_spend.threshold";
45
+ readonly PlanRosterModelRemoved: "plan_roster.model_removed";
45
46
  };
46
47
  export type CreateWebhookEndpointRequestEventTypesEnum = typeof CreateWebhookEndpointRequestEventTypesEnum[keyof typeof CreateWebhookEndpointRequestEventTypesEnum];
47
48
  /**
@@ -32,7 +32,8 @@ exports.CreateWebhookEndpointRequestEventTypesEnum = {
32
32
  BalanceLow: 'balance.low',
33
33
  SubscriptionQuotaThreshold: 'subscription_quota.threshold',
34
34
  ApiKeyBudgetThreshold: 'api_key_budget.threshold',
35
- MemberSpendThreshold: 'member_spend.threshold'
35
+ MemberSpendThreshold: 'member_spend.threshold',
36
+ PlanRosterModelRemoved: 'plan_roster.model_removed'
36
37
  };
37
38
  /**
38
39
  * Check if a given object implements the CreateWebhookEndpointRequest interface.