640px, 1k, or 2k resolution. Resolution is the maximum longest edge, not a promise of exact dimensions.
This is an installable Magic Hour adapter, not a built-in LiteLLM provider. The package is available from GitHub Releases; it is not published on PyPI.
Install and configure
Use Python 3.10 or newer in your application’s virtual environment:MAGIC_HOUR_API_KEY through your server’s environment or secret manager. No OpenAI API key is required. Keep credentials out of browser code, source control, and logs.
Create an image through the SDK
This call submits a paid generation. Prompts are sent to Magic Hour; see our privacy policy.image_generation or asynchronous aimage_generation entrypoint. Bare litellm.image_generation calls without the adapter’s validated options fail before making an API call. Unsupported counts, sizes, response formats, and other options are rejected rather than silently ignored.
The adapter submits at most one creation request per invocation, then polls that same project. Save project_id when it reaches your application. metadata also contains expires_at and the latest credits_charged when returned by Magic Hour. Charges depend on the current operation and account; LiteLLM’s token usage is not a measure of Magic Hour credit cost.
The timeout limits the polling budget; it does not cancel the job or guarantee hard wall-clock cancellation of an in-flight request. After acceptance, handled request errors retain the project ID. A hard process crash can prevent that ID from reaching your application. If acceptance is unknown, inspect your Magic Hour projects before submitting again.
Recover the same project
Set the existing ID to retrieve its status without another creation request:GET /v1/image-projects/{id} and performs no POST. Keep signed download URLs unchanged and private, and use them before expiry. Retrieve the same project again when a temporary download link expires. Ordinary SDK/proxy logs can contain prompts or output URLs, so do not publish raw logs.
Do not automatically retry a failed create, add fallback models, or restart the create example after a timeout. Those actions can submit another paid job; there is no public create-idempotency guarantee for this adapter.
Use the OpenAI-compatible proxy
In the same environment, install LiteLLM’s proxy extra and its required authentication-error dependency:LITELLM_MASTER_KEY through the proxy’s environment. Keep MAGIC_HOUR_API_KEY on the proxy server.
Save this as proxy.yaml, keeping the model alias and hook together: