Slackbot
07/06/2026, 7:49 AMMarvin
07/06/2026, 7:49 AMMarvin
07/06/2026, 7:52 AMdict.
Recommended approach
Instead of this:
python
from typing import Any
from prefect import flow
@flow
def my_flow(config: dict[str, Any]):
print(config)
use this:
python
from pydantic import BaseModel
from prefect import flow
class Config(BaseModel):
database_url: str
timeout: int = 30
debug: bool = False
@flow
def my_flow(config: Config):
print(config.database_url)
print(config.timeout)
Why this helps:
- Prefect generates a structured parameter schema
- the UI can present it more clearly
- Prefect validates the input before the run starts
- your code gets typed access instead of manual dict handling
Important caveat
If you run the deployment via CLI, you'll still pass the value as JSON:
bash
prefect deployment run my-flow/my-deployment \
--param config='{"database_url":"postgres://...","timeout":60,"debug":true}'
If you want to avoid JSON strings entirely, use the Python API instead of the CLI:
python
from prefect.deployments import run_deployment
run_deployment(
name="my-flow/my-deployment",
parameters={
"config": {
"database_url": "postgres://...",
"timeout": 60,
"debug": True,
}
},
)
Bottom line
- CLI: dict/object parameters are passed as JSON
- Python API: you can pass a normal Python dict
- Best practice for structured inputs: use a pydantic.BaseModel instead of dict[str, Any]
If you want, I can also show you:
1. how this looks in the Prefect UI form, or
2. how to define this in a deployment so users get nicer parameter inputs.