Anyscale CLI and SDK
Anyscale is a Python library and CLI that provides programmatic tools for authenticating and interacting with the Anyscale platform. It simplifies the deployment and scaling of machine learning models, particularly those involving large language models (LLMs), by enabling interaction with Anyscale's cloud infrastructure from Python applications or the command line. The library is actively maintained, with frequent updates, and the current version is 0.26.93.
Warnings
- breaking The legacy `AnyscaleSDK` class is deprecated and will be removed by February 28, 2026. Migrate to directly importing `anyscale` and using `anyscale.<module>.<function>()`.
- breaking Legacy CLI commands like `anyscale cluster-env`, `anyscale cluster start/terminate`, and `anyscale machine list/delete` have been removed. Use `anyscale image` and `anyscale workspace_v2` commands instead.
- breaking Support for Python 3.8 was removed starting in Anyscale CLI version 0.26.75.
- deprecated The `anyscale cloud edit` command is deprecated. Use `anyscale cloud update` instead.
- deprecated Legacy cloud SDK methods `get_cloud`, `get_default_cloud`, and `search_clouds` have been removed. Use `anyscale.cloud.get`, `anyscale.cloud.get_default`, and `anyscale.cloud.list` respectively.
- gotcha The default value for `max_retries` when submitting jobs will change from 1 to 0 in a future release. Explicitly set `max_retries` for consistent behavior.
Install
-
pip install anyscale -
pip install anyscale[azure] -
pip install anyscale[gcp]
Imports
- anyscale
import anyscale jobs = anyscale.job.list()
Quickstart
import os
import anyscale
# Ensure you have logged in via `anyscale login` or set ANYSCALE_CLI_TOKEN
# For non-interactive use, generate an API key from the Anyscale console
# and set it as an environment variable.
# os.environ['ANYSCALE_CLI_TOKEN'] = os.environ.get('ANYSCALE_CLI_TOKEN', '')
# List Anyscale jobs
try:
print("Listing Anyscale jobs...")
jobs = anyscale.job.list(max_items=5)
if jobs.results:
for job in jobs.results:
print(f" Job ID: {job.id}, Name: {job.name}, State: {job.state}")
else:
print(" No Anyscale jobs found.")
except Exception as e:
print(f"Error listing jobs: {e}")
print("Please ensure you are authenticated. Run `anyscale login` or set the ANYSCALE_CLI_TOKEN environment variable.")