Installing the FlexAI CLI
System requirements
Section titled “System requirements”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)
Installation Steps
Section titled “Installation Steps”-
Run the installation script
Terminal window curl -fsSL https://cli.flex.ai/install.sh | shYou 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 -eRESET="\\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 runningif [ "$?" -ne 0 ]; then>&2 say_red>&2 say_red "Looks like something has gone wrong!"fi}trap at_exit EXITBASE_URL="https://cli.flex.ai"SILENT=""while [ $# -gt 0 ]; docase "$1" in--url)BASE_URL=$2shift;;--silent)SILENT="--silent";;esacshiftdone# 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 1fiOS=""case $(uname) in"Linux") OS="linux";;"Darwin") OS="darwin";;*)print_unsupported_platformexit 1;;esaccase $(uname -m) in"x86_64") ;;"arm64") ;;"aarch64") ;;*)print_unsupported_platformexit 1;;esacTARBALL_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}" ]; thensay_red "error: ${FLEX_CLI} already exists and is a directory, refusing to proceed."exit 1elif [ ! -f "${FLEX_CLI}" ]; thensay_blue "=== Installing Flex ${VERSION} ==="elsesay_blue "=== Upgrading Flex $(${FLEX_CLI} version) to ${VERSION} ==="fiTARBALL_DEST=$(mktemp -t flex.tar.gz.XXXXXXXXXX)download_tarball() {say_white "+ Downloading ${TARBALL_URL}..."if ! curl --fail ${SILENT} -L \-o "${TARBALL_DEST}" "${TARBALL_URL}"; thensay_red "error: failed to download"return 1fi}if download_tarball; thensay_white "+ Extracting to ${FLEX_INSTALL_ROOT}/bin"# If `~/.flex/bin` exists, remove previous files with a flex prefixif [ -e "${FLEX_INSTALL_ROOT}/bin" ]; thenrm -f "${FLEX_INSTALL_ROOT}/bin"/flex*fimkdir -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 1fiCONFIG_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}"; thensay_red "error: failed to download"return 1fi}if download_config; thensay_white "+ Configuring"if ! "${FLEX_INSTALL_ROOT}/bin/flexai" bootstrap "${CONFIG_DEST}"; then>&2 say_red "error: failed to configure Flex"exit 1fielse>&2 say_red "error: failed to download ${CONFIG_URL}"exit 1fisay_bluesay_blue "=== Flex is now installed! ==="say_white "+ Please add ${FLEX_INSTALL_ROOT}/bin to your \$PATH"say_green "+ Enjoy!" -
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 ~/.bashrcTerminal window echo 'export PATH="$PATH:$HOME/.flexai/bin"' >> ~/.zshrc && source ~/.zshrcTerminal window echo 'set -gx PATH $PATH $HOME/.flexai/bin' >> ~/.config/fish/config.fish && source ~/.config/fish/config.fishTerminal window echo 'export PATH="$PATH:$HOME/.flexai/bin"' >> ~/.bashrc && source ~/.bashrcPlease note that you will need to update the
PATH
variable of your WSL2 Linux environment, not the Windows one.The default Linux distribution installed with WSL2 is Ubuntu, which by default uses the
bash
shell: -
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 doctorYou 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 availableYour system is healthy -
Logging in
The next step is to log in and authenticate your CLI.
Uninstalling the FlexAI CLI
Section titled “Uninstalling the FlexAI 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.