Install
Use Python 3.12 and a dedicated virtual environment. The example pins Prefect 3.9.0 and HTTPX 0.28.1. Install the normal declared dependencies:prefect package for the local server. prefect-client alone does
not include that server. No model provider credentials or optional integrations
are needed.
Start a private local Prefect server
Choose a private Prefect state directory and keep it separate from existing Prefect profiles or deployments. The directory contains local orchestration metadata, including the saved project ID. Use the same directory in both terminals. Set these supported options in the server terminal:Run the recovery flow
In a separate terminal, activate the same virtual environment and set the samePREFECT_HOME, PREFECT_API_URL, telemetry, and logging options. Remove any
inherited PREFECT_API_KEY when using this local server.
Provide MAGIC_HOUR_API_KEY through your normal private environment configuration
in this flow terminal only. Keep it out of scripts, command arguments, Prefect
parameters, screenshots, and logs. Select an image project owned by that account:
@flow and @task decorators with
retries=0, persist_result=False, and log_prints=False. Result persistence
is disabled for both; Prefect does not use a task result cache without persistence.
API log delivery is also disabled. Only safe project ID/status metadata leaves
the task, and errors use a static message without a raw API response or download URL.
Interpret the result
The final output contains onlyid and status. A successful GET confirms
retrieval, not necessarily a completed generation. If the provider reports a
pending status, check the same ID again later. Do not submit a replacement
generation to recover existing work.
The example does not configure schedules, deployments, retries, or automatic
polling. Stop your own local Prefect server when finished. For disposable runs,
remove only the private state directory you created after stopping the server;
preserve existing Prefect state.
Verification scope
The exact example ran with Prefect 3.9.0 and HTTPX 0.28.1 against a stock local Prefect server. Its flow and task both reachedCOMPLETED after one authenticated
GET of an existing Magic Hour project. The result contained only the requested
ID and complete status. Both native run records had retries set to zero and no
persisted state data.
The server environment was verified free of the Magic Hour key before and after
the flow. The task received the key through its own process environment; it was
not a flow or task parameter. Normal Prefect lifecycle messages appeared on
standard error; disabling API log delivery does not silence terminal logs. The
owned server processes, private state and listener were cleaned up after the run.
This verifies native local orchestration and saved-project status recovery. It
does not prove image creation, media download, Prefect Cloud deployment or an
upstream integration listing.