The workflow performs the following action
- upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
- trigger a generation
- poll for a completion status. This is configurable
- if success, download the output to local directory
Tip
This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
In addition to the parameters listed in the create section below, generate introduces 3 new parameters:
waitForCompletion(boolean, default true): Whether to wait for the project to complete.downloadOutputs(boolean, default true): Whether to download the generated filesdownloadDirectory(string, optional): Directory to save downloaded files (defaults to current directory)
import { Client } from "magic-hour";
const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.photoColorizer.generate(
{
assets: { imageFilePath: "/path/to/1234.png" },
name: "Photo Colorizer image",
},
{
waitForCompletion: true,
downloadOutputs: true,
downloadDirectory: ".",
},
);Colorize image. Each image costs 10 credits.
API Endpoint: POST /v1/photo-colorizer
| Parameter | Required | Description | Example |
|---|---|---|---|
assets |
✓ | Provide the assets for photo colorization | {"imageFilePath": "api-assets/id/1234.png"} |
└─ imageFilePath |
✓ | The image used to generate the colorized image. This value is either - a direct URL to the video file - file_path field from the response of the upload urls API. See the file upload guide for details. |
"api-assets/id/1234.png" |
name |
✗ | Give your image a custom name for easy identification. | "My Photo Colorizer image" |
import { Client } from "magic-hour";
const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.photoColorizer.create({
assets: { imageFilePath: "api-assets/id/1234.png" },
name: "My Photo Colorizer image",
});V1PhotoColorizerCreateResponse
{"creditsCharged": 10, "frameCost": 10, "id": "cuid-example"}