diff --git a/.sdk.json b/.sdk.json index b395604..c2bdf65 100644 --- a/.sdk.json +++ b/.sdk.json @@ -1,5 +1,5 @@ { - "id": "79b6b8f9-cd15-4aec-ac0f-cd16313a0353", + "id": "c90fe09f-b516-4af0-b41b-381e051eba94", "tracked_paths": [ { "editable": true, diff --git a/magic_hour/environment.py b/magic_hour/environment.py index 643dcbc..4864771 100644 --- a/magic_hour/environment.py +++ b/magic_hour/environment.py @@ -6,7 +6,7 @@ class Environment(enum.Enum): """Pre-defined base URLs for the API""" ENVIRONMENT = "https://api.magichour.ai" - MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.55.1" + MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.56.0" def _get_base_url( diff --git a/magic_hour/resources/v1/image_to_video/README.md b/magic_hour/resources/v1/image_to_video/README.md index a3972d0..76fc2e0 100644 --- a/magic_hour/resources/v1/image_to_video/README.md +++ b/magic_hour/resources/v1/image_to_video/README.md @@ -94,21 +94,22 @@ For detailed examples, see the [product page](https://magichour.ai/products/imag #### Parameters -| Parameter | Required | Deprecated | Description | Example | -| -------------------- | :------: | :--------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | -| `assets` | ✓ | ✗ | Provide the assets for image-to-video. Sora 2 only supports images with an aspect ratio of `9:16` or `16:9`. | `{"image_file_path": "api-assets/id/1234.png"}` | -| `└─ image_file_path` | ✓ | — | The path of the image file. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.png"` | -| `end_seconds` | ✓ | ✗ | The total duration of the output video in seconds. Supported durations depend on the chosen model: * **`ltx-2`**: 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30 * **`seedance`**: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 * **`kling-2.5`**: 5, 10 * **`kling-3.0`**: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 * **`sora-2`**: 4, 8, 12, 24, 36, 48, 60 * **`veo3.1`**: 4, 6, 8, 16, 24, 32, 40, 48, 56 Legacy models: * **`kling-1.6`**: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 | `5.0` | -| `audio` | ✗ | ✗ | Whether to include audio in the video. Defaults to `false` if not specified. Audio support varies by model: * **`ltx-2`**: Automatically included with no extra credits * **`seedance`**: Not supported * **`kling-2.5`**: Automatically included with no extra credits * **`kling-3.0`**: Toggle-able (can enable/disable) * **`sora-2`**: Automatically included with no extra credits * **`veo3.1`**: Toggle-able (can enable/disable) Legacy models: * **`kling-1.6`**: Not supported | `True` | -| `height` | ✗ | ✓ | `height` is deprecated and no longer influences the output video's resolution. This field is retained only for backward compatibility and will be removed in a future release. | `123` | -| `model` | ✗ | ✗ | The AI model to use for video generation. * `default`: uses our currently recommended model for general use. For paid tiers, defaults to `kling-2.5`. For free tiers, it defaults to `ltx-2`. * `ltx-2`: Great for fast iteration with audio, lip-sync, and expressive faces * `seedance`: Great for fast iteration and start/end frame * `kling-2.5`: Great for motion, action, and camera control * `kling-3.0`: Great for cinematic, multi-scene storytelling with control * `sora-2`: Great for story-telling, dialogue & creativity * `veo3.1`: Great for realism, polish, & prompt adherence Legacy models: * `kling-1.6`: Great for dependable clips with smooth motion If you specify the deprecated model value that includes the `-audio` suffix, this will be the same as included `audio` as `true`. | `"kling-2.5-audio"` | -| `name` | ✗ | ✗ | Give your video a custom name for easy identification. | `"My Image To Video video"` | -| `resolution` | ✗ | ✗ | Controls the output video resolution. Defaults to `720p` on paid tiers and `480p` on free tiers. * **`ltx-2`**: Supports 480p, 720p, 1080p. * **`seedance`**: Supports 480p, 720p, 1080p. * **`kling-2.5`**: Supports 720p, 1080p. * **`kling-3.0`**: Supports 720p, 1080p. * **`sora-2`**: Supports 720p. * **`veo3.1`**: Supports 720p, 1080p. Legacy models: * **`kling-1.6`**: Supports 720p, 1080p. | `"720p"` | -| `style` | ✗ | ✗ | Attributed used to dictate the style of the output | `{"prompt": "a dog running"}` | -| `└─ high_quality` | ✗ | ✓ | Deprecated: Please use `resolution` instead. For backward compatibility, * `false` maps to 720p resolution * `true` maps to 1080p resolution This field will be removed in a future version. Use the `resolution` field to directly specify the resolution. | `True` | -| `└─ prompt` | ✗ | — | The prompt used for the video. | `"a dog running"` | -| `└─ quality_mode` | ✗ | ✓ | 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"` | -| `width` | ✗ | ✓ | `width` is deprecated and no longer influences the output video's resolution. This field is retained only for backward compatibility and will be removed in a future release. | `123` | +| Parameter | Required | Deprecated | Description | Example | +| ------------------------ | :------: | :--------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | +| `assets` | ✓ | ✗ | Provide the assets for image-to-video. Sora 2 only supports images with an aspect ratio of `9:16` or `16:9`. | `{"end_image_file_path": "api-assets/id/1234.png", "image_file_path": "api-assets/id/1234.png"}` | +| `└─ end_image_file_path` | ✗ | — | The image to use as the last frame of the video. * **`ltx-2`**: Not supported * **`seedance`**: Supports 480p, 720p, 1080p. * **`kling-2.5`**: Supports 1080p. * **`kling-3.0`**: Supports 1080p. * **`sora-2`**: Not supported * **`veo3.1`**: Not supported Legacy models: * **`kling-1.6`**: Not supported | `"api-assets/id/1234.png"` | +| `└─ image_file_path` | ✓ | — | The path of the image file. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.png"` | +| `end_seconds` | ✓ | ✗ | The total duration of the output video in seconds. Supported durations depend on the chosen model: * **`ltx-2`**: 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30 * **`seedance`**: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 * **`kling-2.5`**: 5, 10 * **`kling-3.0`**: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 * **`sora-2`**: 4, 8, 12, 24, 36, 48, 60 * **`veo3.1`**: 4, 6, 8, 16, 24, 32, 40, 48, 56 Legacy models: * **`kling-1.6`**: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 | `5.0` | +| `audio` | ✗ | ✗ | Whether to include audio in the video. Defaults to `false` if not specified. Audio support varies by model: * **`ltx-2`**: Automatically included with no extra credits * **`seedance`**: Not supported * **`kling-2.5`**: Automatically included with no extra credits * **`kling-3.0`**: Toggle-able (can enable/disable) * **`sora-2`**: Automatically included with no extra credits * **`veo3.1`**: Toggle-able (can enable/disable) Legacy models: * **`kling-1.6`**: Not supported | `True` | +| `height` | ✗ | ✓ | `height` is deprecated and no longer influences the output video's resolution. This field is retained only for backward compatibility and will be removed in a future release. | `123` | +| `model` | ✗ | ✗ | The AI model to use for video generation. * `default`: uses our currently recommended model for general use. For paid tiers, defaults to `kling-2.5`. For free tiers, it defaults to `ltx-2`. * `ltx-2`: Great for fast iteration with audio, lip-sync, and expressive faces * `seedance`: Great for fast iteration and start/end frame * `kling-2.5`: Great for motion, action, and camera control * `kling-3.0`: Great for cinematic, multi-scene storytelling with control * `sora-2`: Great for story-telling, dialogue & creativity * `veo3.1`: Great for realism, polish, & prompt adherence Legacy models: * `kling-1.6`: Great for dependable clips with smooth motion If you specify the deprecated model value that includes the `-audio` suffix, this will be the same as included `audio` as `true`. | `"kling-2.5-audio"` | +| `name` | ✗ | ✗ | Give your video a custom name for easy identification. | `"My Image To Video video"` | +| `resolution` | ✗ | ✗ | Controls the output video resolution. Defaults to `720p` on paid tiers and `480p` on free tiers. * **`ltx-2`**: Supports 480p, 720p, 1080p. * **`seedance`**: Supports 480p, 720p, 1080p. * **`kling-2.5`**: Supports 720p, 1080p. * **`kling-3.0`**: Supports 720p, 1080p. * **`sora-2`**: Supports 720p. * **`veo3.1`**: Supports 720p, 1080p. Legacy models: * **`kling-1.6`**: Supports 720p, 1080p. | `"720p"` | +| `style` | ✗ | ✗ | Attributed used to dictate the style of the output | `{"prompt": "a dog running"}` | +| `└─ high_quality` | ✗ | ✓ | Deprecated: Please use `resolution` instead. For backward compatibility, * `false` maps to 720p resolution * `true` maps to 1080p resolution This field will be removed in a future version. Use the `resolution` field to directly specify the resolution. | `True` | +| `└─ prompt` | ✗ | — | The prompt used for the video. | `"a dog running"` | +| `└─ quality_mode` | ✗ | ✓ | 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"` | +| `width` | ✗ | ✓ | `width` is deprecated and no longer influences the output video's resolution. This field is retained only for backward compatibility and will be removed in a future release. | `123` | #### Synchronous Client @@ -118,7 +119,10 @@ from os import getenv client = Client(token=getenv("API_TOKEN")) res = client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, model="kling-2.5-audio", @@ -135,7 +139,10 @@ from os import getenv client = AsyncClient(token=getenv("API_TOKEN")) res = await client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, model="kling-2.5-audio", diff --git a/magic_hour/resources/v1/image_to_video/client.py b/magic_hour/resources/v1/image_to_video/client.py index 78cacd4..dc03da9 100644 --- a/magic_hour/resources/v1/image_to_video/client.py +++ b/magic_hour/resources/v1/image_to_video/client.py @@ -273,7 +273,10 @@ def create( Examples: ```py client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, model="kling-2.5-audio", @@ -558,7 +561,10 @@ async def create( Examples: ```py await client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, model="kling-2.5-audio", diff --git a/magic_hour/types/params/v1_image_to_video_create_body_assets.py b/magic_hour/types/params/v1_image_to_video_create_body_assets.py index 57643c9..e1038df 100644 --- a/magic_hour/types/params/v1_image_to_video_create_body_assets.py +++ b/magic_hour/types/params/v1_image_to_video_create_body_assets.py @@ -1,4 +1,5 @@ import pydantic +import typing import typing_extensions @@ -7,6 +8,21 @@ class V1ImageToVideoCreateBodyAssets(typing_extensions.TypedDict): Provide the assets for image-to-video. Sora 2 only supports images with an aspect ratio of `9:16` or `16:9`. """ + end_image_file_path: typing_extensions.NotRequired[str] + """ + The image to use as the last frame of the video. + + * **`ltx-2`**: Not supported + * **`seedance`**: Supports 480p, 720p, 1080p. + * **`kling-2.5`**: Supports 1080p. + * **`kling-3.0`**: Supports 1080p. + * **`sora-2`**: Not supported + * **`veo3.1`**: Not supported + + Legacy models: + * **`kling-1.6`**: Not supported + """ + image_file_path: typing_extensions.Required[str] """ The path of the image file. This value is either @@ -28,6 +44,9 @@ class _SerializerV1ImageToVideoCreateBodyAssets(pydantic.BaseModel): populate_by_name=True, ) + end_image_file_path: typing.Optional[str] = pydantic.Field( + alias="end_image_file_path", default=None + ) image_file_path: str = pydantic.Field( alias="image_file_path", ) diff --git a/magic_hour/types/params/v1_image_to_video_generate_body_assets.py b/magic_hour/types/params/v1_image_to_video_generate_body_assets.py index c68750c..7ae3d4e 100644 --- a/magic_hour/types/params/v1_image_to_video_generate_body_assets.py +++ b/magic_hour/types/params/v1_image_to_video_generate_body_assets.py @@ -7,6 +7,23 @@ class V1ImageToVideoGenerateBodyAssets(typing_extensions.TypedDict): Provide the assets for image-to-video. """ + end_image_file_path: typing_extensions.NotRequired[str] + """ + The path of the image to use as the last frame of the video. This value is either + - a direct URL to the image file + - a path to a local file + + * **`ltx-2`**: Not supported + * **`seedance`**: Supports 480p, 720p, 1080p. + * **`kling-2.5`**: Supports 1080p. + * **`kling-3.0`**: Supports 1080p. + * **`sora-2`**: Not supported + * **`veo3.1`**: Not supported + + Legacy models: + * **`kling-1.6`**: Not supported + """ + image_file_path: typing_extensions.Required[str] """ The path of the image file. This value is either diff --git a/pyproject.toml b/pyproject.toml index ca8e5d1..9b512b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "magic_hour" -version = "0.55.1" +version = "0.56.0" description = "Python SDK for Magic Hour API" readme = "README.md" authors = [] diff --git a/tests/test_v1_image_to_video_client.py b/tests/test_v1_image_to_video_client.py index 05bcab6..da9744a 100644 --- a/tests/test_v1_image_to_video_client.py +++ b/tests/test_v1_image_to_video_client.py @@ -27,7 +27,10 @@ def test_create_200_success_all_params() -> None: # tests calling sync method with example data client = Client(token="API_TOKEN", environment=Environment.MOCK_SERVER) response = client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, height=123, @@ -73,7 +76,10 @@ async def test_await_create_200_success_all_params() -> None: # tests calling async method with example data client = AsyncClient(token="API_TOKEN", environment=Environment.MOCK_SERVER) response = await client.v1.image_to_video.create( - assets={"image_file_path": "api-assets/id/1234.png"}, + assets={ + "end_image_file_path": "api-assets/id/1234.png", + "image_file_path": "api-assets/id/1234.png", + }, end_seconds=5.0, audio=True, height=123,