Skip to main content
The tracing API has four entry points: @trace, start_trace, log_llm_call, and log_tool_call. Plus @tool to register a function as a tracked tool. Use the framework-specific auto-instrumentation instead when possible — these are the manual escape hatches.

@decimalai.trace()

Decorator to trace a function as a complete agent run.
@decimalai.trace(agent_name="my-agent")
def run_agent(query: str) -> str:
    response = openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": query}],
    )
    return response.choices[0].message.content

# Every call to run_agent() creates a trace
result = run_agent("What is the capital of France?")
agent_name
str
required
Name of the agent (appears in dashboard sidebar).

decimalai.start_trace()

Context manager for manual trace boundaries.
with decimalai.start_trace(agent_name="my-agent") as ctx:
    # Everything inside this block is part of one trace
    decimalai.log_llm_call(
        model="gpt-4o",
        input=[{"role": "user", "content": "Hello"}],
        output={"content": "Hi there!"},
    )

decimalai.log_llm_call()

Log an individual LLM call inside a trace.
decimalai.log_llm_call(
    model="gpt-4o",
    input=[{"role": "user", "content": "Hello"}],
    output={"content": "Hi there!"},
    input_tokens=5,
    output_tokens=3,
    latency_ms=320,
)
model
str
required
Model identifier (e.g., "gpt-4o", "claude-sonnet-4-6").
input
list | dict | str
Input messages or prompt.
output
dict | str
LLM response.
input_tokens
int
Prompt token count.
output_tokens
int
Completion token count.
latency_ms
int
Call latency in milliseconds.

decimalai.log_tool_call()

Log a tool invocation inside a trace.
decimalai.log_tool_call(
    name="search_flights",
    input={"from": "SFO", "to": "NRT"},
    output={"results": [...]},
    latency_ms=150,
)

@decimalai.tool

Decorator that registers a function as a tracked tool.
@decimalai.tool
def search_flights(origin: str, destination: str) -> list:
    """Search for available flights."""
    return flight_api.search(origin, destination)

# Tool calls are auto-logged when used inside a traced function

What’s next

Manifests

Track which version of your agent produced each trace.

Frameworks

Skip the manual calls — auto-instrument LangChain, OpenAI Agents, and more.