Skip to main content
The Trace Service in the Galtea SDK allows you to collect, manage, and persist traces that capture the internal operations of your AI agents during inference. This Service is exposed by the galtea.traces object.
Remember that we will be using the galtea object. More information here.

Two Approaches to Trace Collection

The SDK provides two ways to collect traces: When using galtea.inference_results.generate(), trace collection is handled automatically:
# Traces are collected, saved, and cleaned up automatically
inference_result = galtea.inference_results.generate(
    agent=my_agent,
    session=session,
    user_input="What's the price?"
)

2. Manual Collection

For full control over the trace lifecycle:
# 1. Start collection
galtea.traces.start_collection_context()

# 2. Run your agent (traces are collected via @trace decorator)
response = agent.call(agent_input)

# 3. Save traces to the platform
galtea.traces.save_context(
    session_id=session.id,
    inference_result_id=result.id
)

# 4. Clean up (automatic after save_context)

SDK Methods

Context Management

Utilities

Direct API Methods

Trace

Understand how traces capture the internal operations of your AI agents.