To set custom HTTP header parameters for the Prefect client when calling a flow as if you were calling a function, especially for an on-premise deployment, it's typically done through environment variables or configuring the
httpx
Python library used by Prefect under the hood.
However, the official documentation does not provide specific examples for setting custom headers directly. Instead, standard settings like
PREFECT_API_URL
and
PREFECT_API_KEY
can be set using the CLI or environment variables. For communication via proxies, you can set the standard
HTTPS_PROXY
and
SSL_CERT_FILE
variables to configure the
httpx
client.
If you need to add a special custom header field to all API requests, here's a general approach that you can take, assuming you're comfortable modifying the underlying HTTP client:
1. Customize the
httpx
client instance used by the Prefect client to include your custom headers.
2. Define the custom headers as a dictionary:
custom_headers = {"Your-Header-Name": "Your-Header-Value"}
3. Attach these headers to the client instance.
4. Use this custom client when initiating actions with your Prefect on-premises deployment.
You might have to review the Prefect client library's source code or advanced configuration settings (if any) for specifics on implementing custom headers because this is not standard documented behavior.
If this does not suffice, and you still encounter difficulties or need a specific usage example, let me know, and I can help you look further into this, potentially by checking Prefect's GitHub repository for similar issues or code snippets.