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

@perf_technology/sdk

v2.0.1

Published

Official Perf SDK for JavaScript/TypeScript

Downloads

199

Readme

@perf_technology/sdk

Official JavaScript/TypeScript SDK for Perf - the AI Runtime Orchestrator.

Perf automatically picks the best AI model for your prompt based on:

  • Task type and complexity
  • Cost constraints
  • Output reliability
  • Fallback logic

Installation

npm install @perf_technology/sdk
# or
yarn add @perf_technology/sdk
# or
pnpm add @perf_technology/sdk

Quick Start

import { PerfClient } from '@perf_technology/sdk';

const client = new PerfClient({
  apiKey: 'pk_live_your_api_key',
});

// Simple chat completion
const response = await client.chat({
  messages: [
    { role: 'user', content: 'What is the capital of France?' }
  ],
});

console.log(response.choices[0].message.content);
// Output: "The capital of France is Paris."

// Access Perf metadata
console.log(response.perf);
// { model_used: 'gpt-4o-mini', cost_usd: 0.0001, latency_ms: 234, ... }

Streaming

// Stream responses
for await (const chunk of client.chatStream({
  messages: [{ role: 'user', content: 'Write a haiku about coding' }],
})) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

// Or collect into a string
const content = await client.chatStreamToString({
  messages: [{ role: 'user', content: 'Explain quantum computing' }],
});

Error Handling

import {
  PerfClient,
  PerfError,
  RateLimitError,
  AuthenticationError
} from '@perf_technology/sdk';

try {
  const response = await client.chat({
    messages: [{ role: 'user', content: 'Hello!' }],
  });
} catch (error) {
  if (error instanceof RateLimitError) {
    // Wait and retry
    const retryAfter = error.retryAfter || 60;
    console.log(`Rate limited. Retry after ${retryAfter} seconds`);
  } else if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof PerfError) {
    console.error(`API Error: ${error.code} - ${error.message}`);
  } else {
    console.error('Unexpected error:', error);
  }
}

Configuration Options

const client = new PerfClient({
  apiKey: 'pk_live_your_api_key',     // Required
  baseUrl: 'https://api.withperf.pro', // Optional, default shown
  timeout: 120000,                      // Request timeout in ms (default: 2 min)
  maxRetries: 3,                        // Retry attempts (default: 3)
  retryDelay: 1000,                     // Base retry delay in ms (default: 1s)
});

Request Options

const response = await client.chat({
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Hello!' },
  ],
  model: 'gpt-4o',           // Optional: override model selection
  max_tokens: 1000,          // Optional: limit response length
  temperature: 0.7,          // Optional: sampling temperature
  max_cost_per_call: 0.01,   // Optional: cost budget in USD
  metadata: {                // Optional: custom metadata
    user_id: '123',
    session_id: 'abc',
  },
});

TypeScript Types

All types are exported for your convenience:

import type {
  Message,
  ChatRequest,
  ChatResponse,
  ChatStreamChunk,
  PerfMetadata,
  PerfClientConfig,
} from '@perf_technology/sdk';

Features

  • Full TypeScript support with comprehensive type definitions
  • Streaming support with AsyncGenerator API
  • Automatic retries with exponential backoff
  • Error classes for different error types
  • Timeout handling with configurable limits
  • Dual ESM/CommonJS builds

Requirements

  • Node.js 18 or higher
  • Browser environments with Fetch API support

Links

License

MIT