Skip to content

Commit 08c24d4

Browse files
davidhu2000sdk-github-actions[bot]
andauthored
feat: add model selection and aspect ratio support for image/text to video endpoints (#136)
Co-authored-by: sdk-github-actions[bot] <sdk-github-actions[bot]@users.noreply.github.com>
1 parent 3c4dcdb commit 08c24d4

22 files changed

+446
-85
lines changed

.sdk.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "9d50adee-a14f-46f3-9b48-d129d9ad186e",
2+
"id": "09653467-3f34-4a66-8079-c555a3fed33d",
33
"tracked_paths": [
44
{
55
"editable": true,
@@ -953,6 +953,10 @@
953953
"editable": false,
954954
"path": "src/types/v1-image-to-video-create-body-assets.ts"
955955
},
956+
{
957+
"editable": false,
958+
"path": "src/types/v1-image-to-video-create-body-model-enum.ts"
959+
},
956960
{
957961
"editable": false,
958962
"path": "src/types/v1-image-to-video-create-body-resolution-enum.ts"
@@ -1009,6 +1013,14 @@
10091013
"editable": false,
10101014
"path": "src/types/v1-photo-colorizer-create-response.ts"
10111015
},
1016+
{
1017+
"editable": false,
1018+
"path": "src/types/v1-text-to-video-create-body-aspect-ratio-enum.ts"
1019+
},
1020+
{
1021+
"editable": false,
1022+
"path": "src/types/v1-text-to-video-create-body-model-enum.ts"
1023+
},
10121024
{
10131025
"editable": false,
10141026
"path": "src/types/v1-text-to-video-create-body-orientation-enum.ts"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "magic-hour",
3-
"version": "0.46.0",
3+
"version": "0.44.0",
44
"main": "./dist/index.js",
55
"types": "./dist/index.d.ts",
66
"exports": {

src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export enum Environment {
22
Environment = "https://api.magichour.ai",
3-
MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.46.0",
3+
MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.47.0",
44
}

src/resources/v1/ai-image-editor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const res = await client.v1.aiImageEditor.generate(
4848

4949
### AI Image Editor <a name="create"></a>
5050

51-
Edit images with AI. Each edit costs 10 credits.
51+
Edit images with AI. Each edit costs 50 credits.
5252

5353
**API Endpoint**: `POST /v1/ai-image-editor`
5454

@@ -89,5 +89,5 @@ const res = await client.v1.aiImageEditor.create({
8989
##### Example
9090

9191
```typescript
92-
{"creditsCharged": 10, "frameCost": 10, "id": "cuid-example"}
92+
{"creditsCharged": 50, "frameCost": 50, "id": "cuid-example"}
9393
```

src/resources/v1/ai-image-editor/resource-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class AiImageEditorClient extends CoreResourceClient {
145145
/**
146146
* AI Image Editor
147147
*
148-
* Edit images with AI. Each edit costs 10 credits.
148+
* Edit images with AI. Each edit costs 50 credits.
149149
*
150150
* POST /v1/ai-image-editor
151151
*/

src/resources/v1/image-to-video/README.md

Lines changed: 15 additions & 13 deletions
Large diffs are not rendered by default.

src/resources/v1/image-to-video/request-types.ts

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ import {
1717
*/
1818
export type CreateRequest = {
1919
/**
20-
* Provide the assets for image-to-video.
20+
* Provide the assets for image-to-video. Sora 2 only supports images with an aspect ratio of `9:16` or `16:9`.
2121
*/
2222
assets: V1ImageToVideoCreateBodyAssets;
2323
/**
2424
* The total duration of the output video in seconds.
25+
*
26+
* Supported durations depend on the chosen model:
27+
* * **Default**: 5-60 seconds (either 5 or 10 for 480p).
28+
* * **Seedance**: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
29+
* * **Kling 2.5 Audio**: 5, 10
30+
* * **Sora 2**: 4, 8, 12, 24, 36, 48, 60
31+
* * **Veo 3.1 Audio**: 4, 6, 8, 16, 24, 32, 40, 48, 56
32+
* * **Veo 3.1**: 4, 6, 8, 16, 24, 32, 40, 48, 56
33+
* * **Kling 1.6**: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
2534
*/
2635
endSeconds: number;
2736
/**
@@ -34,19 +43,41 @@ export type CreateRequest = {
3443
* This field is retained only for backward compatibility and will be removed in a future release.
3544
*/
3645
height?: number | null | undefined;
46+
/**
47+
* The AI model to use for video generation.
48+
* * `default`: Our recommended model for general use (Kling 2.5 Audio). Note: For backward compatibility, if you use default and end_seconds > 10, we'll fall back to Kling 1.6.
49+
* * `seedance`: Great for fast iteration and start/end frame
50+
* * `kling-2.5-audio`: Great for motion, action, and camera control
51+
* * `sora-2`: Great for story-telling, dialogue & creativity
52+
* * `veo3.1-audio`: Great for dialogue + SFX generated natively
53+
* * `veo3.1`: Great for realism, polish, & prompt adherence
54+
* * `kling-1.6`: Great for dependable clips with smooth motion
55+
*/
56+
model?:
57+
| (
58+
| "default"
59+
| "kling-1.6"
60+
| "kling-2.5-audio"
61+
| "seedance"
62+
| "sora-2"
63+
| "veo3.1"
64+
| "veo3.1-audio"
65+
)
66+
| undefined;
3767
/**
3868
* Give your video a custom name for easy identification.
3969
*/
4070
name?: string | undefined;
4171
/**
4272
* Controls the output video resolution. Defaults to `720p` if not specified.
4373
*
44-
* 480p and 720p are available on Creator, Pro, or Business tiers. However, 1080p require Pro or Business tier.
45-
*
46-
* **Options:**
47-
* - `480p` - Supports only 5 or 10 second videos. Output: 24fps. Cost: 120 credits per 5 seconds.
48-
* - `720p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 300 credits per 5 seconds.
49-
* - `1080p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 600 credits per 5 seconds.
74+
* * **Default**: Supports `480p`, `720p`, and `1080p`.
75+
* * **Seedance**: Supports `480p`, `720p`, `1080p`.
76+
* * **Kling 2.5 Audio**: Supports `720p`, `1080p`.
77+
* * **Sora 2**: Supports `720p`.
78+
* * **Veo 3.1 Audio**: Supports `720p`, `1080p`.
79+
* * **Veo 3.1**: Supports `720p`, `1080p`.
80+
* * **Kling 1.6**: Supports `720p`, `1080p`.
5081
*/
5182
resolution?: ("1080p" | "480p" | "720p") | undefined;
5283
/**
@@ -74,6 +105,17 @@ export type External$CreateRequest = {
74105
assets: External$V1ImageToVideoCreateBodyAssets;
75106
end_seconds: number;
76107
height?: number | null | undefined;
108+
model?:
109+
| (
110+
| "default"
111+
| "kling-1.6"
112+
| "kling-2.5-audio"
113+
| "seedance"
114+
| "sora-2"
115+
| "veo3.1"
116+
| "veo3.1-audio"
117+
)
118+
| undefined;
77119
name?: string | undefined;
78120
resolution?: ("1080p" | "480p" | "720p") | undefined;
79121
style?: External$V1ImageToVideoCreateBodyStyle | undefined;
@@ -92,6 +134,17 @@ const SchemaIn$CreateRequest: z.ZodType<
92134
assets: Schemas$V1ImageToVideoCreateBodyAssets.in,
93135
end_seconds: z.number(),
94136
height: z.number().int().nullable().optional(),
137+
model: z
138+
.enum([
139+
"default",
140+
"kling-1.6",
141+
"kling-2.5-audio",
142+
"seedance",
143+
"sora-2",
144+
"veo3.1",
145+
"veo3.1-audio",
146+
])
147+
.optional(),
95148
name: z.string().optional(),
96149
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
97150
style: Schemas$V1ImageToVideoCreateBodyStyle.in.optional(),
@@ -102,6 +155,7 @@ const SchemaIn$CreateRequest: z.ZodType<
102155
assets: "assets",
103156
end_seconds: "endSeconds",
104157
height: "height",
158+
model: "model",
105159
name: "name",
106160
resolution: "resolution",
107161
style: "style",
@@ -122,6 +176,17 @@ const SchemaOut$CreateRequest: z.ZodType<
122176
assets: Schemas$V1ImageToVideoCreateBodyAssets.out,
123177
endSeconds: z.number(),
124178
height: z.number().int().nullable().optional(),
179+
model: z
180+
.enum([
181+
"default",
182+
"kling-1.6",
183+
"kling-2.5-audio",
184+
"seedance",
185+
"sora-2",
186+
"veo3.1",
187+
"veo3.1-audio",
188+
])
189+
.optional(),
125190
name: z.string().optional(),
126191
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
127192
style: Schemas$V1ImageToVideoCreateBodyStyle.out.optional(),
@@ -132,6 +197,7 @@ const SchemaOut$CreateRequest: z.ZodType<
132197
assets: "assets",
133198
endSeconds: "end_seconds",
134199
height: "height",
200+
model: "model",
135201
name: "name",
136202
resolution: "resolution",
137203
style: "style",

src/resources/v1/text-to-video/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ For detailed examples, see the [product page](https://magichour.ai/products/text
8080

8181
#### Parameters
8282

83-
| Parameter | Required | Description | Example |
84-
| ---------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
85-
| `endSeconds` || The total duration of the output video in seconds. The value must be greater than or equal to 5 seconds and less than or equal to 60 seconds. Note: For 480p resolution, the value must be either 5 or 10. | `5.0` |
86-
| `orientation` || Determines the orientation of the output video | `"landscape"` |
87-
| `style` || | `{"prompt": "a dog running"}` |
88-
| `└─ prompt` || The prompt used for the video. | `"a dog running"` |
89-
| `└─ qualityMode` || DEPRECATED: Please use `resolution` field instead. For backward compatibility: * `quick` maps to 720p resolution * `studio` maps to 1080p resolution This field will be removed in a future version. Use the `resolution` field to directly to specify the resolution. | `"quick"` |
90-
| `name` || Give your video a custom name for easy identification. | `"My Text To Video video"` |
91-
| `resolution` || Controls the output video resolution. Defaults to `720p` if not specified. 480p and 720p are available on Creator, Pro, or Business tiers. However, 1080p require Pro or Business tier. **Options:** - `480p` - Supports only 5 or 10 second videos. Output: 24fps. Cost: 120 credits per 5 seconds. - `720p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 300 credits per 5 seconds. - `1080p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 600 credits per 5 seconds. | `"720p"` |
83+
| Parameter | Required | Deprecated | Description | Example |
84+
| ---------------- | :------: | :--------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
85+
| `endSeconds` ||| The total duration of the output video in seconds. Supported durations depend on the chosen model: * **Default**: 5-60 seconds (either 5 or 10 for 480p). * **Seedance**: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 * **Kling 2.5 Audio**: 5, 10 * **Sora 2**: 4, 8, 12, 24, 36, 48, 60 * **Veo 3.1 Audio**: 4, 6, 8, 16, 24, 32, 40, 48, 56 * **Veo 3.1**: 4, 6, 8, 16, 24, 32, 40, 48, 56 * **Kling 1.6**: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 | `5.0` |
86+
| `style` ||| | `{"prompt": "a dog running"}` |
87+
| `└─ prompt` ||| The prompt used for the video. | `"a dog running"` |
88+
| `└─ qualityMode` ||| DEPRECATED: Please use `resolution` field instead. For backward compatibility: * `quick` maps to 720p resolution * `studio` maps to 1080p resolution This field will be removed in a future version. Use the `resolution` field to directly to specify the resolution. | `"quick"` |
89+
| `aspectRatio` ||| Determines the aspect ratio of the output video. * **Seedance**: Supports `9:16`, `16:9`, `1:1`. * **Kling 2.5 Audio**: Supports `9:16`, `16:9`, `1:1`. * **Sora 2**: Supports `9:16`, `16:9`. * **Veo 3.1 Audio**: Supports `9:16`, `16:9`. * **Veo 3.1**: Supports `9:16`, `16:9`. * **Kling 1.6**: Supports `9:16`, `16:9`, `1:1`. | `"16:9"` |
90+
| `model` ||| The AI model to use for video generation. * `default`: Our recommended model for general use (Kling 2.5 Audio). Note: For backward compatibility, if you use default and end_seconds > 10, we'll fall back to Kling 1.6. * `seedance`: Great for fast iteration and start/end frame * `kling-2.5-audio`: Great for motion, action, and camera control * `sora-2`: Great for story-telling, dialogue & creativity * `veo3.1-audio`: Great for dialogue + SFX generated natively * `veo3.1`: Great for realism, polish, & prompt adherence * `kling-1.6`: Great for dependable clips with smooth motion | `"sora-2"` |
91+
| `name` ||| Give your video a custom name for easy identification. | `"My Text To Video video"` |
92+
| `orientation` ||| Deprecated. Use `aspect_ratio` instead. | `"landscape"` |
93+
| `resolution` ||| Controls the output video resolution. Defaults to `720p` if not specified. * **Default**: Supports `480p`, `720p`, and `1080p`. * **Seedance**: Supports `480p`, `720p`, `1080p`. * **Kling 2.5 Audio**: Supports `720p`, `1080p`. * **Sora 2**: Supports `720p`. * **Veo 3.1 Audio**: Supports `720p`, `1080p`. * **Veo 3.1**: Supports `720p`, `1080p`. * **Kling 1.6**: Supports `720p`, `1080p`. | `"720p"` |
9294

9395
#### Example Snippet
9496

@@ -97,7 +99,9 @@ import Client from "magic-hour";
9799

98100
const client = new Client({ token: process.env["API_TOKEN"]!! });
99101
const res = await client.v1.textToVideo.create({
102+
aspectRatio: "16:9",
100103
endSeconds: 5.0,
104+
model: "sora-2",
101105
name: "My Text To Video video",
102106
orientation: "landscape",
103107
resolution: "720p",

0 commit comments

Comments
 (0)