Prerequisites
- A Carbon account and a space in the dashboard
- An application that calls the OpenAI, Anthropic, or Vercel AI SDK
Create an API key
In the dashboard, go to Settings → API Keys and click New.Store the key in your application’s environment:
.env
Wrap your AI client
Create a
Carbon instance and wrap the SDK you already use. The wrapper
preserves your existing call sites; events are captured automatically.Carbon reads CARBON_API_KEY from the environment by default. You can
pass apiKey explicitly instead — see Configuration.Flush before exit
The SDK buffers events and flushes them in the background. Long-running
servers need no extra code. In serverless and other short-lived
environments — scripts, CLIs, batch jobs — flush before exiting so
buffered events are not lost:
Next steps
Add traces and context
Correlate related calls with a trace ID and tag events with agent, user,
and thread identifiers.
Capture tool calls
Wrap your own functions so tool executions show up next to LLM calls.