FastAPI Cloud CLI
fastapi-cloud-cli is a command-line interface tool for deploying and managing FastAPI applications on FastAPI Cloud. It provides commands for logging in, deploying, managing environment variables, and streaming logs. The library is actively maintained, with frequent releases, and is currently at version 0.15.1.
Warnings
- breaking Version 0.13.0 dropped official support for Python 3.9. Users on Python 3.9 must upgrade their Python version to 3.10 or newer.
- gotcha When `fastapi-cloud-cli` is installed as part of `fastapi[standard]`, it may attempt to create configuration files in privileged root paths (e.g., `/.config`). This can cause deployment failures in restricted environments like some Kubernetes setups.
- gotcha Deployment might fail with 'Build Failed When Installing Dependencies' if required packages do not have pre-built wheels for your specific Python version. This is common when using a very new or less common Python version.
- gotcha On Windows, the `fastapi` command might not be found in the PATH after installation, leading to 'command not found' errors.
Install
-
pip install fastapi-cloud-cli -
pip install "fastapi[standard]"
Imports
- fastapi cloud
This is primarily a CLI tool and not typically imported directly into Python code. Usage is via the `fastapi` command on the command line.
Quickstart
# 1. Create a new FastAPI project (requires uv or pip)
# Using uv (recommended):
# uv init myapp
# cd myapp
# uv add "fastapi[standard]"
# Using pip:
mkdir myapp
cd myapp
pip install "fastapi[standard]"
# 2. Create a basic FastAPI application (main.py)
# (Content of main.py)
# from fastapi import FastAPI
# app = FastAPI()
# @app.get("/")
# def read_root():
# return {"message": "Hello, FastAPI Cloud!"}
# 3. Log in to FastAPI Cloud (if not already logged in)
# This will open a browser for authentication.
# fastapi login
# 4. Deploy your application
# The CLI will detect your app, and for the first deployment,
# it will prompt to select/create a team and app.
# Ensure FASTAPI_CLOUD_TOKEN is set for CI/CD or non-interactive use.
# For example: export FASTAPI_CLOUD_TOKEN=os.environ.get('FASTAPI_CLOUD_TOKEN', '')
fastapi deploy