SuperPenguin Docs
Getting Started

Add attribution metadata

Attach customer, feature, team, and prompt metadata so every request is queryable in the dashboard.

Metadata turns each tracked call into spend you can slice by customer, feature, team, environment, and prompt version.

All fields are optional. Start with none and add them as you need dashboards and alerts.

FieldTypePurpose
customer_idstringEnd-customer or account consuming the AI call
featurestringProduct feature (for example search, support_agent)
teamstringInternal team owning the feature
environmentstringproduction, staging, dev, and similar
prompt_keystringPrompt template identifier
prompt_versionstring | numberPrompt version (1, beta, 2.1)
session_idstringGroups one conversation for content capture
turn_idstringGroups one turn across tool round-trips
Any other keystringStored as a custom tag

Where to set it

  1. Wrap-time defaults apply to every call on that client.
  2. Per-call overrides win for a single request.
  3. Trace / context helpers apply across a block or function.

Precedence is per-call > trace/context > wrap-time defaults.

Python

client = sp.wrap(OpenAI(), metadata={
    "feature": "doc_summary",
    "environment": "production",
})

with sp.metadata(customer_id="cust_acme_123"):
    client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Summarize this"}],
    )

sp.metadata() is the recommended per-call override. It works on every wrapped provider and never touches the HTTP body, so provider validators cannot reject it.

TypeScript

const openai = wrap(new OpenAI(), {
  metadata: { feature: "support_agent", environment: "production" },
});

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

The wrapper strips spMetadata / sp_metadata before forwarding the request to the provider.

Why this matters

Native provider tags are incomplete across vendors: different schemas, soft limits, and units that are not dollars. SuperPenguin uses one structured metadata schema across providers and normalizes estimated cost to USD for dashboards and alerts. See Attribution.