Skip to main content

Rate Limits

Understand API rate limits, quotas, and best practices for building reliable applications.

Overview

Trix uses rate limits to ensure fair usage and maintain service reliability for all users. Limits are applied per API key and reset on a rolling window basis.

Fair Usage

Rate limits ensure all users get consistent performance, even during peak traffic.

Predictable Costs

Quotas help you predict and control your monthly usage and costs.

Rate Limit Tiers

Rate limits vary by plan. Here's what's included in each tier:

PlanRequests/minMemoriesMax Memory SizeSpaces
Free601,0004 KB3
Pro300100,00032 KBUnlimited
Max1,000500,000128 KBUnlimited
EnterpriseCustomUnlimited1 MBUnlimited

Need higher limits? Contact sales to discuss Enterprise pricing with custom rate limits tailored to your needs.

Per-Endpoint Limits

Some endpoints have specific rate limits in addition to your plan's overall limit:

EndpointRate LimitNotes
POST /v1/memories60/minMemory creation triggers embedding generation
POST /v1/memories/bulk10/minUp to 100 memories per request
POST /v1/search120/minSemantic search queries
GET /v1/memories300/minList operations are cheaper
DELETE /v1/memories/:id60/minIndividual deletes
POST /v1/entities/merge10/minEntity merging is resource-intensive

Rate Limit Headers

Every API response includes headers to help you track your usage:

HTTP Response
HTTP/1.1 200 OK
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 287
X-RateLimit-Reset: 1705312800
X-RateLimit-Policy: 300;w=60
HeaderDescription
X-RateLimit-LimitMaximum requests allowed per window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets
X-RateLimit-PolicyRate limit policy (limit;w=window_seconds)

Handling Rate Limits

When you exceed the rate limit, the API returns a 429 status code:

429 Too Many Requests
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please retry after 30 seconds.",
    "retry_after": 30,
    "limit": 300,
    "window": 60
  }
}

Implement retry logic with exponential backoff:

import { Trix, TrixError } from '@trixdb/client';

async function withRetry<T>(
  fn: () => Promise<T>,
  maxRetries = 3
): Promise<T> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await fn();
    } catch (error) {
      if (error instanceof TrixError && error.code === 'rate_limit_exceeded') {
        const delay = error.retryAfter || Math.pow(2, attempt) * 1000;
        console.log(`Rate limited. Retrying in ${delay}ms...`);
        await new Promise(resolve => setTimeout(resolve, delay));
      } else {
        throw error;
      }
    }
  }
  throw new Error('Max retries exceeded');
}

// Usage
const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });
const result = await withRetry(() => trix.memories.create({ content: 'Important note' }));

Built-in retry: The official SDKs include automatic retry logic with exponential backoff. Enable it with { retry: true } in your client config.

Usage Quotas

In addition to rate limits, your plan includes monthly quotas for certain operations:

Quota TypeFreeProMaxEnterprise
Total Memories1,000100,000500,000Unlimited
Search Queries/mo5,000500,0005,000,000Unlimited
Embeddings/mo5,000500,0005,000,000Unlimited
Webhooks11050Unlimited
API Keys31050Unlimited

Check your current usage with the CLI:

Terminal
# View current usage and quotas
trix billing usage

# Output:
# Plan: Pro
# Billing Period: Dec 1 - Dec 31
#
# Memories:     42,150 / 500,000 (8.4%)
# Searches:    128,402 / 500,000 (25.7%)
# Embeddings:   43,892 / 500,000 (8.8%)
# Spaces:           12 (unlimited on paid plans)

Best Practices

Follow these practices to make the most of your rate limits and avoid disruptions:

Exponential Backoff

When rate limited, wait progressively longer between retries: 1s, 2s, 4s, 8s.

Batch Operations

Use /v1/memories/bulk to create multiple memories in one request.

Cache Results

Cache frequently accessed memories locally to reduce API calls.

Monitor Headers

Track X-RateLimit-Remaining to anticipate limits before hitting them.

Queue Requests

Implement a request queue to smooth out bursts and stay within limits.

Use Webhooks

Subscribe to events instead of polling to reduce unnecessary API calls.

Monitoring Your Usage

Set up monitoring and alerts to stay within your limits:

import { Trix } from '@trixdb/client';

const trix = new Trix({
  apiKey: process.env.TRIX_API_KEY,
  onRateLimit: (info) => {
    // Called when approaching or exceeding limits
    console.warn(`Rate limit: ${info.remaining}/${info.limit} remaining`);

    if (info.remaining < 10) {
      // Alert your monitoring system
      alertOps('Approaching rate limit', info);
    }
  }
});

Webhook alerts: Configure webhooks to receive notifications when you're approaching quota limits. Go to Settings -> Notifications in the dashboard.

Rate Limit Error Codes

Error CodeHTTP StatusDescriptionAction
rate_limit_exceeded429Too many requests in the current windowWait for retry_after seconds
daily_limit_exceeded429Daily memory creation limit reachedWait until midnight UTC or upgrade plan
quota_exceeded403Monthly quota exhaustedUpgrade plan or wait for next billing cycle
concurrent_limit_exceeded429Too many concurrent requestsReduce parallelism, implement queuing

Upgrading Your Plan

If you consistently hit rate limits, consider upgrading:

Terminal
# View available plans
trix billing plans

# Upgrade to Pro
trix billing upgrade --plan pro

# Upgrade to Max with yearly billing (save ~2 months)
trix billing upgrade --plan max --period yearly