CLI Reference
Complete reference for all zgrok commands, flags, and options
Every subcommand, flag, type, and default the zgrok CLI supports.
Commands
zgrok http [PORT]
Start an HTTP tunnel. PORT is optional if default_port is set in config.
| Flag | Type | Default | Description |
|---|---|---|---|
PORT | integer (positional) | default_port from config | Local port to forward |
-d, --subdomain <NAME> | string | random name | Custom tunnel name inside your project, e.g. api for api--acme-shop.zgrok.io (PRO plan) |
--project <SLUG> | string | the active project from your config; with none set, a picker when there is a terminal and several projects, otherwise your organization's default project | Project to open the tunnel in, for this run only |
-s, --server <ADDR> | string | relay.zgrok.io:4433 | Relay server address |
-a, --api-key <KEY> | string | resolved via API key resolution | Your zgrok API key |
--header <NAME: VALUE> | string, repeatable | none | Inject a custom response header; repeat the flag for more than one |
--allow-ip <LIST> | comma-separated IPs/CIDRs | none | IP allowlist (PRO only) |
--no-log | boolean flag | false | Disable the terminal request log |
--qr | boolean flag | false | Print a QR code for the tunnel URL |
--no-inspect | boolean flag | false | Disable the local request inspector |
--inspect-port <PORT> | integer | 4040 (or inspect_port from config) | Port for the local inspector; conflicts with --no-inspect |
--log-json | boolean flag | false | Write one JSON object per request to stdout |
--log-file <PATH> | path | none | Append one JSON object per request to a file |
--skip-update-check | boolean flag | false | Ignore update information, so a required update does not stop the tunnel |
-v, --verbose | boolean flag | false | Print diagnostic output (see Verbose output) |
zgrok http 8080 --subdomain myapi --header "Access-Control-Allow-Origin: *"zgrok ai [PORT]
Tunnel a local AI model: Ollama, LM Studio, or any OpenAI-compatible server. Authenticated by default, with no first-byte timeout on long completions. See the Local AI guide.
| Flag | Type | Default | Description |
|---|---|---|---|
PORT | integer (positional) | 11434 (Ollama) | Local port to forward |
--token <TOKEN> | string | auto-generated zg_ai_… | Bearer token clients must send as Authorization: Bearer <token> |
-d, --subdomain <NAME> | string | random name | Custom, stable tunnel name inside your project (PRO plan) |
--project <SLUG> | string | the active project from your config; with none set, a picker when there is a terminal and several projects, otherwise your organization's default project | Project to open the tunnel in, for this run only |
-s, --server <ADDR> | string | relay.zgrok.io:4433 | Relay server address |
-a, --api-key <KEY> | string | resolved via API key resolution | Your zgrok API key |
--no-log | boolean flag | false | Disable the terminal request log |
--qr | boolean flag | false | Print a QR code for the tunnel URL |
--no-inspect | boolean flag | false | Disable the local request inspector |
--inspect-port <PORT> | integer | 4040 (or inspect_port from config) | Port for the local inspector; conflicts with --no-inspect |
--log-json | boolean flag | false | Write one JSON object per request to stdout |
--log-file <PATH> | path | none | Append one JSON object per request to a file |
--skip-update-check | boolean flag | false | Ignore update information, so a required update does not stop the tunnel |
-v, --verbose | boolean flag | false | Print diagnostic output (see Verbose output) |
zgrok ai 1234 --token my-long-secret-token --subdomain my-llm --qrzgrok ai does not accept --header or --allow-ip. Every AI tunnel is already gated by its bearer token at the edge.
zgrok login
Sign this machine in through your browser. The CLI prints a code, waits for you to approve it, and saves a new API key to ~/.zgrok/config.yaml. If the file already holds a key, it is replaced, and the CLI says so.
| Flag | Type | Default | Description |
|---|---|---|---|
--no-browser | boolean flag | false | Print the URL and code without opening a browser |
The browser also stays closed over SSH and on Linux with no display. The URL and code are printed in every case, so you can approve from any device.
zgrok login
zgrok login --no-browserzgrok config add-authtoken TOKEN
Save an API key you already have to ~/.zgrok/config.yaml, for a machine where nobody can approve in a browser. Everywhere else, zgrok login is simpler.
zgrok config add-authtoken zk_abc123def456zgrok update
Download and install the latest release, replacing the running binary in place.
zgrok updateYou do not have to remember to check. When a tunnel connects, the server says whether a newer version exists and the CLI prints it once. A release marked as required stops the tunnel until you update.
zgrok --version / -V
Print the installed version.
zgrok --help / -h
Print help. Also available per-subcommand: zgrok http --help, zgrok ai --help, zgrok config --help.
Verbose output
-v (or --verbose) turns on diagnostic output. It works on every command, before or after the subcommand:
zgrok -v http 3000
zgrok http 3000 -vWithout it, zgrok prints only the interface: the banner, the request log, and its own messages. There is no hidden log file and nothing is written anywhere else, so if something goes wrong and you want to tell us what happened, -v is what to send:
zgrok http 3000 -v 2> zgrok.logEverything zgrok prints goes to stderr, so a single 2> captures the whole session. Verbose adds the QUIC and TLS handshake detail underneath. That is enough to diagnose a connection that will not establish, and deliberately short of the level that would dump request contents.
RUST_LOG overrides -v when it is set, and is applied exactly as written.
API key resolution
zgrok looks for an API key in this order, for both http and ai:
--api-key/-aCLI flagZGROK_API_KEYenvironment variableapi_keyin~/.zgrok/config.yaml
If none is found, the CLI exits with an error explaining all three options.
Examples
# Basic tunnel
zgrok http 3000
# Custom tunnel name (myapi--<project>.zgrok.io) + CORS headers
zgrok http 8080 --subdomain myapi --header "Access-Control-Allow-Origin: *"
# Restricted access with QR code
zgrok http 3000 --allow-ip 203.0.113.0/24 --qr
# Quiet mode (no request logs)
zgrok http 3000 --no-log
# Move the inspector off the default port
zgrok http 3000 --inspect-port 4100
# No web UI, just a machine-readable record per request
zgrok http 3000 --no-inspect --log-json | jq --unbuffered 'select(.status >= 500)'
# Using environment variable
ZGROK_API_KEY=zk_abc123 zgrok http 3000
# Tunnel a local Ollama instance with a stable token
zgrok ai --token my-long-secret-token
# Sign in once, then omit --api-key from every future command
zgrok loginSee also
- Configuration: config file reference
- Request Inspector: the inspector and JSON export flags in depth
- Installation: install and update
- Local AI:
zgrok aiin depth