limitry.client.Track

class limitry.client.Track[source]

Bases: object

Operations for track.

__init__(client)[source]

Initialize Track operations.

Parameters:

client (Client) – The Limitry client instance

Return type:

None

Methods

__init__(client)

Initialize Track operations.

usage(request)

Track usage with enforcement.

__init__(client)[source]

Initialize Track operations.

Parameters:

client (Client) – The Limitry client instance

Return type:

None

async usage(request)[source]

Track usage with enforcement.

All-in-one endpoint for tracking usage with quota and rate limit enforcement.

This is the recommended endpoint for most use cases. It performs three operations in sequence: 1. Rate Limit Check: Validates against configured rate limits (fast, Redis-based) 2. Quota Check: Validates against configured quotas (database-based) 3. Event Ingestion: Records the event if all checks pass

Response Codes: - 201 Created: Event tracked successfully, all limits within bounds - 429 Too Many Requests: Rate limit or quota exceeded (check response body for details)

Rate Limit Headers: The response includes standard rate limit headers: - X-RateLimit-Limit: Maximum requests allowed - X-RateLimit-Remaining: Requests remaining in current window - X-RateLimit-Reset: Unix timestamp when window resets - Retry-After: Seconds to wait before retrying (on 429 responses)

Quota Headers (on quota exceeded): When a quota is exceeded, the response includes: - Retry-After: Seconds to wait before retrying - X-Quota-Reset: Unix timestamp when the quota period resets - X-Quota-Period: Quota period (hour, day, week, month) - X-Quota-Metric: Quota metric (total_tokens, total_events, total_cost_cents)

Dimension Matching: Quotas and rate limits are matched based on dimensions extracted from: - customerIdcustomer_id - eventTypeevent_type - modelmodel - providerprovider - properties → All string values are included as dimensions.

Parameters:

request (TrackPostRequest) – TrackPostRequest object

Returns:

Event tracked successfully - all limits within bounds

Return type:

TrackPostResponse

Example:

request = TrackPostRequest(
    customerId="customerid_123",
    eventType="example",
    model="example",
    provider="provider_123"
    # ... other properties
)

result = await client.track.usage(
    request
)
print(result)
Raises:
Parameters:

request (TrackPostRequest)

Return type:

TrackPostResponse