SDK

One-line instrumentation

The Puse SDK wraps your existing LLM clients in-process. No proxy, no gateway — every call is traced asynchronously to the ingest API.

Initialize

import { createPuse } from "@puse/sdk";

const puse = createPuse({
  apiKey: process.env.PUSE_API_KEY!,
  // optional: baseUrl for self-hosted ingest
  baseUrl: "https://ingest.your-domain.com",
});

OpenAI

import OpenAI from "openai";

const openai = puse.wrapOpenAI(new OpenAI());
const completion = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
});

Anthropic

import Anthropic from "@anthropic-ai/sdk";

const anthropic = puse.wrapAnthropic(new Anthropic());
const message = await anthropic.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

What gets traced

  • Model name and provider
  • Input and output token counts (streaming included)
  • Latency (time to first token and total)
  • Estimated cost from your pricing table
  • Error messages on failure (no prompt content)

Custom trace IDs

puse.wrapOpenAI(client, {
  traceId: (req) => req.headers["x-request-id"],
});