Master smolagents with our step-by-step tutorial, detailed feature walkthrough, and expert tips.
Install smolagents with 'pip install smolagents' in your Python environment Import the framework and create your first CodeAgent or ToolCallingAgent Define a simple tool by writing a Python function with docstring and type hints
💡 Quick Start: Follow these 1 steps in order to get up and running with smolagents quickly.
Explore the key features that make smolagents powerful for ai agent builders workflows.
Revolutionary Agent type that generates and executes Python code to accomplish tasks, enabling arbitrary data processing and tool composition beyond structured function calling.
Building a data analysis agent that can write custom Python code to process CSVs, create visualizations, and generate reports.
Revolutionary Any Python function with a docstring and type hints automatically becomes an agent tool — no schemas, decorators, or configuration files needed.
Turning an existing Python utility function into an agent tool by simply adding a docstring.
Revolutionary Hierarchical agent composition where manager agents delegate to specialized workers, each with their own tools and LLM configuration.
Building a research system where a manager agent coordinates a web search agent, a summarization agent, and a fact-checking agent.
Revolutionary Load tools and agent configurations from the Hub, share custom tools with the community, and deploy agents on Spaces.
Publishing a custom tool on the Hub for the community to use, or loading a community-built tool into your agent.
Revolutionary Readable traces showing every step of agent reasoning, tool calls, code generation, and execution with full inputs and outputs.
Debugging why an agent produced an unexpected result by inspecting the complete execution trace.
Revolutionary Works with OpenAI, Anthropic, local Hugging Face models, and any provider through LiteLLM — swap models without code changes.
Testing the same agent with GPT-4, Claude, and a local Llama model to compare quality and cost.
smolagents prioritizes simplicity and readability — the entire core is a few hundred lines. LangChain is more comprehensive but significantly more complex. smolagents is ideal when you want to understand and control every aspect of your agent.
CodeAgent generates Python code to accomplish tasks instead of using structured function calling. This allows it to combine tools, process data, and implement custom logic dynamically.
Yes, smolagents supports local Hugging Face models via transformers, as well as local inference servers like Ollama and vLLM.
smolagents is suitable for production with appropriate guardrails. Code execution runs in a sandboxed environment by default. For enterprise monitoring, pair it with an observability tool like Langfuse.
Now that you know how to use smolagents, it's time to put this knowledge into practice.
Sign up and follow the tutorial steps
Check pros, cons, and user feedback
See how it stacks against alternatives
Follow our tutorial and master this powerful ai agent builders tool in minutes.
Tutorial updated March 2026