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

ai-subscription-api

v0.0.2

Published

Use ChatGPT, Claude, and Gemini subscriptions programmatically without API keys

Readme

AI Subscription API

CI npm version

Use your ChatGPT Plus/Pro, Claude Pro/Max, and Gemini subscriptions programmatically. No API keys required.

Installation

bun add ai-subscription-api

Requirements

  • Bun runtime (Node.js is not supported)

Quick Start

import { SubscriptionClient } from "ai-subscription-api"

const client = new SubscriptionClient()

// Login (opens browser)
const { session, complete } = await client.login("claude", "browser")
console.log(`Open: ${session.url}`)
// For Claude, paste the code from the browser
const code = "..." // from browser
await complete(code)

// Chat
const response = await client.ask("claude", "What is the meaning of life?")
console.log(response)

Providers

| Provider | ID | Subscription | | -------- | --------- | ----------------- | | Claude | claude | Pro/Max | | ChatGPT | chatgpt | Plus/Pro | | Gemini | gemini | Free/Pro |

Login Methods

Claude

const { session, complete } = await client.login("claude", "browser")
console.log(session.url) // Open this URL
console.log(session.instructions) // "After authorizing, copy and paste the code shown."
Bun.spawn(["open", session.url])
const code = await getCodeFromUser()
await complete(code)

ChatGPT

const { session, complete } = await client.login("chatgpt", "browser")
Bun.spawn(["open", session.url])
await complete() // Waits for OAuth callback

Gemini

const { session, complete } = await client.login("gemini", "browser")
Bun.spawn(["open", session.url])
await complete() // Waits for OAuth callback

Chat

// Simple
const answer = await client.ask("claude", "Hello!")

// With options
const response = await client.chat("claude", [{ role: "user", content: "Hello!" }], {
  model: "claude-sonnet-4-20250514",
  maxTokens: 1024,
  system: "You are a helpful assistant.",
})

console.log(response.content)
console.log(response.usage) // { input: 10, output: 50 }

Streaming

await client.chat("claude", messages, {
  stream: true,
  onChunk: (chunk) => process.stdout.write(chunk),
})

Custom Credential Storage

import {
  SubscriptionClient,
  MemoryCredentialStore,
  FileCredentialStore,
  StaticCredentialStore,
} from "ai-subscription-api"

// In-memory (session only)
const client = new SubscriptionClient({
  store: new MemoryCredentialStore(),
})

// Custom file path
const client = new SubscriptionClient({
  store: new FileCredentialStore("/path/to/auth.json"),
})

// Pre-loaded credentials (read-only)
const client = new SubscriptionClient({
  store: new StaticCredentialStore({
    claude: {
      type: "oauth",
      refresh: "...",
      access: "...",
      expires: Date.now() + 3600000,
    },
  }),
})

Custom Credential Store

Implement the CredentialStore interface:

import type { CredentialStore, Credentials } from "ai-subscription-api"

class RedisCredentialStore implements CredentialStore {
  async get(provider: string): Promise<Credentials | undefined> { ... }
  async set(provider: string, credentials: Credentials): Promise<void> { ... }
  async remove(provider: string): Promise<void> { ... }
  async all(): Promise<Record<string, Credentials>> { ... }
}

const client = new SubscriptionClient({
  store: new RedisCredentialStore()
})

Available Models

Claude

  • claude-sonnet-4-5-20250929 (default)
  • claude-opus-4-5-20251101
  • claude-opus-4-6
  • claude-haiku-4-5-20251001

ChatGPT

  • gpt-5.2 (default)
  • gpt-5.1-codex
  • gpt-5.1-codex-mini
  • gpt-5.1-codex-max
  • gpt-5.2-codex
  • gpt-5.3-codex

Gemini

  • gemini-3-flash-preview (default)
  • gemini-3-pro-preview
  • gemini-2.5-pro
  • gemini-2.5-flash
  • gemini-2.0-flash
  • gemini-2.0-flash-lite

Scripts

# Run tests
bun test

# Run interactive CLI example
bun run example

Use bun run example to play with the APIs.

Notes

  • Claude OAuth credentials require the claude-cli user agent
  • ChatGPT Codex API requires stream: true and store: false
  • Credentials are stored in ~/.local/share/subscription-auth/auth.json by default
  • Tokens are automatically refreshed when expired