Quick Use
pip install smolagentsfrom smolagents import CodeAgent, tool, LiteLLMModel
@tool
def get_weather(city: str) -> str:
'Get city weather'
return f"{city}: 22°C, clear"
agent = CodeAgent(tools=[get_weather], model=LiteLLMModel("anthropic/claude-sonnet-4-20250514"))
agent.run("What's the weather in Tokyo?")Intro
Smolagents is HuggingFace's minimalist Python agent framework, with 15,000+ GitHub stars. Build a full agent in fewer than 30 lines of code. Its signature Code Agent mode lets the LLM write Python directly to call tools. Ideal for developers who want the shortest path to building an agent.
Source & Thanks
Created by HuggingFace. Licensed under Apache 2.0.
smolagents — ⭐ 15,000+