SmolAgents is Hugging Face's lightweight open-source library for building LLM-powered agents in just a few lines of Python. Its primary agent type (CodeAgent) writes tool calls as Python code rather than JSON, enabling natural composability via function nesting and loops. It supports any LLM backend including local Transformers and Ollama models, cloud providers via LiteLLM, and Hugging Face Hub models. Agents and tools can be shared and loaded directly from the Hub as Gradio Spaces. SmolAgents is the successor to the deprecated transformers.agents. Key features: - CodeAgent executes tool calls as Python code for composable, auditable actions - ToolCallingAgent mode for JSON-based tool calling (compatible with standard APIs) - Supports any LLM: Transformers, Ollama, OpenAI, Anthropic, LiteLLM integration - Sandboxed code execution via Modal, E2B, Docker, or Blaxel - Share and load agents and tools from Hugging Face Hub as Gradio Spaces - ~1,000 lines of core code; minimal abstractions by design
Free and open source (Apache 2.0). No paid tiers.
