Anyscale CLI and SDK

0.26.93 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically list Anyscale jobs using the SDK. Before running this code, you must authenticate the Anyscale CLI by running `anyscale login` in your terminal or by setting the `ANYSCALE_CLI_TOKEN` environment variable for non-interactive environments.

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.")

view raw JSON →