smolagents

The smolagents library provides a lightweight foundation for building code based AI agents.

github.com/huggingface/smolagents
smolagents homepage screenshot

About smolagents

smolagents is an open source Python library for building agents that write their actions as code. A CodeAgent can be defined in a few lines, given tools such as web search, and run with a selected language model.

It works with local transformers and Ollama models, Hub inference providers, and models from OpenAI, Anthropic and others via LiteLLM, and handles text, vision, video and audio inputs. Code can be executed in sandboxed environments via Blaxel, E2B, Modal or Docker, and agents and tools can be shared to and loaded from the Hugging Face Hub. It includes smolagent and webagent commands for running agents from the CLI.

Key features

  • CodeAgent writes agent actions as executable code
  • Run code in sandboxed environments via Docker, E2B, Modal, Blaxel
  • Work with local transformers, ollama, Hub, OpenAI, and Anthropic models
  • Use tools from MCP servers, LangChain, or Hub Spaces
  • Support text, vision, video, and audio inputs
  • Share and load agents and tools via Hugging Face Hub
Best for: Developers building Python agents that use code actions across different models and tools.
Good for
  • Small codebase with minimal abstractions above raw code
  • Works with many models, tools, and input modalities
  • Supports sandboxed code execution and Hub sharing

smolagents at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Yes · Source code
Language
English
Last checked
Oct 6, 2026 · Online when checked
Listed
Oct 5, 2026

smolagents alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in AI Agent Frameworks

Well-known listings from the same topic.

All 75

smolagents FAQ

How do I install smolagents with default tools?
Install the package with: pip install "smolagents[toolkit]"
How can code execution be isolated?
CodeAgent supports executing in sandboxed environments via Blaxel, E2B, Modal, or Docker.
How do I share or reuse an agent?
An agent can be shared to the Hub as a Space repository with push_to_hub and loaded with from_hub.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing