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

# Tracing only

> Trace LlamaIndex, Haystack, AutoGen, anything that emits OpenTelemetry spans, or raw provider SDK calls. Skills don't reach these frameworks, because DecimalAI has no way to insert a prompt into them.

Skills don't reach these frameworks. DecimalAI has no way to insert a prompt into them, so it only records what they run. To give an agent skills, pick a framework with a route in [the table](https://docs.decimal.ai/sdk/python/frameworks.md), or use the [neutral `decimalai.agent_config()`](https://docs.decimal.ai/sdk/python/init#your-own-model-calls) for model calls you make yourself. Microsoft Agent Framework and Strands are traced the OpenTelemetry way below and have [skill loaders of their own](https://docs.decimal.ai/guides/native-skill-loaders.md).

## Install

```bash theme={null}
pip install decimalai                 # OpenTelemetry, Haystack, AutoGen, provider SDKs
pip install "decimalai[llamaindex]"   # LlamaIndex
pip install llama-index-llms-openai llama-index-embeddings-openai   # LlamaIndex's default bindings
```

Everything here needs a key from [Settings → API keys](https://app.decimal.ai/settings/api-keys), as `DECIMAL_API_KEY`: `decimalai.init()` raises without one.

## LlamaIndex

`init(llamaindex=True)` installs a span handler on LlamaIndex's instrumentation dispatcher, which records every query engine call, retriever hop and model call:

```python theme={null}
import decimalai
from llama_index.core import Document, VectorStoreIndex

decimalai.init(llamaindex=True, agent_name="my-rag-agent")

index = VectorStoreIndex.from_documents([Document(text="DecimalAI traces AI agents.")])
query_engine = index.as_query_engine()
print(query_engine.query("What is DecimalAI?"))
```

* **What's installed.** The extra brings `llama-index-core>=0.14.25`, which ships no model bindings. LlamaIndex defaults to OpenAI's, which the install's last line supplies. For another provider, point `Settings.embed_model` and `Settings.llm` at its bindings.
* **The name.** Runs are filed under `agent_name` or `DECIMAL_AGENT_NAME`, and under `llamaindex-agent` when nothing names one.
* **What's recorded.** Query engine, retriever and synthesizer spans, embedding calls with token counts, and model calls with the full prompt. The manifest (the agent's setup, which DecimalAI versions) comes from the query engine's config and holds tool names only. For tool schemas, use [`register_manifest()`](https://docs.decimal.ai/sdk/python/manifests).
* **Install it once.** `decimalai.llamaindex.instrument(agent_name=...)` is the by-hand form of the flag. LlamaIndex's dispatcher keeps every handler it's given, so a second install makes one query send two traces.

### Several agents in one process

One handler serves the whole process, so name the run instead of the install, with [`agent_run`](https://docs.decimal.ai/sdk/python/tracing#mark-where-a-run-begins-and-ends):

```python theme={null}
from decimalai.providers import agent_run

with agent_run("support-rag"):
    support_engine.query("Where's my order?")          # filed under support-rag

with agent_run("billing-rag"):
    billing_engine.query("Why was I charged twice?")   # filed under billing-rag
```

Each run gets its own name and manifest. The name belongs to the current context, so concurrent runs stay separate if you open it inside each thread or `asyncio` task, not around the dispatch. LlamaIndex's own `instrument_tags({"agent_name": "..."})` wins when both are set.

## OpenTelemetry and Haystack

`init(otel=True)` puts DecimalAI's exporter on the global tracer provider. The exporter reads span attributes, so anything that puts [`gen_ai.*` spans](https://opentelemetry.io/docs/specs/semconv/gen-ai/) on that provider is recorded: a framework's own instrumentor, or a span you open yourself:

```python theme={null}
import decimalai
from opentelemetry import trace

decimalai.init(otel=True, agent_name="my-pipeline")

tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("chat gpt-5.4-mini") as span:
    span.set_attribute("gen_ai.system", "openai")
    span.set_attribute("gen_ai.request.model", "gpt-5.4-mini")
    span.set_attribute("gen_ai.prompt.0.content", "Hello!")
    reply = "Hi! How can I help?"  # your model call goes here
    span.set_attribute("gen_ai.completion.0.content", reply)

decimalai.flush()
```

That makes one trace with one model call.

| Attribute | What it becomes |
| - | - |
| `gen_ai.system`, `gen_ai.request.model` | Provider and model |
| `gen_ai.prompt.N.content` | Input |
| `gen_ai.completion.N.content` | Output |
| `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens` | Token counts |

The exporter reads OpenInference's `llm.*` attributes too, which is how Haystack gets here: `pip install openinference-instrumentation-haystack`, call `decimalai.init(otel=True)`, then `HaystackInstrumentor().instrument()`.

Spans leave within about five seconds and at exit, and `decimalai.flush()` sends them at once. The manifest is built from what the spans show. For tool schemas, use [`register_manifest()`](https://docs.decimal.ai/sdk/python/manifests).

## AutoGen and AG2

Neither is an integration. `decimalai.init(autogen=True)` and `decimalai.autogen.instrument()` still run, but they only install the same exporter as `init(otel=True)` and log a warning, so nothing instruments your agents for you.

AG2 emits no spans until you call `autogen.opentelemetry.instrument_llm_wrapper(capture_messages=True)` once and `autogen.opentelemetry.instrument_agent(agent)` per agent. Its spans then arrive like any others. The classic `autogen` package is frozen at 0.14.1, because AG2 moved to the `ag2` package, which no longer provides the `autogen` API.

Microsoft's `autogen-core` and `autogen-agentchat` are a different framework. Their spans reach the exporter, but carry no model or token counts.

## Direct provider tracing

For raw SDK calls with no framework, `init(openai=True)`, `init(anthropic=True)` or `init(google=True)` traces every `openai`, `anthropic` or `google.genai` call in the process:

```python theme={null}
import decimalai

decimalai.init(openai=True, agent_name="my-agent")
```

* **Each flag needs its instrumentor.** Install `openinference-instrumentation-openai`, `-anthropic` or `-google-genai`. Without it, the flag warns and skips.
* **Each call is its own trace.** To group a run's calls into one trace, wrap them in [`agent_run`](https://docs.decimal.ai/sdk/python/tracing#mark-where-a-run-begins-and-ends).
* **Don't combine it with a framework flag** that traces the same provider, or each call is recorded twice.

To give those calls skills as well, the [OpenAI SDK](https://docs.decimal.ai/sdk/python/frameworks/openai.md), [Anthropic API](https://docs.decimal.ai/sdk/python/frameworks/anthropic.md) and [Gemini API](https://docs.decimal.ai/sdk/python/frameworks/google-genai.md) each have an `agent_config()`.


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