Ratelane.

Python SDK

Full configuration reference for the Ratelane Python SDK.

Installation

pip install ratelane-sdk

Imports

from ratelane.config import RatelaneConfig
from ratelane.middleware import RatelaneMiddleware, close_ratelane

RatelaneConfig options

OptionTypeRequiredDescription
api_keystr✅Your Ratelane API key from the dashboard
collector_urlstr✅https://api.ratelane.dev for production
fastapi_appFastAPI✅Your FastAPI app instance — used for route discovery
instance_versionstr❌Your app version, shown in instance detail
telemetry_flush_interval_secondsint❌How often telemetry is sent (default: 30)
ep_trigger_after_secondsint❌Seconds before emergency profile auto-triggers

Middleware

app.add_middleware(RatelaneMiddleware, config=config)

Shutdown hook

Always register the shutdown hook to flush telemetry cleanly:

@app.on_event("shutdown")
async def shutdown():
    await close_ratelane()

On this page