# smolagents

CreateWithAI Hub page: https://createwithaihub.com/frameworks/smolagents
Latest version of this file: https://createwithaihub.com/frameworks/smolagents.md

- Type: Framework · Category: Harnesses & Frameworks
- Publisher: Hugging Face
- Pricing: Free · License: Apache-2.0

Hugging Face's minimal Python library for agents that write their actions as code, with any LLM and MCP tools.

smolagents is a small open-source Python library from Hugging Face for running agents in a few lines of code. Its CodeAgent writes its actions as Python code, which can be executed in sandboxes such as E2B, Modal, Blaxel or Docker, and a ToolCallingAgent is also available. It is model-agnostic (local transformers or Ollama models, Hub inference providers, or OpenAI, Anthropic and others via LiteLLM) and can use tools from MCP servers, LangChain or Hub Spaces. Agents and tools can be shared on the Hugging Face Hub.

Useful for: Prototyping a research agent that searches the web and computes answers in Python code, then sharing it on the Hugging Face Hub.

## Key features

- Core agent logic in about 1,000 lines of code
- CodeAgent that writes actions as code, plus ToolCallingAgent
- Sandboxed code execution via E2B, Modal, Blaxel or Docker
- Tools from MCP servers, LangChain or Hub Spaces
- Text, vision, video and audio inputs
- smolagent and webagent CLI commands

## Connection

- Language: Python
- Focus: Agents & tool use
- Model support: Multi-provider

## Before you start

- Python 3.10+

## Install steps from the official documentation

pip (with default tools):

```
pip install "smolagents[toolkit]"
```

## Limitations

- Code agents execute model-written code; the README recommends sandboxed environments for security
- Python only

## Official links

- Source repository: https://github.com/huggingface/smolagents
- Documentation: https://huggingface.co/docs/smolagents/index
- Source: https://github.com/huggingface/smolagents (README: features, CodeAgent and sandboxes, model support, MCP/LangChain/Space tools, install, CLI; LICENSE: Apache-2.0)
- Source: https://github.com/huggingface/smolagents/blob/main/pyproject.toml (requires-python >=3.10)
