@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
@@ -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}
@@ -12,6 +12,7 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
  import { ApiKeyScopesFromJSON, ApiKeyScopesToJSON, } from './ApiKeyScopes';
15
+ import { ApiKeyFallbackEntryFromJSON, ApiKeyFallbackEntryToJSON, } from './ApiKeyFallbackEntry';
15
16
  /**
16
17
  * Check if a given object implements the ApiKey interface.
17
18
  */
@@ -30,6 +31,8 @@ export function instanceOfApiKey(value) {
30
31
  return false;
31
32
  if ((!('allowedModels' in value) && !('allowed_models' in value)) || (value['allowedModels'] === undefined && value['allowed_models'] === undefined))
32
33
  return false;
34
+ if ((!('fallbackModels' in value) && !('fallback_models' in value)) || (value['fallbackModels'] === undefined && value['fallback_models'] === undefined))
35
+ return false;
33
36
  if ((!('rateLimitRps' in value) && !('rate_limit_rps' in value)) || (value['rateLimitRps'] === undefined && value['rate_limit_rps'] === undefined))
34
37
  return false;
35
38
  if ((!('rateLimitBurst' in value) && !('rate_limit_burst' in value)) || (value['rateLimitBurst'] === undefined && value['rate_limit_burst'] === undefined))
@@ -60,6 +63,9 @@ export function ApiKeyFromJSONTyped(json, ignoreDiscriminator) {
60
63
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
61
64
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
62
65
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
66
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
67
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : (json['fallback_entries'].map(ApiKeyFallbackEntryFromJSON)),
68
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
63
69
  'rateLimitRps': json['rate_limit_rps'],
64
70
  'rateLimitBurst': json['rate_limit_burst'],
65
71
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -86,6 +92,9 @@ export function ApiKeyToJSONTyped(value, ignoreDiscriminator = false) {
86
92
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
87
93
  'allowed_models': value['allowedModels'],
88
94
  'stale_models': value['staleModels'],
95
+ 'fallback_models': value['fallbackModels'],
96
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : (value['fallbackEntries'].map(ApiKeyFallbackEntryToJSON)),
97
+ 'primary_model': value['primaryModel'],
89
98
  'rate_limit_rps': value['rateLimitRps'],
90
99
  'rate_limit_burst': value['rateLimitBurst'],
91
100
  '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}
@@ -33,6 +33,7 @@ export function ApiKeyCreateFromJSONTyped(json, ignoreDiscriminator) {
33
33
  'scopes': json['scopes'],
34
34
  'budgetCents': json['budget_cents'] == null ? undefined : json['budget_cents'],
35
35
  'allowedModels': json['allowed_models'] == null ? undefined : json['allowed_models'],
36
+ 'fallbackModels': json['fallback_models'] == null ? undefined : json['fallback_models'],
36
37
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
37
38
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
38
39
  'expiresAt': json['expires_at'] == null ? undefined : (new Date(json['expires_at'])),
@@ -50,6 +51,7 @@ export function ApiKeyCreateToJSONTyped(value, ignoreDiscriminator = false) {
50
51
  'scopes': value['scopes'],
51
52
  'budget_cents': value['budgetCents'],
52
53
  'allowed_models': value['allowedModels'],
54
+ 'fallback_models': value['fallbackModels'],
53
55
  'rate_limit_rps': value['rateLimitRps'],
54
56
  'rate_limit_burst': value['rateLimitBurst'],
55
57
  '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}
@@ -12,6 +12,7 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
  import { ApiKeyScopesFromJSON, ApiKeyScopesToJSON, } from './ApiKeyScopes';
15
+ import { ApiKeyFallbackEntryFromJSON, ApiKeyFallbackEntryToJSON, } from './ApiKeyFallbackEntry';
15
16
  /**
16
17
  * Check if a given object implements the ApiKeyCreated interface.
17
18
  */
@@ -30,6 +31,8 @@ export function instanceOfApiKeyCreated(value) {
30
31
  return false;
31
32
  if ((!('allowedModels' in value) && !('allowed_models' in value)) || (value['allowedModels'] === undefined && value['allowed_models'] === undefined))
32
33
  return false;
34
+ if ((!('fallbackModels' in value) && !('fallback_models' in value)) || (value['fallbackModels'] === undefined && value['fallback_models'] === undefined))
35
+ return false;
33
36
  if ((!('rateLimitRps' in value) && !('rate_limit_rps' in value)) || (value['rateLimitRps'] === undefined && value['rate_limit_rps'] === undefined))
34
37
  return false;
35
38
  if ((!('rateLimitBurst' in value) && !('rate_limit_burst' in value)) || (value['rateLimitBurst'] === undefined && value['rate_limit_burst'] === undefined))
@@ -62,6 +65,9 @@ export function ApiKeyCreatedFromJSONTyped(json, ignoreDiscriminator) {
62
65
  'budgetResetsAt': json['budget_resets_at'] == null ? undefined : (new Date(json['budget_resets_at'])),
63
66
  'allowedModels': json['allowed_models'] == null ? null : json['allowed_models'],
64
67
  'staleModels': json['stale_models'] == null ? undefined : json['stale_models'],
68
+ 'fallbackModels': json['fallback_models'] == null ? null : json['fallback_models'],
69
+ 'fallbackEntries': json['fallback_entries'] == null ? undefined : (json['fallback_entries'].map(ApiKeyFallbackEntryFromJSON)),
70
+ 'primaryModel': json['primary_model'] == null ? undefined : json['primary_model'],
65
71
  'rateLimitRps': json['rate_limit_rps'],
66
72
  'rateLimitBurst': json['rate_limit_burst'],
67
73
  'expiresAt': (json['expires_at'] == null ? null : new Date(json['expires_at'])),
@@ -89,6 +95,9 @@ export function ApiKeyCreatedToJSONTyped(value, ignoreDiscriminator = false) {
89
95
  'budget_resets_at': value['budgetResetsAt'] == null ? value['budgetResetsAt'] : value['budgetResetsAt'].toISOString(),
90
96
  'allowed_models': value['allowedModels'],
91
97
  'stale_models': value['staleModels'],
98
+ 'fallback_models': value['fallbackModels'],
99
+ 'fallback_entries': value['fallbackEntries'] == null ? undefined : (value['fallbackEntries'].map(ApiKeyFallbackEntryToJSON)),
100
+ 'primary_model': value['primaryModel'],
92
101
  'rate_limit_rps': value['rateLimitRps'],
93
102
  'rate_limit_burst': value['rateLimitBurst'],
94
103
  '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,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 ApiKeyFallbackEntryStateEnum = {
18
+ Ok: 'ok',
19
+ WalletOnly: 'wallet_only',
20
+ Unavailable: 'unavailable'
21
+ };
22
+ /**
23
+ * Check if a given object implements the ApiKeyFallbackEntry interface.
24
+ */
25
+ export function instanceOfApiKeyFallbackEntry(value) {
26
+ if (!('model' in value) || value['model'] === undefined)
27
+ return false;
28
+ if (!('state' in value) || value['state'] === undefined)
29
+ return false;
30
+ if ((!('inputPer1mTokensMicrocents' in value) && !('input_per_1m_tokens_microcents' in value)) || (value['inputPer1mTokensMicrocents'] === undefined && value['input_per_1m_tokens_microcents'] === undefined))
31
+ return false;
32
+ if ((!('outputPer1mTokensMicrocents' in value) && !('output_per_1m_tokens_microcents' in value)) || (value['outputPer1mTokensMicrocents'] === undefined && value['output_per_1m_tokens_microcents'] === undefined))
33
+ return false;
34
+ if ((!('abovePrimary' in value) && !('above_primary' in value)) || (value['abovePrimary'] === undefined && value['above_primary'] === undefined))
35
+ return false;
36
+ return true;
37
+ }
38
+ export function ApiKeyFallbackEntryFromJSON(json) {
39
+ return ApiKeyFallbackEntryFromJSONTyped(json, false);
40
+ }
41
+ export function ApiKeyFallbackEntryFromJSONTyped(json, ignoreDiscriminator) {
42
+ if (json == null) {
43
+ return json;
44
+ }
45
+ return {
46
+ 'model': json['model'],
47
+ 'state': json['state'],
48
+ 'inputPer1mTokensMicrocents': json['input_per_1m_tokens_microcents'],
49
+ 'outputPer1mTokensMicrocents': json['output_per_1m_tokens_microcents'],
50
+ 'abovePrimary': json['above_primary'],
51
+ };
52
+ }
53
+ export function ApiKeyFallbackEntryToJSON(json) {
54
+ return ApiKeyFallbackEntryToJSONTyped(json, false);
55
+ }
56
+ export function ApiKeyFallbackEntryToJSONTyped(value, ignoreDiscriminator = false) {
57
+ if (value == null) {
58
+ return value;
59
+ }
60
+ return {
61
+ 'model': value['model'],
62
+ 'state': value['state'],
63
+ 'input_per_1m_tokens_microcents': value['inputPer1mTokensMicrocents'],
64
+ 'output_per_1m_tokens_microcents': value['outputPer1mTokensMicrocents'],
65
+ 'above_primary': value['abovePrimary'],
66
+ };
67
+ }
@@ -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}
@@ -28,6 +28,7 @@ export function ApiKeyUpdateFromJSONTyped(json, ignoreDiscriminator) {
28
28
  'name': json['name'] == null ? undefined : json['name'],
29
29
  'budgetCents': json['budget_cents'] === undefined ? undefined : json['budget_cents'] === null ? null : json['budget_cents'],
30
30
  'allowedModels': json['allowed_models'] === undefined ? undefined : json['allowed_models'] === null ? null : json['allowed_models'],
31
+ 'fallbackModels': json['fallback_models'] === undefined ? undefined : json['fallback_models'] === null ? null : json['fallback_models'],
31
32
  'rateLimitRps': json['rate_limit_rps'] == null ? undefined : json['rate_limit_rps'],
32
33
  'rateLimitBurst': json['rate_limit_burst'] == null ? undefined : json['rate_limit_burst'],
33
34
  'expiresAt': json['expires_at'] === undefined ? undefined : json['expires_at'] === null ? null : (new Date(json['expires_at'])),
@@ -44,6 +45,7 @@ export function ApiKeyUpdateToJSONTyped(value, ignoreDiscriminator = false) {
44
45
  'name': value['name'],
45
46
  'budget_cents': value['budgetCents'],
46
47
  'allowed_models': value['allowedModels'],
48
+ 'fallback_models': value['fallbackModels'],
47
49
  'rate_limit_rps': value['rateLimitRps'],
48
50
  'rate_limit_burst': value['rateLimitBurst'],
49
51
  '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>}
@@ -35,6 +35,7 @@ export function ChatCompletionRequestFromJSONTyped(json, ignoreDiscriminator) {
35
35
  }
36
36
  return {
37
37
  'model': json['model'],
38
+ 'models': json['models'] === undefined ? undefined : json['models'] === null ? null : json['models'],
38
39
  'messages': (json['messages'].map(ChatMessageFromJSON)),
39
40
  'temperature': json['temperature'] == null ? undefined : json['temperature'],
40
41
  'maxTokens': json['max_tokens'] == null ? undefined : json['max_tokens'],
@@ -62,6 +63,7 @@ export function ChatCompletionRequestToJSONTyped(value, ignoreDiscriminator = fa
62
63
  }
63
64
  return {
64
65
  'model': value['model'],
66
+ 'models': value['models'],
65
67
  'messages': (value['messages'].map(ChatMessageToJSON)),
66
68
  'temperature': value['temperature'],
67
69
  '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
  /**
@@ -24,7 +24,8 @@ export const CreateWebhookEndpointRequestEventTypesEnum = {
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 CreateWebhookEndpointRequest interface.
@@ -17,21 +17,41 @@
17
17
  */
18
18
  export interface RefereeStatus {
19
19
  /**
20
- * Lifecycle state. `pending` until the spend gate is met; `qualified` inside the hold; `settled` once paid.
20
+ * 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.
21
21
  * @type {RefereeStatusStatusEnum}
22
22
  * @memberof RefereeStatus
23
23
  */
24
24
  status: RefereeStatusStatusEnum;
25
25
  /**
26
- * Cumulative inference spend so far.
26
+ * 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.
27
+ * @type {RefereeStatusGateEnum}
28
+ * @memberof RefereeStatus
29
+ */
30
+ gate?: RefereeStatusGateEnum;
31
+ /**
32
+ * Progress toward the gate so far — net deposits for `deposit`, inference spend for `spend`.
33
+ * @type {number}
34
+ * @memberof RefereeStatus
35
+ */
36
+ progressCents?: number;
37
+ /**
38
+ * The amount that qualifies the referral.
27
39
  * @type {number}
28
40
  * @memberof RefereeStatus
29
41
  */
42
+ goalCents?: number;
43
+ /**
44
+ * Deprecated alias of `progress_cents`.
45
+ * @type {number}
46
+ * @memberof RefereeStatus
47
+ * @deprecated
48
+ */
30
49
  spentCents: number;
31
50
  /**
32
- * The spend that qualifies the referral.
51
+ * Deprecated alias of `goal_cents`.
33
52
  * @type {number}
34
53
  * @memberof RefereeStatus
54
+ * @deprecated
35
55
  */
36
56
  qualifySpendCents: number;
37
57
  /**
@@ -41,7 +61,7 @@ export interface RefereeStatus {
41
61
  */
42
62
  rewardCents: number;
43
63
  /**
44
- * When the spend gate was met. Absent while pending.
64
+ * When the gate was met. Absent while pending.
45
65
  * @type {Date}
46
66
  * @memberof RefereeStatus
47
67
  */
@@ -67,8 +87,17 @@ export declare const RefereeStatusStatusEnum: {
67
87
  readonly Qualified: "qualified";
68
88
  readonly Settled: "settled";
69
89
  readonly Rejected: "rejected";
90
+ readonly Reversed: "reversed";
70
91
  };
71
92
  export type RefereeStatusStatusEnum = typeof RefereeStatusStatusEnum[keyof typeof RefereeStatusStatusEnum];
93
+ /**
94
+ * @export
95
+ */
96
+ export declare const RefereeStatusGateEnum: {
97
+ readonly Deposit: "deposit";
98
+ readonly Spend: "spend";
99
+ };
100
+ export type RefereeStatusGateEnum = typeof RefereeStatusGateEnum[keyof typeof RefereeStatusGateEnum];
72
101
  /**
73
102
  * Check if a given object implements the RefereeStatus interface.
74
103
  */
@@ -18,7 +18,15 @@ export const RefereeStatusStatusEnum = {
18
18
  Pending: 'pending',
19
19
  Qualified: 'qualified',
20
20
  Settled: 'settled',
21
- Rejected: 'rejected'
21
+ Rejected: 'rejected',
22
+ Reversed: 'reversed'
23
+ };
24
+ /**
25
+ * @export
26
+ */
27
+ export const RefereeStatusGateEnum = {
28
+ Deposit: 'deposit',
29
+ Spend: 'spend'
22
30
  };
23
31
  /**
24
32
  * Check if a given object implements the RefereeStatus interface.
@@ -43,6 +51,9 @@ export function RefereeStatusFromJSONTyped(json, ignoreDiscriminator) {
43
51
  }
44
52
  return {
45
53
  'status': json['status'],
54
+ 'gate': json['gate'] == null ? undefined : json['gate'],
55
+ 'progressCents': json['progress_cents'] == null ? undefined : json['progress_cents'],
56
+ 'goalCents': json['goal_cents'] == null ? undefined : json['goal_cents'],
46
57
  'spentCents': json['spent_cents'],
47
58
  'qualifySpendCents': json['qualify_spend_cents'],
48
59
  'rewardCents': json['reward_cents'],
@@ -60,6 +71,9 @@ export function RefereeStatusToJSONTyped(value, ignoreDiscriminator = false) {
60
71
  }
61
72
  return {
62
73
  'status': value['status'],
74
+ 'gate': value['gate'],
75
+ 'progress_cents': value['progressCents'],
76
+ 'goal_cents': value['goalCents'],
63
77
  'spent_cents': value['spentCents'],
64
78
  'qualify_spend_cents': value['qualifySpendCents'],
65
79
  'reward_cents': value['rewardCents'],
@@ -30,13 +30,13 @@ export interface Referral {
30
30
  */
31
31
  inviteUrl: string;
32
32
  /**
33
- * Friends who signed up through the link but have not yet reached the spend gate.
33
+ * Friends who signed up through the link but have not yet reached the qualifying deposit.
34
34
  * @type {number}
35
35
  * @memberof Referral
36
36
  */
37
37
  pending: number;
38
38
  /**
39
- * Friends past the spend gate whose reward is inside the chargeback hold.
39
+ * Friends past the qualifying deposit whose reward is inside the chargeback hold.
40
40
  * @type {number}
41
41
  * @memberof Referral
42
42
  */
@@ -72,10 +72,17 @@ export interface Referral {
72
72
  */
73
73
  refereeRewardCents: number;
74
74
  /**
75
- * The friend's cumulative inference spend that qualifies a referral.
75
+ * The friend's cumulative net real deposits (card, auto-pay and crypto, less refunds) that qualify a referral.
76
76
  * @type {number}
77
77
  * @memberof Referral
78
78
  */
79
+ qualifyDepositCents?: number;
80
+ /**
81
+ * Deprecated — referrals now qualify on deposits. Mirrors `qualify_deposit_cents`.
82
+ * @type {number}
83
+ * @memberof Referral
84
+ * @deprecated
85
+ */
79
86
  qualifySpendCents: number;
80
87
  /**
81
88
  * Days between qualification and payout (chargeback hold).
@@ -59,6 +59,7 @@ export function ReferralFromJSONTyped(json, ignoreDiscriminator) {
59
59
  'commissionEarnedCents': json['commission_earned_cents'],
60
60
  'rewardCents': json['reward_cents'],
61
61
  'refereeRewardCents': json['referee_reward_cents'],
62
+ 'qualifyDepositCents': json['qualify_deposit_cents'] == null ? undefined : json['qualify_deposit_cents'],
62
63
  'qualifySpendCents': json['qualify_spend_cents'],
63
64
  'holdDays': json['hold_days'],
64
65
  'commissionPct': json['commission_pct'],
@@ -82,6 +83,7 @@ export function ReferralToJSONTyped(value, ignoreDiscriminator = false) {
82
83
  'commission_earned_cents': value['commissionEarnedCents'],
83
84
  'reward_cents': value['rewardCents'],
84
85
  'referee_reward_cents': value['refereeRewardCents'],
86
+ 'qualify_deposit_cents': value['qualifyDepositCents'],
85
87
  'qualify_spend_cents': value['qualifySpendCents'],
86
88
  'hold_days': value['holdDays'],
87
89
  'commission_pct': value['commissionPct'],
@@ -0,0 +1,71 @@
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 model in a request's backup-model trail.
14
+ * @export
15
+ * @interface RequestAttempt
16
+ */
17
+ export interface RequestAttempt {
18
+ /**
19
+ *
20
+ * @type {string}
21
+ * @memberof RequestAttempt
22
+ */
23
+ model: string;
24
+ /**
25
+ * `ok`: this model served. `failed`: it was dialled and every provider failed before the first token. `skipped`: it was passed over without being dialled.
26
+ * @type {RequestAttemptOutcomeEnum}
27
+ * @memberof RequestAttempt
28
+ */
29
+ outcome: RequestAttemptOutcomeEnum;
30
+ /**
31
+ * Why the attempt failed (a public error code such as `upstream_timeout`) or was skipped: `model_not_allowed_for_key`, `subscription_quota_exhausted`, `api_key_budget_exceeded`, `member_spend_limit_reached`, `insufficient_balance`, `daily_limit_reached`, `spending_limit_reached`, `wallet_only` (not on the plan roster, for a plan-covered request), `unavailable`, `capability_mismatch`, `context_window_too_small`, `breaker_open` or `deadline_exhausted` (too little time was left to start another model).
32
+ * @type {string}
33
+ * @memberof RequestAttempt
34
+ */
35
+ reason?: string;
36
+ /**
37
+ * How long this model's attempt took, in milliseconds.
38
+ * @type {number}
39
+ * @memberof RequestAttempt
40
+ */
41
+ durationMs: number;
42
+ /**
43
+ * Time to first token, for the model that served a streamed call.
44
+ * @type {number}
45
+ * @memberof RequestAttempt
46
+ */
47
+ ttftMs?: number;
48
+ /**
49
+ * How many upstream attempts were made for this model. 0 for a skipped model.
50
+ * @type {number}
51
+ * @memberof RequestAttempt
52
+ */
53
+ tries: number;
54
+ }
55
+ /**
56
+ * @export
57
+ */
58
+ export declare const RequestAttemptOutcomeEnum: {
59
+ readonly Ok: "ok";
60
+ readonly Failed: "failed";
61
+ readonly Skipped: "skipped";
62
+ };
63
+ export type RequestAttemptOutcomeEnum = typeof RequestAttemptOutcomeEnum[keyof typeof RequestAttemptOutcomeEnum];
64
+ /**
65
+ * Check if a given object implements the RequestAttempt interface.
66
+ */
67
+ export declare function instanceOfRequestAttempt(value: object): value is RequestAttempt;
68
+ export declare function RequestAttemptFromJSON(json: any): RequestAttempt;
69
+ export declare function RequestAttemptFromJSONTyped(json: any, ignoreDiscriminator: boolean): RequestAttempt;
70
+ export declare function RequestAttemptToJSON(json: any): RequestAttempt;
71
+ export declare function RequestAttemptToJSONTyped(value?: RequestAttempt | null, ignoreDiscriminator?: boolean): any;