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

@summoned/ai

v0.1.1

Published

Summoned AI Gateway SDK — OpenAI-compatible client with routing, caching, guardrails, and multi-provider support

Downloads

34

Readme

@summoned/ai

TypeScript SDK for the Summoned AI Gateway — OpenAI-compatible client with multi-provider routing, caching, guardrails, and more.

Install

npm install @summoned/ai

Quick Start

import { Summoned } from "@summoned/ai"

const client = new Summoned({
  apiKey: "sk-smnd-...",
  baseURL: "http://localhost:4000",  // your gateway URL
})

// Chat completion — specify provider/model
const response = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "What is the capital of France?" }],
})

console.log(response.choices[0].message.content)
console.log(response.summoned) // { provider, cost, latency_ms, ... }

Streaming

const stream = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4-20250514",
  messages: [{ role: "user", content: "Write a poem" }],
  stream: true,
})

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "")
}

Config — Retries, Fallbacks, Caching, Guardrails

const response = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
  config: {
    retry: { attempts: 3, backoff: "exponential" },
    fallback: ["anthropic/claude-sonnet-4-20250514", "groq/llama-3.3-70b-versatile"],
    timeout: 30000,
    cache: true,
    guardrails: {
      input: [{ type: "pii", deny: true }],
      output: [{ type: "contains", params: { operator: "none", words: ["confidential"] }, deny: true }],
    },
  },
})

withConfig — Reusable Client Configuration

const cachedClient = client.withConfig({ cache: true, cacheTtl: 3600 })

// All requests through cachedClient use caching
await cachedClient.chat.completions.create({ model: "openai/gpt-4o", messages: [...] })

Use with OpenAI's SDK

If you prefer the official OpenAI SDK, use createHeaders to route through the gateway:

import OpenAI from "openai"
import { createHeaders } from "@summoned/ai"

const openai = new OpenAI({
  baseURL: "http://localhost:4000/v1",
  apiKey: "sk-smnd-...",
  defaultHeaders: createHeaders({
    config: { cache: true, fallback: ["groq/llama-3.3-70b-versatile"] },
  }),
})

// Uses Summoned gateway with all its features
const res = await openai.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
})

Embeddings

const embeddings = await client.embeddings.create({
  model: "openai/text-embedding-3-small",
  input: "The quick brown fox",
})

Admin API

const admin = new Summoned({
  apiKey: "sk-smnd-...",
  adminKey: "your-admin-key",
})

// API keys
const key = await admin.admin.keys.create({ name: "production", tenantId: "tenant_1" })
const keys = await admin.admin.keys.list("tenant_1")
await admin.admin.keys.revoke("key_abc")

// Virtual keys (encrypted provider credentials)
const vk = await admin.admin.virtualKeys.create({
  name: "my-openai-key",
  tenantId: "tenant_1",
  providerId: "openai",
  apiKey: "sk-real-openai-key-...",
})

// Logs & stats
const logs = await admin.admin.logs.list({ limit: 50 })
const stats = await admin.admin.stats.get("24h")
const providers = await admin.admin.providers.list()

Debug Mode

const client = new Summoned({
  apiKey: "sk-smnd-...",
  debug: true, // prints request/response details to console
})

Response Headers

Every request populates lastResponseHeaders:

await client.chat.completions.create({ model: "openai/gpt-4o", messages: [...] })

console.log(client.lastResponseHeaders)
// { provider: "openai", cache: "MISS", latencyMs: "432", costUsd: "0.000150", traceId: "..." }

Error Handling

import { SummonedError } from "@summoned/ai"

try {
  await client.chat.completions.create({ model: "openai/gpt-4o", messages: [...] })
} catch (err) {
  if (err instanceof SummonedError) {
    console.log(err.status)   // 429
    console.log(err.code)     // "RATE_LIMITED"
    console.log(err.headers)  // response headers
  }
}