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

@djangocfg/llm

v2.1.216

Published

Lightweight LLM client with SDKRouter, OpenAI, Anthropic support and smart JSON translator

Readme

@djangocfg/llm

LLM client with SDKRouter, OpenAI, and Anthropic support. Includes JSON translator with validation.

Installation

pnpm add @djangocfg/llm

Quick Start

import { createLLMClient, Model, createTranslator } from '@djangocfg/llm'

// Auto-detect from env (SDKRouter preferred)
const llm = createLLMClient()

// With model alias
const llm = createLLMClient({ model: Model.balanced({ code: true }) })

// Simple chat
const response = await llm.chat('Hello!')

// JSON response
const data = await llm.json<{ name: string }>('Return a user object')

// Translate JSON
const translator = createTranslator(llm)
const result = await translator.translate({ title: 'Hello' }, 'ru')
console.log(result.data) // { title: 'Привет' }

Environment Variables

# SDKRouter (recommended)
SDKROUTER_API_KEY=sk-...

# Or OpenAI
OPENAI_API_KEY=sk-...

# Or Anthropic
ANTHROPIC_API_KEY=sk-ant-...

Priority: SDKROUTER_API_KEY > OPENAI_API_KEY > ANTHROPIC_API_KEY

Model Aliases (SDKRouter)

SDKRouter uses smart model aliases to select the best model for your task:

import { Model, ModelPresets } from '@djangocfg/llm'

// Tier methods
Model.cheap()                    // '@cheap' - Cheapest
Model.balanced()                 // '@balanced' - Best value (default)
Model.smart()                    // '@smart' - Highest quality
Model.fast()                     // '@fast' - Lowest latency

// With capabilities
Model.cheap({ vision: true })    // '@cheap+vision'
Model.balanced({ tools: true })  // '@balanced+tools'
Model.smart({ json: true })      // '@smart+json'

// With categories
Model.balanced({ code: true })   // '@balanced+code'
Model.smart({ reasoning: true }) // '@smart+reasoning'

// Pre-built presets
ModelPresets.translation   // '@cheap+json' - For translation tasks
ModelPresets.code          // '@balanced+code' - For code generation
ModelPresets.reasoning     // '@smart+reasoning' - For complex reasoning

Available Tiers

  • cheap - Cheapest available model
  • budget - Budget-friendly with decent quality
  • standard - Standard tier
  • balanced - Best quality/price ratio (recommended)
  • smart - Highest quality model
  • fast - Lowest latency model
  • premium - Top-tier premium model

Available Capabilities

  • vision - Image understanding
  • tools - Function/tool calling
  • agents - Agent tool calling (verified)
  • json - JSON mode
  • streaming - Streaming support
  • long - Long context (128k+)
  • image - Image generation

Available Categories

  • code - Code generation
  • reasoning - Reasoning & math
  • creative - Creative writing
  • chat - Conversational
  • analysis - Analysis & extraction

API

createLLMClient(config?)

const llm = createLLMClient({
  provider: 'sdkrouter',   // 'sdkrouter' | 'openai' | 'anthropic'
  apiKey: 'sk-...',        // Optional, uses env
  model: '@balanced',      // Default model
  temperature: 0.1,
  maxTokens: 4096,
})

llm.chat(prompt, options?)

const response = await llm.chat('Translate to Russian: Hello', {
  temperature: 0,
  system: 'You are a professional translator',
})

console.log(response.content)  // 'Привет'
console.log(response.usage)    // { promptTokens, completionTokens, totalTokens }

llm.json(prompt, options?)

interface User {
  name: string
  email: string
}

const user = await llm.json<User>('Return a sample user object')

createTranslator(llm)

const translator = createTranslator(llm)

const result = await translator.translate(
  { title: 'Hello', items: ['One', 'Two'] },
  'ru',
  {
    sourceLanguage: 'en',
    maxRetries: 2
  }
)

if (result.valid) {
  console.log(result.data) // { title: 'Привет', items: ['Один', 'Два'] }
} else {
  console.error('Errors:', result.errors)
}

Providers

SDKRouter (Default)

  • Base URL: https://llm.sdkrouter.com/v1
  • Uses smart model aliases (@cheap, @balanced, @smart)
  • Automatically selects best model for capabilities

OpenAI

Models: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo

Anthropic

Models: claude-3-5-sonnet-latest, claude-3-5-haiku-latest, claude-3-opus-latest

License

MIT