Rate Limits

Understanding Talk API usage limits

The Talk API uses rate limiting to ensure fair usage and service stability. Rate limits are enforced per API key through the unified do.dev billing system.

Rate Limits

Rate limits are determined by your do.dev billing plan and are shared across all services.

Limit TypeDescription
Requests per minuteMaximum API calls per minute per key
Requests per dayMaximum API calls per day per key

Check your plan's limits in the do.dev Dashboard.

Handling Rate Limits

429 Response

When you exceed rate limits, you'll receive a 429 Too Many Requests response:

{
  "error": "Rate limit exceeded: 60 requests per minute"
}

The response includes a Retry-After header indicating how long to wait (in seconds).

Best Practices

  1. Check response status before processing to catch rate limits early
  2. Implement exponential backoff when you receive 429 responses
  3. Cache audio to reduce repeated API calls for the same text
  4. Batch efficiently — generate longer audio segments when possible

Example: Retry Logic

async function generateSpeechWithRetry(text, voice, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const response = await fetch("https://api.do.dev/v1/talk/speech", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.DO_API_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ text, voice })
    });

    if (response.ok) {
      return response.blob();
    }

    if (response.status === 429) {
      const retryAfter = response.headers.get("Retry-After") || 60;
      console.log(`Rate limited. Waiting ${retryAfter} seconds...`);
      await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
      continue;
    }

    throw new Error(`API error: ${response.status}`);
  }

  throw new Error("Max retries exceeded");
}

Python Example

import time
import requests
import os

def generate_speech_with_retry(text, voice="aria", max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(
            "https://api.do.dev/v1/talk/speech",
            headers={
                "Authorization": f"Bearer {os.environ['DO_API_KEY']}",
                "Content-Type": "application/json"
            },
            json={"text": text, "voice": voice}
        )

        if response.ok:
            return response.content

        if response.status_code == 429:
            retry_after = int(response.headers.get("Retry-After", 60))
            print(f"Rate limited. Waiting {retry_after} seconds...")
            time.sleep(retry_after)
            continue

        response.raise_for_status()

    raise Exception("Max retries exceeded")

Monitoring Usage

Track your API usage in the do.dev Dashboard:

  • Real-time request counts — See usage across all services
  • Per-key usage — Monitor individual API keys
  • Usage history — View trends over time

Upgrading Limits

To increase your rate limits, upgrade your plan in the do.dev Dashboard. Higher-tier plans include more requests per minute and per day across all do.dev services.