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

# Create Trace Batch

> Create a batch of traces in a session.

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

## Returns

Returns a list of [Trace](https://docs.galtea.ai/v5.16/concepts/product/version/session/trace.md) objects.

## Example

```python theme={"system"}
trace = galtea.traces.create_batch(
    session_id=session_id,
    conversation_turns=[
        {"role": "user", "content": "Hi"},
        {"role": "assistant", "content": "Hello!"},
    ],
)
```

## Parameters

**session\_id** `string`

The session ID to log the traces to.

> [!NOTE]
>
> Instead of a `session_id`, you can reference an existing session by its own conversation id (see the section below). Provide exactly one of the two.

> [accordion] Log to an existing session by your own conversation ID
>
> If you already created the session via the [sessions API](https://docs.galtea.ai/v5.16/sdk/api/session/service.md) with your own `custom_id`, reference it here with `session_custom_id` plus a `version_id` or `product_id` to append traces to it. If no matching session exists, the call returns a `400` error — create it first via the sessions API.
>
> **session\_custom\_id** `string`
>
> Your own conversation id, as an alternative to `session_id`. Galtea finds an existing session with this id (per version); the session is not created here. Requires `version_id` or `product_id`.
>
> **version\_id** `string`
>
> The version the session is anchored to when using `session_custom_id`. If both anchors are given, `version_id` wins and `product_id` is ignored.
>
> **product\_id** `string`
>
> Product anchor used when no `version_id` is given with `session_custom_id`: Galtea finds the session with this custom id under the product (across its versions).
>
> > [!NOTE]
> >
> > If no session matches the `session_custom_id` and anchor, the call returns a `400` error. Create the session first via the [sessions API](https://docs.galtea.ai/v5.16/sdk/api/session/service.md).

**conversation\_turns** `list[dict]` *required*

A list of dictionaries, where each dictionary represents a **conversation turn** with `role` and `content` keys as mandatory and an optional `retrieval_context` key.
The `role` key can only have these values: `user` or `assistant`.

> [!NOTE]
>
> The `retrieval_context` key is optional and can be sent to our platform if you have used it when calling your AI product.
> For this reason, it only makes sense to send it when we have a message with role `assistant`.
> When set, Galtea also records it as a `RETRIEVER` span on that turn's trace.

> [!WARNING]
>
> Maximum batch size recommended: **100 turns**. For longer conversations, split into
> multiple batches or use the individual `create()` method.

**conversation\_simulator\_version** `string`

The version of Galtea's conversation simulator used to generate the user messages. This should only be provided when logging a conversation that was generated using the simulator. This parameter helps with traceability and analytics for conversations created through Galtea's simulation capabilities.


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