@deeprelay/sdk 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) 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/InferenceApi.d.ts +3 -2
  6. package/dist/apis/InferenceApi.js +5 -2
  7. package/dist/apis/RequestsApi.d.ts +4 -2
  8. package/dist/apis/RequestsApi.js +8 -2
  9. package/dist/esm/apis/ApiKeysApi.d.ts +2 -2
  10. package/dist/esm/apis/ApiKeysApi.js +2 -2
  11. package/dist/esm/apis/InferenceApi.d.ts +3 -2
  12. package/dist/esm/apis/InferenceApi.js +5 -2
  13. package/dist/esm/apis/RequestsApi.d.ts +4 -2
  14. package/dist/esm/apis/RequestsApi.js +8 -2
  15. package/dist/esm/models/ApiKey.d.ts +19 -0
  16. package/dist/esm/models/ApiKey.js +9 -0
  17. package/dist/esm/models/ApiKeyCreate.d.ts +6 -0
  18. package/dist/esm/models/ApiKeyCreate.js +2 -0
  19. package/dist/esm/models/ApiKeyCreated.d.ts +19 -0
  20. package/dist/esm/models/ApiKeyCreated.js +9 -0
  21. package/dist/esm/models/ApiKeyFallbackEntry.d.ts +65 -0
  22. package/dist/esm/models/ApiKeyFallbackEntry.js +67 -0
  23. package/dist/esm/models/ApiKeyUpdate.d.ts +7 -1
  24. package/dist/esm/models/ApiKeyUpdate.js +2 -0
  25. package/dist/esm/models/ChatCompletionRequest.d.ts +6 -0
  26. package/dist/esm/models/ChatCompletionRequest.js +2 -0
  27. package/dist/esm/models/CreateWebhookEndpointRequest.d.ts +1 -0
  28. package/dist/esm/models/CreateWebhookEndpointRequest.js +2 -1
  29. package/dist/esm/models/RequestAttempt.d.ts +71 -0
  30. package/dist/esm/models/RequestAttempt.js +67 -0
  31. package/dist/esm/models/RequestLogEntry.d.ts +25 -0
  32. package/dist/esm/models/RequestLogEntry.js +9 -0
  33. package/dist/esm/models/WebhookEndpoint.d.ts +1 -0
  34. package/dist/esm/models/WebhookEndpoint.js +2 -1
  35. package/dist/esm/models/index.d.ts +2 -0
  36. package/dist/esm/models/index.js +2 -0
  37. package/dist/esm/runtime.js +1 -1
  38. package/dist/models/ApiKey.d.ts +19 -0
  39. package/dist/models/ApiKey.js +9 -0
  40. package/dist/models/ApiKeyCreate.d.ts +6 -0
  41. package/dist/models/ApiKeyCreate.js +2 -0
  42. package/dist/models/ApiKeyCreated.d.ts +19 -0
  43. package/dist/models/ApiKeyCreated.js +9 -0
  44. package/dist/models/ApiKeyFallbackEntry.d.ts +65 -0
  45. package/dist/models/ApiKeyFallbackEntry.js +75 -0
  46. package/dist/models/ApiKeyUpdate.d.ts +7 -1
  47. package/dist/models/ApiKeyUpdate.js +2 -0
  48. package/dist/models/ChatCompletionRequest.d.ts +6 -0
  49. package/dist/models/ChatCompletionRequest.js +2 -0
  50. package/dist/models/CreateWebhookEndpointRequest.d.ts +1 -0
  51. package/dist/models/CreateWebhookEndpointRequest.js +2 -1
  52. package/dist/models/RequestAttempt.d.ts +71 -0
  53. package/dist/models/RequestAttempt.js +75 -0
  54. package/dist/models/RequestLogEntry.d.ts +25 -0
  55. package/dist/models/RequestLogEntry.js +9 -0
  56. package/dist/models/WebhookEndpoint.d.ts +1 -0
  57. package/dist/models/WebhookEndpoint.js +2 -1
  58. package/dist/models/index.d.ts +2 -0
  59. package/dist/models/index.js +2 -0
  60. package/dist/runtime.js +1 -1
  61. package/docs/ApiKey.md +6 -0
  62. package/docs/ApiKeyCreate.md +2 -0
  63. package/docs/ApiKeyCreated.md +6 -0
  64. package/docs/ApiKeyFallbackEntry.md +43 -0
  65. package/docs/ApiKeyUpdate.md +3 -1
  66. package/docs/ApiKeysApi.md +1 -1
  67. package/docs/ChatCompletionRequest.md +2 -0
  68. package/docs/InferenceApi.md +29 -26
  69. package/docs/RequestAttempt.md +45 -0
  70. package/docs/RequestLogEntry.md +8 -0
  71. package/docs/RequestsApi.md +9 -3
  72. package/package.json +1 -1
  73. package/src/apis/ApiKeysApi.ts +2 -2
  74. package/src/apis/InferenceApi.ts +7 -2
  75. package/src/apis/RequestsApi.ts +12 -2
  76. package/src/models/ApiKey.ts +32 -0
  77. package/src/models/ApiKeyCreate.ts +8 -0
  78. package/src/models/ApiKeyCreated.ts +32 -0
  79. package/src/models/ApiKeyFallbackEntry.ts +114 -0
  80. package/src/models/ApiKeyUpdate.ts +9 -1
  81. package/src/models/ChatCompletionRequest.ts +8 -0
  82. package/src/models/CreateWebhookEndpointRequest.ts +2 -1
  83. package/src/models/RequestAttempt.ts +121 -0
  84. package/src/models/RequestLogEntry.ts +40 -0
  85. package/src/models/WebhookEndpoint.ts +2 -1
  86. package/src/models/index.ts +2 -0
  87. package/src/runtime.ts +1 -1
@@ -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.
@@ -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;
@@ -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.0' }, this.configuration.headers);
64
+ return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.4.2' }, 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(),