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-modelscope

v0.1.2

Published

Pi extension for the ModelScope OpenAI-compatible provider

Readme

pi-modelscope

Pi extension for ModelScope's OpenAI-compatible inference API. It registers the modelscope provider, supports streaming chat completions and multimodal text + image messages, refreshes the available model catalog from /v1/models in the background, and provides commands for inspecting models, capabilities, and session usage.

Install

pi install npm:pi-modelscope

For a local checkout:

pi -e .

Configuration

Set a ModelScope Token before starting pi:

export MODELSCOPE_API_KEY="ms-..."
  • Base URL: https://api-inference.modelscope.cn/v1
  • Provider id: modelscope
  • Auth: MODELSCOPE_API_KEY (sent as Authorization: Bearer <token>)

The token is read from the environment and is not included in this package. Do not commit a real token to source control.

Or store the token through Pi:

/login modelscope

Pi saves it in ~/.pi/agent/auth.json; MODELSCOPE_API_KEY remains supported as a fallback.

The documented multimodal seed model is available immediately:

pi --model modelscope/Qwen/Qwen3.8-Flash-Next "你好,介绍一下你自己"

ModelScope's OpenAI-compatible API also accepts image parts. In pi, attach an image to a message while using a model whose catalog entry advertises image input; the extension passes the resulting OpenAI-compatible message to ModelScope.

Equivalent API usage outside pi:

from openai import OpenAI

client = OpenAI(
    base_url="https://api-inference.modelscope.cn/v1",
    api_key="ms-your-token",
)

response = client.chat.completions.create(
    model="Qwen/Qwen3.8-Flash-Next",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "描述这幅图"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://modelscope.oss-cn-beijing.aliyuncs.com/demo/images/audrey_hepburn.jpg",
                },
            },
        ],
    }],
    stream=True,
)

for chunk in response:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Commands

The extension registers the following commands:

| Command | Description | |---|---| | /modelscope-models [image\|vision\|audio\|video\|reasoning\|tools] | List ModelScope models with capabilities, context/output limits; an optional filter narrows the table. | | /modelscope-usage | Show token/cost usage accumulated in the current Pi process. |

Examples:

/modelscope-models
/modelscope-models vision
/modelscope-usage

/modelscope-usage is based on message_end usage reported by completed assistant messages and is therefore local to the current Pi process. ModelScope's OpenAI-compatible API does not expose a uniform account-level billing/usage endpoint through this provider, so this command is not an account invoice.

Model discovery

Qwen/Qwen3.8-Flash-Next is registered synchronously as a seed model, so the provider remains usable during startup and when the network is unavailable. Pi subsequently calls https://api-inference.modelscope.cn/v1/models; a successful result replaces the seed list and is persisted for later offline starts. Failed or empty discovery falls back to the cached catalog or the seed model.

Development

npm test

The extension uses pi-ai's openai-completions API and resolves both the newer lazy subpath and the older bare-package export for compatibility with different pi versions.

Release to npm

The GitHub Actions workflow in .github/workflows/publish.yml publishes on tags matching v* and also supports manual dispatch. It runs npm ci, npm test, and publishes with npm provenance:

npm version patch
# or: npm version minor / npm version major
git push origin main --follow-tags

Before the first release, configure npm Trusted Publishing for the pgciq/pi-modelscope repository and the Publish to npm workflow. The workflow uses GitHub OIDC (id-token: write) and does not store an npm token in the repository.