smolagents

Active
GitHub Python Apache-2.0

Description

smolagents is a lightweight agent framework from Hugging Face for quickly building tool-using LLM agents.

Key Features

  • Code-generating agent — CodeAgent writes and executes Python code directly as tool calls, not JSON
  • Sandboxed execution — Secure code running via Blaxel, E2B, Modal, Docker sandboxes
  • Hub integration — One-click share/pull agents and tools from Hugging Face Hub
  • Model-agnostic architecture — Supports 100+ models including transformers, Ollama, OpenAI, Anthropic
  • Multi-modal support — Agents handle text, vision, video, and audio inputs
  • CLI tools — smolagent and webagent commands to run agents directly from terminal

Use Cases

💡 Quickly build automated data analysis agents that write and execute code
💡 Share custom agent tools via Hub for team member reuse
💡 Build multi-modal agents for image understanding and video content analysis tasks
💡 Connect external services via MCP tool servers to extend agent capabilities

Quick Start

pip install "smolagents[toolkit]"

```python
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel

model = InferenceClientModel()
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True)

agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
```

Related Projects

Related Articles