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

specado-temp

v0.1.1-alpha.8

Published

High-performance Node.js bindings for Specado - Spec-driven LLM integration library with automatic fallback routing and provider transformations

Downloads

3

Readme

specado

High-performance Node.js bindings for Specado - Spec-driven LLM integration library with automatic fallback routing and provider transformations

Specado provides a unified interface for working with multiple LLM providers (OpenAI, Anthropic) with automatic fallback routing, request transformation, and comprehensive error handling, all powered by a high-performance Rust core.

🚀 Features

  • 🔄 Automatic Fallback Routing: Seamlessly switch between providers when primary fails
  • 🔧 Request Transformation: Convert between OpenAI and Anthropic formats automatically
  • 📊 Lossiness Tracking: Monitor when transformations lose information (e.g., system role merging)
  • ⚡ High Performance: Built with Rust core and NAPI-RS for maximum speed
  • 🛡️ Production Ready: Comprehensive error handling, retry policies, and observability
  • 🔗 OpenAI Compatible: Drop-in replacement for OpenAI Node.js client patterns
  • 🔧 TypeScript First: Full TypeScript support with comprehensive type definitions

📦 Installation

npm install specado
# or
yarn add specado
# or
pnpm add specado

🏃 Quick Start

Basic Usage

import { Client, createMessage } from 'specado';

// Create client with default configuration (OpenAI primary, Anthropic fallback)
const client = new Client();

// Simple chat completion
const response = await client.getChat().getCompletions().create(
  'gpt-4',
  [
    createMessage('system', 'You are a helpful assistant'),
    createMessage('user', 'Hello, world!')
  ]
);

console.log(response.choices[0].message.content);
console.log(`Provider used: ${response.extensions.providerUsed}`);

Custom Provider Configuration

import { Client, createMessage } from 'specado';

// Configure specific providers and fallback behavior
const client = new Client({
  primary_provider: 'openai',
  fallback_provider: 'anthropic'
});

const response = await client.getChat().getCompletions().create(
  'gpt-4',
  [createMessage('user', 'Explain quantum computing')],
  0.7,   // temperature
  500    // max_tokens
);

// Access routing metadata
console.log(`Fallback triggered: ${response.extensions.fallbackTriggered}`);
console.log(`Attempts made: ${response.extensions.attempts}`);
console.log(`Provider used: ${response.extensions.providerUsed}`);

Fallback Routing Demo

import { Client, createMessage } from 'specado';

const client = new Client({
  primary_provider: 'openai',
  fallback_provider: 'anthropic'
});

// Trigger fallback by using a model that causes timeout
const response = await client.getChat().getCompletions().create(
  'timeout-test-model',  // This will fail on OpenAI
  [createMessage('user', 'This will use fallback')]
);

// Verify fallback occurred
console.assert(response.extensions.fallbackTriggered === true);
console.assert(response.extensions.providerUsed === 'anthropic');
console.assert(response.extensions.attempts === 2);  // Primary failed, fallback succeeded

Transformation and Lossiness Tracking

import { Client, createMessage } from 'specado';

// Use Anthropic as primary (system roles are lossy)
const client = new Client({ primary_provider: 'anthropic' });

const response = await client.getChat().getCompletions().create(
  'claude-3',
  [
    createMessage('system', 'You are a coding assistant'),  // Will be merged
    createMessage('user', 'Write a TypeScript function')
  ]
);

// Check transformation metadata
const metadata = response.extensions.metadata;
if (metadata['transformation_lossy'] === 'true') {
  console.log('Transformation was lossy:');
  console.log(`Reasons: ${metadata['lossy_reasons']}`);
}

Error Handling

import { Client, createMessage } from 'specado';

const client = new Client();

try {
  const response = await client.getChat().getCompletions().create(
    'auth-error-test-model',  // Triggers auth error
    [createMessage('user', 'This will fail')]
  );
} catch (error) {
  console.error(`Request failed: ${error.message}`);
  // Non-retryable errors (auth, invalid request) are not sent to fallback
}

🔧 Configuration Options

Client Configuration

const config = {
  primary_provider: 'openai',    // Primary provider to try first
  fallback_provider: 'anthropic' // Fallback when primary fails
};
const client = new Client(config);

Supported Providers

  • OpenAI: GPT-4, GPT-3.5, and other OpenAI models
  • Anthropic: Claude-3, Claude-2, and other Claude models

Message Creation

import { createMessage } from 'specado';

// Supported message roles
const systemMsg = createMessage('system', 'You are helpful');
const userMsg = createMessage('user', 'Hello');
const assistantMsg = createMessage('assistant', 'Hi there!');

📊 Response Format

Specado responses extend the OpenAI format with additional routing metadata:

const response = await client.getChat().getCompletions().create(/*...*/);

// Standard OpenAI fields
response.id            // Completion ID
response.model         // Model used
response.choices       // Response choices
response.created       // Timestamp

// Specado extensions
response.extensions.providerUsed       // "openai" | "anthropic"
response.extensions.fallbackTriggered  // boolean
response.extensions.attempts           // Number of provider attempts
response.extensions.metadata          // Record<string, string> with routing details

🛠️ Development

Building from Source

# Clone the repository
git clone https://github.com/specado/specado
cd specado/specado-node

# Install dependencies
npm install

# Build the native module
npm run build

# Run tests
npm test

Development Scripts

# Development build (faster)
npm run build:debug

# Watch mode for development
npm run watch

# Clean build artifacts
npm run clean

# Format code
npm run format

# Lint code
npm run lint

# Verify build and installation
npm run verify

Running Tests

# Run the comprehensive test suite
npm test

# Run tests in CI mode
npm run test:ci

# Test specific functionality
node test_specado.js

🚦 Status

Current Version: 0.1.0 (Week 2 MVP)

✅ Implemented Features

  • OpenAI ↔ Anthropic request/response transformation
  • Automatic fallback routing with retry policies
  • Lossiness tracking for transformations
  • High-performance Node.js bindings with NAPI-RS
  • Comprehensive error handling and metadata
  • Full TypeScript support

🚧 Planned Features

  • Additional provider support (Cohere, etc.)
  • Advanced routing strategies (circuit breakers, health checks)
  • Streaming response support
  • Performance optimizations and caching

⚡ Performance

The Rust core with NAPI-RS bindings provides:

  • Fast Native Performance: Direct memory management without garbage collection overhead
  • Zero-Copy Operations: Efficient data transfer between JavaScript and Rust
  • Async/Await Support: Non-blocking operations with proper Promise integration
  • Multi-Platform: Prebuilt binaries for macOS (Intel/Apple Silicon), Linux (x64/ARM), and Windows

🔧 System Requirements

  • Node.js: 16.0.0 or higher
  • Operating Systems: macOS, Linux, Windows
  • Architectures: x64, ARM64

📄 License

Apache-2.0 - see LICENSE for details.

🔗 Links

  • Homepage: https://github.com/specado/specado
  • Documentation: https://docs.specado.com
  • Issues: https://github.com/specado/specado/issues
  • Changelog: https://github.com/specado/specado/blob/main/specado-node/CHANGELOG.md
  • npm Package: https://www.npmjs.com/package/specado

🤝 Contributing

We welcome contributions! Please see our contributing guidelines for details.

📞 Support


Built with ❤️ using Rust, NAPI-RS, and TypeScript