Skip to content

Logfire Integration

  1. Navigate to Integrations in your team settings
  2. Click Connect on the Logfire integration
  3. You’ll be redirected to Logfire to authorize FastAPI Cloud
  4. Grant the requested permissions and you’ll be redirected back

FastAPI Cloud requests access to read your organizations and projects, create projects, and create write tokens for selected projects.

After connecting your Logfire account, you can link a Logfire project to any app in your team:

  1. Go to your app’s Integrations tab in the app details
  2. Select the Logfire integration
  3. Choose an existing project, or create a new private project
  4. Optionally trigger an immediate redeployment

FastAPI Cloud will automatically create a LOGFIRE_TOKEN environment variable using a Logfire write token and store it as an encrypted secret. Removing the connected resource revokes the write token in Logfire.

The default environment variable name is LOGFIRE_TOKEN. You can customize this when connecting if you already have a LOGFIRE_TOKEN in use.

Install Logfire with FastAPI support:

Terminal window
uv add "logfire[fastapi]"

Then configure Logfire in your FastAPI app. The Logfire SDK reads the LOGFIRE_TOKEN environment variable that FastAPI Cloud injects.

main.py
from fastapi import FastAPI
import logfire
app = FastAPI()
logfire.configure()
logfire.instrument_fastapi(app)
@app.get("/")
def read_root():
logfire.info("Handling root request")
return {"message": "Hello World"}

For more instrumentation options, see the Logfire FastAPI integration docs.