Skip to main content

What This Covers

  • The exact window the discount applies to (8 PM – 6 AM America/Los_Angeles) and what it covers
  • Realistic monthly savings: a team running 1,000 swarm jobs/day at daytime rates vs. overnight rates
  • A drop-in cron recipe for scheduling overnight batch swarms from any server
  • An Airflow DAG pattern for production-grade overnight orchestration
  • The two failure modes to watch: timezone drift and on-the-boundary jobs

Why This Matters

The single highest-ROI cost lever the Swarms API offers is its overnight discount: swarm-completion input and output tokens are billed at 50% between 8 PM and 6 AM Pacific time. For any workload that doesn’t need sub-second turnaround — overnight reports, daily research digests, RAG-index refreshes, training-data generation, backfills, evaluation suites — this is free money you collect by changing when the job runs, not what the job runs. A team spending $10,000/month on swarm jobs that could shift to the overnight window saves roughly $4,500/month with zero code-quality tradeoff. This guide makes that shift mechanical.

How the Discount Works

The discount is applied server-side, in api/swarm_completions.py, inside the calculate_swarm_cost function. When a swarm completion finishes, the billing function checks the current hour in America/Los_Angeles:
What’s discounted:
  • swarm_completions_input_cost_per_1m — full 50% off
  • swarm_completions_output_cost_per_1m — full 50% off
What’s NOT discounted:
  • swarm_completions_agent_cost — the $0.01 per-agent fee is billed full price
For most production workloads the per-agent fee is a rounding error, but for high-fan-out heavy swarms with 20+ agents per job, it stays linear. Your savings ceiling on token costs is exactly 50%; agent-fee savings are 0%.
The check is on the time the run finishes, in Pacific. A job that starts at 5:55 AM and finishes at 6:02 AM PT will be billed at the daytime rate. Schedule batches to land cleanly inside the window — see “Scheduling on the Boundary” below.

The Monthly Math

Take a realistic mid-sized team: 1,000 swarm jobs per day, each averaging:
  • 5 agents
  • 6,000 input tokens
  • 3,000 output tokens

Daytime baseline (jobs run during business hours)

Per-job cost:
Per day: $0.1445 * 1,000 = $144.50 Per 30-day month: $4,335.00

Overnight: same workload, scheduled 8 PM – 6 AM PT

Per-job cost:
Per day: $0.09725 * 1,000 = $97.25 Per 30-day month: $2,917.50

Savings

$4,335 – $2,917.50 = $1,417.50/month saved by shifting the same workload into the overnight window. Annualized: $17,010. Zero code changes to the agents themselves — just when they run. For larger workloads the savings scale linearly until the agent-fee floor dominates. At 10,000 jobs/day this same calculation yields $14,175/month in savings.

Verifying the Discount in Your Response

Every swarm completion response includes a discount_active flag. Check it programmatically to confirm your scheduling actually landed in the window:
If discount_active is False on a job you scheduled for overnight, your cron or worker timezone is wrong — see the troubleshooting section below.

Scheduling Recipe 1: System cron

The simplest possible setup. Add this to your crontab and you’re done. Note that cron schedules are interpreted in the system’s local time — be deliberate about which timezone your server runs in.
If your server runs in UTC (common on cloud VMs), convert explicitly:
CRON_TZ is supported by Vixie cron and systemd timers — it makes your schedule survive DST shifts without manual adjustment. The batch script itself is the same swarm call you’d write at any other time. The discount is applied server-side based on when the request hits the API, not on any flag you set.

Scheduling Recipe 2: Airflow DAG

For teams already running Airflow, this is the production-grade pattern. The DAG runs once per night at 9 PM PT, fans out to N batch jobs in parallel via batch_swarm_completions, and writes a cost-discount audit so you can prove the 50% landed.
The audit_discount task is the bit most teams forget. Without it, a daylight-savings change or a quiet timezone reconfiguration can move your overnight job back into the daytime band and you won’t notice until the invoice arrives.

Scheduling on the Boundary

The discount window is hour >= 20 or hour < 6 in Pacific. Two practical implications:
  1. 5:59 AM PT is still discounted; 6:00 AM PT is not. If your job is long-running, start it earlier so it finishes inside the window.
  2. 8:00 PM PT is the earliest discounted moment. A job that starts at 7:55 PM lands at the full-price rate.
Give yourself a buffer. Schedule starts at 9 PM PT (one hour past the boundary) and target completion by 5 AM PT (one hour before the boundary closes). That gives you eight clean hours of discount and protects against DST-driven hour shifts.

Troubleshooting

SymptomCauseFix
discount_active: false on a job you scheduled overnightScheduler ran in UTC/local-server-time, not PacificSet CRON_TZ=America/Los_Angeles or convert in your DAG
Discount lands on some runs in the batch but not othersLong-running job crossed the 6 AM boundaryStart earlier; cap batch size so all runs finish before 5 AM PT
Discount applied but bill barely changedAgent fee dominates (heavy-swarm pattern with many agents)Token costs are 50% off; the $0.01 * num_agents fee is not. Prune agents per the Cost Optimization Playbook
Daylight savings broke the scheduleCron is using a fixed UTC offset that no longer matches PTUse CRON_TZ=America/Los_Angeles (or Airflow’s tz=...) — these handle DST

When NOT to Use Night Mode

Night-mode is a batch-economics play. Don’t shoehorn the following into the overnight window — the user-experience cost outweighs the discount:
  • Interactive chat or assistant traffic — users want answers now
  • Webhook-driven agent runs where the upstream caller is blocking
  • Realtime fraud / moderation / classification pipelines
  • Anything where a 6-hour latency would break a contract
Use it for everything else: backfills, analyst digests, RAG-index refreshes, evaluation suites, content pre-generation, model-comparison sweeps, and bulk research jobs.

Next Steps