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.aiMemeGenerator.generate(
{
name: "My Funny Meme",
style: {
searchWeb: false,
template: "Drake Hotline Bling",
topic: "When the code finally works",
},
},
{
waitForCompletion: true,
downloadOutputs: true,
downloadDirectory: ".",
},
);Create an AI generated meme. Each meme costs 10 credits.
API Endpoint: POST /v1/ai-meme-generator
| Parameter | Required | Description | Example |
|---|---|---|---|
style |
✓ | {"searchWeb": false, "template": "Drake Hotline Bling", "topic": "When the code finally works"} |
|
└─ searchWeb |
✗ | Whether to search the web for meme content. | false |
└─ template |
✓ | To use our templates, pass in one of the enum values. | "Drake Hotline Bling" |
└─ topic |
✓ | The topic of the meme. | "When the code finally works" |
name |
✗ | The name of the meme. | "My Funny Meme" |
import { Client } from "magic-hour";
const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiMemeGenerator.create({
name: "My Funny Meme",
style: {
searchWeb: false,
template: "Drake Hotline Bling",
topic: "When the code finally works",
},
});V1AiMemeGeneratorCreateResponse
{"creditsCharged": 10, "frameCost": 10, "id": "cuid-example"}