> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blaxel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Blaxel CLI overview

> Install the Blaxel CLI (bl) to manage sandboxes, agents, MCP servers, jobs, and other resources from your terminal, with auth and command reference.

Blaxel CLI (`bl`) is a command line tool to interact with the Blaxel APIs.

## Install

<AccordionGroup>
  <Accordion title="Install on Mac" icon="apple">
    <Warning>
      To install Blaxel CLI, you must use [Homebrew](https://brew.sh/): make sure it is installed on your machine. We are currently in the process of supporting additional installers. Check out the cURL method down below for general installation.
    </Warning>

    Install Blaxel CLI by running the two following commands successively in a terminal:

    ```shell theme={null}

    brew tap blaxel-ai/blaxel

    ```

    ```shell theme={null}

    brew install blaxel

    ```
  </Accordion>

  <Accordion title="Install on Linux" icon="linux">
    Install Blaxel CLI by running the following command in a terminal (non-sudo alternatives below):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | BINDIR=/usr/local/bin sudo -E sh
    ```

    If you need a non-sudo alternative (**it will ask you questions to configure**):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | sh
    ```

    If you need to install a specific version (e.g. v0.1.21):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | VERSION=v0.1.21 sh
    ```
  </Accordion>

  <Accordion title="Install with cURL" icon="code">
    Install Blaxel CLI by running the following command in a terminal (non-sudo alternatives below):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | BINDIR=/usr/local/bin sudo -E sh
    ```

    If you need a non-sudo alternative (**it will ask you questions to configure**):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | sh
    ```

    If you need to install a specific version (e.g. v0.1.21):

    ```shell theme={null}
    curl -fsSL \
    https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh \
    | VERSION=v0.1.21 sh
    ```
  </Accordion>

  <Accordion title="Install on Windows" icon="windows">
    Run the following command in PowerShell:

    ```powershell theme={null}
    powershell -Command "irm https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.ps1 | iex"
    ```

    Alternatively, you can use Windows Subsystem for Linux (WSL) and follow the Linux installation instructions.
  </Accordion>
</AccordionGroup>

## Update

<AccordionGroup>
  <Accordion title="Update on Mac" icon="apple">
    Update Blaxel CLI by running the following command in a terminal:

    ```shell theme={null}
    bl upgrade
    ```

    If you need to update to a specific version (e.g. v0.1.21):

    ```shell theme={null}
    bl upgrade --version 0.1.21
    ```

    You can also upgrade using Homebrew:

    ```shell theme={null}
    brew upgrade blaxel
    ```
  </Accordion>

  <Accordion title="Update on Linux" icon="linux">
    Update Blaxel CLI by running the following command in a terminal:

    ```shell theme={null}
    bl upgrade
    ```

    If you need to update to a specific version (e.g. v0.1.21):

    ```shell theme={null}
    bl upgrade --version 0.1.21
    ```
  </Accordion>

  <Accordion title="Update on Windows" icon="windows">
    For the most reliable solution, we recommend adapting the aforementioned Linux commands by using Windows Subsystem for Linux.

    First make sure WSL (Windows Subsystem for Linux) is installed if not already. This can be done by:

    * Opening PowerShell as Administrator
    * Running: `wsl --install -d Ubuntu-20.04`
    * Restarting the computer
    * From the Microsoft Store, install the Ubuntu app
    * Run the command line using the aforementioned Linux installation process. Make sure to install using **sudo**.
  </Accordion>
</AccordionGroup>

## Shell autocompletion

To enable shell autocompletion for Blaxel CLI commands, run one of the following:

<CodeGroup>
  ```zsh zsh theme={null}
  echo 'eval "$(bl completion zsh)"' >> ~/.zshrc
  ```

  ```bash bash theme={null}
  echo 'eval "$(bl completion bash)"' >> ~/.bashrc
  ```

  ```fish fish theme={null}
  echo 'bl completion fish' > ~/.config/fish/completions/bl.fish
  ```

  ```powershell powershell theme={null}
  if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
  }
  Add-Content -Path $PROFILE -Value '(& bl completion powershell) | Out-String | Invoke-Expression'
  ```
</CodeGroup>

## Get started

First, create a [workspace](../Security/Workspace-access-control) on the Blaxel console. Then, login to Blaxel:

```bash theme={null}
bl login
```

If you have multiple workspaces, the one you last logged into will be used automatically in every subsequent command you run. You can login to as many workspaces as you want.

To set your context to a different workspace you already logged in to, use the following command:

```bash theme={null}
bl workspaces your-workspace

### You can retrieve the list of all your workspaces by running:
bl workspaces
```

Basic commands to scaffold, develop, and deploy your resources:

| Command     | Purpose                                                                           |
| ----------- | --------------------------------------------------------------------------------- |
| `bl new`    | Scaffold a new local project (code + `blaxel.toml`)                               |
| `bl deploy` | Build image + push image + create/update resource + watch logs                    |
| `bl push`   | Build image + push image to Blaxel registry (no resource created or updated)      |
| `bl apply`  | Declarative resource creation/update using YAML files, similar to `kubectl apply` |
| `bl serve`  | Local execution *(not available for sandboxes)*                                   |

`bl deploy` is an all-in-one command that packages local files into an image, pushes it as a template, and deploys it as a resource on Blaxel. Use the `--skip-build` flag to skip image rebuilding. Use `bl push` instead to only build and push the image.

Interact with existing resources in your workspace:

```shellscript theme={null}
bl get sandboxes
```

## **Options**

```text theme={null}
-h, --help               Get the help for Blaxel
-w, --workspace string   Specify the Blaxel workspace to work on.
-o, --output string      Output format. One of: pretty, yaml, json, table
-v, --verbose            Enable verbose output
```
