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

blackboxify

v1.0.0

Published

BlackboxAI API client with OpenAI-compatible interface, streaming support, multiple auth accounts, and token pricing

Readme

Blackboxify

npm version License: MIT

A powerful Node.js client for BlackboxAI with an OpenAI-compatible interface, streaming support, multiple auth accounts, and token pricing.

Features

  • 🔄 OpenAI-Compatible Interface: Drop-in replacement for OpenAI's chat completion API
  • 🌊 Streaming Support: Real-time streaming responses with token counting
  • 🔑 Multiple Auth Accounts: Automatic retry with multiple accounts on rate limits
  • 💰 Token Pricing: Accurate token counting and cost estimation
  • 🚀 High Performance: Optimized for speed and reliability
  • 🛡️ Error Handling: Comprehensive error handling and rate limit detection

Installation

npm install blackboxify

Quick Start

import { BlackboxAI } from 'blackboxify';

const client = new BlackboxAI({
  models: {
    "blackboxai-default": {
      id: "blackboxai-default",
      input: 0,
      output: 0
    }
  },
  auth: [
    {
      email: "[email protected]",
      customer_id: "your_customer_id"
    }
  ]
});

// Basic chat completion
const response = await client.chat.completions.create({
  model: "blackboxai-default",
  messages: [
    { role: "user", content: "Hello, how are you?" }
  ],
  max_tokens: 50,
  temperature: 0.7
});

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

Streaming Example

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

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

Configuration

Client Options

const client = new BlackboxAI({
  models: {
    // Configure available models with pricing
    "model-name": {
      id: "model-identifier",
      input: 2.5,  // Cost per 1M input tokens
      output: 10   // Cost per 1M output tokens
    }
  },
  auth: [
    // Multiple auth accounts for automatic retry
    {
      email: "[email protected]",
      customer_id: "cus_account1"
    },
    {
      email: "[email protected]",
      customer_id: "cus_account2"
    }
  ]
});

Request Options

const response = await client.chat.completions.create({
  model: "model-name",          // Model identifier
  messages: [],                 // Array of message objects
  max_tokens: 4096,            // Maximum tokens in response
  temperature: 0.7,            // Response randomness (0-1)
  stream: false,               // Enable streaming mode
  user: "user-identifier"      // Optional user identifier
});

Response Format

Regular Response

{
  id: "chatcmpl-123",
  object: "chat.completion",
  created: 1677858242,
  model: "model-name",
  choices: [{
    index: 0,
    message: {
      role: "assistant",
      content: "Response content here"
    },
    finish_reason: "stop"
  }],
  usage: {
    prompt_tokens: 10,
    completion_tokens: 20,
    total_tokens: 30,
    cost: 0.0004
  }
}

Streaming Response

{
  id: "chatcmpl-123",
  object: "chat.completion.chunk",
  created: 1677858242,
  model: "model-name",
  choices: [{
    index: 0,
    delta: {
      content: "Chunk content here"
    },
    finish_reason: null
  }],
  usage: {
    prompt_tokens: 10,
    completion_tokens: 5,
    total_tokens: 15,
    cost: 0.0002
  }
}

Error Handling

try {
  const response = await client.chat.completions.create({
    model: "model-name",
    messages: [{ role: "user", content: "Hello" }]
  });
} catch (error) {
  if (error.statusCode === 429) {
    console.log("Rate limit reached, retrying with next account...");
  } else {
    console.error("Request failed:", error.message);
  }
}

Token Calculation

The client automatically calculates tokens for both input and output:

  • Input tokens: Calculated from the messages array
  • Output tokens: Calculated from the response content
  • Cost: Based on model-specific pricing per 1M tokens

Best Practices

  1. Multiple Auth Accounts: Configure multiple accounts for better reliability
  2. Error Handling: Always implement proper error handling
  3. Streaming: Use streaming for real-time responses and better UX
  4. Token Monitoring: Monitor token usage and costs
  5. Rate Limits: Handle rate limits gracefully

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.