Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 6.84 KB

File metadata and controls

92 lines (66 loc) · 6.84 KB

v1.ai-image-upscaler

Module Functions

AI Image Upscaler Generate Workflow

The workflow performs the following action

  1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
  2. trigger a generation
  3. poll for a completion status. This is configurable
  4. 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.

Parameters

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 files
  • downloadDirectory (string, optional): Directory to save downloaded files (defaults to current directory)

Example Snippet

import { Client } from "magic-hour";

const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiImageUpscaler.generate(
  {
    assets: { imageFilePath: "/path/to/1234.png" },
    name: "Image Upscaler image",
    scaleFactor: 2.0,
    style: { enhancement: "Balanced" },
  },
  {
    waitForCompletion: true,
    downloadOutputs: true,
    downloadDirectory: ".",
  },
);

AI Image Upscaler

Upscale your image using AI. Each 2x upscale costs 50 credits for balanced/creative modes, and 25 credits for preserve. 4x upscale costs 200 and 100 credits respectively.

API Endpoint: POST /v1/ai-image-upscaler

Parameters

Parameter Required Description Example
assets Provide the assets for upscaling {"imageFilePath": "api-assets/id/1234.png"}
└─ imageFilePath The image to upscale. 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. . The maximum input image size is 4096x4096px. "api-assets/id/1234.png"
scaleFactor How much to scale the image. Must be either 2 or 4. Note: 4x upscale is only available on Creator, Pro, or Business tier. 2.0
name Give your image a custom name for easy identification. "My Image Upscaler image"
style Style settings for the upscale. Use mode ("preserve", "balanced", or "creative"). Defaults to "balanced". {"mode": "balanced"}
└─ enhancement Deprecated: use mode instead. "Resemblance" maps to "preserve". "Balanced" and "Creative" map to the same-named modes. "Balanced"
└─ mode The upscaling mode. "preserve" uses the fast pro pipeline (1× credit multiplier). "balanced" and "creative" use the creative pipeline (2× credit multiplier). "pro" is deprecated and maps to "preserve". Defaults to "balanced". "balanced"
└─ prompt A prompt to guide the final image. Only used when mode is creative. "string"

Example Snippet

import { Client } from "magic-hour";

const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiImageUpscaler.create({
  assets: { imageFilePath: "api-assets/id/1234.png" },
  name: "My Image Upscaler image",
  scaleFactor: 2.0,
});

Response

Type

V1AiImageUpscalerCreateResponse

Example
{"creditsCharged": 50, "frameCost": 50, "id": "cuid-example"}