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

chatdelta

v0.3.0

Published

A unified JavaScript/TypeScript library for connecting to multiple AI APIs (OpenAI ChatGPT, Google Gemini, Anthropic Claude)

Readme

ChatDelta JS

ChatDelta JS is a lightweight TypeScript/JavaScript SDK that provides a unified interface for sending prompts to multiple AI providers such as OpenAI, Google Gemini and Anthropic Claude. It exposes a common client abstraction so your application code can swap providers without rewriting business logic.

Features

  • Consistent AiClient interface across providers
  • Built‑in error handling with descriptive error types
  • Optional parallel execution and response summarisation helpers
  • TypeScript definitions out of the box
  • NEW in v0.3.0: Response metadata with token counts and latency tracking
  • NEW in v0.3.0: ChatSession for high-level conversation management
  • NEW in v0.3.0: Advanced retry strategies (Fixed, Linear, Exponential, ExponentialWithJitter)
  • NEW in v0.3.0: Performance metrics tracking system
  • NEW in v0.3.0: Custom base URL support for Azure OpenAI and local models

Installation

npm install chatdelta

The library targets modern Node runtimes (ES2020). Type declarations are bundled so it works in both JavaScript and TypeScript projects.

Usage

Basic Usage

import { createClient, executeParallel, generateSummary } from 'chatdelta';

const openai = createClient('openai', process.env.OPENAI_KEY!, 'gpt-4');
const gemini = createClient('gemini', process.env.GEMINI_KEY!, 'gemini-pro');

async function run() {
  const results = await executeParallel([openai, gemini], 'Explain quantum entanglement');
  console.log(results);

  const summary = await generateSummary(openai, results.map(r => ({ name: r.name, response: String(r.result) })));
  console.log('Summary:', summary);
}

Chat Sessions (NEW in v0.3.0)

import { createClient, ChatSession } from 'chatdelta';

const client = createClient('openai', process.env.OPENAI_KEY!, 'gpt-4');
const session = ChatSession.withSystemMessage(client, 'You are a helpful assistant.');

// Send messages with automatic history management
const response1 = await session.send('What is TypeScript?');
const response2 = await session.send('What are its main benefits?'); // Remembers context

// Get response with metadata
const responseWithMeta = await session.sendWithMetadata('How does it compare to JavaScript?');
console.log('Tokens used:', responseWithMeta.metadata.totalTokens);
console.log('Latency:', responseWithMeta.metadata.latencyMs, 'ms');

Response Metadata (NEW in v0.3.0)

const client = createClient('openai', process.env.OPENAI_KEY!, 'gpt-4');

// Get detailed metadata with responses
const response = await client.sendPromptWithMetadata('Explain recursion');
console.log('Content:', response.content);
console.log('Model used:', response.metadata.modelUsed);
console.log('Prompt tokens:', response.metadata.promptTokens);
console.log('Completion tokens:', response.metadata.completionTokens);
console.log('Total tokens:', response.metadata.totalTokens);
console.log('Latency:', response.metadata.latencyMs, 'ms');

Advanced Retry Strategies (NEW in v0.3.0)

import { createClient, RetryStrategy } from 'chatdelta';

const config = {
  retries: 5,
  retryStrategy: RetryStrategy.ExponentialWithJitter,
  baseUrl: 'https://your-azure-instance.openai.azure.com' // Custom endpoint support
};

const client = createClient('openai', process.env.OPENAI_KEY!, 'gpt-4', config);

Performance Metrics (NEW in v0.3.0)

import { ClientMetrics } from 'chatdelta';

const metrics = new ClientMetrics();

// Track requests
metrics.recordSuccess(150, 100, 50); // latency, prompt tokens, completion tokens
metrics.recordFailure();

// Get statistics
const snapshot = metrics.getSnapshot();
console.log('Success rate:', snapshot.successRate, '%');
console.log('Average latency:', snapshot.averageLatencyMs, 'ms');
console.log('P95 latency:', snapshot.p95LatencyMs, 'ms');
console.log('Total tokens:', snapshot.totalTokens);

Configuration

createClient accepts an optional ClientConfig allowing control over timeouts, retries, temperature and token limits. See src/types.ts for the full interface.

Contributing

Bug reports and pull requests are welcome! Please read CONTRIBUTING.md for details on our process.

License

This project is released under the MIT License.