@modelrelay/sdk 0.4.0 → 0.5.0

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.
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  SDK_VERSION: () => SDK_VERSION,
39
39
  STAGING_BASE_URL: () => STAGING_BASE_URL,
40
40
  StopReasons: () => StopReasons,
41
+ TiersClient: () => TiersClient,
41
42
  TransportError: () => TransportError,
42
43
  isPublishableKey: () => isPublishableKey,
43
44
  mergeMetrics: () => mergeMetrics,
@@ -272,7 +273,7 @@ function isTokenReusable(token) {
272
273
  // package.json
273
274
  var package_default = {
274
275
  name: "@modelrelay/sdk",
275
- version: "0.4.0",
276
+ version: "0.5.0",
276
277
  description: "TypeScript SDK for the ModelRelay API",
277
278
  type: "module",
278
279
  main: "dist/index.cjs",
@@ -917,6 +918,46 @@ var CustomersClient = class {
917
918
  }
918
919
  };
919
920
 
921
+ // src/tiers.ts
922
+ var TiersClient = class {
923
+ constructor(http, cfg) {
924
+ this.http = http;
925
+ this.apiKey = cfg.apiKey;
926
+ }
927
+ ensureApiKey() {
928
+ if (!this.apiKey || !this.apiKey.startsWith("mr_pk_") && !this.apiKey.startsWith("mr_sk_")) {
929
+ throw new ConfigError(
930
+ "API key (mr_pk_* or mr_sk_*) required for tier operations"
931
+ );
932
+ }
933
+ }
934
+ /**
935
+ * List all tiers in the project.
936
+ */
937
+ async list() {
938
+ this.ensureApiKey();
939
+ const response = await this.http.json("/tiers", {
940
+ method: "GET",
941
+ apiKey: this.apiKey
942
+ });
943
+ return response.tiers;
944
+ }
945
+ /**
946
+ * Get a tier by ID.
947
+ */
948
+ async get(tierId) {
949
+ this.ensureApiKey();
950
+ if (!tierId?.trim()) {
951
+ throw new ConfigError("tierId is required");
952
+ }
953
+ const response = await this.http.json(`/tiers/${tierId}`, {
954
+ method: "GET",
955
+ apiKey: this.apiKey
956
+ });
957
+ return response.tier;
958
+ }
959
+ };
960
+
920
961
  // src/http.ts
921
962
  var HTTPClient = class {
922
963
  constructor(cfg) {
@@ -1289,6 +1330,9 @@ var ModelRelay = class {
1289
1330
  this.customers = new CustomersClient(http, {
1290
1331
  apiKey: cfg.key
1291
1332
  });
1333
+ this.tiers = new TiersClient(http, {
1334
+ apiKey: cfg.key
1335
+ });
1292
1336
  }
1293
1337
  };
1294
1338
  function resolveBaseUrl(env, override) {
@@ -1315,6 +1359,7 @@ function resolveBaseUrl(env, override) {
1315
1359
  SDK_VERSION,
1316
1360
  STAGING_BASE_URL,
1317
1361
  StopReasons,
1362
+ TiersClient,
1318
1363
  TransportError,
1319
1364
  isPublishableKey,
1320
1365
  mergeMetrics,
package/dist/index.d.cts CHANGED
@@ -656,6 +656,50 @@ declare class CustomersClient {
656
656
  getSubscription(customerId: string): Promise<SubscriptionStatus>;
657
657
  }
658
658
 
659
+ /**
660
+ * Billing interval for a tier.
661
+ */
662
+ type PriceInterval = "month" | "year";
663
+ /**
664
+ * Tier represents a pricing tier in a ModelRelay project.
665
+ */
666
+ interface Tier {
667
+ id: string;
668
+ project_id: string;
669
+ tier_code: string;
670
+ display_name: string;
671
+ actions_limit: number;
672
+ token_limit: number;
673
+ stripe_price_id?: string;
674
+ price_amount?: number;
675
+ price_currency?: string;
676
+ price_interval?: PriceInterval;
677
+ trial_days?: number;
678
+ created_at: string;
679
+ updated_at: string;
680
+ }
681
+ interface TiersClientConfig {
682
+ apiKey?: string;
683
+ }
684
+ /**
685
+ * TiersClient provides methods to query tiers in a project.
686
+ * Works with both publishable keys (mr_pk_*) and secret keys (mr_sk_*).
687
+ */
688
+ declare class TiersClient {
689
+ private readonly http;
690
+ private readonly apiKey?;
691
+ constructor(http: HTTPClient, cfg: TiersClientConfig);
692
+ private ensureApiKey;
693
+ /**
694
+ * List all tiers in the project.
695
+ */
696
+ list(): Promise<Tier[]>;
697
+ /**
698
+ * Get a tier by ID.
699
+ */
700
+ get(tierId: string): Promise<Tier>;
701
+ }
702
+
659
703
  type ErrorCategory = "config" | "transport" | "api";
660
704
  declare class ModelRelayError extends Error {
661
705
  category: ErrorCategory;
@@ -704,8 +748,9 @@ declare class ModelRelay {
704
748
  readonly chat: ChatClient;
705
749
  readonly auth: AuthClient;
706
750
  readonly customers: CustomersClient;
751
+ readonly tiers: TiersClient;
707
752
  readonly baseUrl: string;
708
753
  constructor(options: ModelRelayOptions);
709
754
  }
710
755
 
711
- export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type Environment, type ErrorCategory, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type HttpRequestMetrics, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, ModelRelayError, type ModelRelayOptions, Models, type NonEmptyArray, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, SANDBOX_BASE_URL, SDK_VERSION, STAGING_BASE_URL, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type TokenUsageMetrics, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, providerToString, stopReasonToString };
756
+ export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type Environment, type ErrorCategory, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type HttpRequestMetrics, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, ModelRelayError, type ModelRelayOptions, Models, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, SANDBOX_BASE_URL, SDK_VERSION, STAGING_BASE_URL, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, providerToString, stopReasonToString };
package/dist/index.d.ts CHANGED
@@ -656,6 +656,50 @@ declare class CustomersClient {
656
656
  getSubscription(customerId: string): Promise<SubscriptionStatus>;
657
657
  }
658
658
 
659
+ /**
660
+ * Billing interval for a tier.
661
+ */
662
+ type PriceInterval = "month" | "year";
663
+ /**
664
+ * Tier represents a pricing tier in a ModelRelay project.
665
+ */
666
+ interface Tier {
667
+ id: string;
668
+ project_id: string;
669
+ tier_code: string;
670
+ display_name: string;
671
+ actions_limit: number;
672
+ token_limit: number;
673
+ stripe_price_id?: string;
674
+ price_amount?: number;
675
+ price_currency?: string;
676
+ price_interval?: PriceInterval;
677
+ trial_days?: number;
678
+ created_at: string;
679
+ updated_at: string;
680
+ }
681
+ interface TiersClientConfig {
682
+ apiKey?: string;
683
+ }
684
+ /**
685
+ * TiersClient provides methods to query tiers in a project.
686
+ * Works with both publishable keys (mr_pk_*) and secret keys (mr_sk_*).
687
+ */
688
+ declare class TiersClient {
689
+ private readonly http;
690
+ private readonly apiKey?;
691
+ constructor(http: HTTPClient, cfg: TiersClientConfig);
692
+ private ensureApiKey;
693
+ /**
694
+ * List all tiers in the project.
695
+ */
696
+ list(): Promise<Tier[]>;
697
+ /**
698
+ * Get a tier by ID.
699
+ */
700
+ get(tierId: string): Promise<Tier>;
701
+ }
702
+
659
703
  type ErrorCategory = "config" | "transport" | "api";
660
704
  declare class ModelRelayError extends Error {
661
705
  category: ErrorCategory;
@@ -704,8 +748,9 @@ declare class ModelRelay {
704
748
  readonly chat: ChatClient;
705
749
  readonly auth: AuthClient;
706
750
  readonly customers: CustomersClient;
751
+ readonly tiers: TiersClient;
707
752
  readonly baseUrl: string;
708
753
  constructor(options: ModelRelayOptions);
709
754
  }
710
755
 
711
- export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type Environment, type ErrorCategory, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type HttpRequestMetrics, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, ModelRelayError, type ModelRelayOptions, Models, type NonEmptyArray, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, SANDBOX_BASE_URL, SDK_VERSION, STAGING_BASE_URL, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type TokenUsageMetrics, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, providerToString, stopReasonToString };
756
+ export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type Environment, type ErrorCategory, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type HttpRequestMetrics, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, ModelRelayError, type ModelRelayOptions, Models, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, SANDBOX_BASE_URL, SDK_VERSION, STAGING_BASE_URL, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, providerToString, stopReasonToString };
package/dist/index.js CHANGED
@@ -218,7 +218,7 @@ function isTokenReusable(token) {
218
218
  // package.json
219
219
  var package_default = {
220
220
  name: "@modelrelay/sdk",
221
- version: "0.4.0",
221
+ version: "0.5.0",
222
222
  description: "TypeScript SDK for the ModelRelay API",
223
223
  type: "module",
224
224
  main: "dist/index.cjs",
@@ -863,6 +863,46 @@ var CustomersClient = class {
863
863
  }
864
864
  };
865
865
 
866
+ // src/tiers.ts
867
+ var TiersClient = class {
868
+ constructor(http, cfg) {
869
+ this.http = http;
870
+ this.apiKey = cfg.apiKey;
871
+ }
872
+ ensureApiKey() {
873
+ if (!this.apiKey || !this.apiKey.startsWith("mr_pk_") && !this.apiKey.startsWith("mr_sk_")) {
874
+ throw new ConfigError(
875
+ "API key (mr_pk_* or mr_sk_*) required for tier operations"
876
+ );
877
+ }
878
+ }
879
+ /**
880
+ * List all tiers in the project.
881
+ */
882
+ async list() {
883
+ this.ensureApiKey();
884
+ const response = await this.http.json("/tiers", {
885
+ method: "GET",
886
+ apiKey: this.apiKey
887
+ });
888
+ return response.tiers;
889
+ }
890
+ /**
891
+ * Get a tier by ID.
892
+ */
893
+ async get(tierId) {
894
+ this.ensureApiKey();
895
+ if (!tierId?.trim()) {
896
+ throw new ConfigError("tierId is required");
897
+ }
898
+ const response = await this.http.json(`/tiers/${tierId}`, {
899
+ method: "GET",
900
+ apiKey: this.apiKey
901
+ });
902
+ return response.tier;
903
+ }
904
+ };
905
+
866
906
  // src/http.ts
867
907
  var HTTPClient = class {
868
908
  constructor(cfg) {
@@ -1235,6 +1275,9 @@ var ModelRelay = class {
1235
1275
  this.customers = new CustomersClient(http, {
1236
1276
  apiKey: cfg.key
1237
1277
  });
1278
+ this.tiers = new TiersClient(http, {
1279
+ apiKey: cfg.key
1280
+ });
1238
1281
  }
1239
1282
  };
1240
1283
  function resolveBaseUrl(env, override) {
@@ -1260,6 +1303,7 @@ export {
1260
1303
  SDK_VERSION,
1261
1304
  STAGING_BASE_URL,
1262
1305
  StopReasons,
1306
+ TiersClient,
1263
1307
  TransportError,
1264
1308
  isPublishableKey,
1265
1309
  mergeMetrics,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelrelay/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript SDK for the ModelRelay API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",