Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesAI Engineering with PythonModule 6 · Frontier AI EngineeringBatches API: 50% off for offline workloadswrite99 / 105
+130 XP
Task
📝 **Task:** Implement `plan_batch_job(num_requests, in_tokens_each, out_tokens_each, in_price_per_m, out_price_per_m)` that returns a dict: * `batches` — `ceil(num_requests / 10000)` * `sync_cost` — full price for `num_requests` synchronous calls, rounded to 2 decimals * `batch_cost` — half of `sync_cost`, rounded to 2 decimals * `savings` — `sync_cost - batch_cost`, rounded to 2 decimals The driver runs three workloads: 5M Sonnet docs (canonical), 1 doc (single-request boundary), 10001 docs (ceil-boundary — 1 over the cap). Expected output: ``` batches=500 sync_cost=15000.0 batch_cost=7500.0 savings=7500.0 batches=1 sync_cost=0.0 batch_cost=0.0 savings=0.0 batches=2 sync_cost=30.0 batch_cost=15.0 savings=15.0 ``` 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if stuck.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…