Doug Applegate
12/08/2025, 11:30 PMMarvin
12/08/2025, 11:30 PMMarvin
12/08/2025, 11:31 PMfrom prefect import flow
from prefect.runtime import flow_run
@flow(log_prints=True)
def my_flow():
print(f"Flow run UI URL: {flow_run.ui_url}")
print(f"Flow run API URL: {flow_run.api_url}")
my_flow()
Notes:
- Works from inside a running flow (or task). Outside a run context these will be None.
- The URLs are built from your PREFECT_UI_URL and PREFECT_API_URL settings, so it works the same for Prefect Cloud and self-hosted Server.
Docs:
- Runtime context guide
- Runtime flow_run API