SuperPenguin Docs
SDKsTypeScript

TypeScript providers

Wrap OpenAI, Azure OpenAI, Anthropic, Gemini, Bedrock, Deepgram, ElevenLabs, and Realtime with @superpenguin/js.

OpenAI

OpenRouter can use the OpenAI-compatible wrapper described below or OpenRouter Broadcast. Avoid enabling both for the same calls unless a shared generation ID makes exact deduplication possible.

import OpenAI from "openai";
import { wrap } from "@superpenguin/js";

const openai = wrap(new OpenAI());
await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  spMetadata: { customer_id: "cust_123" },
});

Supported: chat.completions.create, completions.create, embeddings.create, responses.create, including streams that report usage.

Azure OpenAI

Wrap AzureOpenAI (or an OpenAI client pointed at an Azure endpoint). SuperPenguin detects Azure from the host (*.openai.azure.com, *.services.ai.azure.com, and related Azure AI hosts). There is no separate Azure wrapper.

Azure region is not auto-captured. Typical Azure hosts use a resource name, not a region, so pass wrap-level region and deploymentType if you want SDK estimates to use the matching rate card. Omit both for Global Standard (the default).

import { AzureOpenAI } from "openai";
import { wrap } from "@superpenguin/js";

const openai = wrap(
  new AzureOpenAI({
    endpoint: "https://my-resource.openai.azure.com",
    apiKey: "...",
    apiVersion: "2024-10-21",
  }),
  {
    region: "eastus2",
    deploymentType: "regional",
  },
);
DeploymentWhat to pass
Global Standardomit region and deploymentType
Data ZonedeploymentType: "data-zone"
Regionalregion (location code, e.g. eastus2) and deploymentType: "regional"

region must be the Azure location code from the portal / ARM (eastus2, westeurope, swedencentral). Case does not matter (EastUS2 works). Display names (East US 2) and AWS-style ids (us-east-2) will not match, so the estimate falls back to Global. For deploymentType, use exactly "regional" or "data-zone" (keep the hyphen). Passing only region is not enough for regional rates. Connecting Azure for billed spend already uses invoice amounts; these fields only affect SDK estimates. See Batch and service-tier pricing.

Doubleword

Wrap an OpenAI client pointed at https://api.doubleword.ai/v1. SuperPenguin attributes the billed route as doubleword (the model maker stays in model_vendor). Scope custom prices to doubleword.

Anthropic

import Anthropic from "@anthropic-ai/sdk";
import { wrap } from "@superpenguin/js";

const anthropic = wrap(new Anthropic());
await anthropic.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello!" }],
  spMetadata: { customer_id: "cust_123" },
});

Google Gemini

import { GoogleGenAI } from "@google/genai";
import { wrap } from "@superpenguin/js";

const genai = wrap(new GoogleGenAI({ apiKey: "..." }));
await genai.models.generateContent({
  model: "gemini-2.5-pro",
  contents: "Hello!",
});

Deepgram

import { createClient } from "@deepgram/sdk";
import { wrap } from "@superpenguin/js";

const dg = wrap(createClient("..."), {
  metadata: { customer_id: "cust_123" },
  deepgramTier: "growth",
});

ElevenLabs

import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import { wrap } from "@superpenguin/js";

const el = wrap(new ElevenLabsClient({ apiKey: "..." }), {
  metadata: { customer_id: "cust_123" },
});

AWS Bedrock

import {
  BedrockRuntimeClient,
  ConverseCommand,
} from "@aws-sdk/client-bedrock-runtime";
import { wrap } from "@superpenguin/js";

const bedrock = wrap(
  new BedrockRuntimeClient({ region: "us-west-2" }),
  {
    metadata: { customer_id: "cust_123", feature: "doc_summary" },
    deploymentType: "global",
  },
);

await bedrock.send(
  new ConverseCommand({
    modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
    messages: [{ role: "user", content: [{ text: "Hello!" }] }],
  }),
);

Usage is sent with cost_usd_micros: 0; the server prices with the live aws_bedrock catalog. Region is auto-captured.

OpenAI Realtime

import { OpenAIRealtimeWebSocket } from "openai/beta/realtime/websocket";
import { wrapRealtime } from "@superpenguin/js";

const rt = new OpenAIRealtimeWebSocket({ model: "gpt-realtime" });
wrapRealtime(rt, { metadata: { feature: "voice-agent" } });

For raw WebSocket / WebRTC consumers, use trackRealtimeEvent(event, { model: "gpt-realtime" }).

Provider-specific helpers

import {
  wrapOpenAI,
  wrapAnthropic,
  wrapGoogleGenAI,
  wrapDeepgram,
  wrapElevenLabs,
  wrapBedrock,
  wrapRealtime,
  trackRealtimeEvent,
} from "@superpenguin/js";

Next