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

@tokvera/sdk

v0.2.9

Published

Tokvera TypeScript SDK for provider tracking, manual tracing, and runtime integrations.

Readme

@tokvera/sdk

JavaScript SDK for Tokvera AI cost and trace telemetry.

Current version: 0.2.9

What It Tracks

  • OpenAI (chat.completions.create, responses.create)
  • Anthropic (messages.create)
  • Gemini (models.generateContent / generate_content)
  • Mistral (chat.complete)

Each tracked call emits normalized telemetry to Tokvera ingest (/v1/events) with:

  • latency, status, model, token usage
  • trace context (trace_id, run_id, span_id, parent_span_id, conversation_id)
  • evaluation signals (outcome, retry_reason, fallback_reason, quality_label, feedback_score)
  • optional v2 trace fields (span/tool metadata, payload refs/blocks, per-step metrics, routing decisions)

Install

npm install @tokvera/sdk

Quick Start

import OpenAI from "openai";
import { trackOpenAI } from "@tokvera/sdk";

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const tracked = trackOpenAI(openai, {
  api_key: process.env.TOKVERA_API_KEY,
  feature: "support_bot",
  tenant_id: "acme",
  environment: "production",
  step_name: "draft_reply",
  emitLifecycleEvents: true,
});

await tracked.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello" }],
});

Enable emitLifecycleEvents: true when you want /dashboard/traces/live to show a run immediately at call start and keep it marked as processing until the terminal event lands.

Set ingest URL (optional if using default):

export TOKVERA_INGEST_URL="https://api.tokvera.org/v1/events"

Integration Helpers

Framework/runtime helpers shipped in this SDK:

  • Existing app / manual tracing:

    • createTokveraTracer(...)
    • startTrace(...)
    • startSpan(...)
    • finishSpan(...)
    • failSpan(...)
    • attachPayload(...)
    • getTrackOptionsFromTraceContext(...)
  • OpenAI Agents SDK:

    • createTokveraOpenAIAgentsTracingProcessor(...)
  • LangGraph:

    • createTokveraLangGraphHooks(...)
  • Wave 2 beta runtimes:

    • createTokveraAutoGenHooks(...)
    • createTokveraMastraHooks(...)
    • createTokveraTemporalHooks(...)
    • createTokveraPipecatHooks(...)
    • createTokveraLiveKitHooks(...)
    • createTokveraOpenAICompatibleGatewayHooks(...)
  • OpenTelemetry bridge:

    • TokveraOTelSpanExporter
  • Express:

    • createTokveraExpressMiddleware(...)
    • getTrackOptionsFromExpressRequest(...)
  • Next.js route handlers/server actions:

    • createTokveraNextRouteContext(...)
    • getTrackOptionsFromNextRouteContext(...)
  • NestJS:

    • createTokveraNestMiddleware(...)
    • getTrackOptionsFromNestExecutionContext(...)
  • Background jobs:

    • createTokveraBackgroundJobContext(...)
    • getTrackOptionsFromBackgroundJobContext(...)
  • BullMQ:

    • createTokveraBullMQJobContext(...)
    • getTrackOptionsFromBullMQJobContext(...)
  • LangChain:

    • createTokveraLangChainCallback(...)
  • Vercel AI SDK:

    • wrapVercelAIGenerateText(...)

Trace Schema Support

  • v1 schema version: 2026-02-16
  • v2 schema version: 2026-04-01

Contract references:

  • tokvera-api/docs/event-envelope-v1.contract.json
  • tokvera-api/docs/event-envelope-v2.contract.json
  • tokvera-api/docs/SCHEMA_COMPATIBILITY_POLICY.md

Privacy Behavior

  • Tracking is fire-and-forget and non-blocking
  • Prompt/output content is not required
  • If you enable content capture in v2 mode, hashes/blocks are attached based on options

Examples

  • examples/quickstart.ts
  • examples/manual-tracer.ts
  • examples/openai-agents.ts
  • examples/beta-runtime-helpers.ts
  • examples/express-middleware.ts
  • examples/background-jobs.ts

Realtime Tracing

  • /dashboard/traces is the main engineering workspace for execution, payload, and optimization debugging.
  • /dashboard/traces/live is the realtime feed for active and recently completed runs.
  • Lifecycle start events are additive. They do not replace the normal terminal success/failure event.

Test

npm run build
npm test
npm run test:schema-compat
npm run test:canonical-contract