opensi·si

The smolagents library can be installed using pip. Here are the different installation methods and options available.

Installation options

The smolagents library can be installed using pip. Here are the different installation methods and options available.

Prerequisites

  • Python 3.10 or newer
  • Python package manager: pip or uv

Virtual Environment

It's strongly recommended to install smolagents within a Python virtual environment. Virtual environments isolate your project dependencies from other Python projects and your system Python installation, preventing version conflicts and making package management more reliable.

venv

Using venv:

python -m venv .venv
source .venv/bin/activate

uv

Using uv:

uv venv .venv
source .venv/bin/activate

Basic Installation

Install smolagents core library with:

pip

pip install smolagents

uv

uv pip install smolagents

Installation with Extras

smolagents provides several optional dependencies (extras) that can be installed based on your needs. You can install these extras using the following syntax:

pip

pip install "smolagents[extra1,extra2]"

uv

uv pip install "smolagents[extra1,extra2]"

Tools

These extras include various tools and integrations:

pip

  • toolkit: Install a default set of tools for common tasks.
    pip install "smolagents[toolkit]"
  • mcp: Add support for the Model Context Protocol (MCP) to integrate with external tools and services.
    pip install "smolagents[mcp]"

uv

  • toolkit: Install a default set of tools for common tasks.
    uv pip install "smolagents[toolkit]"
  • mcp: Add support for the Model Context Protocol (MCP) to integrate with external tools and services.
    uv pip install "smolagents[mcp]"

Model Integration

These extras enable integration with various AI models and frameworks:

pip

  • openai: Add support for OpenAI API models.
    pip install "smolagents[openai]"
  • transformers: Enable Hugging Face Transformers models.
    pip install "smolagents[transformers]"
  • vllm: Add VLLM support for efficient model inference.
    pip install "smolagents[vllm]"
  • mlx-lm: Enable support for MLX-LM models.
    pip install "smolagents[mlx-lm]"
  • litellm: Add LiteLLM support for lightweight model inference.
    pip install "smolagents[litellm]"
  • bedrock: Enable support for AWS Bedrock models.
    pip install "smolagents[bedrock]"

uv

  • openai: Add support for OpenAI API models.
    uv pip install "smolagents[openai]"
  • transformers: Enable Hugging Face Transformers models.
    uv pip install "smolagents[transformers]"
  • vllm: Add VLLM support for efficient model inference.
    uv pip install "smolagents[vllm]"
  • mlx-lm: Enable support for MLX-LM models.
    uv pip install "smolagents[mlx-lm]"
  • litellm: Add LiteLLM support for lightweight model inference.
    uv pip install "smolagents[litellm]"
  • bedrock: Enable support for AWS Bedrock models.
    uv pip install "smolagents[bedrock]"

Multimodal Capabilities

Extras for handling different types of media and input:

pip

  • vision: Add support for image processing and computer vision tasks.
    pip install "smolagents[vision]"
  • audio: Enable audio processing capabilities.
    pip install "smolagents[audio]"

uv

  • vision: Add support for image processing and computer vision tasks.
    uv pip install "smolagents[vision]"
  • audio: Enable audio processing capabilities.
    uv pip install "smolagents[audio]"

Remote Execution

Extras for executing code remotely:

pip

  • blaxel: Add support for Blaxel sandboxes - fast-launching VMs with hibernation (recommended).
    pip install "smolagents[blaxel]"
  • e2b: Enable E2B support for remote execution.
    pip install "smolagents[e2b]"
  • docker: Add support for executing code in Docker containers.
    pip install "smolagents[docker]"

uv

  • blaxel: Add support for Blaxel sandboxes - fast-launching VMs with hibernation (recommended).
    uv pip install "smolagents[blaxel]"
  • e2b: Enable E2B support for remote execution.
    uv pip install "smolagents[e2b]"
  • docker: Add support for executing code in Docker containers.
    uv pip install "smolagents[docker]"

Telemetry and User Interface

Extras for telemetry, monitoring and user interface components:

pip

  • telemetry: Add support for monitoring and tracing.
    pip install "smolagents[telemetry]"
  • gradio: Add support for interactive Gradio UI components.
    pip install "smolagents[gradio]"

uv

  • telemetry: Add support for monitoring and tracing.
    uv pip install "smolagents[telemetry]"
  • gradio: Add support for interactive Gradio UI components.
    uv pip install "smolagents[gradio]"

Complete Installation

To install all available extras, you can use:

pip

pip install "smolagents[all]"

uv

uv pip install "smolagents[all]"

Verifying Installation

After installation, you can verify that smolagents is installed correctly by running:

import smolagents
print(smolagents.__version__)

Next Steps

Once you have successfully installed smolagents, you can:

  • Follow the guided tour to learn the basics.
  • Explore the how-to guides for practical examples.
  • Read the conceptual guides for high-level explanations.
  • Check out the tutorials for in-depth tutorials on building agents.
  • Explore the API reference for detailed information on classes and functions.

Source and license

Source: smolagents documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.