Python SDK

Install the Roboflow Python SDK and write a first script to download datasets and work with projects, versions, and models.

The Roboflow Python SDK is a wrapper around the Roboflow REST API, providing abstract methods for interacting with Roboflow in Python code.

The Python SDK offers methods for managing projects and workspaces, uploading and downloading datasets, running inference on models, uploading model weights, and more.

Examples and references for using methods in the Python SDK are documented in the API Reference documentation.

Resources

Installation

The Roboflow Python package requires Python >=3.10.

pip install roboflow

Lite Package

If you only need the Vision Events SDK and the CLI without heavy image processing dependencies (OpenCV, NumPy, Pillow), install the lightweight variant instead:

pip install roboflow-slim

The roboflow-slim package is significantly smaller than the full roboflow package because it omits NumPy, OpenCV, Matplotlib, and Pillow. It is well-suited for edge devices, serverless environments, CI/CD pipelines, and microservices that only need vision-event logging or basic CLI operations.

Both packages share the same codebase and API. Code written against roboflow-slim works identically against the full roboflow package - drop the lighter dependency where you don't need image visualization.

Your first script

Grab your API key from Settings → API Key and export it:

export ROBOFLOW_API_KEY=rf_xxxxx

Then download a version of a public Universe dataset:

import roboflow

rf = roboflow.Roboflow()  # picks up ROBOFLOW_API_KEY
project = rf.workspace("roboflow-100").project("poker-cards-cxcvz")
version = project.version(1)

version.download("yolov8")

See Authenticate with the Python SDK for the other two ways to pass a key. To run inference, use a Workflow or the REST API - SDK inference is deprecated.

Quick Reference

The SDK's main objects:

ClassWhat it representsCommon methods
RoboflowTop-level clientworkspace(), project()
WorkspaceA Roboflow workspacelist_projects(), create_project(), upload_dataset(), list_workflows(), list_folders(), trash()
ProjectA dataset/projectversions(), version(n), upload(), train(), delete(), restore()
VersionA frozen dataset versiondownload(), train(), model, delete(), restore()
*.Model (per task)A hosted trained modelpredict()

For task-oriented walkthroughs of every public method, browse the rest of this section in the sidebar.

Microsoft Visual C++ Instructions

Microsoft Visual C++ redistributable, is needed for some Python packages. You can download it from the official Microsoft website:

For x64 systems: https://aka.ms/vs/16/release/vc_redist.x64.exe

For x86 systems: https://aka.ms/vs/16/release/vc_redist.x86.exe

After downloading the appropriate file, run the installer and follow the prompts to install the redistributable.