A command-line interface for Google Colab. Provision high-performance CPU, GPU, and TPU runtimes, execute local code, manage remote files, and orchestrate automated cloud pipelines — directly from your terminal.
Designed to support seamless developer productivity, headless automation, and AI agent integrations.
Important
This is a fork of Google's googlecolab/google-colab-cli, not the official release. It is built on Google's code and keeps every command of it; what it adds is listed under What this fork adds. Releases are published on GitHub, not on PyPI (the google-colab-cli package there is Google's).
demo.mov
Google's CLI provisions runtimes and runs code on them from Linux and macOS. This fork runs the same commands on Windows too, and adds what long or unattended work needs: background jobs you can follow, results scripts and AI agents can read, a desktop panel, saved run setups and a watch on compute units.
| Google's Colab CLI 0.8.0 | This fork (0.8.0.N) | |
|---|---|---|
| Platforms | Linux, macOS ("Windows is not supported") | Linux, macOS and Windows (PowerShell, cmd.exe, Git Bash): Drive mount, colab edit, colab ssh/forward with Windows OpenSSH, any code page |
| Desktop | — | colab tray: a tray icon and panel with every runtime's progress, ETA, loss trend, compute units left, Log/SSH/Stop, notifications, start with the computer |
| Saved setups | — | colab profile: a script or notebook as a background job, or a server in the kernel with port forwards and a ready check, started with one command or click; the runtime stops itself when the job ends |
| Long runs | colab exec / colab run stay attached |
colab job and colab run --detach: start, follow (status, tail, wait), stop; progress over the whole run (epochs, notebook cells) |
| Scripts and AI agents | text output | --json records with the failing line in your file, a diagnosis code and the commands to try next; colab inspect (variables, GPU, disk, packages); colab history (recurring failures and what fixed them) |
| Cost | colab usage |
a compute-unit --budget that stops the run, estimates per runtime, a low-balance warning |
| Execution control | run the whole file | --cells, --stop-on-error, --check/--check-only, --var NAME=JSON; --timeout has no default limit and interrupts the kernel when set |
| Secrets and networking | — | colab secret / --secret, colab ssh -L / colab forward, colab share (cloudflared, ngrok), colab keepalive, colab hf, colab clone |
| Updates | from PyPI | colab update installs this fork's releases; a newer Google release is announced, never installed over the fork |
Commands only in this fork: colab tray, colab profile, colab job, colab inspect, colab history, colab secret, colab forward, colab share, colab keepalive, colab hf, colab clone. Design notes: docs/09_tray_and_profiles.md (tray, profiles, progress), docs/08_agent_feedback.md (JSON results, jobs, inspect, cost, history).
Versions are numbered after the Google release they are based on: 0.8.0.N is Google's 0.8.0 plus this fork's changes, so Google's next release (0.8.1) still sorts above it. Google's changes are merged in when they are released, and sometimes before: 0.8.0.4 already has Google's commits up to 17 November 2026. See CHANGELOG.md.
Note
Platform support: Linux, macOS, and Windows (PowerShell and cmd.exe). colab ssh --proxy-mode reads stdin with a blocking read so it works as an OpenSSH ProxyCommand under Windows OpenSSH.
Tip
Looking for in-notebook, interactive agent-assisted coding instead of a terminal workflow? See the Colab MCP Server.
- Instant VM Provisioning: Spin up CPU, GPU (T4, L4, G4, H100, A100), or TPU (v5e1, v6e1) runtimes in seconds.
- Robust Code Execution: Run local Python scripts, Jupyter Notebooks (
.ipynb), or pipedstdincode; launch interactive REPLs or SSH shells (colab ssh). - Ephemeral Job Runner (
colab run): Provision a fresh VM, execute a local script with forwarded arguments, retrieve output files, and automatically tear down the runtime in a single command. - Activity-Based Liveness: Sessions stay alive as long as the kernel is active, with the Colab backend automatically maintaining liveness.
- Seamless Workspace Automation: Mount Google Drive, authenticate Google Cloud Platform (GCP) credentials, and install dependencies with high-performance
uvpackage management. - State & Log Archival: Inspect local session states or export interactive history logs to standard Jupyter Notebooks, Markdown, or structured JSONL.
Install the latest version of this fork from GitHub using uv (recommended) or pip. It is pure Python and works on Linux, macOS and Windows; git must be installed:
# Using uv (recommended)
uv tool install git+https://github.com/arlinamid/google-colab-cli
# Using pip
pip install git+https://github.com/arlinamid/google-colab-cliFor the tray panel add the [tray] extra (it installs Qt, PySide6, about 80 MB):
uv tool install "google-colab-cli[tray] @ git+https://github.com/arlinamid/google-colab-cli"This installs the main branch, which holds the latest release (and documentation fixes made since). If main has moved on since the release, colab version shows a development version such as 0.8.0.4.dev1; colab update --install replaces it with the next release. To install one release, add its tag (git+https://github.com/arlinamid/google-colab-cli@v0.8.0.3), or install its wheel from the releases page.
uv tool install google-colab-cli / pip install google-colab-cli install Google's official release from PyPI instead, without this fork's changes.
Standalone binary (no Python needed): each release also has a single-file colab program: colab-<version>-windows-x64.exe, colab-<version>-linux-x64 and colab-<version>-macos-arm64 (Apple silicon; on an Intel Mac install with uv or pip). Download it from the latest release, rename it to colab (colab.exe on Windows), put it on your PATH, and on Linux/macOS run chmod +x colab. colab update tells you when a new one is out; download it the same way (colab update --install only upgrades pip/uv installs). The binary includes the tray panel (colab tray). To build one yourself: uv run --locked --exact --no-dev --extra tray --with pyinstaller python packaging/build_binary.py (then uv sync to get the dev tools back).
Run a CPU-based VM runtime, execute some code, and clean up:
# 1. Provision a new session
colab new
# 2. Execute code from stdin
echo 'print("Hello from Google Colab!")' | colab exec
# 3. Stop and release the VM resource
colab stopNote
When only one session is active, you can omit the -s, --session option;
the CLI automatically knows it.
Run colab <command> --help to view specific options, defaults, and detailed help.
| Command | Description |
|---|---|
colab new [-s NAME] [--gpu GPU] [--tpu TPU] [--high-mem] |
Allocate a new CPU, GPU, or TPU VM runtime (optionally high-RAM) |
colab sessions |
List all active sessions currently active on the backend |
colab status [-s NAME] |
Display hardware, machine shape, status, and local metadata for active sessions |
colab restart-kernel [-s NAME] |
Restart the active session's Jupyter kernel |
colab stop [-s NAME] |
Terminate a session VM and release its resources |
colab stop --all |
Stop every local session the server still has |
colab stop --orphans [--yes] |
List server-side runtimes with no local session ([?] in colab sessions) and stop them after confirmation |
colab attach --endpoint ID [-s NAME] |
Use a runtime opened elsewhere (e.g. in the Colab web UI) as a local session: colab upload, colab exec, colab ssh and scp then work on it |
colab stop --endpoint ID |
Stop one runtime by the endpoint colab sessions lists, also one opened in the Colab web UI |
colab url [-s NAME] [--open] |
Print or open a browser URL connecting to the active session |
| Command | Description |
|---|---|
colab run [--gpu GPU] [--tpu TPU] [--high-mem] [--keep | --detach] [--secret SPEC] [--json] [--budget CU] SCRIPT [ARGS...] |
Run a local script on a fresh VM, forwarding arguments, then release it; --detach starts it as a background colab job and keeps the VM |
colab exec [-s NAME] [-f FILE] [--output-image PATH] [--secret SPEC] [--var NAME=JSON] [--cells SPEC] [--stop-on-error] [--check | --check-only] [--json | --json-stream] |
Execute Python code from stdin, a local .py file, or a .ipynb notebook (exits 1 if the code or any cell raised an error) |
colab repl [-s NAME] [--output-image PATH] |
Start an interactive Python REPL on the VM (exits cleanly on piped EOF) |
colab ssh [-s NAME] [--proxy-mode] [-i KEY] [--gpu GPU] [--tpu TPU] [--high-mem] [-L PORT [-N]] [--force] [-- CMD ...] |
Open an SSH shell to the runtime over WebSocket, run a one-shot remote command (-- CMD), or act as an OpenSSH ProxyCommand bridge for IDE remote-dev |
colab job start [-s NAME] [--name N] [--env K=V] [--secret SPEC] [--budget CU] [--json] (-f SCRIPT [-- ARGS] | -- CMD) |
Start a long job in the background on the runtime and return at once; -f also takes a notebook (.ipynb, its cells run in order in IPython); Python jobs report metrics, and report(epoch=, epochs=) the overall progress, with colab_feedback.report(); --budget stops the job once it has used about that many compute units |
colab job status|tail|wait|stop|list [-s NAME] [ID] [--json] |
Follow a job: state, tqdm progress, overall progress, epoch or notebook cell, metrics trend, last output, stall flag and a diagnosis of failures; wait keeps the runtime alive and exits with the job's code |
colab profile list|show|add|edit|rm|path|run |
Saved run setups in profiles.toml: run NAME starts a script or notebook as a background job (new runtime, or its fixed session), or runs a server in the kernel (vars), forwards its ports and opens its URL when ready |
colab tray [--interval S] [--detach] [--snapshot [--json]] [--autostart on|off|status] |
Tray icon and panel (needs the [tray] extra): runtimes with progress, ETA and main metric, Log/SSH/Stop, compute units left (estimated), start profiles, notifications, an About window (version, links); it never keeps a runtime alive. --snapshot prints the same without a GUI; --autostart starts the tray when you sign in (Windows, macOS, Linux) |
colab inspect [-s NAME] [--vars] [--gpu] [--disk] [--packages] [--files PATH] [--json] |
Show the kernel's variables (types and shapes, never values), GPU, disk, memory and packages installed since the first inspect; a busy kernel is not queued behind |
colab history errors|stats [-s NAME] [--since 7d] [--json] |
Learn from earlier runs: recurring failures and what fixed them last time; runs, success rate, usual duration and cost per file (local history only) |
colab forward [-s NAME] PORT... |
Forward local ports to the runtime over ssh (private; keeps the runtime alive until Ctrl+C) |
colab share [-s NAME] PORT [--via cloudflared|ngrok] [--detach] |
Share a runtime port at a public URL (keeps the runtime alive until Ctrl+C; --list, --stop) |
| Command | Description |
|---|---|
colab ls [-s NAME] [--json] [PATH] |
List remote files on the VM (--json: name, type, size, modified) |
colab upload [-s NAME] [-r] [--via contents|ssh] LOCAL REMOTE |
Upload a local file or directory (-r) to the VM filesystem; --via ssh copies with scp |
colab download [-s NAME] [-r] [--via contents|ssh] REMOTE LOCAL |
Download a remote file or directory (-r) from the VM filesystem; --via ssh copies with scp |
colab mkdir [-s NAME] PATH |
Create a remote folder |
colab rm [-s NAME] [-r] PATH |
Delete a remote file, or a folder with everything in it (-r) |
colab edit [-s NAME] PATH |
Edit a remote file in-place using your local $EDITOR |
| Command | Description |
|---|---|
colab auth [-s NAME] |
Authenticate the VM for GCP services (BigQuery, GCS, etc.) |
colab drivemount [-s NAME] [--authuser N] [PATH] |
Mount Google Drive on the VM (default: /content/drive) |
colab install [-s NAME] [-r FILE | PKG...] |
Install packages on the VM using uv (falls back to pip) |
colab secret set [-s NAME] NAME[=SOURCE]... |
Set secrets in the kernel's environment; values never go on the command line or into the history log |
colab hf login [-s NAME] [--token SOURCE] |
Log the runtime in to Hugging Face |
colab hf download [-s NAME] REPO_ID [--repo-type T] [--revision R] [--local-dir DIR] |
Download a Hugging Face model, dataset or space onto the runtime |
colab clone [-s NAME] REPO [DEST] [--branch B] [--depth N] [--token SOURCE] |
Clone a git repository (GitHub owner/name or https URL) onto the runtime |
colab keepalive [-s NAME] [--minutes N] |
Keep a runtime alive without running code (e.g. behind a detached share) |
colab log [-s NAME] [-n N] [-o FILE] |
View or export session history (.ipynb, .md, .txt, .jsonl) |
colab usage [--json] |
Show account compute-unit usage rate and balance (--json: balance, rate and hours left at that rate) |
colab pay |
Open the Colab subscription page to manage compute units |
colab version |
Print the installed version of the CLI |
colab update [--install] |
Check for a newer release (and optionally upgrade the CLI in place) |
Tokens are passed as NAME[=SOURCE], never as values: SOURCE is env (the local NAME variable, the default), env:VAR, prompt (hidden), hf-cli (hf auth token) or gh-cli (gh auth token). Values are written as *** in the history log.
colab secret set -s s1 HF_TOKEN WANDB_API_KEY=prompt
colab exec -s s1 --secret OPENAI_API_KEY -f job.py
colab hf login -s s1 && colab hf download -s s1 google/gemma-3-1b-it
colab clone -s s1 me/private-repo # uses GH_TOKEN or your gh login
colab forward -s s1 7860 # http://localhost:7860, only for you
colab share -s s1 7860 # public https://...trycloudflare.com
colab share -s s1 7860 --via ngrok # needs NGROK_AUTHTOKENThe Colab backend only counts kernel activity as use, so colab forward, colab ssh -L and colab share keep the runtime alive while they run. See docs/07_secrets_tunnels_integrations.md.
--auth {oauth2,adc}— Authentication strategy for the Colab API (default:oauth2). To authenticate with Application Default Credentials (--auth adc), run:gcloud auth application-default login \ --scopes=openid,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/colaboratory-c, --client-oauth-config PATH— Path to public OAuth client credentials configuration (default:~/.colab-cli-oauth-config.json).--config PATH— Path to local session metadata storage (default:~/.config/colab-cli/sessions.json).--logtostderr— Direct debug logging output to stderr.--public-api / --no-public-api— List runtimes through Google's new Colab Public API (colaboratory.googleapis.com) instead of the tunnel API (default: off; alsoCOLAB_CLI_PUBLIC_API=1oruse_public_apiinsettings.json). Google's API currently refuses this CLI's sign-in;colab test-public-apichecks which API your credentials can reach.
Provision an A100 GPU, install requirements, run a local training script, retrieve the resulting model weights, and terminate the VM:
colab new -s trainer --gpu A100
colab install -s trainer torch transformers
colab exec -s trainer -f train.py
colab download -s trainer checkpoints/model.bin ./model.bin
colab stop -s trainerMount Google Drive, run a local notebook against the VM kernel (outputs are written back into report_output.ipynb), export a Markdown log of the execution, and clean up:
colab new -s analysis
colab drivemount -s analysis
colab exec -s analysis -f report.ipynb
colab log -s analysis -o execution_log.md
colab stop -s analysiscolab exec runs every code cell top to bottom by default. A cell that raises an error does not stop the run, but the command exits with code 1 and lists the failed cells. You can change this with the following options:
--cells SPEC: run only some cells, in the order given.SPECis a comma-separated list of code-cell numbers (counted from 1, without markdown cells), ranges such as2-5,#@titlevalues or cell ids. An entry that looks like a number or range is always read as one, so select a cell whose title or id is numeric by its number.--stop-on-error: stop at the first failing cell.--check: check the selected cells locally before anything runs: the notebook structure,--cells, and Python syntax (IPython!cmd,%magic,x = !cmdand top-levelawaitare accepted;%%cell magics are skipped). If a check fails, nothing runs.--check-only: run the same checks and print which cells would run, without a session.
colab exec -f report.ipynb --check-only --cells "Setup,4-6"
colab exec -s analysis -f report.ipynb --check --cells "Setup,4-6" --stop-on-error-
Machine shape: Use
--high-memwithcolab new,colab run, orcolab ssh(when auto-creating a runtime) to request a high-RAM machine shape. Requires Colab Pro or Pro+ entitlement for supported accelerators (CPU, T4, A100, etc.). L4 and TPU runtimes ignore this flag because they only offer one shape. Machine shape is shown incolab sessionsandcolab status. -
TTY Requirements:
colab repland interactivecolab sshexpect a local TTY. When running inside automated scripts or pipelines, pipe stdin tocolab repl(e.g.,echo "print(1)" | colab repl) to trigger its non-interactive mode, or run one-shot shell commands withcolab ssh -s NAME -- CMD(e.g.,colab ssh -s NAME -- ls /content); pass untrusted values as separate arguments (after--where the program accepts it), since a single argument is a remote shell line.colab sshneeds a localsshclient and key, so where it can't work (no client or key, a tool not on the minimal ssh environment'sPATH, or the runtime's concurrent SSH connections in use), pipe the commands tocolab execwith IPython's!prefix (e.g.,echo '!ls /content' | colab exec); each!line is its own shell and IPython expands{expr}and$namein it, so start a multi-line script with%%bashand keep untrusted text out of!lines. -
Drive mount and multiple Google accounts:
colab drivemountprints a consent URL (and opens it in the browser when it can) and waits up to 10 minutes. On the account chooser, select the same account the CLI authenticated as (colab whoami/ thelogin_hintin the URL). A browser that is signed into several accounts otherwise attributes the Drive session to the active account, and Colab rejects the mount with HTTP 400.--authuser Nappends that index to the consent URL when the chooser keeps opening the wrong account. -
Git Bash on Windows: Git Bash rewrites arguments that look like POSIX paths, so
/content/xreaches Windows programs asC:/Program Files/Git/content/x.colab ls,rm,upload,download,edit,inspect --files, the remote command ofcolab ssh -- CMDandcolab job start -- CMD, and the script arguments ofcolab runturn such remote paths back (also after--opt=). Python code you pipe tocolab execis not rewritten by Git Bash. -
Results for AI agents (
--json):colab exec --jsonandcolab run --jsonprint one JSON record per cell and a summary on stdout (everything else goes to stderr). A failed cell's record names the failing line in your local file, a diagnosis code (e.g.missing_module,cuda_oom,file_not_found) and thecolabcommands to try next:$ echo 'import torchvision' | colab exec -s demo --json {"schema": "colab.v1", "type": "cell", "status": "error", "error": {"ename": "ModuleNotFoundError", "location": {"file": "<stdin>", "line": 1, ...}, ...}, "diagnosis": {"code": "missing_module", "next_actions": [{"cmd": "colab install -s demo torchvision", "why": "install the missing package"}, ...]}, ...} {"schema": "colab.v1", "type": "summary", "status": "error", "cells_run": 1, "cells_failed": 1, "exit_code": 1, ...}
Exit codes: 1 code error, 3 lost session, 4 timeout, 5
--budgetreached (runkeeps the script's own code). A failure seen before carriesdiagnosis.seen_beforewith what fixed it last time (from the local history, seecolab history). The summary'scostblock estimates the compute units used;--budget CU(also oncolab job start) stops a run before it costs more, andcolab usage --jsongives balance and rate.COLAB_CLI_JSON=1turns--jsonon everywhere;--json-streamalso streams output events. See docs/08_agent_feedback.md. -
Transparent Code Execution: When calling
colab exec -f file.py, the CLI reads the file locally and transmits its content to the remote kernel. You do not need to manually upload files before execution. -
Storage & State Paths: Session tokens and metadata are stored at
~/.config/colab-cli/sessions.json. Global CLI settings are located at~/.config/colab-cli/settings.json. These can be customized or isolated via the global--configflag.
Use colab run to run a local script on dedicated hardware without manual session lifecycle management. The CLI handles provisioning, script execution, and immediate VM teardown automatically:
# Run train.py on a T4 GPU and release the VM on completion
colab run --gpu T4 train.pyTo execute a local file directly on a remote accelerator, place the colab run interpreter in the shebang line:
#!/usr/bin/env -S colab run --gpu L4 --keep
import torch
print("L4 GPU Available:", torch.cuda.is_available())
print("Device Name:", torch.cuda.get_device_name(0))Make the script executable (chmod +x script.py) and run it: ./script.py. The --keep option tells the CLI to preserve the session VM on completion so you can re-execute or inspect logs.
colab tray shows a Files button on each runtime's card. It opens a two-pane window, like Total Commander: this computer on the left, the runtime's /content on the right.
- Copy: drag and drop between the panes (or from Explorer), the Upload / Download buttons, or F5. F7 new folder, F8 delete (local files go to the recycle bin), Enter opens, Backspace goes up, the drive list switches drives.
- Transfer: Contents API (no key needed) or SSH / scp (faster for big files; needs an SSH key without a passphrase: set
"ssh_identity": "~/.ssh/your_key"in~/.config/colab-cli/settings.jsonif it is not~/.ssh/id_ed25519). - Progress and Cancel: a bar with files done / total and the time; Cancel stops the copy (files already copied stay; with scp the file being copied may be cut short).
- Command line: the field at the bottom runs a command in the runtime's current folder.
- If the runtime stops or the connection ends, a red banner says so and only the local pane stays usable.
Details: docs/09_tray_and_profiles.md, section 5.
A runtime you started in the browser shows as [?] in colab sessions. Attach it to use it from the CLI:
colab sessions # [?] m-s-usc1c3-29lht8cq7mkz8 | Hardware: CPU ...
colab attach --endpoint m-s-usc1c3-29lht8cq7mkz8 -s web
colab upload -s web data.csv /content/data.csv
colab upload -s web -r --via ssh ./project /content/project
colab ssh -s web -- ls -la /content
colab stop -s web # stops it in the browser tooThe CLI runs code in its own kernel, not the notebook's, but /content is shared, so uploaded files show in the notebook's Files panel at once. In the tray, the card of such a runtime has a Connect button that runs colab attach for you. To stop one without attaching: colab stop --endpoint ID.
For comprehensive architectural overviews and deep-dives into specific CLI sub-systems, refer to the detailed documentation:
- Session Management Architecture
- Interactive & Non-Interactive Execution Design
- File Management & Jupyter Contents API
- Authentication Providers & VM Automation
- Ephemeral Job Runner Design
- Agent Feedback Loop
- Tray Panel, Progress and Run Profiles
To view interactive walkthroughs of eleven real-world automated scenarios, check out the Demo Walkthroughs.
Feedback and contributions are welcome! Please read CONTRIBUTING.md for details.
See Colab's Terms of Service and the Google Privacy Policy, which apply to usage of this CLI.
