Fernando Müller
09/30/2025, 1:31 PMMarvin
09/30/2025, 1:31 PMMarvin
09/30/2025, 1:33 PMprefect.runtime.flow_run.ui_url.
Example:
from prefect import flow, runtime, get_run_logger
@flow
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>(f"Flow run UI: {runtime.flow_run.ui_url}")
# Also available if you want the API URL or ID:
<http://logger.info|logger.info>(f"Flow run API: {runtime.flow_run.api_url}")
<http://logger.info|logger.info>(f"Flow run ID: {runtime.flow_run.id}")
if __name__ == "__main__":
my_flow()
Notes:
- runtime.flow_run.ui_url returns the human-friendly URL to this run in Prefect Cloud.
- These values are only populated when code is running inside an actual flow run; otherwise they may be empty/None.
Docs: prefect.runtime.flow_run
If you’re on Prefect 2.x instead, let me know and I’ll share the equivalent approach.