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-model-prices

v1.0.1

Published

Show per-model prices in CNY (in/out/cacheRead/cacheWrite + tiers) inside pi's built-in /model selector

Readme

pi-model-prices

Show per-model prices in CNY directly inside pi's built-in /model selector.

pi-model-prices: the built-in /model selector showing CNY prices on every row

No extra command to learn: /model (or Ctrl+L) now shows what each model costs.

Why

pi's built-in selector renders only model.id per row, so picking a model by price means memorising a table somewhere else. This extension puts the numbers where you choose.

Features

  • All four price metrics on every row — in / out price, plus cr (cacheRead) and cw (cacheWrite).
  • Tier warnings — ⚠ marks models whose price jumps above an input-token threshold; the highlighted model expands every tier.
  • CNY display — pi's catalog stores USD per 1M tokens; this converts at render time, so it never hardcodes a price.
  • Transparent rate — the USD→CNY rate actually in force, its source, and its refresh time are always printed in the detail block.
  • Live registry data — reads model.cost on every render, so catalog refreshes (including your models.json overrides) show up immediately.

Install

pi install npm:pi-model-prices

Then /reload (or restart pi). Verify with Ctrl+L.

Configuration

Optional config at ~/.pi/agent/model-selector-prices.json:

{
  "usdToCny": null,
  "liveRate": true,
  "refreshHours": 12
}

| Key | Default | Meaning | | --- | --- | --- | | usdToCny | null | Pin a fixed rate (e.g. 7.2). When set, live fetching is disabled. | | liveRate | true | false never hits the network — uses the cache, then the built-in default. | | refreshHours | 12 | How long a cached live rate stays fresh. |

Rate resolution order

  1. usdToCny in the config file — fixed override
  2. cached live rate in ~/.pi/agent/model-selector-prices-cache.json
  3. live fetch — open.er-api.com, falling back to jsdelivr / fawazahmed0
  4. a built-in default (6.72), only when nothing else is available

The rate in use is always visible in the selector's detail block, so a stale or fallback rate is never silent.

To keep everything offline and deterministic:

{ "usdToCny": 7.2, "liveRate": false }

How it works

The built-in selector renders only model.id per row, so this extension replaces ModelSelectorComponent.prototype.updateList with an equivalent implementation that appends prices. Costs come from the live model registry, resolved as models.json → models-store.json → built-in catalog.

Because it patches an internal method rather than using a public hook, a future pi release that changes updateList may require this wrapper to be re-checked. If prices stop appearing after a pi update, that is the first thing to look at.

Development

git clone [email protected]:kiwizhu0719/pi-model-prices.git
cd pi-model-prices
pi install "$PWD"     # pi installs from a path without copying

Edit extensions/index.ts, then /reload in pi to pick up changes.

Requirements

  • pi with an interactive (TUI) session — the selector only exists there.
  • Network access is optional; only used to refresh the exchange rate.

License

MIT — see LICENSE.


中文说明

在 pi 内置的 /model 选择器里直接显示每个模型的人民币价格,不需要记额外的命令。

  • 每一行显示四项指标:输入价 / 输出价(in/out)、缓存读 cr、缓存写 cw
  • ⚠ 表示该模型有阶梯价,高亮行下方会展开全部阶梯阈值
  • 单位为人民币/百万 token;pi 目录本身存的是美元,插件在渲染时按实时汇率换算,不写死价格
  • 汇率来源和刷新时间始终打印在详情块最后一行,走缓存或默认值时一眼可见

安装

pi install npm:pi-model-prices

然后 /reload 或重启 pi,按 Ctrl+L 打开 /model 查看。

汇率配置:~/.pi/agent/model-selector-prices.json

{ "usdToCny": 7.2, "liveRate": false }

想锁死汇率就用上面这样;留 "usdToCny": null + "liveRate": true 则自动联网取最新汇率(默认 12 小时缓存一次)。