# Colab CLI

> Google's terminal client for Colab — provision a GPU or TPU runtime, run local scripts on it, move files back and forth, and tear it down, all without a browser tab

- Category: Models & Inference / GPU & Compute Clouds
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/googlecolab/google-colab-cli
- Canonical page: https://ai-tldr.dev/tools/google-colab-cli/
- Updated: 2026-06-05

## In short

Colab CLI is Google's official command-line interface for Google Colab. It provisions high-performance CPU, GPU and TPU runtimes, executes local code on them, manages remote files and orchestrates automated pipelines from a terminal — no notebook tab required. It sits in the GPU & Compute Clouds category of the Models & Inference tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Colab CLI is Google's official command-line interface for Google Colab. It provisions high-performance CPU, GPU and TPU runtimes, executes local code on them, manages remote files and orchestrates automated pipelines from a terminal — no notebook tab required. The stated design targets are developer productivity, headless automation and AI-agent integration, which is what makes it interesting beyond notebook users: a coding agent can request a real accelerator for one job and release it afterwards.

The command surface is small and predictable. `colab new` allocates a runtime, optionally with `--gpu` (T4, L4, G4, H100, A100), `--tpu` (v5e1, v6e1) or `--high-mem`. `colab exec` runs Python from stdin, a local `.py` file, or a `.ipynb` notebook; `colab repl` and `colab console` give an interactive Python REPL or a raw TTY shell; `colab ssh` opens a shell over WebSocket or acts as an OpenSSH `ProxyCommand` bridge for IDE remote development. `colab run` is the ephemeral job runner: fresh VM, run a local script with forwarded arguments, retrieve output files, tear the runtime down, in one command.

Around that sit the practical pieces — `upload`, `download`, `ls`, `rm` and `edit` for remote files, `drivemount` for Google Drive, `auth` for GCP credentials, and `install` which uses `uv` (falling back to pip) for dependencies. A background keep-alive daemon prevents idle termination without an open browser tab, and `colab log` exports session history to `.ipynb`, Markdown, plain text or JSONL. The project is Apache-2.0 and installs from PyPI as `google-colab-cli`; note that it supports Linux and macOS only — Windows is not supported.

## What it does

- Provision CPU, GPU (T4, L4, G4, H100, A100) or TPU (v5e1, v6e1) runtimes in seconds, optionally high-RAM
- `colab run` is a one-shot job runner: fresh VM, run a local script with forwarded arguments, fetch outputs, tear down
- Execute local .py files, .ipynb notebooks or piped stdin remotely; interactive REPL and raw TTY console also available
- `colab ssh` over WebSocket, usable as an OpenSSH ProxyCommand bridge for IDE remote development
- Background keep-alive daemon stops idle VM termination without keeping a browser tab open
- Remote file operations, Google Drive mounting, GCP authentication and uv-based package installation

## Getting started

Install the CLI, provision a session, run something on it, then stop it. When only one session is active you can omit -s.

1. Install

   uv is the recommended installer; pip works too. Linux and macOS only.

```bash
# recommended
uv tool install google-colab-cli

# or
pip install google-colab-cli
```

2. Provision, execute, clean up

   The three-command loop for a CPU runtime.

```bash
colab new
echo "print('Hello from Google Colab!')" | colab exec
colab stop
```

3. Train on an A100 and pull the checkpoint back

   Name the session, install dependencies on the VM with uv, run a local training script, download the weights, release the runtime.

```bash
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 trainer
```

4. Run a notebook against Drive and export a log

   Outputs are written back into the notebook; colab log exports the session history as Markdown, .ipynb, .txt or .jsonl.

```bash
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 analysis
```

5. Use it from a script or an agent

   The interactive commands need a local TTY, so pipe stdin to trigger non-interactive mode inside automation.

```bash
echo "print(1)" | colab repl
```

## When to use it

- Run a training or benchmarking script on a Colab A100 or H100 from your normal shell instead of a notebook
- Give a coding agent short-lived access to a real accelerator for one task, then release it automatically
- Attach an IDE to a Colab runtime for remote development over the SSH ProxyCommand bridge
- Script a repeatable pipeline — provision, install, execute, retrieve artefacts, tear down — in CI or a cron job

## Version history

- 2026-06-05: Google released the Colab CLI under Apache-2.0 — an official terminal client that provisions T4, L4, A100 and H100 GPUs plus v5e1/v6e1 TPUs, executes local code remotely, and ships an agent skill for use from coding agents.
