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

# Export OpenInference traces

> Learn how to export OpenInference traces for a context for observability and debugging.

This guide shows you how to export OpenInference-format traces for a context. Traces provide detailed observability into the agent's reasoning, connector calls, and tool usage.

## Prerequisites

* An existing context with at least one task (see [Send a message](/agentic/guides/send-message))
* An access token or client credentials

## What are OpenInference traces

OpenInference is an open standard for tracing LLM applications. Each trace contains spans that represent individual operations: LLM calls, connector invocations, tool usage, and more. Each span has attributes like `llm.token_count.total`, `tool.name`, and `input.value`.

## Export traces

```bash theme={null}
# Replace these with your values
CONTEXT_ID="<your-context-id>"
ENVIRONMENT="<eu-or-us>"
TENANT="<your-tenant-name>"
TOKEN="<your-access-token>"

curl "https://api.${ENVIRONMENT}.corti.app/v2/agentic/contexts/${CONTEXT_ID}/trace" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Tenant-Name: ${TENANT}"
```

### Pagination

The trace endpoint supports pagination with `pageSize` (default: 50, max: 200) and `pageToken` query parameters. The response includes `nextPageToken` (opaque cursor for the next page, or `null` if there are no more pages) and `totalSize` (not currently populated by the server):

```bash theme={null}
curl "https://api.${ENVIRONMENT}.corti.app/v2/agentic/contexts/${CONTEXT_ID}/trace?pageSize=100&pageToken=${PAGE_TOKEN}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Tenant-Name: ${TENANT}"
```

## Trace structure

The response contains a `traces` array, ordered newest first. Each trace has:

| Field              | Description                                   |
| ------------------ | --------------------------------------------- |
| `trace.id`         | Trace identifier (OTel trace ID, 32-char hex) |
| `trace.name`       | Human-readable trace name                     |
| `trace.start_time` | When the trace started                        |
| `trace.thread_id`  | Context ID associated with the trace          |
| `spans`            | Array of OpenInference spans in this trace    |

Each span has:

| Field            | Description                                                 |
| ---------------- | ----------------------------------------------------------- |
| `name`           | Human-readable span name                                    |
| `span_id`        | Unique span identifier                                      |
| `parent_span_id` | Parent span ID (omitted for root span)                      |
| `start_time`     | When the span started                                       |
| `attributes`     | Span attributes (e.g. `llm.token_count.total`, `tool.name`) |

## Using traces for debugging

Traces help you understand:

* **Which connectors were called**: Look for spans with `tool.name` attributes
* **How many tokens were consumed**: Look for `llm.token_count.total` attributes
* **What inputs were sent to connectors**: Look for `input.value` attributes
* **How long each step took**: Compare `start_time` across spans
* **The reasoning chain**: Follow `parent_span_id` to reconstruct the call tree

## Next steps

* Learn how to [work with contexts](/agentic/guides/work-with-contexts) via the API
* Read about [viewing usage](/agentic/guides/view-usage) for aggregated metrics
* Understand the [architecture](/agentic/architecture) for how traces fit into the system
