Practical overview
When it fits
Use Smolagents when building a custom Python agent and you want to choose its model and tools while using code as the CodeAgent’s action format.
Who it is for
- Python developers building custom AI agents
- Teams prototyping tool-using agent workflows
- Developers selecting model providers and tools for domain-specific agents
Documented uses
- Define an agent that uses Python code for actions and tool calls.
- Connect an agent to a chosen model provider and relevant tools.
- Run agent tasks from Python or the command line.
- Share or load agents through the Hugging Face Hub.
Requirements & limits
The project repository is public and identifies the software as Apache-2.0 licensed.
- CodeAgent executes generated Python actions; the project lists Blaxel, E2B, Modal and Docker as sandboxed execution options.
- Model integrations include hosted providers and local Transformers models, so the choice affects configuration and access requirements.
- Tools can come from MCP servers, LangChain, Hub tools or Spaces.
- The README documents Python and command-line use, including a separate webagent command for browsing tasks.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install the toolkit and define a web-search agent
Set up the documented Python example that pairs a CodeAgent with web search and a Hugging Face inference model.
Before you start
- Python package installation using pip
- A model configuration supported by InferenceClientModel
Steps
Install the package with the documented toolkit extras: pip install "smolagents[toolkit]".
Import CodeAgent, WebSearchTool and InferenceClientModel from smolagents.
Create an InferenceClientModel, then pass it and a WebSearchTool instance to CodeAgent.
Call the agent’s run method with a task prompt.
Expected outcome
A configured CodeAgent can receive a prompt and use the web-search tool as part of its task.
Guide limitations
- The example depends on a configured inference model; provider credentials or settings may be needed for the chosen provider.
- The README example documents the setup and call pattern, not a verified result for a particular prompt.
Configure an agent through the interactive CLI
Use the documented smolagent interactive setup to choose an agent type, tools, model settings and a task prompt.
Before you start
- The smolagents package installed in a Python environment
- Model type, model ID and any required API settings for the selected provider
Steps
Run smolagent without a prompt to open interactive mode.
Choose CodeAgent or ToolCallingAgent.
Select tools and configure the model type, ID and API settings.
Enter any advanced options, such as additional imports, and provide a task prompt.
Expected outcome
The CLI guides configuration of an agent and task prompt.
Guide limitations
- The documentation describes configuration stages but does not specify a universal provider setup or execution environment.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 30 September 2026
- Original website title
- huggingface/smolagents · Official homepage title · retained in its source language

