<@ULVA73B9P> what's is the best way to get the PRE...
# ask-marvin
e
@Marvin what's is the best way to get the PREFECT_API_URL
m
thought for 102.2 seconds
Do you want it in code or from the CLI? Either way, ask Prefect, not your shell — it actually knows the current value. - Python (anywhere, Prefect 3.x recommended):
Copy code
from prefect.settings import get_current_settings

api_url = get_current_settings().api.url
print(api_url)
- Inside a running flow/task (runtime context):
Copy code
from prefect.runtime import flow_run

print(flow_run.api_url)
- From the CLI:
Copy code
prefect config view --show-defaults
Look for
api.url
in the output. - If you absolutely must use the environment:
Copy code
echo $PREFECT_API_URL
But note this may be unset if your value comes from a Prefect profile.