Models

A code agent is only as good as the model writing the code — and smolagents, true to its Hugging Face roots and minimalist ethos, lets you run almost any model behind it: open models from the Hub, hosted APIs, local models, anything reachable through its integrations. Model choice matters especially here, because the model's code-writing ability is the agent's ability.

smolagents agents write code, so the model behind them is what determines how well they work. This post covers models in smolagents: its model-agnostic design (Hugging Face models, hosted APIs, local models, and more), why model choice is especially consequential for code agents, and how the code-agent approach interacts with the model landscape. The library’s Hugging Face origin makes open and local models first-class, which is part of its appeal.

Model-agnostic, with open models first-class

smolagents is model-agnostic — it works with many model backends through its integrations, and you choose the model when creating the agent:

This breadth — open, hosted, and local models all supported — reflects both the Hugging Face ethos (open models are first-class, not an afterthought) and the general keep-the-model-swappable principle. You write the agent once and choose (and change) the model behind it. The first-class support for open and local models is a distinguishing feature: where some frameworks orient around hosted APIs, smolagents makes running an open model (including locally) straightforward, which suits privacy-sensitive, cost-sensitive, or offline scenarios.

Why model choice matters especially for code agents

Model choice matters in any agent framework, but for a code agent there’s a specific dependency: the model has to write good code. The whole code-agent advantage (the earlier posts) rests on the model producing correct, expressive code as its actions — so the model’s code-writing ability directly determines the agent’s capability:

So for a code agent, “choose a model that writes good code” is the specific selection criterion, and it’s why smolagents pairs naturally with the many capable open code-writing models. The model isn’t just a component — it’s the author of every action, so its code ability is the agent’s ceiling.

Model choice as a cost, privacy, and capability lever

Because the model is swappable and central, it’s a lever for the familiar production concerns, with smolagents’s open/local support adding a privacy dimension:

Key takeaways

Further reading

Sources & References