DEV Community

Peter Park
Peter Park

Posted on

How I Handle 10,000 Email Generations per Day on a Shoestring Budget

When I launched ColdMailAI, I had one goal: keep the price at $9/month and still handle serious volume. Six months later, we're generating over 10,000 personalized cold emails per day. Here's the exact technical playbook that makes it possible without burning through cash.

The Problem: AI APIs Are Expensive at Scale

Let's do the math. If you're calling GPT-4 for every email generation:

  • Average prompt: ~800 tokens
  • Average completion: ~200 tokens
  • Cost per email: ~$0.01-0.03
  • 10,000 emails/day = $100-300/day
  • Monthly: $3,000-9,000

At $9/month per user, you'd need 333-1,000 paying users just to cover API costs. That's before servers, domains, or your coffee budget.

Solution 1: Intelligent Model Routing

Not every email needs GPT-4-level intelligence. I built a routing layer that classifies generation requests:

function routeModel(request) {
  const complexity = analyzeComplexity(request);

  if (complexity.requiresResearch) {
    return 'gpt-4o';        // Deep personalization
  }
  if (complexity.hasTemplate) {
    return 'gpt-4o-mini';   // Template variation
  }
  return 'gpt-4o-mini';     // Simple generation
}
Enter fullscreen mode Exit fullscreen mode

Result: 70% of requests go to cheaper models. Average cost dropped from $0.02 to $0.004 per email.

Solution 2: Aggressive Caching with Semantic Matching

Here's what most people miss: cold emails to similar prospects in the same industry follow similar patterns. I built a semantic cache:

async function generateWithCache(prospect) {
  const embedding = await getEmbedding(prospect.context);
  const cached = await vectorDB.search(embedding, { threshold: 0.92 });

  if (cached) {
    // Modify cached result slightly instead of full generation
    return await cheapVariation(cached.result, prospect);
  }

  const result = await fullGeneration(prospect);
  await vectorDB.store(embedding, result);
  return result;
}
Enter fullscreen mode Exit fullscreen mode

Cache hit rate after 2 weeks of operation: ~40%. Those hits cost almost nothing.

Solution 3: Batch Processing with Queue Management

Instead of processing emails one-by-one with individual API calls, I batch similar requests:

User Request -> Redis Queue -> Batch Aggregator (every 30s)
                                    |
                            Group by industry/template
                                    |
                            Single API call per batch
                                    |
                            Distribute results back
Enter fullscreen mode Exit fullscreen mode

Batching similar prompts reduced my API calls by 60% while maintaining personalization quality.

Solution 4: The Infrastructure Stack

Here's what runs ColdMailAI in production:

Component Choice Monthly Cost
Hosting Vercel (serverless) $20
Database Supabase (free tier + $25 pro) $25
Vector DB Pinecone (starter) $0
Queue Upstash Redis $10
AI APIs OpenAI (with routing) ~$400
Email verification ZeroBounce $50
Domain/DNS Cloudflare $0
Monitoring Sentry (free tier) $0
Total ~$505/month

At $9/user with 200+ users, the margins actually work. The key is that costs scale sub-linearly because of caching and batching.

Solution 5: Progressive Generation

This was the biggest unlock. Instead of generating a perfect email in one shot, I break it into stages:

  1. Stage 1 (instant): Generate email structure + hook using cached patterns
  2. Stage 2 (background): Enrich with prospect-specific research
  3. Stage 3 (on-demand): Polish and personalize when user reviews

Users see Stage 1 results in under 2 seconds. Stages 2-3 run asynchronously, which spreads the computational load and lets me use cheaper batch processing.

The Numbers After 6 Months

  • Cost per email generated: $0.003 (down from $0.02)
  • Average response time: 1.8 seconds for first draft
  • Cache hit rate: 42%
  • API cost as % of revenue: 28% (healthy for SaaS)
  • Uptime: 99.7%

What I'd Do Differently

  1. Start with caching from day one. I added it in month 3 and kicked myself for not doing it earlier.
  2. Don't over-optimize early. I spent a week building a custom model fine-tune that saved $30/month. Not worth it at that scale.
  3. Monitor cost per request religiously. I have a Grafana dashboard that alerts me if cost-per-email exceeds $0.005.

The Takeaway

You don't need massive infrastructure funding to run an AI product at scale. Smart routing, aggressive caching, and batch processing got me from "this will bankrupt me" to "this is a real business" in about 3 months.

If you're building something similar, I'm happy to answer questions in the comments. And if you want to see the end result, check out ColdMailAI - it's $9/month because I actually figured out how to make that price work.


Building in public. Follow me for more technical deep dives on running an AI SaaS on a shoestring budget.

Top comments (0)