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

@piedpiperrh/sdk

v0.2.0

Published

TypeScript client for the Pied Piper distributed inference API (OpenAI-compatible chat completions served by community GPUs).

Downloads

250

Readme

@piedpiperrh/sdk

TypeScript client for the Pied Piper distributed inference API — OpenAI-compatible chat completions served by community GPUs.

Zero dependencies. Node ≥ 18, Bun, Deno, and browsers.

Install

npm install @piedpiperrh/sdk

Quick start

Mint an API key in the dashboard (Settings → API keys), then:

import PiedPiper from "@piedpiperrh/sdk";

const client = new PiedPiper({ apiKey: process.env.PIEDPIPER_API_KEY! });

const models = await client.models.list();

const completion = await client.chat.completions.create({
  model: models[0].id,
  messages: [{ role: "user", content: "Explain WebGPU in one paragraph." }],
});

console.log(completion.choices[0].message.content);

Streaming

const stream = await client.chat.completions.create({
  model: "llama-3.2-3b-instruct-q4f16_1",
  messages: [{ role: "user", content: "Write a haiku about GPUs." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta.content ?? "");
}

Routing options

Every request accepts a second options argument:

await client.chat.completions.create(params, {
  host: "provider-session-uuid", // pin to one specific host
  priority: true,                // jump the queue on that host (costs more)
  waitSeconds: 30,               // wait up to 30s for capacity instead of failing fast
  signal: abortController.signal,
});

Errors

Failed requests throw PiedPiperError with status (HTTP) and code (e.g. insufficient_credits, no_capacity, rate_limited).

import { PiedPiperError } from "@piedpiperrh/sdk";

try {
  await client.chat.completions.create(params);
} catch (err) {
  if (err instanceof PiedPiperError && err.code === "no_capacity") {
    // retry with { waitSeconds: 60 }
  }
}

Tool calling

Pass OpenAI-format tools; requests route to tool-capable console hosts automatically.

const r = await client.chat.completions.create({
  model: "llama-3.2-3b-instruct-q4f16_1",
  messages: [{ role: "user", content: "What's the weather in Paris?" }],
  tools: [{
    type: "function",
    function: {
      name: "get_weather",
      description: "Get current weather for a city",
      parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"] },
    },
  }],
});

if (r.choices[0].finish_reason === "tool_calls") {
  for (const call of r.choices[0].message.tool_calls!) {
    console.log(call.function.name, JSON.parse(call.function.arguments));
  }
}

Vision

Send images as inline data URLs in content-part arrays (remote image URLs are not fetched). Requests route to hosts serving vision models (llava, llama3.2-vision, …).

await client.chat.completions.create({
  model: "llava-1.6-mistral-7b-q4f16_1",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What's in this image?" },
      { type: "image_url", image_url: { url: `data:image/png;base64,${b64}` } },
    ],
  }],
});

Supported parameters

model, messages (string or content-part arrays), stream, temperature, top_p, max_tokens, stop, tools, tool_choice. n must be 1 — multiple choices per request aren't supported.

Self-hosted / preview deployments

new PiedPiper({ apiKey, baseURL: "https://your-deployment.example.com" });