The Vast.ai SDK automatically retries rate-limited requests. You do not need to implement your own retry logic — both theDocumentation Index
Fetch the complete documentation index at: https://docs.vast.ai/llms.txt
Use this file to discover all available pages before exploring further.
VastAI client and the serverless client handle retries with exponential backoff out of the box.
This page covers the error format, how rate limits work, and how to configure retry behavior for each client. For the full details on rate limit mechanics, see the API Rate Limits and Errors page.
Error Responses
The underlying API error shape is:success or error and return only msg or message.
The VastAI client returns the error as a dictionary when raw=True is set, or prints the message otherwise. The serverless client raises an exception after exhausting all retries.
How Rate Limits Work
Vast.ai applies rate limits per endpoint and per identity. The identity is determined by your bearer token, session user,api_key parameter, and client IP.
Some endpoints also enforce method-specific limits (GET vs POST) and max-calls-per-period limits for short bursts.
For the full breakdown, see How rate limits are applied.
Rate Limit Response
When you hit a rate limit, the API returns HTTP 429 with a message like:Retry-After header. The SDK handles this automatically using its built-in retry logic.
Built-in Retry Behavior
The SDK includes two clients with different retry strategies.VastAI Client
The mainVastAI client retries on rate limit responses:
- Retried status codes: 429 only
- Default retries: 3
- Backoff strategy: starts at 0.15 seconds, multiplied by 1.5x after each attempt
- Retry delays: ~0.15s, ~0.225s, ~0.34s
Serverless Client
The serverless client has a broader retry scope, covering transient server errors in addition to rate limits:- Retried status codes: 408 (timeout), 429 (rate limit), and 5xx (server errors)
- Default retries: 5
- Backoff strategy: exponential with jitter —
min(2^attempt + random(0, 1), 5.0)seconds - Max delay: 5 seconds per retry
The serverless client retries on a wider range of errors than the
VastAI client. Server errors (5xx) and timeouts (408) are retried automatically — you do not need to handle these yourself.Configuring Retries
VastAI Client
Pass theretry parameter to the constructor to change the number of retry attempts:
Serverless Client
The serverless client defaults to 5 retries. The retry count is configured internally per request through the_make_request() method’s retries parameter.