Rate Limits on shared models
Last updated on
With shared models STACKIT AI Model Serving serves compute-intense AI workloads via a shared API. To ensure that the resources are available to all customers, STACKIT applies rate limits on shared models.
Purpose of rate limits
Section titled “Purpose of rate limits”The main goals of rate limits in STACKIT AI Model Serving are:
- Ensure fair use of shared resources among all users.
- Protect the service against misuse and potential abuse.
How rate limits are applied on shared models
Section titled “How rate limits are applied on shared models”In STACKIT AI Model Serving, we apply rate limits on shared models in the following ways:
- Two dimensions: STACKIT enforces rate limits based on two dimensions
- Requests per minute (RPM)
- Tokens per minute (TPM)
- Per-project basis: Rate limits are aggregated across all STACKIT AI Model Serving authentication tokens associated with a single STACKIT project.
- Model-specific limits: Rate limits vary depending on the specific model being used, with details available in Getting Started with Shared Models.
- System-wide capacity: The serving capacity of a shared model is shared across all customers. When the total demand for a model exceeds the available capacity, the API may reject requests with
429 Too Many Requests, independently of your project’s rate limits.
TPM limit computation
Section titled “TPM limit computation”For Tokens Per Minute (TPM) limits, the computation is based on the total number of tokens used, considering both prompt tokens and generation tokens (for embedding models, only prompt tokens are used). The TPM limit is calculated by adding the prompt tokens to the generation tokens, with generation tokens weighted by a factor of 5. This means that generation tokens are counted as 5 times the number of prompt tokens:
TPM = (prompt tokens + 5 * generation tokens) / minuteBurst capacity and rate limit enforcement
Section titled “Burst capacity and rate limit enforcement”STACKIT also provides a slight burst capacity to accommodate short-term spikes in traffic. This means that the rate limits can be exceeded slightly for a very short time, allowing for a brief increase in usage above the standard limits. However, sustained usage above the limits will still be enforced, and requests may be rejected or throttled to prevent abuse.
Response headers for rate limit information
Section titled “Response headers for rate limit information”When you make a request to the STACKIT AI Model Serving, the response includes headers that provide useful information about the remaining capacity and rate limit status. You can use these headers to implement efficient retry mechanisms and optimize your application’s usage of the service.
Every response contains rate-limit specific headers:
x-ratelimit-limit-requests: The RPM limit for your project.x-ratelimit-limit-tokens: The TPM limit for your projectx-ratelimit-remaining-requests: The number of requests remaining, before you get rate-limited.x-ratelimit-remaining-tokens: The number of tokens remaining, before you get rate-limited.x-ratelimit-reset-requests: The time remaining until the request rate limit resets.x-ratelimit-reset-tokens: The time remaining until the token rate limit resets.
Once you hit a rate limit (RPM or TPM) the API responds with 429 Too Many Requests. Given the x-ratelimit-remaining-* headers in the response, you can determine when to retry the request.
The API can also respond with 429 Too Many Requests when the shared model capacity is saturated, independently of your project’s rate limits. Such responses do not include the x-ratelimit-* headers.
With this information, the client-side application can handle rate limiting according to the specific use-case scenario. However, some general strategies and approaches to deal with rate limits are mentioned below.
Strategies for handling rate limits
Section titled “Strategies for handling rate limits”To build a resilient application, we recommend implementing the following strategies to manage API rate limits gracefully.
Implement exponential backoff with jitter
Section titled “Implement exponential backoff with jitter”When you receive a rate limit error (429 Too Many Requests), retry the request with a progressively longer delay. Adding “jitter” (a small, random amount of time) to this delay prevents multiple clients from retrying simultaneously.
The same strategy applies to system-wide capacity rejections, which do not include the x-ratelimit-* headers: since the reset time cannot be determined from the response, retry with exponential backoff and jitter.
Proactively monitor your quota
Section titled “Proactively monitor your quota”Use the x-ratelimit-remaining-* headers returned with every API response to track your available quota. Your application can then intelligently pause new requests when the quota is low, avoiding errors before they happen.
What to do if standard rate limits are insufficient
Section titled “What to do if standard rate limits are insufficient”If the standard rate limits are not sufficient for your application, please submit a Service Request via STACKIT Help Center to discuss possible adjustments.