The 300-second timeout with one SDK retry (line 341) is wrapped by a 3-attempt tenacity retry on the batch path (line 1807) and, after the batch gives up, by a per-paragraph sweep in which each paragraph has its own 3-attempt retry (line 1513).
A batch that times out is therefore attempted up to 6 times, about 30 minutes, which is the stall the comment above REQUEST_LIMITS set out to prevent, and each abandoned attempt may still be generated and billed.
- To confirm
- Whether any grouped request on the endpoints people use (reasoning models at high effort, slow local servers, gateways) takes longer than 300 seconds, and whether the endpoint keeps generating and billing after the client gives up. A run log with request durations, or the provider's usage page against the run's own meter, shows it.
- Change, if confirmed
- Keep one retry layer for timeouts: either set max_retries to 0 on this client and let tenacity own retries, or exclude APITimeoutError from the tenacity retry on the batch path and let the existing one-by-one fallback (or the ladder) handle it. Non-streaming requests can also use streaming so a slow but working answer is not mistaken for a dead one.
- Why it matters
- A client timeout stops the client waiting; it does not stop the server generating. Each retry after a timeout pays the prompt again while the abandoned answer may still be billed, and the same request times out the same way.
- Estimate
- about 18k output and 17k prompt tokens per 1,000 calls (estimate, if timeouts happen at all)
What the estimate assumes
0.2% of grouped requests exceed 300 seconds; each produces 5 extra attempts of about 1.7k prompt and 1.8k output tokens, billed although abandoned. If the timeouts come from a gateway that never answers, no tokens are lost and the cost is only wall time.