Skip to main content
Learn about API rate limits and quotas for Hopx Sandboxes.

Rate Limits

API rate limits help ensure fair usage and system stability. Rate limits are applied per API key.

Default Rate Limits

  • Sandbox Creation: 100 requests per minute
  • Code Execution: 1000 requests per minute
  • File Operations: 500 requests per minute
  • Command Execution: 500 requests per minute
Rate limits may vary based on your plan. Check your dashboard for your specific limits.

Handling Rate Limits

Handle rate limit errors gracefully:
  • Python
  • JavaScript/TypeScript
from hopx_ai import Sandbox
from hopx_ai.errors import RateLimitError
import time

def execute_with_rate_limit_handling(code: str):
    """Execute with rate limit handling"""
    max_retries = 3
    for attempt in range(max_retries):
        try:
            with Sandbox.create(template="code-interpreter") as sandbox:
                return sandbox.run_code(code)
        except RateLimitError as e:
            if attempt < max_retries - 1:
                wait_time = e.retry_after if e.retry_after else 60
                print(f"Rate limited. Retrying after {wait_time}s...")
                time.sleep(wait_time)
                continue
            raise

# Example
result = execute_with_rate_limit_handling("print('Hello')")

Quotas

Quotas limit the total usage over a time period (typically per month).

Default Quotas

  • Sandbox Hours: Varies by plan
  • API Requests: Varies by plan
  • Data Transfer: Varies by plan
Check your dashboard for your specific quotas and current usage.

Best Practices

Always implement retry logic with exponential backoff for rate limit errors.
Monitor your rate limit usage to avoid hitting limits unexpectedly.
Batch operations when possible to reduce API calls.
Don’t ignore rate limit errors - implement proper handling.
Don’t make unnecessary API requests - cache results when possible.

Checking Rate Limits

Rate limit information is included in API responses:
  • X-RateLimit-Limit: Maximum requests per time window
  • X-RateLimit-Remaining: Remaining requests in current window
  • X-RateLimit-Reset: Time when rate limit resets

Next Steps