The Request object
request.headers, request.cookies, request.url, request.query_params — everything the client sent.
Code example
@router.get('/x')
async def handler(request: Request):
user_agent = request.headers.get('user-agent')
token = request.cookies.get('access_token')
next_url = request.query_params.get('next', '/')
How it works
The Request object is FastAPI's representation of the incoming HTTP request. It exposes headers, cookies, query params, the URL, the client's IP, and the body (for POST/PUT). Most routes need it for cookie-based auth (reading the access_token cookie) or for building absolute URLs. You ask for it by adding `request: Request` to the function signature — FastAPI sees the type annotation and injects it.
🔍 Where this is used in OpenBenchML
Every auth-gated route reads request.cookies to get the JWT.