runapi-vidu 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runapi/vidu/__init__.py +24 -0
- runapi/vidu/client.py +20 -0
- runapi/vidu/py.typed +0 -0
- runapi/vidu/resources/__init__.py +4 -0
- runapi/vidu/resources/image_to_video.py +56 -0
- runapi/vidu/resources/reference_to_video.py +56 -0
- runapi/vidu/types.py +32 -0
- runapi_vidu-0.1.0.dist-info/METADATA +47 -0
- runapi_vidu-0.1.0.dist-info/RECORD +10 -0
- runapi_vidu-0.1.0.dist-info/WHEEL +4 -0
runapi/vidu/__init__.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Vidu client for RunAPI."""
|
|
2
|
+
|
|
3
|
+
from runapi.core import (
|
|
4
|
+
AuthenticationError,
|
|
5
|
+
InsufficientCreditsError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
RateLimitError,
|
|
8
|
+
TaskFailedError,
|
|
9
|
+
TaskTimeoutError,
|
|
10
|
+
ValidationError,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from .client import ViduClient
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ViduClient",
|
|
17
|
+
"AuthenticationError",
|
|
18
|
+
"RateLimitError",
|
|
19
|
+
"InsufficientCreditsError",
|
|
20
|
+
"NotFoundError",
|
|
21
|
+
"ValidationError",
|
|
22
|
+
"TaskFailedError",
|
|
23
|
+
"TaskTimeoutError",
|
|
24
|
+
]
|
runapi/vidu/client.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Vidu client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import ProviderClient
|
|
8
|
+
|
|
9
|
+
from .resources.image_to_video import ImageToVideo
|
|
10
|
+
from .resources.reference_to_video import ReferenceToVideo
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ViduClient(ProviderClient):
|
|
14
|
+
"""Vidu image-to-video and reference-to-video client."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
|
|
17
|
+
super().__init__(api_key, **options)
|
|
18
|
+
http = self._http
|
|
19
|
+
self.image_to_video = ImageToVideo(http)
|
|
20
|
+
self.reference_to_video = ReferenceToVideo(http)
|
runapi/vidu/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Vidu image-to-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, RequestOptions
|
|
8
|
+
|
|
9
|
+
from ..types import (
|
|
10
|
+
CompletedImageToVideoResponse,
|
|
11
|
+
ImageToVideoResponse,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ImageToVideo(Resource):
|
|
16
|
+
"""Generate videos from a first-frame image with Vidu models."""
|
|
17
|
+
|
|
18
|
+
ENDPOINT = "/api/v1/vidu/image_to_video"
|
|
19
|
+
|
|
20
|
+
RESPONSE_CLASS = ImageToVideoResponse
|
|
21
|
+
COMPLETED_RESPONSE_CLASS = CompletedImageToVideoResponse
|
|
22
|
+
|
|
23
|
+
def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
24
|
+
"""Create an image-to-video task and poll until it completes.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
**params: Image-to-video parameters (model, first_frame_image_url, ...).
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
The completed task with videos.
|
|
31
|
+
"""
|
|
32
|
+
task = self.create(options=options, **params)
|
|
33
|
+
return self._poll_until_complete(lambda: self.get(task.id, options=options))
|
|
34
|
+
|
|
35
|
+
def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
36
|
+
"""Create an image-to-video task and return immediately with an ``id``.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
**params: Image-to-video parameters (model, first_frame_image_url, ...).
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
The task creation result with an id.
|
|
43
|
+
"""
|
|
44
|
+
compacted = self._compact_params(params)
|
|
45
|
+
return self._request("post", self.ENDPOINT, body=compacted, options=options)
|
|
46
|
+
|
|
47
|
+
def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
|
|
48
|
+
"""Fetch the current status of an image-to-video task.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
id: The task id.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
The current task status.
|
|
55
|
+
"""
|
|
56
|
+
return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Vidu reference-to-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, RequestOptions
|
|
8
|
+
|
|
9
|
+
from ..types import (
|
|
10
|
+
CompletedReferenceToVideoResponse,
|
|
11
|
+
ReferenceToVideoResponse,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ReferenceToVideo(Resource):
|
|
16
|
+
"""Generate videos from a first-frame image with Vidu models."""
|
|
17
|
+
|
|
18
|
+
ENDPOINT = "/api/v1/vidu/reference_to_video"
|
|
19
|
+
|
|
20
|
+
RESPONSE_CLASS = ReferenceToVideoResponse
|
|
21
|
+
COMPLETED_RESPONSE_CLASS = CompletedReferenceToVideoResponse
|
|
22
|
+
|
|
23
|
+
def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
24
|
+
"""Create an reference-to-video task and poll until it completes.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
**params: Image-to-video parameters (model, reference_image_urls, ...).
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
The completed task with videos.
|
|
31
|
+
"""
|
|
32
|
+
task = self.create(options=options, **params)
|
|
33
|
+
return self._poll_until_complete(lambda: self.get(task.id, options=options))
|
|
34
|
+
|
|
35
|
+
def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
36
|
+
"""Create an reference-to-video task and return immediately with an ``id``.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
**params: Image-to-video parameters (model, reference_image_urls, ...).
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
The task creation result with an id.
|
|
43
|
+
"""
|
|
44
|
+
compacted = self._compact_params(params)
|
|
45
|
+
return self._request("post", self.ENDPOINT, body=compacted, options=options)
|
|
46
|
+
|
|
47
|
+
def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
|
|
48
|
+
"""Fetch the current status of an reference-to-video task.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
id: The task id.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
The current task status.
|
|
55
|
+
"""
|
|
56
|
+
return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
|
runapi/vidu/types.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Vidu model lists, enums, and response models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from runapi.core import BaseModel, TaskResponse, optional, required
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MediaUrl(BaseModel):
|
|
10
|
+
url = optional(str)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class VideoResponse(TaskResponse):
|
|
14
|
+
"""Response for a video generation task."""
|
|
15
|
+
|
|
16
|
+
id = required(str)
|
|
17
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
18
|
+
videos = optional([lambda: MediaUrl])
|
|
19
|
+
error = optional(str)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CompletedVideoResponse(VideoResponse):
|
|
23
|
+
"""Narrowed response from ``run()`` once polling observes completion."""
|
|
24
|
+
|
|
25
|
+
videos = required([lambda: MediaUrl])
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ImageToVideoResponse = VideoResponse
|
|
29
|
+
CompletedImageToVideoResponse = CompletedVideoResponse
|
|
30
|
+
|
|
31
|
+
ReferenceToVideoResponse = VideoResponse
|
|
32
|
+
CompletedReferenceToVideoResponse = CompletedVideoResponse
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: runapi-vidu
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: RunAPI Vidu SDK for image-to-video and reference-to-video workflows in JavaScript, Python, Ruby, Go, Java, and PHP
|
|
5
|
+
Project-URL: Homepage, https://runapi.ai/models/vidu
|
|
6
|
+
Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
|
|
7
|
+
Project-URL: Source, https://github.com/runapi-ai/vidu-sdk
|
|
8
|
+
Project-URL: Issues, https://github.com/runapi-ai/vidu-sdk/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/runapi-ai/vidu-sdk/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Release Notes, https://github.com/runapi-ai/vidu-sdk/releases/tag/python%2Fv0.1.0
|
|
11
|
+
Author-email: RunAPI <contact@runapi.ai>
|
|
12
|
+
License-Expression: Apache-2.0
|
|
13
|
+
Keywords: api,golang,gradle,java,maven,python,reference-to-video,ruby,runapi,runapi-ai,sdk,typescript,video-api,video-generation,vidu,vidu-ai-api
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Requires-Dist: runapi-core~=0.10.1
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# Vidu Python SDK for RunAPI
|
|
19
|
+
|
|
20
|
+
Create image-to-video or reference-to-video tasks, retrieve their status, or use `run` to poll until completion. Validation runs on the RunAPI server.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pip install runapi-vidu
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
Set `RUNAPI_API_KEY` in your environment. Replace the example image URL with a publicly accessible reference image.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from runapi.vidu import ViduClient
|
|
34
|
+
|
|
35
|
+
client = ViduClient() # reads RUNAPI_API_KEY
|
|
36
|
+
result = client.reference_to_video.run(
|
|
37
|
+
model="vidu-q4-reference-to-video",
|
|
38
|
+
prompt="Animate the referenced scene with a slow camera pan",
|
|
39
|
+
reference_image_urls=["https://cdn.runapi.ai/public/samples/image.jpg"],
|
|
40
|
+
audio=False,
|
|
41
|
+
)
|
|
42
|
+
print(result.videos[0].url)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use `create` to submit without waiting and `get` to retrieve the task by ID. Reference generation requires a prompt and 1–15 image URLs; it also accepts up to 3 MP3 reference audio URLs. Images must be JPG/JPEG/PNG/WEBP, at most 50 MB each; MP3 references must be 3–12 seconds and at most 50 MB each. Remote file properties are checked during provider processing, so a task can fail asynchronously.
|
|
46
|
+
|
|
47
|
+
See the [API reference](https://runapi.ai/docs/api/vidu/reference-to-video) and [SDK guide](https://runapi.ai/docs/resources/sdks). For current pricing, use the canonical model pages: [image-to-video](https://runapi.ai/models/vidu/q4-image-to-video) and [reference-to-video](https://runapi.ai/models/vidu/q4-reference-to-video).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
runapi/vidu/__init__.py,sha256=nb39DbBe2CeY9kLb3THjSnPHkCZr9WnUclvWsDTHc2U,454
|
|
2
|
+
runapi/vidu/client.py,sha256=4OjUvf4JU0c3UCfRMjoOIBqYcbYPjdsQZ3QvhoagvUE,594
|
|
3
|
+
runapi/vidu/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
runapi/vidu/types.py,sha256=A6lmqGaZQFSSOvNdZvjp-SZxyU-_eqXXQ-q1muB2TIA,815
|
|
5
|
+
runapi/vidu/resources/__init__.py,sha256=bW0Lk86IIQ__Wy9l0ormFmaNpNnEIClhQr5XQxwzCnY,138
|
|
6
|
+
runapi/vidu/resources/image_to_video.py,sha256=LreBWlVCRRd9j4XGhW8KlOyUmvROk4exSESFPzRvZwc,1770
|
|
7
|
+
runapi/vidu/resources/reference_to_video.py,sha256=MMWeJHilcricEz-pQkdVfx8a5EjdDYyhPHM6wHurgCE,1808
|
|
8
|
+
runapi_vidu-0.1.0.dist-info/METADATA,sha256=kOcg-GgeLBXf5Udxf2LA-MuOYOzkRmTYPXpVeTQVUgk,2382
|
|
9
|
+
runapi_vidu-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
10
|
+
runapi_vidu-0.1.0.dist-info/RECORD,,
|