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

# Python SDK

> The `decimalai` Python package — installation, tracing, manifests, evaluations, replay, datasets, framework adapters, and skills.

The Python SDK is the primary way to integrate DecimalAI into your agent code. It wraps every public REST endpoint, auto-instruments 8 agent framework integrations plus 3 direct LLM provider SDKs (OpenAI, Anthropic, Google) — including native plugins for Google ADK and Anthropic's Claude Agent SDK — and ships zero-config helpers for tracing, evaluation, and dataset export.

```bash theme={null}
pip install decimalai
```

```python theme={null}
import decimalai
decimalai.init(api_key="dai_sk_...", openai_agents=True)
# Every supported framework call is now traced.
```

## Sections

<CardGroup cols={2}>
  <Card title="Init & Setup" icon="play" href="/sdk/python/init">
    `decimalai.init()`, environment variables, framework flags.
  </Card>

  <Card title="Tracing" icon="route" href="/sdk/python/tracing">
    `@trace`, `start_trace`, `log_llm_call`, `log_tool_call`, `@tool`.
  </Card>

  <Card title="Manifests" icon="layer-group" href="/sdk/python/manifests">
    `register_manifest`, `flush_manifest_for_ci`.
  </Card>

  <Card title="Evaluations" icon="check-double" href="/sdk/python/evaluations">
    `eval`, `score`, `get_eval_breakdown`, `batch_eval`, `@eval`, external imports.
  </Card>

  <Card title="Replay & Experiments" icon="rotate" href="/sdk/python/replay">
    `get_replay_prompts`, `create_replay_batch`, `get_replay_batch`.
  </Card>

  <Card title="Datasets & Training" icon="database" href="/sdk/python/datasets">
    `pull_dataset`, `push_to_hub`, `load_hf_dataset`.
  </Card>

  <Card title="Framework Instrumentation" icon="puzzle-piece" href="/sdk/python/frameworks">
    8 framework integrations — OpenAI Agents, LangChain, LlamaIndex, CrewAI, AutoGen, generic OTel, plus native plugins for Google ADK and Anthropic Claude Agent SDK.
  </Card>

  <Card title="Skills" icon="brain" href="/sdk/python/skills">
    Sync from disk, pull from platform, `SkillRouter` CRUD.
  </Card>
</CardGroup>

## Complete API Summary

### Top-level functions (in `decimalai`)

Grouped by surface. Every function below is importable directly from `decimalai`.

<AccordionGroup>
  <Accordion title="Tracing" icon="route">
    | Method            | Description                                    |
    | ----------------- | ---------------------------------------------- |
    | `init()`          | Initialize SDK and auto-instrument frameworks. |
    | `@trace()`        | Decorator to trace a function as an agent run. |
    | `start_trace()`   | Context manager for manual trace boundaries.   |
    | `log_llm_call()`  | Log an LLM call inside a trace.                |
    | `log_tool_call()` | Log a tool call inside a trace.                |
    | `@tool`           | Decorator to register a tracked tool.          |
    | `send()`          | Send a fully-constructed trace payload.        |
  </Accordion>

  <Accordion title="Manifests" icon="layer-group">
    | Method                    | Description                                                        |
    | ------------------------- | ------------------------------------------------------------------ |
    | `register_manifest()`     | Explicitly register agent configuration.                           |
    | `flush_manifest_for_ci()` | Capture and write the manifest ID for the regression-check Action. |
  </Accordion>

  <Accordion title="Evaluations" icon="check-double">
    | Method                    | Description                                                                                                                                                |
    | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `eval()`                  | **Pushes a single named score to a trace** (alias of `score()`). The custom-evaluator *decorator* is `@decimalai.evals.eval`, not this top-level function. |
    | `score()`                 | Push a single named score to a trace.                                                                                                                      |
    | `batch_eval()`            | Apply evaluators across multiple traces in parallel.                                                                                                       |
    | `get_eval_breakdown()`    | Get full eval breakdown for a trace.                                                                                                                       |
    | `push_deepeval_results()` | Import DeepEval scores.                                                                                                                                    |
    | `push_langsmith_scores()` | Import LangSmith feedback as eval scores.                                                                                                                  |
    | `push_custom_scores()`    | Push scores from any source.                                                                                                                               |
  </Accordion>

  <Accordion title="Datasets" icon="database">
    | Method              | Description                                                                        |
    | ------------------- | ---------------------------------------------------------------------------------- |
    | `pull_dataset()`    | Download a dataset version to a local JSONL/Parquet file (returns a summary dict). |
    | `push_to_hub()`     | Push a dataset to HuggingFace Hub.                                                 |
    | `load_hf_dataset()` | Load a dataset version directly as an in-memory `datasets.Dataset` (no file).      |
  </Accordion>

  <Accordion title="Replay" icon="rotate">
    | Method                   | Description                        |
    | ------------------------ | ---------------------------------- |
    | `get_replay_prompts()`   | Download stale prompts for replay. |
    | `create_replay_batch()`  | Create a batch of replay tasks.    |
    | `get_replay_batch()`     | Check replay batch progress.       |
    | `submit_replay_result()` | Submit a replayed trace result.    |
  </Accordion>
</AccordionGroup>

### Framework instrumentation (subpackages)

8 framework integrations. Google ADK and Anthropic's Claude Agent SDK use **native** plugins (not OTel).

| Module                       | Function             | Use it for                                                              |
| ---------------------------- | -------------------- | ----------------------------------------------------------------------- |
| `decimalai.langchain`        | `install()`          | LangChain / LangGraph callbacks                                         |
| `decimalai.openai_agents`    | `install(agent=...)` | OpenAI Agents SDK — pass the Agent object for full schema introspection |
| `decimalai.llamaindex`       | `install()`          | LlamaIndex span handler                                                 |
| `decimalai.crewai`           | `install()`          | CrewAI via OpenTelemetry                                                |
| `decimalai.autogen`          | `install()`          | AutoGen / AG2 via OpenTelemetry                                         |
| `decimalai.adk`              | `install()`          | Google ADK — native plugin (Gemini-native)                              |
| `decimalai.claude_agent_sdk` | `install()`          | Anthropic Claude Agent SDK — native plugin                              |
| `decimalai.otel`             | `install()`          | Generic OpenTelemetry GenAI span exporter                               |

### Class-based clients

| Class                            | Use it for                                                                                                                                                                                                                                                                                      |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SkillRouter` (from `decimalai`) | Registry + skill lifecycle: `fork` (workspace copy), `install` (fork + write to disk), `preview` (read-only snapshot), `create_skill`, `list_skills`, `get_skill`, `update_skill`, `delete_skill`, `sync_skills`, `list_versions`, `get_menu`, `smart_route`, `export_to_disk`, `pull_missing`. |

### REST-only endpoints

For endpoints that don't yet have a top-level SDK wrapper (list\_datasets, get\_trace\_stats, get\_manifest, repair preview/apply, compatibility policy set, etc.), use `httpx` directly against the REST API:

```python theme={null}
import httpx

resp = httpx.get(
    "https://api.decimal.ai/api/v1/datasets",
    headers={"Authorization": "Bearer dai_sk_..."},
)
resp.raise_for_status()
```

See the [API Reference](/api-reference/authentication) for the full endpoint registry.
