vastai-rate-limits

Featured

Handle Vast.ai API rate limits with backoff and request optimization. Use when encountering 429 errors, implementing retry logic, or optimizing API request throughput. Trigger with phrases like "vastai rate limit", "vastai throttling", "vastai 429", "vastai retry", "vastai backoff".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Vast.ai Rate Limits ## Overview Handle Vast.ai REST API rate limits gracefully. The API at `cloud.vast.ai/api/v0` returns HTTP 429 when request limits are exceeded. Most operations (search, show) are read-heavy and rarely hit limits, but automated scripts doing rapid provisioning or polling can trigger throttling. ## Prerequisites - Vast.ai CLI or REST API client - Understanding of exponential backoff ## Instructions ### Step 1: Rate-Limited HTTP Client ```python import requests import time class RateLimitedVastClient: BASE_URL = "https://cloud.vast.ai/api/v0" def __init__(self, api_key, min_delay=0.5, max_retries=5): self.session = requests.Session() self.session.headers["Authorization"] = f"Bearer {api_key}" self.min_delay = min_delay self.max_retries = max_retries self.last_request = 0 def request(self, method, endpoint, **kwargs): # Enforce minimum delay between requests elapsed = time.time() - self.last_request if elapsed < self.min_delay: time.sleep(self.min_delay - elapsed) for attempt in range(self.max_retries): self.last_request = time.time() resp = self.session.request(method, f"{self.BASE_URL}{endpoint}", **kwargs) if resp.status_code == 429: retry_after = int(resp.headers.get("Retry-After", 2 ** attempt)) print(f"Rate limited. Waiting {retry_after}s (attempt {attempt+1})") ti...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category