Quickstart

From signup to first event in the dashboard — under three minutes.

You'll install the SDK, ship a test event, and watch it appear in the dashboard. This takes about three minutes.

1. Create a workspace

Sign up at app.margint.dev with your GitHub or Google account. A workspace is created for you.

2. Get an API key

In the dashboard, go to Settings → API Keys and create one. Copy it — you'll only see the full value once.

API keys are prefixed m_live_. The same key authenticates the SDK, the public REST API, and the MCP server.

3. Install the SDK

npm install @margint-ai/sdk

4. Send your first event

import { Margint } from '@margint-ai/sdk'

const m = new Margint({ apiKey: process.env.MARGINT_API_KEY! })

m.track({
  customerId: 'cust_demo',
  feature: 'chat',
  provider: 'openai',
  model: 'gpt-4o',
  inputTokens: 820,
  outputTokens: 310
})

await m.flush()

5. See it in the dashboard

Open Customers in the dashboard. cust_demo should appear within ~10 seconds. At $2.50/M input and $10.00/M output for gpt-4o, that single call costs about half a cent.

Next: wire it into your real app

Most teams use the wrap() pattern — you install the SDK once and forget about it.

import OpenAI from 'openai'
import { Margint } from '@margint-ai/sdk'

const m = new Margint({ apiKey: process.env.MARGINT_API_KEY! })

// In your request handler:
const openai = m.wrap(new OpenAI(), {
  customerId: user.id,
  feature: 'chat'
})

// Use openai normally — every call is tracked
const res = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: prompt }]
})

Framework-specific setup (Next.js, Nuxt, FastAPI, Django, Flask, Express) lives in the SDK reference pages: