@limitry/client - v0.4.1
    Preparing search index...

    Class Quotas

    Index

    Constructors

    Methods

    • Check quotas

      Check usage against all matching quotas for the given dimensions without consuming quota.

      This endpoint allows you to query quota status without actually recording usage. Useful for:

      • Pre-flight checks before processing requests
      • Displaying quota status to users
      • Monitoring quota consumption

      Dimension Matching:* Quotas are matched based on dimension filters. Pass dimensions like:

      • customer_id: Filter by customer
      • event_type: Filter by event type
      • model: Filter by model
      • provider: Filter by provider
      • Any custom dimension from event properties

      Parameters

      • request: { [key: string]: unknown }

        Request body

      Returns Promise<
          {
              allowed: boolean;
              quotas: {
                  exceeded: boolean;
                  id: string;
                  limit: number;
                  metric: string;
                  name: string;
                  period: string;
                  remaining: number;
                  used: number;
              }[];
          },
      >

      Quota check result

      const request: Request = {
      // Add request properties here
      };

      const result = await client.quotas.check(request);
      console.log(result);

      Unauthorized

      If a network error occurs

    • Create a quota

      Create a new usage quota with dimension filters.

      Quotas allow you to limit usage based on metrics like total tokens, cost, or event count. You can apply quotas to specific customers, models, event types, or any combination using dimension filters.

      Parameters

      • request: {
            dimensionFilters: { [key: string]: unknown };
            limitValue: number;
            metric: "total_tokens" | "total_events" | "total_cost_cents";
            name: string;
            period: "hour" | "day" | "week" | "month";
        }

        Request body

        • dimensionFilters: { [key: string]: unknown }

          Dimension filters that determine which events match this quota

          {}
          
        • limitValue: number

          Quota limit value

        • metric: "total_tokens" | "total_events" | "total_cost_cents"

          Metric being tracked

        • name: string

          Human-readable name for the quota

        • period: "hour" | "day" | "week" | "month"

          Time period for the quota

      Returns Promise<
          {
              createdAt: string;
              dimensionFilters: { [key: string]: unknown };
              id: string;
              limitValue: number;
              metric: string;
              name: string;
              period: string;
              projectId: string;
              updatedAt: string;
          },
      >

      Quota created

      const request: Request = {
      name: "example",
      metric: "example",
      limitValue: 123,
      dimensionFilters: {}
      // ... other properties
      };

      const result = await client.quotas.create(request);
      console.log(result);

      Invalid request

      Unauthorized

      If a network error occurs

    • Create a quota alert

      Configure an alert for when a quota reaches a threshold. Alerts are sent to all active project webhooks.

      Parameters

      • quotaId: string

        No description provided

      • request: { threshold: number }

        Request body

        • threshold: number

          Threshold percentage (1-100) at which to trigger the alert

      Returns Promise<
          {
              createdAt: string;
              id: string;
              lastTriggeredAt?: string
              | null;
              quotaId: string;
              threshold: number;
              updatedAt: string;
          },
      >

      Alert created successfully

      const request: Request = {
      threshold: 123
      };

      const result = await client.quotas.createAlert(
      "quotaid_123",
      request
      );
      console.log(result);

      Invalid request body

      Unauthorized

      If a network error occurs

    • Delete a quota

      Delete a quota by ID.

      Parameters

      • id: string

        Unique identifier for the quota

      Returns Promise<{ success: boolean }>

      Quota deleted

      const result = await client.quotas.delete("id_123");
      console.log(result);

      Unauthorized

      Quota not found

      If a network error occurs

    • Get a quota

      Get a specific quota by ID.

      Parameters

      • id: string

        Unique identifier for the quota

      Returns Promise<
          {
              createdAt: string;
              dimensionFilters: { [key: string]: unknown };
              id: string;
              limitValue: number;
              metric: string;
              name: string;
              period: string;
              projectId: string;
              updatedAt: string;
          },
      >

      Quota found

      const result = await client.quotas.get("id_123");
      console.log(result);

      Unauthorized

      Quota not found

      If a network error occurs

    • List quotas

      List all quotas for the project.

      Parameters

      • Optionallimit: string

        Maximum number of quotas to return (1-100, default: 50) (default: "50")

      • Optionalcursor: string

        Pagination cursor from the previous response

      Returns Promise<QuotasListResponse>

      List of quotas

      const items = await client.quotas.list();
      for (const item of items.data) {
      console.log(item);
      }

      Invalid query parameters

      Unauthorized

      If a network error occurs

    • List quota alerts

      Get all alerts configured for a quota

      Parameters

      • quotaId: string

        No description provided

      • Optionallimit: string

        Maximum number of alerts to return (1-100, default: 50) (default: "50")

      • Optionalcursor: string

        Pagination cursor from the previous response

      Returns Promise<QuotasListAlertsResponse>

      List of alerts

      const items = await client.quotas.listAlerts("quotaid_123");
      for (const item of items.data) {
      console.log(item);
      }

      Invalid query parameters

      Unauthorized

      If a network error occurs

    • Update a quota

      Update an existing quota.

      Parameters

      • id: string

        Unique identifier for the quota

      • request: {
            dimensionFilters?: { [key: string]: unknown };
            limitValue?: number;
            metric?: "total_tokens" | "total_events" | "total_cost_cents";
            name?: string;
            period?: "hour" | "day" | "week" | "month";
        }

        Request body

        • OptionaldimensionFilters?: { [key: string]: unknown }

          Dimension filters that determine which events match this quota

        • OptionallimitValue?: number

          Quota limit value

        • Optionalmetric?: "total_tokens" | "total_events" | "total_cost_cents"

          Metric being tracked

        • Optionalname?: string

          Human-readable name for the quota

        • Optionalperiod?: "hour" | "day" | "week" | "month"

          Time period for the quota

      Returns Promise<
          {
              createdAt: string;
              dimensionFilters: { [key: string]: unknown };
              id: string;
              limitValue: number;
              metric: string;
              name: string;
              period: string;
              projectId: string;
              updatedAt: string;
          },
      >

      Quota updated

      const request: Request = {
      name: "example",
      dimensionFilters: {}
      // ... other properties
      };

      const result = await client.quotas.update(
      "id_123",
      request
      );
      console.log(result);

      Unauthorized

      Quota not found

      If a network error occurs