Documentation Index
Fetch the complete documentation index at: https://tracepilot.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
tp.wrapOpenAI() intercepts an OpenAI chat completion call, records the input messages, output, token usage, latency, and any errors as a structured span, and then returns the original ChatCompletion object without modification. You can use the returned spanId to attach child spans and build a nested execution tree that is visible in the dashboard.
Signature
Parameters
A zero-argument function that calls
openai.chat.completions.create(...) and returns a Promise<ChatCompletion>. Wrap your call in an arrow function so TracePilot can time it and catch errors.The messages array you pass to the completion. TracePilot records these as the span input so you can inspect and edit them in the dashboard’s Fork & Rerun flow.
The
spanId of a parent span. Providing this value links the current span as a child of the parent, building a hierarchical execution tree in the dashboard. Omit for root-level LLM calls.An integer indicating this span’s position in the execution sequence. Used to order sibling spans in the dashboard when multiple spans share the same parent.
Return value
The original OpenAI
ChatCompletion response, returned unchanged. Your agent code can use this exactly as it would without TracePilot.The ID of the span created for this call. Pass this as
parentSpanId to subsequent wrapOpenAI or wrapToolCall calls to nest them under this span.Examples
Building span trees
EverywrapOpenAI call returns a spanId. Passing that spanId as parentSpanId in a later call creates a parent-child relationship between the two spans. The dashboard renders these relationships as an indented execution tree, making it easy to see which LLM call triggered which downstream steps.