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

@onlist/sdk

v0.2.0

Published

Official JavaScript/TypeScript SDK for Onlist, the AI API marketplace. Access 200+ AI models (GPT, Claude, Gemini, DeepSeek, Llama) through a unified OpenAI-compatible API with provider routing, marketplace data, and competitive pricing.

Readme

Onlist JavaScript/TypeScript SDK

The official JavaScript/TypeScript SDK for Onlist, the AI API marketplace. Access 200+ AI models through a unified, OpenAI-compatible API with intelligent provider routing and competitive pricing.

Installation

npm install @onlist/sdk

Quick Start

import { Onlist } from "@onlist/sdk";

const client = new Onlist({ apiKey: "sk-..." });

const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4",
  messages: [{ role: "user", content: "Hello!" }],
});

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

Authentication

The SDK looks for API keys in this order:

  1. apiKey constructor parameter
  2. ONLIST_API_KEY environment variable
  3. OPENAI_API_KEY environment variable (OpenAI SDK fallback)
// Explicit key
const client = new Onlist({ apiKey: "sk-..." });

// From ONLIST_API_KEY
// export ONLIST_API_KEY=sk-...
const client = new Onlist();

// Falls back to OPENAI_API_KEY if ONLIST_API_KEY is not set
// export OPENAI_API_KEY=sk-...
const client = new Onlist();

Provider Routing

Route requests to specific providers on the Onlist marketplace:

// Pin to a specific provider
const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4",
  messages: [{ role: "user", content: "Hello!" }],
  provider: { only: ["alice-shop"] },
});

// Sort by price
const response = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  provider: { sort: "price" },
});

// Prioritize specific providers with fallback
const response = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  provider: {
    order: ["alice-shop", "bob-ai"],
    allow_fallbacks: true,
  },
});

Streaming

const stream = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4",
  messages: [{ role: "user", content: "Tell me a story" }],
  stream: true,
});

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

Marketplace API

Browse models and providers on the Onlist marketplace:

// List models with pricing
const models = await client.marketplace.models.list({ limit: 10 });
console.log(`Found ${models.total} models`);
for (const model of models.data) {
  console.log(`${model.id}: $${model.pricing?.prompt}/M tokens`);
}

// Search models
const results = await client.marketplace.models.list({ q: "claude" });

// Get detailed model info with all provider offers
const detail = await client.marketplace.models.get("anthropic/claude-sonnet-4");
for (const offer of detail.providers) {
  console.log(`${offer.name}: $${offer.price_input_usd}/M input`);
}

// List providers
const providers = await client.marketplace.providers.list();
for (const provider of providers.items) {
  console.log(`${provider.name} (${provider.listing_count} models)`);
}

// Get provider profile
const profile = await client.marketplace.providers.get("alice-shop");

Rankings API

Access model and app usage rankings:

// Model usage leaderboard
const rankings = await client.marketplace.rankings.models({
  sort: "popular",
  window: "week",
});
for (const entry of rankings.leaderboard) {
  console.log(`#${entry.rank} ${entry.model_name} (${entry.total_requests} requests)`);
}

// Trending models
const trending = await client.marketplace.rankings.models({
  sort: "trending",
  window: "month",
});

// App rankings
const apps = await client.marketplace.rankings.apps({
  sort: "popular",
  window: "month",
  limit: 10,
});
for (const app of apps.apps) {
  console.log(`#${app.rank} ${app.title} (${app.domain})`);
}

Error Handling

OpenAI-compatible calls (chat.completions, embeddings, etc.) throw standard openai errors. Marketplace calls throw onlist errors:

import OpenAI from "openai";
import { AuthenticationError, NotFoundError } from "@onlist/sdk";

// OpenAI-compatible endpoints throw openai errors
try {
  await client.chat.completions.create({ model: "gpt-4o", messages: [] });
} catch (e) {
  if (e instanceof OpenAI.AuthenticationError) {
    console.log("Invalid API key");
  }
}

// Marketplace endpoints throw onlist errors
try {
  await client.marketplace.models.get("nonexistent/model");
} catch (e) {
  if (e instanceof NotFoundError) {
    console.log("Model not found");
  }
  if (e instanceof AuthenticationError) {
    console.log("Invalid API key for marketplace");
  }
}

Retry Configuration

Marketplace API calls automatically retry on transient failures (408, 429, 5xx) with exponential backoff:

const client = new Onlist({
  apiKey: "sk-...",
  maxRetries: 3, // default: 2
});

Migration from OpenAI

Replace the openai import with onlist:

- import OpenAI from "openai";
+ import { Onlist } from "@onlist/sdk";

- const client = new OpenAI({ apiKey: "sk-..." });
+ const client = new Onlist({ apiKey: "sk-..." });

// All existing code works unchanged
const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});

Migration from OpenRouter

- import OpenAI from "openai";
+ import { Onlist } from "@onlist/sdk";

- const client = new OpenAI({
-   baseURL: "https://openrouter.ai/api/v1",
-   apiKey: process.env.OPENROUTER_API_KEY,
- });
+ const client = new Onlist();

// Provider routing syntax is compatible
const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4",
  messages: [{ role: "user", content: "Hello!" }],
});

TypeScript

The SDK is written in TypeScript and ships with full type definitions. All marketplace response types are exported:

import type {
  Model,
  Provider,
  ProviderRouting,
  ModelRankingsResponse,
  AppRankingsResponse,
} from "@onlist/sdk";

Links

License

MIT