> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galtea.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace Service

> Trace Service API methods in the Galtea SDK

The Trace Service in the Galtea SDK allows you to manage [traces](/concepts/product/version/session/trace) for evaluating your products.
This Service is exposed by the `galtea.traces` object.

<Info>
  Remember that we will be using the `galtea` object. More information [here](/sdk/api/galtea).
</Info>

## Quick Example

First, initialize the Galtea SDK:

```python theme={"system"}
galtea = Galtea(api_key="YOUR_API_KEY")
```

Generate a trace using an Agent (recommended):

```python theme={"system"}
# Define your agent function
def my_agent(user_message: str) -> str:
    return f"Response to: {user_message}"


trace = galtea.traces.generate(agent=my_agent, session=session, input="Generate something")
```

Manually create a trace:

```python theme={"system"}
trace = galtea.traces.create(
    session_id=session_id,
    input="What is the capital of France?",
    output="Paris",
    latency=150.5,
)
```

Update a trace:

```python theme={"system"}
trace = galtea.traces.update(
    trace_id=trace_id,
    output="Paris is the capital.",
    cost=0.0001,
)
```

## Service Methods

* [Generate Trace](/sdk/api/trace/generate) - **Recommended** for automatic span collection
* [Create Trace](/sdk/api/trace/create)
* [Create and Evaluate](/sdk/api/trace/create-and-evaluate) - Create a trace and evaluate it in one call
* [Create Trace Batch](/sdk/api/trace/create-batch)
* [Update Trace](/sdk/api/trace/update)
* [List Traces](/sdk/api/trace/list)
* [Get Trace](/sdk/api/trace/get)
* [Delete Trace](/sdk/api/trace/delete)

## Related

<Card title="Trace" icon="arrow-right-from-bracket" iconType="solid" href="/concepts/product/version/session/trace">
  A single turn in a conversation between a user and the AI.
</Card>
