Skip to content

Installing the FlexAI CLI

The FlexAI CLI is available for the following operating systems and versions:

  • Ubuntu 20.04, 22.04, 24.04
  • macOS 14 and above
  • Windows 10 and Windows 11 (through WSL2 in both cases)
  1. Run the installation script

    Terminal window
    curl -fsSL https://cli.flex.ai/install.sh | sh

    You can review the installation script before running it:

    View the script
    install.sh
    #!/bin/sh
    # Install script for the Flex CLI.
    # Largely inspired by the excellent https://get.pulumi.com.
    set -e
    RESET="\\033[0m"
    RED="\\033[31;1m"
    GREEN="\\033[32;1m"
    YELLOW="\\033[33;1m"
    BLUE="\\033[34;1m"
    WHITE="\\033[37;1m"
    print_unsupported_platform()
    {
    >&2 say_red "error: Your platform is not currently supported."
    >&2 say_red " We only support 64-bit versions of Linux and macOS."
    }
    say_green()
    {
    [ -z "${SILENT}" ] && printf "%b%s%b\\n" "${GREEN}" "$1" "${RESET}"
    return 0
    }
    say_red()
    {
    printf "%b%s%b\\n" "${RED}" "$1" "${RESET}"
    }
    say_yellow()
    {
    [ -z "${SILENT}" ] && printf "%b%s%b\\n" "${YELLOW}" "$1" "${RESET}"
    return 0
    }
    say_blue()
    {
    [ -z "${SILENT}" ] && printf "%b%s%b\\n" "${BLUE}" "$1" "${RESET}"
    return 0
    }
    say_white()
    {
    [ -z "${SILENT}" ] && printf "%b%s%b\\n" "${WHITE}" "$1" "${RESET}"
    return 0
    }
    at_exit()
    {
    # shellcheck disable=SC2181
    # https://github.com/koalaman/shellcheck/wiki/SC2181
    # Disable because we don't actually know the command we're running
    if [ "$?" -ne 0 ]; then
    >&2 say_red
    >&2 say_red "Looks like something has gone wrong!"
    fi
    }
    trap at_exit EXIT
    BASE_URL="https://cli.flex.ai"
    SILENT=""
    while [ $# -gt 0 ]; do
    case "$1" in
    --url)
    BASE_URL=$2
    shift
    ;;
    --silent)
    SILENT="--silent"
    ;;
    esac
    shift
    done
    # Fetch the identifier of the latest version.
    if ! VERSION=$(curl --retry 3 --fail --silent -L "$BASE_URL/latest"); then
    >&2 say_red "error: could not determine latest version of Flex"
    exit 1
    fi
    OS=""
    case $(uname) in
    "Linux") OS="linux";;
    "Darwin") OS="darwin";;
    *)
    print_unsupported_platform
    exit 1
    ;;
    esac
    case $(uname -m) in
    "x86_64") ;;
    "arm64") ;;
    "aarch64") ;;
    *)
    print_unsupported_platform
    exit 1
    ;;
    esac
    TARBALL_URL="$BASE_URL/bin/${VERSION}/flex-cli-${VERSION}-${OS}64.tar.gz"
    CONFIG_URL="$BASE_URL/config.yaml"
    FLEX_INSTALL_ROOT="${HOME}/.flexai"
    FLEX_CLI="${FLEX_INSTALL_ROOT}/bin/flexai"
    if [ -d "${FLEX_CLI}" ]; then
    say_red "error: ${FLEX_CLI} already exists and is a directory, refusing to proceed."
    exit 1
    elif [ ! -f "${FLEX_CLI}" ]; then
    say_blue "=== Installing Flex ${VERSION} ==="
    else
    say_blue "=== Upgrading Flex $(${FLEX_CLI} version) to ${VERSION} ==="
    fi
    TARBALL_DEST=$(mktemp -t flex.tar.gz.XXXXXXXXXX)
    download_tarball() {
    say_white "+ Downloading ${TARBALL_URL}..."
    if ! curl --fail ${SILENT} -L \
    -o "${TARBALL_DEST}" "${TARBALL_URL}"; then
    say_red "error: failed to download"
    return 1
    fi
    }
    if download_tarball; then
    say_white "+ Extracting to ${FLEX_INSTALL_ROOT}/bin"
    # If `~/.flex/bin` exists, remove previous files with a flex prefix
    if [ -e "${FLEX_INSTALL_ROOT}/bin" ]; then
    rm -f "${FLEX_INSTALL_ROOT}/bin"/flex*
    fi
    mkdir -p "${FLEX_INSTALL_ROOT}/bin"
    tar zxf "${TARBALL_DEST}" -C "${FLEX_INSTALL_ROOT}/bin"
    rm -f "${TARBALL_DEST}"
    else
    >&2 say_red "error: failed to download ${TARBALL_URL}"
    exit 1
    fi
    CONFIG_DEST=$(mktemp -t flex-config.yaml.XXXXXXXXXX)
    download_config() {
    say_white "+ Downloading ${BASE_URL}/config.yaml..."
    if ! curl --fail ${SILENT} -L \
    -o "${CONFIG_DEST}" "${CONFIG_URL}"; then
    say_red "error: failed to download"
    return 1
    fi
    }
    if download_config; then
    say_white "+ Configuring"
    if ! "${FLEX_INSTALL_ROOT}/bin/flexai" bootstrap "${CONFIG_DEST}"; then
    >&2 say_red "error: failed to configure Flex"
    exit 1
    fi
    else
    >&2 say_red "error: failed to download ${CONFIG_URL}"
    exit 1
    fi
    say_blue
    say_blue "=== Flex is now installed! ==="
    say_white "+ Please add ${FLEX_INSTALL_ROOT}/bin to your \$PATH"
    say_green "+ Enjoy!"
  2. Add it to your system’s $PATH

    Add the ~/.flexai/bin directory to your $PATH:

    Terminal window
    echo 'export PATH="$PATH:$HOME/.flexai/bin"' >> ~/.bashrc && source ~/.bashrc
  3. Verify your installation

    As a first step, it’s always a good idea to verify your system can connect to FlexAI and make sure CLI is properly installed.

    That’s the purpose of the doctor command:

    Terminal window
    flexai doctor

    You should get a message like this:

    Terminal window
    Running doctor checks...
    [1/4] ✅ The FlexAI binary file is part of the system's $PATH variable
    [2/4] ✅ Successfully connected to the FlexAI API server
    [3/4] ✅ Successfully connected to the FlexAI update server
    [4/4] ✅ Using the latest FlexAI CLI version available
    Your system is healthy
  4. Logging in

    The next step is to log in and authenticate your CLI.


If you ever need to uninstall the FlexAI CLI, you can do so by removing both the ~/.flexai directory and the reference to the flexai binary from your $PATH variable.