npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-deepseek-pricing-by-time

v0.2.0

Published

Time-of-day-aware DeepSeek cost accounting for pi: re-prices every DeepSeek assistant message with the official peak/off-peak rates in effect at the message's own UTC timestamp, so session totals, the footer, the statusline cost segment, and exports match

Downloads

107

Readme

pi-deepseek-pricing-by-time

Time-of-day-aware DeepSeek cost accounting for pi.

DeepSeek prices every request with peak/off-peak (valley) rates that depend on the hour of day, but pi's cost display is static: it applies one fixed rate set from the model metadata to every message. This extension fixes that by re-pricing each DeepSeek assistant message with the rate tier that was actually in effect when the message was produced, so everything pi derives from per-message cost — session totals, the footer, the statusline cost segment, /usage, exports — matches what DeepSeek bills.

How it works

  • Hooks message_end (the same event pi's own docs use for cost correction) and, for assistant messages from the deepseek provider, recomputes usage.cost from the message's token counts (input, output, cacheRead, cacheWrite) using the peak or off-peak rate in effect at the message's own timestamp (UTC).
  • pi's session totals are the sum of per-message usage.cost.total, so the corrected values flow into every cost display automatically — no other state to sync.
  • Also registers the /deepseek-tier command to show which tier is active right now, and sets a footer status (peak ⚠️/off-peak) that only updates when the tier flips (disableable, see Configuration).

Official rate schedule (as of 2026)

Peak hours: 01:00–04:00 & 06:00–10:00 UTC (09:00–12:00 & 14:00–18:00 Beijing). Off-peak rates are exactly half of peak. DeepSeek does not charge for cache writes.

| Model | Tier | Input (cache miss) | Output | Cache hit (input) | Cache write | |-------|------|--------------------|--------|-------------------|-------------| | deepseek-v4-flash | peak | $0.44 /M | $1.32 /M | $0.014 /M | $0 | | deepseek-v4-flash | off-peak | $0.22 /M | $0.66 /M | $0.007 /M | $0 | | deepseek-v4-pro | peak | $1.32 /M | $3.96 /M | $0.044 /M | $0 | | deepseek-v4-pro | off-peak | $0.66 /M | $1.98 /M | $0.022 /M | $0 | | deepseek-v4-flash-vision-exp | peak | $0.44 /M | $1.32 /M | $0.014 /M | $0 | | deepseek-v4-flash-vision-exp | off-peak | $0.22 /M | $0.66 /M | $0.007 /M | $0 |

Install

pi install npm:pi-deepseek-pricing-by-time

or from a local clone of this repo:

pi install ./extensions/deepseek-pricing-by-time

Usage

When a DeepSeek response completes, its cost is re-priced at the tier in effect for that message's timestamp:

  • message_end corrects the stored per-message cost before it is summed into session totals, so the footer/statusline cost segment is accurate in real time.
  • /deepseek-tier reports the currently active tier and its rates (useful for deciding when to run a batch).

Configuration

The footer tier status is on by default. It can be disabled from project settings (when the project is trusted) or global settings, with project settings taking precedence:

{
  "deepseekPricingByTime": false
}

or the object form:

{
  "deepseekPricingByTime": {
    "showTierStatus": false
  }
}

Cost re-pricing itself is always on; only the footer status indicator is affected.

Optionally: keep models.json as the fallback

If you also override DeepSeek rates in ~/.pi/agent/models.json (e.g. with the off-peak values, since most of the day is off-peak), keep them — they remain the baseline for any message this extension does not touch (for example other frontends that consume your config). This extension corrects the display on top of them.

Customizing

The rate table and peak windows live in the top of deepseek-pricing-by-time.ts (PEAK_HOURS_UTC and RATES). Edit them there if DeepSeek changes the schedule or prices, or to add other models. The peak windows are defined in UTC on purpose — DeepSeek publishes them in UTC and your local timezone must not affect the tier.

Compatibility

  • pi 0.84+ (uses the message_end extension event and ctx.ui status API).
  • Tested with deepseek-v4-flash, deepseek-v4-pro, and deepseek-v4-flash-vision-exp on the official DeepSeek API.
  • Cost correctness is display-side: like all pi cost accounting, it is an estimate based on reported usage tokens and published rates, not an invoice.

License

MIT