smolagents
Open-source Python library for building agents that write their actions as code
- Tool type
- Python agent library
- Made for
- Python developers building agents
- Runs on
- Your Python environment
- Install with pip; models run via APIs or locally; sandbox recommended for code execution
What it does
smolagents takes a task written in plain language, plus a language model and an optional set of tools, and returns the agent's final answer. Its main agent, CodeAgent, writes each action as a Python snippet that calls tools as functions, so one step can loop over several searches or combine results. It also offers ToolCallingAgent, which uses conventional JSON or text tool calls. Agents can work with text, vision, video and audio inputs.
Developers install it with pip, create a model object, attach tools and call agent.run(). The model can be a Hugging Face inference provider, OpenAI, Anthropic and many others through LiteLLM, Azure, Amazon Bedrock, or a local Transformers or Ollama model. Tools can come from MCP servers, LangChain or Hub Spaces, and agents can be shared to or loaded from the Hub. It also ships two command-line tools, smolagent and webagent. The core logic is kept to roughly a thousand lines, so the source is easy to read and modify.
It suits Python developers and researchers prototyping agents who want a small, readable framework rather than a hosted app. You need a Python environment and access to a model, which may mean API keys or local hardware. Because CodeAgent runs generated code, run it in a sandbox such as Docker, E2B, Modal or Blaxel; the built-in local executor is explicitly not a security boundary.
What it can do
- CodeAgent writes its actions as Python code that calls tools as functions
- ToolCallingAgent supports JSON/text-based tool calling
- Model-agnostic: Hub inference providers, LiteLLM, OpenAI-compatible servers, Azure, Bedrock, Transformers, Ollama
- Uses tools from MCP servers, LangChain or Hub Spaces
- Share and load agents and tools via the Hugging Face Hub
- Command-line tools smolagent and webagent for running agents without boilerplate
Works with
- Hugging Face Hub
- Modal
- Blaxel
- E2B
- Docker
- LiteLLM
- Ollama
- Transformers
- MCP servers
- LangChain
Example workflows
- Web research agent
- Input: a question and a web search tool. Steps: install smolagents[toolkit], create a CodeAgent with the search tool and a model, call agent.run(question). Output: the agent's final answer after it writes and runs code that searches.
- Command-line trip planning
- Input: a trip prompt, a model type and ID, and a web search tool. Steps: run the smolagent command with those options, or launch interactive mode and follow the setup wizard. Output: the agent's answer printed in the terminal.
Before you choose
- CodeAgent executes model-generated code; use Docker, E2B, Modal or Blaxel, because the built-in LocalPythonExecutor is not a security boundary.
- The library itself carries no stated fee, but model inference, sandbox services and local hardware costs depend on your choices.
- It is a developer library with no hosted end-user app; some model options need extras such as smolagents[litellm] or smolagents[transformers].
Listed under
Get started
Use the quickstart and Installation Guide; a model provider is needed
- Install with pip install 'smolagents[toolkit]'
- Choose and configure a model, such as InferenceClientModel, LiteLLMModel or TransformersModel, with any required API keys
- Create a CodeAgent with tools, run it in a sandbox, and call agent.run()
Plans and prices
The source code is available under Apache 2.0. Model inference, sandbox and compute costs depend on your providers.
- Apache 2.0 license
Source: github.com/huggingface/smolagents, checked 28 Oct 2026. Prices can change; check before you buy.
Sources for this overview
Product pages, documentation, and pricing checked 28 Oct 2026. Each source supports part of the overview; availability and prices can change.
Ratings and reviews
No ratings for smolagents yet.
What’s changed
Free accountSignals
Free accountData and security
Free accountCompare with similar tools
Free accountWhere this comes from
How we research- Company website
- huggingface.co: product, pricing and policy pages
- YC directory mirror
- Batch and company name
- Web search
- Confirms the official site
- Social accounts
- Accounts the company links, and its posts on X
- Human review
- Checked by a person
- knowledge_base
Last checked 28 Oct 2026. Every field keeps its source and date; unknown means we couldn’t confirm it.