Python SDK
Install the Roboflow Python SDK and write a first script to download datasets and work with projects, versions, and models.
Last updated
Was this helpful?
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.
Installation (GitHub)
Quickstart (GitHub)
The Roboflow Python package requires Python >=3.10.
pip install roboflowIf 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-slimThe 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.
Grab your API key from Settings → API Key and export it:
Then download a version of a public Universe dataset:
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.
The SDK's main objects:
Roboflow
Top-level client
workspace(), project()
Workspace
A Roboflow workspace
list_projects(), create_project(), upload_dataset(), list_workflows(), list_folders(), trash()
Project
A dataset/project
versions(), version(n), upload(), train(), delete(), restore()
Version
A frozen dataset version
download(), train(), model, delete(), restore()
*.Model (per task)
A hosted trained model
predict()
For task-oriented walkthroughs of every public method, browse the rest of this section in the sidebar.
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.
Last updated
Was this helpful?
Was this helpful?
export ROBOFLOW_API_KEY=rf_xxxxximport 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")