colab
Command-line interface for Google Colab runtimes
TLDR
SYNOPSIS
colab [global-options] command [options] [args...]
DESCRIPTION
colab is the official command-line client for Google Colab. The installed binary is `colab` (PyPI package `google-colab-cli`). It provisions CPU, GPU, and TPU VMs, runs local Python and notebooks on those kernels, copies files, and can open a REPL, tmux console, or SSH session, all from a Linux or macOS terminal.A session is a named assignment stored locally in `sessions.json` and on Colab's backend. When exactly one session is active, -s / --session can be omitted. `colab exec -f` reads the file on the client and sends the source to the kernel; the working directory on the VM is `/content`. Sessions stay assigned while the kernel is active; the CLI pings the tunnel frontend keep-alive path rather than requiring a separate local daemon.GPU values accepted by --gpu are T4, L4, G4, H100, and A100. TPU values for --tpu are v5e1 and v6e1. Availability and high-RAM shapes depend on the Colab subscription. Allocation can fail with a 412 (too many assignments or a capacity limit) or a 400 (no entitlement for that accelerator).
PARAMETERS
-h, --help
Show help. `colab help` [command] prints the same text for one subcommand.--auth oauth2|adc
How the CLI authenticates to Colab. Default is oauth2 (copy-paste Installed App flow). adc uses Application Default Credentials (`GOOGLEAPPLICATIONCREDENTIALS`, `gcloud auth application-default login`, or a GCE/GKE metadata server).-c, --client-oauth-config PATH
OAuth client JSON for --auth oauth2. Default: `~/.colab-cli-oauth-config.json`. The wheel also ships an inlined client used when that file is missing.--config PATH
Session metadata file. Default: `~/.config/colab-cli/sessions.json`.--logtostderr
Send debug logs to stderr.new [-s NAME] [--gpu T4|L4|G4|H100|A100] [--tpu v5e1|v6e1] [--high-mem]
Allocate a VM. With neither --gpu nor --tpu, the runtime is CPU. --high-mem requests a high-RAM shape (Colab Pro or Pro+; ignored for L4 and TPU).sessions
List assignments on the backend, with local names, hardware, machine shape, and variant.status [-s NAME]
Print hardware, shape, IDLE/BUSY, and last-execution metadata for local sessions.restart-kernel [-s NAME]
Restart the Jupyter kernel on an existing session.stop [-s NAME]
Shut down the kernel, unassign the VM, and drop local state.url [-s NAME] [--host ORIGIN] [--open]
Print a Colab notebook URL that attaches to the existing VM. --open also launches a browser. Default host is `https://colab.research.google.com`.exec [-s NAME] [-f FILE] [--output-image PATH] [--timeout SEC] [--env KEY=VALUE]
Execute stdin, a `.py` file, or a `.ipynb` notebook on an existing session. See colab-exec(1).run [--gpu GPU] [--tpu TPU] [--high-mem] [--keep] [-s NAME] [--timeout SEC] [--env KEY=VALUE] SCRIPT [ARGS...]
Allocate a fresh VM, run a local script, then release it unless --keep. See colab-run(1).repl [-s NAME] [--output-image PATH]
Interactive Python REPL on the VM. Piped stdin runs once and exits.console [-s NAME]
Raw TTY (tmux) on the remote VM. Needs a local TTY.ssh [-s NAME] [--proxy-mode] [-i KEY] [--gpu GPU] [--tpu TPU] [--high-mem] [--rm]
SSH over WebSocket into `/content`. With no sessions, auto-creates a runtime. --proxy-mode is an OpenSSH `ProxyCommand` bridge. --rm stops an auto-created runtime on exit (and, in proxy mode, the bridged session on disconnect). RSA keys are rejected; Ed25519 or ECDSA only.ls [-s NAME] [PATH]
List remote files. Default path is `content` (the Jupyter contents API name for `/content`).upload [-s NAME] LOCAL REMOTE
Upload a local file to the VM.download [-s NAME] REMOTE LOCAL
Download a remote file.rm [-s NAME] PATH
Delete a remote file.edit [-s NAME] PATH
Download a remote file, open `$EDITOR`, upload if it changed. A missing remote file starts empty.drivemount [-s NAME] [PATH]
Mount Google Drive. Default path: `/content/drive`. May prompt for a browser authorization URL.install [-s NAME] [-r FILE] [PKG...]
Install packages on the VM with `uv pip install --system`, falling back to `pip`. A --requirement file is uploaded first.auth [-s NAME]
Run `google.colab.auth.authenticate_user()` on the VM (hidden from `colab --help`).log [-s NAME] [-n N] [-t TYPE] [-o FILE]
Show or export local session history. --output suffix selects `.ipynb`, `.md`, `.txt`, or `.jsonl`.usage
Print compute-unit rate and balance.pay
Open `https://colab.research.google.com/signup`.version
Print the installed CLI version.update [--install]
Check PyPI for a newer `google-colab-cli`. --install runs `pip install -U google-colab-cli` on Linux and macOS.
CONFIGURATION
~/.config/colab-cli/sessions.json
Local session tokens, endpoints, hardware, and last-execution metadata. Override with --config.~/.config/colab-cli/settings.json
CLI settings, including the cached latest-version banner used by update.~/.config/colab-cli/token.json
Cached OAuth2 user token for --auth oauth2.~/.colab-cli-oauth-config.json
Optional public OAuth client JSON. If absent, the packaged `oauth_config.json` is used.
CAVEATS
Linux and macOS only. Requires Python 3.12 or later. A Google account and Colab's Terms of Service apply; GPU, TPU, and --high-mem need the matching Colab plan and quota.colab exec and colab run default --timeout to 30 seconds. Long jobs must raise it. An unrecognized --gpu string is mapped to A100, not rejected. --high-mem is ignored for L4 and TPU shapes.repl and console need a local TTY unless stdin is piped. colab ssh does not accept RSA keys. auth is registered but hidden from the default help listing.Default --auth is oauth2, which prints an authorization URL and reads a pasted code (the same remote flow as `gcloud auth application-default login`). README text that names adc as the default does not match the Typer callback.
HISTORY
Google announced the Colab CLI on 5 June 2026. The first PyPI release was 0.5.4 on 22 May 2026. 0.6.0 (16 June 2026) switched OAuth2 to the remote copy-paste flow and replaced a keep-alive RPC that 403'd for external users. 0.7.0 (3 September 2026) added colab ssh, --env, and --high-mem; 0.7.1 (14 September 2026) unblocked that release on PyPI. The package is Apache-2.0 and built with Typer.
