Magic Hour for Haystack
Generate images with Magic Hour in Haystack pipelines. Creating an image and retrieving it are separate components, so you can save the project ID in between and resume a job without paying for it again.
It uses the z-image-turbo model and makes one square 640-pixel image per call.
Install
pip install magic-hour-haystack
Requires Python 3.11 or newer and Haystack 3.0 or newer. Set MAGIC_HOUR_API_KEY to a key from your Magic Hour developer dashboard.
Components
| Component | Input | Output |
|---|---|---|
MagicHourImageGenerator |
prompt |
project_id, credits_charged. Starts one paid job. |
MagicHourImageWaiter |
project_id |
project, once the job completes |
MagicHourImageDownloader |
project |
images as ByteStreams, and project_id |
Save the project ID from the generator, then wait for and download it in a second pipeline:
from haystack import Pipeline
from magic_hour_haystack import (
MagicHourImageDownloader,
MagicHourImageGenerator,
MagicHourImageWaiter,
)
create = Pipeline()
create.add_component("generate", MagicHourImageGenerator())
project_id = create.run({"generate": {"prompt": "A tiny orange paper bird"}})["generate"]["project_id"]
# Save project_id somewhere durable before waiting.
fetch = Pipeline()
fetch.add_component("wait", MagicHourImageWaiter())
fetch.add_component("download", MagicHourImageDownloader())
fetch.connect("wait.project", "download.project")
images = fetch.run({"wait": {"project_id": project_id}})["download"]["images"]
Running the second pipeline again with the same ID retrieves the same image, with fresh download URLs. examples/image_pipeline.py does this from the command line, saving the ID to a file between the two steps.
MagicHourImageWaiter takes timeout (default 300 seconds) and poll_interval (default 5 seconds).
Credits and failures
- The generator never retries. If its request fails, the job may still have been accepted, so check your Magic Hour projects before generating again.
- Waiter errors name the project, so you can run the waiter again with the same ID. A timeout doesn't cancel the job.
- The API key only goes to
api.magichour.ai. The downloader sends no key, and only downloads over HTTPS fromvideos.magichour.ai. No request follows redirects.
Saving pipelines
The components read the key from MAGIC_HOUR_API_KEY, and a saved pipeline stores only the variable's name. To load one, allow the module:
Pipeline.loads(saved_yaml, allowed_modules=["magic_hour_haystack.components"])
Development
pip install -e .
python -m unittest discover -s tests
The tests replace HTTP with a fake, so they spend no credits. Set HAYSTACK_TELEMETRY_ENABLED=false to stop Haystack sending usage data while you work.
License
MIT
Metadata
Release files for magic-hour-haystack 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| magic_hour_haystack-0.1.2.tar.gz | 8.3 kB | With provenance | Details for magic_hour_haystack-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| magic_hour_haystack-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for magic_hour_haystack-0.1.2-py3-none-any.whl |
Total release size: 14.4 kB
Release files / magic_hour_haystack-0.1.2.tar.gz
| Download URL | magic_hour_haystack-0.1.2.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72132ab40514c5cd989025f65ee00e948ffc7efc420df41bd7048256a93b8174
|
|
BLAKE2b-256 checksum How to use checksums |
f25743d98204976c7cb0ff84a719f9ac305f7fc40fcb21444f3ce10a89955bc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / magic_hour_haystack-0.1.2-py3-none-any.whl
| Download URL | magic_hour_haystack-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1195e903068ea0c54f0ffe0c9b30e383f794412dbd9e7d1d274a82fa0b31825d
|
|
BLAKE2b-256 checksum How to use checksums |
e4f2d86eb767e6e2bb5c9032487feb4334ee4063e2c29fca89fa1d9fe543560d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for magic-hour-haystack 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for magic_hour_haystack-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.