Your First Trace
This guide walks you through tracing your first LLM call. By the end, you will see real trace data in your MutagenT dashboard.Prerequisites
- MutagenT CLI installed and authenticated (
mutagent auth login) - An API key (
mt_prefix) — see API Keys - An existing project that uses an LLM framework
How Tracing Works
Step 1: Generate Integration Code
Runmutagent integrate in your project directory. The CLI detects your framework and generates the code you need.
Step 2: Install the Integration Package
Install the integration package for your framework.Step 3: Set Your API Key
Set theMUTAGENT_API_KEY environment variable. The SDK reads it automatically.
Step 4: Add the Integration Code
Add the generated integration code to your LLM calls. Each integration follows the same pattern: initialize tracing, then use the framework adapter.- OpenAI
- LangChain
- Vercel AI
- Mastra
initTracing() Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Required. Your MutagenT API key (mt_ prefix) |
endpoint | string | https://api.mutagent.io | API endpoint URL |
environment | string | — | Environment name (e.g., production, staging) |
batchSize | number | 10 | Number of spans to buffer before flushing |
flushIntervalMs | number | 5000 | Flush interval in milliseconds |
debug | boolean | false | Log span start/end events to console |
source | string | sdk | Source identifier for traces |
Step 5: Run Your Application
Run your application as you normally would. The integration sends traces to MutagenT automatically in the background, batching spans and flushing every 5 seconds or when 10 spans accumulate.Step 6: View Your Traces
Open the MutagenT dashboard at app.mutagent.io to see your traces, or use the CLI.- Input prompt and output response
- Model used and token counts
- Latency and timing data
- Span hierarchy (parent/child relationships)
Traces are sent asynchronously in batches and typically appear within a few seconds. If you do not see traces, check that your
MUTAGENT_API_KEY is valid with mutagent auth status.Graceful Shutdown
For server applications or scripts that exit after tracing, callshutdownTracing() to flush remaining buffered spans:
Next Steps
Manage Prompts
Version and organize your prompts
Run Evaluations
Measure prompt quality with metrics
Optimize
Automatically improve your prompts
All Integrations
See all supported frameworks