Kernel Logo

GitHub License Discord Follow @juecd__ Follow @rfgarcia

# Kernel CLI The Kernel CLI is a fast, friendly command‑line interface for Kernel — the platform that provides sandboxed, ready‑to‑use Chrome browsers for browser automations and web agents. Sign up at [kernel.sh](https://www.kernel.sh/) and read the [docs](https://www.kernel.sh/docs/introduction). ## What's Kernel? Kernel provides sandboxed, ready-to-use Chrome browsers for browser automations and web agents. This CLI helps you deploy apps, run actions, manage browsers, and access live views. ### What you can do with the CLI - Create new Kernel applications from templates - Deploy and version apps to Kernel - Invoke app actions (sync or async) and stream logs - Create, list, view, and delete managed browser sessions - Get a live view URL for visual monitoring and remote control - Search the web across providers and retrieve page content for results ## Installation Install the Kernel CLI using your favorite package manager: ```bash # Using brew (recommended) brew install onkernel/tap/kernel # Using pnpm pnpm install -g @onkernel/cli # Using npm npm install -g @onkernel/cli ``` Verify the installation: ```bash which kernel kernel --version ``` ## Quick Start 1. **Create a new Kernel app:** ```bash kernel create ``` 2. **Authenticate with Kernel:** ```bash kernel login ``` 3. **Deploy your app:** ```bash kernel deploy index.ts ``` 4. **Invoke your app:** ```bash kernel invoke my-app action-name --payload '{"key": "value"}' ``` ## Authentication ### OAuth 2.0 (Recommended) The easiest way to authenticate is using OAuth: ```bash kernel login ``` This opens your browser to complete the authentication flow. Choose organization-wide access or restrict the login to one project. Your credentials are securely stored, automatically refreshed, and retain the selected scope until you log in again. ### API Key You can also authenticate using an API key: ```bash export KERNEL_API_KEY= ``` Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com). ### Workload identity federation A CI job or other workload can authenticate without a stored API key. Set `KERNEL_FEDERATION_RULE_ID` to a federation rule (see `kernel workload-identity federation-rules`), and the CLI exchanges the workload's own identity token for a short-lived Kernel access token: ```yaml # GitHub Actions permissions: id-token: write steps: - run: kernel browsers list env: KERNEL_FEDERATION_RULE_ID: wifr_... ``` | Variable | Purpose | | --- | --- | | `KERNEL_FEDERATION_RULE_ID` | The federation rule to authenticate with. Turns federation on. | | `KERNEL_IDENTITY_TOKEN_SOURCE` | Where the identity token comes from: `github_actions`, `gcp_metadata`, `aws_sts`, `file` or `env`. When unset: `KERNEL_IDENTITY_TOKEN_FILE` if set, then `KERNEL_IDENTITY_TOKEN`, then GitHub Actions when the job exposes an OIDC token. | | `KERNEL_IDENTITY_TOKEN_FILE` | Path of a file holding the identity token, read again for every exchange. | | `KERNEL_IDENTITY_TOKEN` | A literal identity token. | | `KERNEL_IDENTITY_TOKEN_AUDIENCE` | Audience the built-in sources request. Defaults to the authorization server URL. | | `KERNEL_FEDERATION_TOKEN_CACHE` | Set to `off` (or `false`, `0`, `no`) to exchange a new access token in every command instead of caching it. | The CLI authenticates with the first of these that is configured: `KERNEL_API_KEY`, then `KERNEL_FEDERATION_RULE_ID`, then the login saved by `kernel login`. When `KERNEL_FEDERATION_RULE_ID` is set and the exchange fails, the command fails. It does not fall back to a saved login. `kernel auth` shows which one is in use. Each command is a new process, so the access token is cached between commands until 60 seconds before it expires. If the API rejects a cached token, the command fails, the CLI drops the token, and the next command exchanges a new one. A request is never sent twice. A token is cached only where it can be tied to the workload that obtained it: | Identity token source | Cached | Where | Reused only by | | --- | --- | --- | --- | | `github_actions` | Yes, when `RUNNER_TEMP` is set | A file under `RUNNER_TEMP`, which the runner empties for every job | The same job: same repository, run, attempt, job name and OIDC request credentials | | `file` | Yes | Next to the saved login: the OS keychain, or a file in `~/.config/kernel` that only you can read. Under `RUNNER_TEMP` in a GitHub Actions job. | A process whose token file has the same path and holds the same identity token | | `env` | Yes | As for `file` | A process with the same `KERNEL_IDENTITY_TOKEN` | | `aws_sts`, `gcp_metadata` | No | | | The cache entry is also specific to the federation rule, the authorization server, the API URL and `KERNEL_IDENTITY_TOKEN_AUDIENCE`. It never replaces the saved login. ## Commands Reference ### Global Flags - `--version`, `-v` - Print the CLI version - `--no-color` - Disable color output - `--log-level ` - Set log level (trace, debug, info, warn, error, fatal, print) - `--project ` - Scope requests to a project by ID or exact name (or set `KERNEL_PROJECT`). A non-empty flag overrides the environment variable. The selector is sent to the API as `X-Kernel-Project`, without a client-side project lookup. Project-scoped API keys and OAuth tokens cannot switch projects. ## JSON Output Many commands support JSON output for scripting and automation. Use `--output json` or `-o json` to get machine-readable output: ```bash # Get browser session details as JSON kernel browsers create -o json # List apps as JSON kernel app list -o json # Deploy with JSONL streaming output (one JSON object per line) kernel deploy index.ts -o json ``` Commands with JSON output support: - **Browsers**: `create`, `list`, `get`, `view` - **Browser Pools**: `create`, `list`, `get`, `update`, `acquire` - **Profiles**: `create`, `list`, `get`, `update` - **Extensions**: `upload`, `list` - **Proxies**: `create`, `list`, `get`, `update`, `check` - **API Keys**: `create`, `list`, `get`, `update`, `rotate` - **Auth Connections**: `timeline` - **Vaults**: `create`, `list`, `get`, `credentials create/update`, `items list/get/events/invoke` (including `collect`, `fill`, `webmcp_invoke`, and `prepare_checkout`), `wallets create/payment-methods`, `cards create/update` (display-safe public fields only) - **Projects**: `update` - **Org**: `limits get/set` - **Apps**: `list`, `history` - **Deploy**: `deploy` (JSONL streaming), `history` - **Invoke**: `invoke` (JSONL streaming), `history` - **Browser Sub-commands**: `replays list/start`, `process exec/spawn`, `fs file-info/list-files`, `webmcp list`, `webmcp custom-tools list/add` (`webmcp invoke` always prints JSON output) - **Browser NDJSON streaming**: `telemetry stream` ### Search Search commands always return the full API response as JSON, including results, warnings, provider attempts, usage, and expiry. They use the normal API key or OAuth authentication and global `--project` scope. Your organization must have Search API access enabled. ```bash # Discover currently configured providers and capabilities kernel search providers # Automatic routing kernel search "Playwright browser automation" --max-results 5 # Retrieve a retained result without another provider call or search charge kernel search get srch_01jsearchresult # Use portable filters or other advanced request fields kernel search --request '{"query":"browser automation","include_domains":["example.com"],"strict_params":true}' # Fetch content for the top results of a retained search kernel search contents srch_01jsearchresult --limit 3 --content-source browser ``` - `--max-results` accepts 1–100; the API may clamp it to the provider cap. - `--request` accepts the complete Search API JSON object, including `max_results`, typed strategies (`auto`, `pinned`, or `fallback`), portable filters, `content`, `include_raw`, date/locale filters, and provider-specific options. It cannot be combined with a positional query, `--provider`, or `--max-results`. Provider-specific and advanced request validation is performed by the API. - Create requests are not automatically retried, to avoid duplicate billable searches after an ambiguous failure. If a request fails ambiguously, use `search get` only when the API returned a retained search ID. - Retained searches return 404 when missing, expired, or inaccessible. - `search contents ` retrieves content for selected results of a retained search. Provide exactly one of `--result-ids` (in desired response order) or `--limit` (top N results, 1–100). `--timeout-ms` sets the overall deadline (1000–120000). Content options: `--content-source` (`auto`, `provider`, or `browser`; default `auto`), `--content-format` (`markdown` or `text`), `--content-max-chars`, `--content-max-age-hours`, `--content-timeout-ms`, `--content-browser-id` (reuse an existing browser session), and `--content-browser-mode` (`curl` or `render`). When no browser ID is given and a result needs browser retrieval, Kernel creates a temporary browser for the request; it is billed like any other browser. Requests are not automatically retried. - To search for a literal query equal to a subcommand name (`get` or `providers`), use `--request '{"query":"providers"}'`. ### Authentication - `kernel login [--force]` - Login via OAuth 2.0 - `kernel logout` - Clear stored credentials - `kernel auth` - Check authentication status and which credential is in use (API key, workload identity or saved login) ### App Creation - `--name `, `-n` - Name of the application - `--language `, `-l` - Sepecify app language: `typescript`, or `python` - `--template