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

@oma-home/pi-bailian

v0.1.0

Published

阿里云百炼 (DashScope) 模型 Provider —— pi 扩展,支持多 API Key 管理与精选模型目录

Readme

@oma-home/pi-bailian

English | 简体中文

@oma-home/pi-bailian = pi × OhMyAgent × 阿里云百炼。

一个 pi 扩展,注册**阿里云百炼(DashScope)**模型 Provider,提供精选模型目录与多 API Key 管理能力。

百炼不是 pi 的内置 Provider。pi 内置的是 qwen-token-plan / qwen-token-plan-cn 订阅产品,不覆盖百炼通用的 OpenAI 兼容端点。本扩展补上这个缺口,并修掉手写 models.json 时会踩的两个坑。

为什么需要这个扩展?

  1. developer role 400 报错 — pi 的 openai-completions 发送器默认用新版 OpenAI 的 developer 系统角色,百炼只认 system,不做处理的话每个请求都报 developer is not one of [...]。本扩展给每个模型设 supportsDeveloperRole: false,让 pi 改发 system

  2. 思考模型不输出推理流 — 百炼的思考模型(Qwen3.x / DeepSeek-V4 / GLM-5.x / Kimi-K2.x / MiniMax-M2.x)用顶层 enable_thinking 字段开关,并以 reasoning_content 流式返回推理——两者都不是 OpenAI 标准。本扩展接上 thinkingFormat: "qwen" + requiresReasoningContentOnAssistantMessages: true,推理开箱即用。

  3. 多 API Key 管理 — 支持配置多个百炼 API Key,每个 Key 可命名并自定义可用模型列表。通过 /bailian 命令一键切换,即时生效。

快速开始

安装

# 从 npm 安装(推荐)
pi install npm:@oma-home/pi-bailian

# 从 GitHub 安装
pi install git:github.com/oma-home/pi-bailian

# 本地开发测试
pi -e /path/to/pi-bailian

配置 API Key

方式一:多 Key 管理(推荐)

在 pi 会话中运行 /bailianAdd API Key,交互式配置:

  1. 输入 Key 名称(如 zhangsan
  2. 输入 API Key(在 百炼控制台 → API-KEY 获取)
  3. 勾选该 Key 可用的模型(多选)
  4. 保存,自动生效

配置存储在 ~/.pi/agent/bailian-keys.json

{
  "active": "zhangsan",
  "keys": [
    {
      "name": "zhangsan",
      "apiKey": "sk-xxxxxxxx",
      "models": ["glm-5.2", "kimi-k2.7-code", "qwen3.7-plus"]
    },
    {
      "name": "lisi",
      "apiKey": "sk-bbbbbbbb",
      "models": ["deepseek-v4-pro", "qwen3.7-max"]
    }
  ]
}

切换 Key:/bailianSwitch API Key,选择后即时生效。

方式二:环境变量(单 Key)

export DASHSCOPE_API_KEY=sk-xxxxxxxx

不创建配置文件时,自动回退到此方式,所有模型可用。

使用

# 命令行指定
pi --provider bailian --model qwen3.7-plus

# 会话中交互选择
/model              # 从 bailian/* 条目中选
/bailian            # 管理 API Key

精选模型目录

9 个精选模型,逐个对照百炼官方文档核实(2026-07)。定价为华北2(北京)原价(元/百万 token),非限时折扣价。

| 模型 ID | 上下文 | 推理 | 输入 | 输入 / 输出(¥/M) | 缓存 | |:---|:---|:---|:---|:---|:---| | deepseek-v4-pro | 1M | ✅ | 文本 | 12 / 24 | ✓ | | deepseek-v4-flash | 1M | ✅ | 文本 | 1 / 2 | ✓ | | glm-5.2 | 1M | ✅ | 文本 | 8 / 28 | — | | kimi-k2.6 | 256K | ✅ | 文本+图片 | 6.5 / 27 | ✓ | | kimi-k2.7-code | 256K | ✅(仅思考) | 文本+图片 | 6.5 / 27 | ✓ | | MiniMax-M2.5 | 192K | ✅(仅思考) | 文本 | 2.1 / 8.4 | — | | qwen3.7-flash | 1M | ✅ | 文本 | 0.2 / 0.8 | ✓ | | qwen3.7-max | 1M | ✅ | 文本 | 12 / 36 | ✓ | | qwen3.7-plus | 1M | ✅ | 文本 | 2 / 8 | ✓ |

缓存定价

标 ✓(支持百炼上下文缓存)的模型,按官方缓存计费规则:

  • cacheRead = 输入价的 10%
  • cacheWrite = 输入价的 125%

关于 maxTokens

官方未逐模型公布最大输出值,maxTokens 按模型档位给了保守默认值。如需更长单次输出,在 index.ts 中修改 MODELS 数组。

端点

https://dashscope.aliyuncs.com/compatible-mode/v1

百炼的 OpenAI 兼容 Chat Completions 端点。请求携带 Authorization: Bearer <api-key>

命令参考

| 命令 | 说明 | |:---|:---| | /bailian | 打开 API Key 管理菜单 | | ├ Switch API Key | 切换当前使用的 API Key | | ├ Add API Key | 添加新的 API Key(命名 + 选模型) | | └ Remove API Key | 删除已配置的 API Key |

开发

git clone https://github.com/oma-home/pi-bailian.git
cd pi-bailian
npm install          # 安装 typecheck 依赖
npx tsc --noEmit     # 类型检查
pi -e .              # 本地测试

数据来源

License

MIT


OhMyAgent 构建 — 你的 AI 指挥中心。