Deploy
FastAPI
This guide walks you through deploying a FastAPI application on Takk. FastAPI is a modern, high-performance Python web framework for building APIs. Takk has first-class support for FastAPI, making deployment as simple as defining your app and running a single command.
Prerequisites
Make sure you have the Takk CLI installed and are logged in. If not, follow the Get Started guide first.
Create the Project
Start by creating a new directory and initializing it with uv:
mkdir fastapi-hello
cd fastapi-hello
uv init
Then add your dependencies:
uv add fastapi takk
Write the Application
Create app.py with a minimal FastAPI application:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def hello():
return {"message": "Hello, World!"}
@app.get("/greet/{name}")
def greet(name: str):
return {"message": f"Hello, {name}!"}
Define the Project
Create project.py to tell Takk how to run your application:
from takk.models import Project, FastAPIApp
project = Project(
name="fastapi-hello",
server=FastAPIApp(),
)
Takk automatically discovers your FastAPI app, configures the server, and handles networking, TLS, and health checks for you.
Run Locally
Start the local development environment:
uv run takk up
Your API is now running at http://localhost:8000. Visit it in your browser or test with curl:
curl http://localhost:8000
# {"message": "Hello, World!"}
curl http://localhost:8000/greet/Alice
# {"message": "Hello, Alice!"}
Changes to your code are automatically reloaded while takk up is running.
Deploy
When you're ready to go live, deploy with a single command:
uv run takk deploy
Takk builds a container image, provisions infrastructure, and starts your application in the cloud. No Dockerfiles, no YAML, no infrastructure configuration needed.
Next Steps
Add a custom domain to your project
Configure secrets for API keys and credentials
Set up database revisions for persistent storage

