This is an example of how to deploy a FastAPI application on Clever Cloud, using uv to manage the Python project and its dependencies.
This example uses the Python runtime
with its native uv support,
on Python 3.14. The application is a "Hello world" JSON API that listens on 0.0.0.0:8080.
Native uv deployment activates when both conditions are met:
- a
uv.lockfile exists at the root of the project, - the
CC_PYTHON_UV_RUN_COMMANDenvironment variable is set.
During the build, Clever Cloud installs the locked dependencies with
uv sync --locked --no-progress --no-dev. At run time, it executes CC_PYTHON_UV_RUN_COMMAND
(without shell expansion), here the FastAPI CLI from the virtual environment:
.venv/bin/fastapi run server.py --port 8080 --host 0.0.0.0.
No Nginx, uWSGI or Gunicorn is involved: FastAPI (through Uvicorn) serves HTTP itself.
.
├── .python-version # Python version used by uv (3.14)
├── pyproject.toml # Project metadata and dependencies (fastapi[standard])
├── uv.lock # Locked dependency tree, required for native uv deployment
└── server.py # The FastAPI application
To deploy this application, you need Clever Tools, the Clever Cloud CLI.
git clone https://github.com/CleverCloud/python-fastapi-uv-example.git
cd python-fastapi-uv-example
# Step 1: Create the application
clever create --type python fastapi-uv-example
# Step 2: Configure the Python version and the uv run command
clever env set CC_PYTHON_VERSION 3.14
clever env set CC_PYTHON_UV_RUN_COMMAND ".venv/bin/fastapi run server.py --port 8080 --host 0.0.0.0"
# Step 3: Add your domain (optional but recommended)
clever domain add <YOUR_DOMAIN_NAME>
# Step 4: Deploy
clever deployAnd you're done! Your application is deploying and will be available on the <YOUR_DOMAIN_NAME> domain
(or on the default cleverapps.io domain shown by clever domain).
Install uv, then:
uv sync --locked
uv run fastapi dev server.py # start the server on http://localhost:8000The interactive API documentation is available at /docs.
If you encounter issues:
- Check the application logs:
clever logs - Verify all environment variables are correctly set:
clever env - Make sure
uv.lockis committed and up to date (uv lock --check), as the build runsuv sync --locked. - Make sure the application listens on
0.0.0.0:8080.
Contributions to improve this deployment example are welcome! Please feel free to submit pull requests or open issues for any enhancements or bug fixes.
This example is provided under the terms of the MIT license.