Rate Limiting
To ensure consistent performance and fair resource allocation for all Telesoft API users, we implement rate limiting across our API endpoints. Understanding these limits will help you optimize your application's integration with our services.
Overview
Rate limits in the Telesoft API are applied on a per-key basis, with different tiers having different limits. These limits are tracked using a sliding window algorithm that counts the number of requests you make in a specific time period.
Rate Limit Headers
Every API response includes headers that provide information about your current rate limit status:
Header | Description |
---|---|
X-RateLimit-Limit | The maximum number of requests allowed in the current time window |
X-RateLimit-Remaining | The number of requests remaining in the current time window |
X-RateLimit-Reset | The time at which the current rate limit window resets in UTC epoch seconds |
Retry-After | Only present when rate limited. The number of seconds to wait before retrying |
Rate Limit Categories
Different API endpoints have different rate limits based on their computational intensity and resource requirements.
Standard Endpoints
Standard endpoints include basic operations such as retrieving, updating, or deleting resources.
Plan | Rate Limit |
---|---|
Developer | 100 requests per minute |
Professional | 300 requests per minute |
Enterprise | 1,000 requests per minute |
AI Diagnostic Endpoints
AI diagnostic endpoints perform complex medical analysis and require more computational resources.
Plan | Rate Limit |
---|---|
Developer | 20 requests per minute |
Professional | 50 requests per minute |
Enterprise | 200 requests per minute |
Bulk Operations
Bulk operations handle multiple records in a single request and have special rate limiting rules.
Plan | Rate Limit |
---|---|
Developer | 5 requests per minute (max 100 items per request) |
Professional | 15 requests per minute (max 500 items per request) |
Enterprise | 30 requests per minute (max 1,000 items per request) |
Endpoint-Specific Limits
Some endpoints have specific rate limits due to their specialized nature or resource requirements.
Endpoint | Description | Rate Limit |
---|---|---|
/v1/diagnostics/differential | Generates differential diagnoses based on symptoms | 10 requests per minute (all plans) |
/v1/diagnostics/image-analysis | Analyzes medical images for anomalies | 5 requests per minute (all plans) |
/v1/knowledge/drug-interactions | Checks for potential drug interactions | 30 requests per minute (all plans) |
/v1/patients/batch-update | Updates multiple patient records | See Bulk Operations |
Handling Rate Limiting
Recommended Approach
When your application receives a rate limit error (HTTP 429), follow these best practices:
- Respect the
Retry-After
header, which tells you how long to wait before retrying. - Implement exponential backoff with jitter when retrying to avoid creating sudden spikes in traffic.
- Consider caching responses where appropriate to reduce the number of API calls.
- Monitor the
X-RateLimit-Remaining
header to adjust your request patterns before hitting limits.
Example: Handling Rate Limiting with Exponential Backoff
import { TelesoftAI, TelesoftAPIError } from '@telesoft/healthcare-sdk';
// Configure the SDK
const telesoft = new TelesoftAI({
apiKey: 'YOUR_API_KEY',
environment: 'production'
});
// Retry function with exponential backoff
async function retryWithBackoff(fn, maxRetries = 5) {
let retries = 0;
while (true) {
try {
return await fn();
} catch (error) {
if (!(error instanceof TelesoftAPIError) ||
error.status !== 429 ||
retries >= maxRetries) {
throw error; // Not a rate limit error or max retries exceeded
}
retries++;
// Get retry time from header or calculate with exponential backoff
let retryAfterSeconds;
if (error.headers && error.headers['retry-after']) {
retryAfterSeconds = parseInt(error.headers['retry-after'], 10);
} else {
// Exponential backoff with jitter: 2^retries * 100ms + random jitter
const baseDelay = Math.pow(2, retries) * 100;
const jitter = Math.random() * 100;
retryAfterSeconds = (baseDelay + jitter) / 1000;
}
console.log(`Rate limited. Retrying in ${retryAfterSeconds} seconds. Attempt ${retries} of ${maxRetries}`);
// Wait before retrying
await new Promise(resolve => setTimeout(resolve, retryAfterSeconds * 1000));
}
}
}
// Example usage
async function getDifferentialDiagnosis(symptoms) {
return retryWithBackoff(async () => {
return await telesoft.diagnostics.getDifferential({
symptoms,
patientInfo: {
age: 35,
sex: 'female'
}
});
});
}
// Call the function
getDifferentialDiagnosis(['fever', 'cough', 'fatigue'])
.then(result => console.log('Diagnosis:', result))
.catch(error => console.error('Error:', error));
Concurrent Request Limits
In addition to rate limits based on requests per minute, we also limit the number of concurrent requests that can be made with a single API key.
Plan | Concurrent Request Limit |
---|---|
Developer | 5 concurrent requests |
Professional | 20 concurrent requests |
Enterprise | 50 concurrent requests |
⚠️ Note
Exceeding concurrent request limits will result in a 429 error with a specific error code of concurrent_request_limit
. Your application should manage parallel requests to stay within these limits.
Rate Limit Exemptions
Enterprise customers may request rate limit exemptions for specific use cases or during planned high-traffic events.
- To request a temporary rate limit increase, contact your account manager at least 48 hours in advance.
- Provide details about the expected traffic pattern, duration, and business justification.
- For permanent rate limit increases, please contact sales to discuss upgrading your plan.
💡 Pro Tip
If you're consistently hitting rate limits, consider using our bulk API endpoints where available. For example, instead of making 100 separate patient update requests, you can use the /v1/patients/batch-update
endpoint to update multiple patients in a single request.