Documentation Index
Fetch the complete documentation index at: https://traceroot.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Once you have initialized TraceRoot, LLM calls are traced automatically. To go further — tracing custom functions, identifying users, grouping sessions, or tracking cost — you can use observe and attach rich context to every trace.
Quickstart
Here’s everything you can attach in one place:
import traceroot
from traceroot import Integration, observe, using_attributes
from openai import OpenAI
traceroot.initialize(integrations=[Integration.OPENAI])
client = OpenAI()
@observe(name="run_agent", type="agent", metadata={"version": "v2"})
def run_agent(query: str) -> str:
response = client.chat.completions.create(...) # tokens + cost tracked automatically
return response.choices[0].message.content
with using_attributes(user_id="user-42", session_id="chat-abc", tags=["production"]):
run_agent("What's the weather?")
run_agent("What about tomorrow?")
import OpenAI from 'openai';
import { TraceRoot, observe, usingAttributes } from '@traceroot-ai/traceroot';
TraceRoot.initialize({ instrumentModules: { openAI: OpenAI } });
const client = new OpenAI();
async function runAgent(query: string): Promise<string> {
return observe({ name: 'run_agent', type: 'agent', metadata: { version: 'v2' } }, async () => {
const response = await client.chat.completions.create({ ... }); // tokens + cost tracked automatically
return response.choices[0].message.content ?? '';
});
}
await usingAttributes(
{ userId: 'user-42', sessionId: 'chat-abc', tags: ['production'] },
async () => {
await runAgent("What's the weather?");
await runAgent('What about tomorrow?');
},
);
Quick Reference
| I want to… | Attribute | Guide |
|---|
| Identify which user triggered a trace | User ID | Users |
| Group traces from the same conversation | Session ID | Sessions |
| Label traces for filtering | Tags | Tags |
| Attach structured key-value context | Metadata | Metadata |
| Track token usage and LLM cost | auto via instrumentation | Cost Tracking |
| Link traces back to source code + commit | auto via observe | Git Context |