> ## 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

> [!WARNING]
>
> You are reading the docs of Galtea 5.11. [Read this page in the latest version](https://docs.galtea.ai/sdk/api/trace/service.md).

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

> [!NOTE]
>
> Remember that we will be using the `galtea` object. More information [here](https://docs.galtea.ai/v5.11/sdk/api/galtea.md).

## 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](https://docs.galtea.ai/v5.11/sdk/api/trace/generate.md) - **Recommended** for automatic span collection
* [Create Trace](https://docs.galtea.ai/v5.11/sdk/api/trace/create.md)
* [Create and Evaluate](https://docs.galtea.ai/v5.11/sdk/api/trace/create-and-evaluate.md) - Create a trace and evaluate it in one call
* [Create Trace Batch](https://docs.galtea.ai/v5.11/sdk/api/trace/create-batch.md)
* [Update Trace](https://docs.galtea.ai/v5.11/sdk/api/trace/update.md)
* [Upload Output File](https://docs.galtea.ai/v5.11/sdk/api/trace/upload-output-file.md) - Upload a file to attach to a turn's answer
* [List Traces](https://docs.galtea.ai/v5.11/sdk/api/trace/list.md)
* [Get Trace](https://docs.galtea.ai/v5.11/sdk/api/trace/get.md)
* [Delete Trace](https://docs.galtea.ai/v5.11/sdk/api/trace/delete.md)

## Related

> [card] [Trace](https://docs.galtea.ai/v5.11/concepts/product/version/session/trace.md)
>
> A single turn in a conversation between a user and the AI.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.