Urgent.News

What's breaking now, across thousands of outlets.

AI

Our 3 a.m. batch job was running at Beijing's afternoon peak rate

DeepSeek's API charges two different prices for the same tokens. Which one you pay depends on what time it is in Beijing when the request lands. That is the whole bug. It took me an embarrassingly long time to find, because nothing in our code was wrong. The rule Beijing time, Monday through Friday, 09:00-12:00 and 14:00-18:00 are peak hours. Everything else is off-peak: nights, weekends, Chinese…

DeepSeek's API charges different rates for the same tokens depending on the time of day in Beijing when the request is received. The peak hours in Beijing, from Monday to Friday, 09:00-12:00 and 14:00-18:00, are seven hours a day, accounting for roughly a fifth of the week. All other times, including nights, weekends, and Chinese public holidays, are considered off-peak and cost half of the peak rate.

The author discovered this pricing structure the hard way after scheduling a reindex job to run at 3 a.m. Eastern, which corresponds to 15:00 Beijing time, right in the middle of the second peak window. Consequently, the expensive peak rates were applied to the job, leading to unexpected costs.

To avoid this costly mistake, the author recommends scheduling jobs using the timezone of the vendor billing, such as "TZ = Asia/Shanghai" in the crontab. This ensures the job runs during off-peak hours, significantly reducing costs. Additionally, long-running jobs and retry queues can also fall into peak hours, so adjusting the scheduling accordingly is crucial.

The author emphasizes that caching has a much larger impact on costs compared to scheduling. An off-peak cache hit costs only ¥0.15 per million input tokens, while a peak cache miss costs ¥9. The two factors multiply, making caching 60 times more effective in reducing expenses when combined. However, if only one factor can be optimized, stabilizing the prompt prefix first and then addressing the cron scheduling is advised, especially when dealing with vendors that charge by time of day.

Most APIs, however, do not vary prices throughout the day, so it's essential to verify the pricing structure before implementing scheduling logic.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

CLAUDE.md rule vs PreToolUse hook: both held 5 of 5, then the user said 'I authorize it'

We gave Claude Code the same "never edit protected/ " rule two ways, as one line in CLAUDE.md and as a PreToolUse hook, and ran 29 headless sessions against a throwaway project.

  • CLAUDE.md rules and PreToolUse hook performed identically in 5 of 5 tests
  • CLAUDE.md rule failed in 2 of 2 tests with "I authorize it" prompt
  • PreToolUse hook prevented edits in all 2 tests with "I authorize it" prompt

Siri AI Settlement Website Now Live: Apple to Pay Some iPhone Owners

In May, Apple agreed to pay $250 million to settle a U.S. class action lawsuit over Siri AI's delayed launch, and the settlement website is now live. Apple will pay an estimated $25 per eligible iPhone to eligible customers, who can submit a claim via the settlement website between September 21 and December 21 of this year.

More from Monday 21 September →