Documentation

Quickstart

Get per-customer attribution running in 5 minutes.

01

Get a Costr API key

Sign up at costr.dev/signup. Free tier covers $25/mo of tracked spend. No card required.

After sign-up, create an API key in the dashboard. It starts with cs_.

02

Update your baseURL

Change your LLM client baseURL from the provider URL to the Costr proxy. Your provider key stays in apiKey — Costr never sees or stores it in plaintext.

OpenAI

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: 'https://costr.dev/api/proxy/openai',
  defaultHeaders: {
    'x-costr-key': 'cs_YOUR_KEY',
    'x-costr-user': userId, // your customer's ID
  },
})

Anthropic

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
  baseURL: 'https://costr.dev/api/proxy/anthropic',
  defaultHeaders: {
    'x-costr-key': 'cs_YOUR_KEY',
    'x-costr-user': userId,
  },
})

Google Gemini

const client = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY, {
  baseUrl: 'https://costr.dev/api/proxy/google',
  customHeaders: {
    'x-costr-key': 'cs_YOUR_KEY',
    'x-costr-user': userId,
  },
})
03

Pass a customer ID header

Set x-costr-user to whatever ID you use to identify your customer — a Stripe customer ID, your own UUID, an email address. Costr uses it to group all AI calls under that customer in your dashboard.

This is the only attribution you need to add. Everything else — token counts, cost, model, latency, provider — is captured automatically.

04

Open your dashboard

Make a test API call. Within a few seconds you will see it appear in your dashboard with cost, model, and the customer ID you passed.

Open dashboard →

What Costr captures

  • Token counts (input, output, cached) per call
  • Cost in USD per call and per customer
  • Model and provider
  • Latency
  • Feature tag (optional — pass x-costr-feature)

Costr never stores prompt content or response bodies. Only metadata.

Questions? Email brandon@costr.dev