Scale AI Python Client
raw JSON → 2.18.4 verified Fri May 01 auth: no python
The official Python client library for Scale AI, the Data Platform for AI. Provides programmatic access to Scale's APIs for creating tasks, managing batches, datasets, and more. Current version is 2.18.4, with active development and a new v2 API client. Release cadence is roughly monthly.
pip install scaleapi Common errors
error ImportError: cannot import name 'ScaleClient' from 'scaleapi' ↓
cause The module scaleapi may be outdated or installed incorrectly. Check that the package is installed and you're using the correct import path.
fix
Run 'pip install --upgrade scaleapi' and then use 'import scaleapi; client = scaleapi.ScaleClient(...)'.
error scaleapi.exceptions.ScaleUnauthorized: 401 Client Error: Unauthorized for url: https://api.scale.com/v1/projects ↓
cause API key is invalid, missing, or expired.
fix
Set the SCALE_API_KEY environment variable to a valid Scale API key. Generate a new key if needed.
error TypeError: 'module' object is not callable ↓
cause The user tried to call 'scaleapi()' instead of 'scaleapi.ScaleClient()'.
fix
Use 'scaleapi.ScaleClient(api_key)' to create a client instance.
error AttributeError: module 'scaleapi' has no attribute 'v2' ↓
cause You are using a version older than 2.16.0 which does not have the v2 client.
fix
Upgrade to scaleapi >= 2.16.0 with 'pip install --upgrade scaleapi'.
Warnings
breaking Starting v2.16.0, Python 3.7 support is dropped. Requires Python >= 3.8. ↓
fix Upgrade Python to 3.8 or later.
gotcha The v2 client (client.v2) uses different methods than the v1 client. For example, create_task is not available under v2; use v2_create_task or the respective v2 endpoint. ↓
fix Check the v2 API docs: https://docs.genai.scale.com/v2.
deprecated The method 'get_tasks' without pagination helper is deprecated. Use 'get_tasks' with parameters or 'v2.get_tasks' for paginated results. ↓
fix Use 'client.get_tasks(project_name=..., batch_name=..., limit=..., offset=...)' or 'client.v2.get_tasks(...)'.
gotcha API key must be passed as a string. Passing None or empty string gives a 401 Unauthorized error on first request. ↓
fix Ensure the environment variable is set and non-empty. For local testing, set SCALE_API_KEY explicitly.
Imports
- ScaleClient wrong
from scaleapi import clientcorrectimport scaleapi client = scaleapi.ScaleClient('api_key') - ScaleClient wrong
from scaleapi import ScaleClient as Clientcorrectfrom scaleapi import ScaleClient client = ScaleClient('api_key')
Quickstart
import os
import scaleapi
api_key = os.environ.get('SCALE_API_KEY', '')
client = scaleapi.ScaleClient(api_key)
# List your projects
for project in client.get_projects():
print(project.name, project.type)