const session = tracia.createSession();
// First call - creates the session (trace)
const result1 = await session.runLocal({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What is the weather?' }],
});
// result1.spanId = "sp_abc123"
// session.getTraceId() = "tr_xyz789" (session ID)
// Second call - automatically linked to first
const result2 = await session.runLocal({
model: 'gpt-4o',
messages: [
{ role: 'user', content: 'What is the weather?' },
result1.message,
{ role: 'user', content: 'What about tomorrow?' },
],
});
// Automatically sends: traceId: "tr_xyz789", parentSpanId: "sp_abc123"
// Third call - chain continues
const result3 = await session.runLocal({
model: 'gpt-4o',
messages: [
{ role: 'user', content: 'What is the weather?' },
result1.message,
{ role: 'user', content: 'What about tomorrow?' },
result2.message,
{ role: 'user', content: 'Thanks!' },
],
});
// Automatically sends: traceId: "tr_xyz789", parentSpanId: result2.spanId