@aliou/pi-neuralwatt

中文文档
0.19.1发布于 2026/11/05MITTypeScriptES Module构建来源已验证近 30 天下载 2176

banner

原始使用文档
文档目录14 节
  1. Installation
  2. Get API Key
  3. Configure Credentials
  4. Install Extension
  5. Usage
  6. API surface
  7. Quota Command
  8. Quota Warnings
  9. Library use
  10. Settings
  11. Model list
  12. Development
  13. Requirements
  14. Links

banner

Pi Neuralwatt Extension

A Pi extension that adds Neuralwatt as a model provider, giving you access to open-source models through an OpenAI-compatible API with energy transparency.

Installation

Get API Key

Sign up here to get an API key (referral link).

Configure Credentials

The extension uses Pi's credential storage. Add your API key to ~/.pi/agent/auth.json (recommended):

{
  "neuralwatt": { "type": "api_key", "key": "your-api-key-here" }
}

Or set environment variable:

export NEURALWATT_API_KEY="your-api-key-here"

Install Extension

# From npm
pi install npm:@aliou/pi-neuralwatt

# From git
pi install git:github.com/aliou/pi-neuralwatt

# Local development
pi -e ./extensions/provider/index.ts

Usage

Once installed, select neuralwatt as your provider and pick a model:

/model neuralwatt kimi-k3

API surface

Neuralwatt serves every model on two APIs. Pick one in /neuralwatt:settings → API (or set provider.api in the extension config):

  • openai-completions (default): the OpenAI-compatible chat/completions endpoint.
  • anthropic-messages: the Anthropic-compatible POST /v1/messages endpoint, which streams native tool use and thinking blocks.

Both use the same model ids. The setting applies on /reload. Cost, energy, and quota tracking work on both.

Quota Command

Check your API usage at a glance:

/neuralwatt:quota

The quota command shows three tabs:

  • Subscription (when subscribed): plan details, energy quota with progress bar, billing period
  • Credits: credit balance with progress bar, accounting method
  • Usage & Key: monthly usage (cost, requests, tokens, energy), API key info, key allowance, rate limits

https://github.com/user-attachments/assets/a8994940-c467-4744-a0f2-833cb63923ff

Quota Warnings

When enabled, the extension notifies you when credits or energy are running low. With an active subscription, only energy warnings fire (credits are on-demand top-up only).

Library use

Use @aliou/pi-neuralwatt/provider outside the coding agent:

Install the library with its runtime peers, @earendil-works/pi-ai and typebox.

import { InMemoryModelsStore } from "@earendil-works/pi-ai";
import { createModels } from "@earendil-works/pi-ai/models";
import createNeuralwattProvider from "@aliou/pi-neuralwatt/provider";

const models = createModels({ modelsStore: new InMemoryModelsStore() });
models.setProvider(
  createNeuralwattProvider({
    baseUrl: "https://gateway.example.com/v1",
    provenance: { referer: "https://my-app.example" },
  }),
);
await models.refresh();

All options are optional. Without credentials, the provider lists and refreshes the public catalog. NEURALWATT_API_KEY or a stored credential enables keyed models. The X-NW-Conversation-ID header comes from each request's sessionId. Set provenance: { enabled: false } to stop adding the Referer and conversation ID headers to inference requests.

Settings

Configure features with /neuralwatt:settings:

  • API — Choose between openai-completions (default) and anthropic-messages; applies on /reload
  • API base URL — Send requests to a different base URL, such as a gateway; empty uses the Neuralwatt API
  • Quota command — Show/hide /neuralwatt:quota
  • Quota warnings — Enable/disable low quota notifications

The provider itself cannot be disabled — it is always loaded.

Model list

The extension ships a built-in model list, so it works offline on first start. Pi refreshes the catalog from the Neuralwatt API in the background (authenticated when an API key is configured, so key-scoped models appear too) and caches it in ~/.pi/agent/models-store.json. pi update --models forces a refresh.

Development

git clone https://github.com/aliou/pi-neuralwatt.git
cd pi-neuralwatt
pnpm install
pnpm run typecheck
pnpm run lint
pnpm run test
pnpm run check:models   # compare the built-in model list with the live API

The pre-commit hook runs typecheck, lint, the lockfile check, and the changeset check. Releases use Changesets.

Requirements

  • Pi coding agent 1.4 or later
  • Neuralwatt API key (configured in ~/.pi/agent/auth.json or via NEURALWATT_API_KEY)

版本与发布记录

@aliou/pi-neuralwatt 共发布 52 个版本,首次发布于 2026/04/20;过去 12 个月发布了 52 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.19.1latest2026/11/052 天前
0.19.02026/11/044 天前
0.18.12026/11/025 天前
0.18.02026/10/1128 天前
0.17.02026/10/1028 天前
0.16.32026/10/071 个月前

关于 @aliou/pi-neuralwatt 的常见问题

如何安装 @aliou/pi-neuralwatt?

在项目目录运行 npm install @aliou/pi-neuralwatt,或使用 pnpm add / yarn add / bun add。

@aliou/pi-neuralwatt 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aliou/pi-neuralwatt 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aliou/pi-neuralwatt 可以商用吗?

@aliou/pi-neuralwatt 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aliou/pi-neuralwatt 的下载量有多少?

根据 npm 官方下载统计,@aliou/pi-neuralwatt 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,176 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aliou/pi-neuralwatt 还在维护吗?

最新版本 0.19.1 发布于 2026/11/05(2 天前);至今共发布 52 个版本,其中过去 12 个月发布了 52 个;首次发布于 2026/04/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。