{"id":2264,"library":"roboflow","title":"Roboflow Python SDK","description":"The Roboflow Python package (version 1.3.1) is the official SDK for interacting with the Roboflow API, enabling programmatic access for tasks such as dataset management, image upload, model training, and inference. It is actively developed, with recent updates including a comprehensive rewrite of the command-line interface and enhanced capabilities for workspace-level asset management.","status":"active","version":"1.3.1","language":"en","source_language":"en","source_url":"https://github.com/roboflow-ai/roboflow-python","tags":["computer vision","machine learning","API client","object detection","image classification","segmentation","dataset management"],"install":[{"cmd":"pip install roboflow","lang":"bash","label":"Install Roboflow"}],"dependencies":[],"imports":[{"symbol":"Roboflow","correct":"from roboflow import Roboflow"}],"quickstart":{"code":"import os\nfrom roboflow import Roboflow\n\n# Ensure your Roboflow API key is set as an environment variable (recommended)\n# os.environ[\"ROBOFLOW_API_KEY\"] = \"YOUR_API_KEY\"\n\n# Initialize Roboflow with your API key\n# Replace 'YOUR_ROBOFLOW_API_KEY' with os.environ.get(\"ROBOFLOW_API_KEY\", \"\") for production\nrf = Roboflow(api_key=os.environ.get(\"ROBOFLOW_API_KEY\", \"\"))\n\n# Example: Get a workspace (replace 'your-workspace-id' with your actual workspace ID)\n# You can often omit the ID if you only have one workspace associated with your API key\ntry:\n    workspace = rf.workspace(\"your-workspace-id\") \n    print(f\"Connected to workspace: {workspace.name}\")\nexcept Exception as e:\n    print(f\"Could not connect to workspace: {e}. Check your API key and workspace ID.\")\n\n# Example: List projects in the workspace\n# if 'workspace' in locals():\n#     projects = workspace.projects()\n#     print(f\"Projects in workspace: {[p.name for p in projects]}\")","lang":"python","description":"Initializes the Roboflow client and demonstrates connecting to a workspace. It's recommended to store your API key in an environment variable for security."},"warnings":[{"fix":"Review the updated Roboflow CLI documentation for the new command structure and output formats. Adapt any scripts or automation workflows that relied on the older CLI behavior.","message":"The v1.3.1 release introduced a complete rewrite of the Roboflow CLI. Users who programmatically invoked CLI commands (e.g., via `subprocess`) will find command structures, argument patterns (`noun verb`), and output formats (e.g., `--json` output) have fundamentally changed. While the Python SDK's core programmatic interface (`roboflow.Roboflow` class) remains stable, direct CLI interaction patterns are now significantly different.","severity":"breaking","affected_versions":">=1.3.1"},{"fix":"Upgrade your Python environment to 3.10 or newer if you need to process HEIF images with the Roboflow SDK. Alternatively, avoid HEIF images on Python 3.9.","message":"When working with HEIF (.heic/.heif) image formats, users on Python 3.9 might encounter issues due to a dependency (`pi_heif`) dropping support for Python 3.9 around Roboflow v1.2.13. This is a dependency-related incompatibility rather than a core Roboflow SDK issue.","severity":"gotcha","affected_versions":">=1.2.13 (when using Python 3.9 for HEIF processing)"},{"fix":"Set your `ROBOFLOW_API_KEY` as an environment variable. When initializing, use `rf = Roboflow(api_key=os.environ.get(\"ROBOFLOW_API_KEY\", \"\"))` to safely retrieve it.","message":"For security and best practice, your Roboflow API key should always be loaded from environment variables (e.g., `os.environ[\"ROBOFLOW_API_KEY\"]`) rather than being hardcoded directly into your scripts. Hardcoding keys can lead to security vulnerabilities if your code is exposed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}