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

# smolagents

> Track HuggingFace's smolagents with AgentOps seamlessly

[smolagents](https://github.com/huggingface/smolagents) is a framework for building and running AI agents from [HuggingFace](https://huggingface.co/).
Checkout their [docs](https://huggingface.co/docs/smolagents/index) to get started with creating your own agents.

## Integrating AgentOps with smolagents

**1. Install the AgentOps SDK**

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

```bash poetry theme={null}
poetry add agentops
```

**2. Install smolagents**

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

```bash poetry theme={null}
poetry add smolagents
```

**3. Initialize AgentOps and use LiteLLM in your code**

> [!NOTE]
>
> AgentOps tracks calls from smolagents via LiteLLM currently.

```python python theme={null}
import agentops
from smolagents import LiteLLMModel

agentops.init(<INSERT YOUR API KEY HERE>)
model = LiteLLMModel(<model_name>)

# Your code here...

agentops.end_session('Success')
```

> [!TIP]
>
> Set your API key as an `.env` variable for easy access.

```python .env theme={null}
AGENTOPS_API_KEY=<YOUR API KEY>
```

Read more about environment variables in [Advanced Configuration](https://docs.agentops.ai/v1/usage/advanced-configuration.md)

**4. Run your Agent**

Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Agent! 🕵️

> [!TIP]
>
> After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard

![](https://raw.githubusercontent.com/AgentOps-AI/agentops/refs/heads/main/docs/images/external/app_screenshots/session-replay.png?raw=true)

Clickable link to session

## Full Examples

You can refer to the following examples -

* [Text to SQL](https://github.com/AgentOps-AI/agentops/blob/main/examples/smolagents_examples/text_to_sql.ipynb)
* [Multi-Agent System](https://github.com/AgentOps-AI/agentops/blob/main/examples/smolagents_examples/multi_smolagents_system.ipynb)


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