New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

openrouter-ts

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openrouter-ts

A production-ready TypeScript client library for the OpenRouter API

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
855
-36.38%
Maintainers
1
Weekly downloads
 
Created
Source

OpenRouter TypeScript Client

A production-ready TypeScript client library for the OpenRouter API. This library provides comprehensive access to multiple AI models through OpenRouter's unified interface with full TypeScript support, streaming, error handling, and developer-friendly utilities.

Features

  • Full TypeScript Support - Complete type definitions for all endpoints and parameters
  • Streaming Support - Real-time streaming responses with async iterators
  • Error Handling - Comprehensive error classes with proper categorization
  • Retry Logic - Configurable exponential backoff for network resilience
  • Tool Calling - Full support for function calling across providers
  • Input Validation - Parameter validation with helpful error messages
  • Helper Utilities - Builder patterns and convenience functions
  • Request Cancellation - AbortController support for canceling requests
  • Rate Limit Handling - Automatic retry with proper rate limit respect
  • Multimodal Support - Text and image inputs for compatible models

Installation

npm install @openrouter/typescript-client

Quick Start

import { OpenRouterClient, MODELS } from '@openrouter/typescript-client';

const client = new OpenRouterClient({
  apiKey: process.env.OPENROUTER_API_KEY!,
  siteUrl: 'https://yoursite.com', // Optional: for rankings
  siteName: 'Your App Name'        // Optional: for rankings
});

// Basic chat completion
const response = await client.chat.completions.create({
  model: MODELS.GPT_4O,
  messages: [
    { role: 'user', content: 'Hello! How are you?' }
  ]
});

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

License

MIT License. See LICENSE for details.

Keywords

openrouter

FAQs

Package last updated on 30 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts