runapi-pixverse 0.1.1__tar.gz

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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 RunAPI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: runapi-pixverse
3
+ Version: 0.1.1
4
+ Summary: RunAPI PixVerse SDK for text-to-video, image-to-video, reference editing, transitions, and video extension in JavaScript, Python, Ruby, Go, Java, and PHP
5
+ Project-URL: Homepage, https://runapi.ai/models/pixverse
6
+ Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
7
+ Project-URL: Source, https://github.com/runapi-ai/pixverse-sdk
8
+ Project-URL: Issues, https://github.com/runapi-ai/pixverse-sdk/issues
9
+ Project-URL: Changelog, https://github.com/runapi-ai/pixverse-sdk/blob/main/CHANGELOG.md
10
+ Project-URL: Release Notes, https://github.com/runapi-ai/pixverse-sdk/releases/tag/python%2Fv0.1.1
11
+ Author-email: RunAPI <contact@runapi.ai>
12
+ License-Expression: Apache-2.0
13
+ License-File: LICENSE
14
+ Keywords: api,golang,gradle,java,maven,pixverse,pixverse-api,python,ruby,runapi,runapi-ai,sdk,text-to-video,typescript,video-api,video-generation
15
+ Requires-Python: >=3.9
16
+ Requires-Dist: runapi-core>=0.3.5
17
+ Description-Content-Type: text/markdown
18
+
19
+ # PixVerse Python SDK for RunAPI
20
+
21
+ Install `runapi-pixverse` and use `PixVerseClient` for all five PixVerse V6 video resources.
22
+
23
+ ```bash
24
+ pip install runapi-pixverse
25
+ ```
26
+
27
+ Model details and pricing: https://runapi.ai/models/pixverse/pixverse-v6
@@ -0,0 +1,9 @@
1
+ # PixVerse Python SDK for RunAPI
2
+
3
+ Install `runapi-pixverse` and use `PixVerseClient` for all five PixVerse V6 video resources.
4
+
5
+ ```bash
6
+ pip install runapi-pixverse
7
+ ```
8
+
9
+ Model details and pricing: https://runapi.ai/models/pixverse/pixverse-v6
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "runapi-pixverse"
7
+ version = "0.1.1"
8
+ description = "RunAPI PixVerse SDK for text-to-video, image-to-video, reference editing, transitions, and video extension in JavaScript, Python, Ruby, Go, Java, and PHP"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ authors = [{ name = "RunAPI", email = "contact@runapi.ai" }]
13
+ keywords = ["runapi", "runapi-ai", "pixverse", "api", "sdk", "typescript", "python", "ruby", "golang", "java", "maven", "gradle", "video-generation", "text-to-video", "video-api", "pixverse-api"]
14
+ dependencies = ["runapi-core>=0.3.5"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://runapi.ai/models/pixverse"
18
+ Documentation = "https://runapi.ai/docs/resources/sdks"
19
+ Source = "https://github.com/runapi-ai/pixverse-sdk"
20
+ Issues = "https://github.com/runapi-ai/pixverse-sdk/issues"
21
+ Changelog = "https://github.com/runapi-ai/pixverse-sdk/blob/main/CHANGELOG.md"
22
+ "Release Notes" = "https://github.com/runapi-ai/pixverse-sdk/releases/tag/python%2Fv0.1.1"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/runapi"]
26
+
27
+ [tool.uv]
28
+ package = true
29
+
30
+ [dependency-groups]
31
+ dev = ["pytest>=8"]
32
+
33
+ [tool.runapi]
34
+ slug = "pixverse"
@@ -0,0 +1,24 @@
1
+ """PixVerse 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 PixVerseClient
14
+
15
+ __all__ = [
16
+ "PixVerseClient",
17
+ "AuthenticationError",
18
+ "RateLimitError",
19
+ "InsufficientCreditsError",
20
+ "NotFoundError",
21
+ "ValidationError",
22
+ "TaskFailedError",
23
+ "TaskTimeoutError",
24
+ ]
@@ -0,0 +1,34 @@
1
+ """PixVerse 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.edit_video import EditVideo
10
+ from .resources.image_to_video import ImageToVideo
11
+ from .resources.text_to_video import TextToVideo
12
+ from .resources.transition_video import TransitionVideo
13
+ from .resources.extend_video import ExtendVideo
14
+
15
+
16
+ class PixVerseClient(ProviderClient):
17
+ """PixVerse V6 video generation, editing, transition, and extension client.
18
+
19
+ Example::
20
+
21
+ client = PixVerseClient(api_key="sk-...")
22
+ result = client.text_to_video.run(
23
+ model="pixverse-v6", prompt="A lighthouse above a stormy sea"
24
+ )
25
+ """
26
+
27
+ def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
28
+ super().__init__(api_key, **options)
29
+ http = self._http
30
+ self.text_to_video = TextToVideo(http)
31
+ self.image_to_video = ImageToVideo(http)
32
+ self.edit_video = EditVideo(http)
33
+ self.transition_video = TransitionVideo(http)
34
+ self.extend_video = ExtendVideo(http)
@@ -0,0 +1,182 @@
1
+ CONTRACT = {
2
+ "edit-video": {
3
+ "models": ["pixverse-v6"],
4
+ "fields_by_model": {
5
+ "pixverse-v6": {
6
+ "aspect_ratio": {
7
+ "enum": ["16:9", "4:3", "1:1", "3:4", "9:16", "2:3", "3:2", "21:9"],
8
+ "required": True
9
+ },
10
+ "duration_seconds": {
11
+ "required": True,
12
+ "min": 1,
13
+ "max": 15,
14
+ "type": "integer"
15
+ },
16
+ "model": {
17
+ "required": True
18
+ },
19
+ "output_resolution": {
20
+ "enum": ["360p", "540p", "720p", "1080p"],
21
+ "required": True
22
+ },
23
+ "prompt": {
24
+ "required": True,
25
+ "min": 3,
26
+ "max": 5000,
27
+ "length": True
28
+ },
29
+ "reference_image_urls": {
30
+ "required": True,
31
+ "min_items": 1,
32
+ "max_items": 7
33
+ },
34
+ "seed": {
35
+ "min": 0,
36
+ "max": 2147483647,
37
+ "type": "integer"
38
+ }
39
+ }
40
+ }
41
+ },
42
+ "extend-video": {
43
+ "models": ["pixverse-v6"],
44
+ "fields_by_model": {
45
+ "pixverse-v6": {
46
+ "duration_seconds": {
47
+ "required": True,
48
+ "min": 1,
49
+ "max": 15,
50
+ "type": "integer"
51
+ },
52
+ "model": {
53
+ "required": True
54
+ },
55
+ "output_resolution": {
56
+ "enum": ["360p", "540p", "720p", "1080p"],
57
+ "required": True
58
+ },
59
+ "prompt": {
60
+ "required": True,
61
+ "min": 3,
62
+ "max": 5000,
63
+ "length": True
64
+ },
65
+ "seed": {
66
+ "min": 0,
67
+ "max": 2147483647,
68
+ "type": "integer"
69
+ },
70
+ "source_task_id": {
71
+ "required": True
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "image-to-video": {
77
+ "models": ["pixverse-v6"],
78
+ "fields_by_model": {
79
+ "pixverse-v6": {
80
+ "duration_seconds": {
81
+ "required": True,
82
+ "min": 1,
83
+ "max": 15,
84
+ "type": "integer"
85
+ },
86
+ "first_frame_image_url": {
87
+ "required": True
88
+ },
89
+ "model": {
90
+ "required": True
91
+ },
92
+ "output_resolution": {
93
+ "enum": ["360p", "540p", "720p", "1080p"],
94
+ "required": True
95
+ },
96
+ "prompt": {
97
+ "required": True,
98
+ "min": 3,
99
+ "max": 5000,
100
+ "length": True
101
+ },
102
+ "seed": {
103
+ "min": 0,
104
+ "max": 2147483647,
105
+ "type": "integer"
106
+ }
107
+ }
108
+ }
109
+ },
110
+ "text-to-video": {
111
+ "models": ["pixverse-v6"],
112
+ "fields_by_model": {
113
+ "pixverse-v6": {
114
+ "aspect_ratio": {
115
+ "enum": ["16:9", "4:3", "1:1", "3:4", "9:16", "2:3", "3:2", "21:9"],
116
+ "required": True
117
+ },
118
+ "duration_seconds": {
119
+ "required": True,
120
+ "min": 1,
121
+ "max": 15,
122
+ "type": "integer"
123
+ },
124
+ "model": {
125
+ "required": True
126
+ },
127
+ "output_resolution": {
128
+ "enum": ["360p", "540p", "720p", "1080p"],
129
+ "required": True
130
+ },
131
+ "prompt": {
132
+ "required": True,
133
+ "min": 3,
134
+ "max": 5000,
135
+ "length": True
136
+ },
137
+ "seed": {
138
+ "min": 0,
139
+ "max": 2147483647,
140
+ "type": "integer"
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "transition-video": {
146
+ "models": ["pixverse-v6"],
147
+ "fields_by_model": {
148
+ "pixverse-v6": {
149
+ "duration_seconds": {
150
+ "required": True,
151
+ "min": 1,
152
+ "max": 15,
153
+ "type": "integer"
154
+ },
155
+ "first_frame_image_url": {
156
+ "required": True
157
+ },
158
+ "last_frame_image_url": {
159
+ "required": True
160
+ },
161
+ "model": {
162
+ "required": True
163
+ },
164
+ "output_resolution": {
165
+ "enum": ["360p", "540p", "720p", "1080p"],
166
+ "required": True
167
+ },
168
+ "prompt": {
169
+ "required": True,
170
+ "min": 3,
171
+ "max": 5000,
172
+ "length": True
173
+ },
174
+ "seed": {
175
+ "min": 0,
176
+ "max": 2147483647,
177
+ "type": "integer"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ from .edit_video import EditVideo
2
+ from .image_to_video import ImageToVideo
3
+ from .text_to_video import TextToVideo
4
+ from .transition_video import TransitionVideo
5
+ from .extend_video import ExtendVideo
6
+
7
+ __all__ = ["TextToVideo", "ImageToVideo", "EditVideo", "TransitionVideo", "ExtendVideo"]
@@ -0,0 +1,54 @@
1
+ """PixVerse edit-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 ..contract_gen import CONTRACT
10
+ from ..types import CompletedEditVideoResponse, EditVideoResponse
11
+
12
+
13
+ class EditVideo(Resource):
14
+ """Edit a source video from a prompt with PixVerse models."""
15
+
16
+ ENDPOINT = "/api/v1/pixverse/edit_video"
17
+
18
+ RESPONSE_CLASS = EditVideoResponse
19
+ COMPLETED_RESPONSE_CLASS = CompletedEditVideoResponse
20
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
21
+ """Create an edit-video task and poll until it completes.
22
+
23
+ Args:
24
+ **params: Reference-guided video parameters.
25
+
26
+ Returns:
27
+ The completed task with videos.
28
+ """
29
+ task = self.create(options=options, **params)
30
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
31
+
32
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
33
+ """Create an edit-video task and return immediately with an ``id``.
34
+
35
+ Args:
36
+ **params: Reference-guided video parameters.
37
+
38
+ Returns:
39
+ The task creation result with an id.
40
+ """
41
+ compacted = self._compact_params(params)
42
+ self._validate_contract(CONTRACT["edit-video"], compacted)
43
+ return self._request("post", self.ENDPOINT, body=compacted, options=options)
44
+
45
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
46
+ """Fetch the current status of an edit-video task.
47
+
48
+ Args:
49
+ id: The task id.
50
+
51
+ Returns:
52
+ The current task status.
53
+ """
54
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -0,0 +1,20 @@
1
+ """PixVerse extend-video resource."""
2
+
3
+ from typing import Any, Optional
4
+ from runapi.core import Resource, RequestOptions
5
+ from ..contract_gen import CONTRACT
6
+ from ..types import CompletedExtendVideoResponse, ExtendVideoResponse
7
+
8
+ class ExtendVideo(Resource):
9
+ ENDPOINT = "/api/v1/pixverse/extend_video"
10
+ RESPONSE_CLASS = ExtendVideoResponse
11
+ COMPLETED_RESPONSE_CLASS = CompletedExtendVideoResponse
12
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
13
+ task = self.create(options=options, **params)
14
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
15
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
16
+ body = self._compact_params(params)
17
+ self._validate_contract(CONTRACT["extend-video"], body)
18
+ return self._request("post", self.ENDPOINT, body=body, options=options)
19
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
20
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -0,0 +1,55 @@
1
+ """PixVerse 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 ..contract_gen import CONTRACT
10
+ from ..types import CompletedImageToVideoResponse, ImageToVideoResponse
11
+
12
+
13
+ class ImageToVideo(Resource):
14
+ """Generate videos from a first-frame image with PixVerse models."""
15
+
16
+ ENDPOINT = "/api/v1/pixverse/image_to_video"
17
+
18
+ RESPONSE_CLASS = ImageToVideoResponse
19
+ COMPLETED_RESPONSE_CLASS = CompletedImageToVideoResponse
20
+
21
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
22
+ """Create an image-to-video task and poll until it completes.
23
+
24
+ Args:
25
+ **params: Image-to-video parameters (model, first_frame_image_url, ...).
26
+
27
+ Returns:
28
+ The completed task with videos.
29
+ """
30
+ task = self.create(options=options, **params)
31
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
32
+
33
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
34
+ """Create an image-to-video task and return immediately with an ``id``.
35
+
36
+ Args:
37
+ **params: Image-to-video parameters (model, first_frame_image_url, ...).
38
+
39
+ Returns:
40
+ The task creation result with an id.
41
+ """
42
+ compacted = self._compact_params(params)
43
+ self._validate_contract(CONTRACT["image-to-video"], compacted)
44
+ return self._request("post", self.ENDPOINT, body=compacted, options=options)
45
+
46
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
47
+ """Fetch the current status of an image-to-video task.
48
+
49
+ Args:
50
+ id: The task id.
51
+
52
+ Returns:
53
+ The current task status.
54
+ """
55
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -0,0 +1,54 @@
1
+ """PixVerse text-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 ..contract_gen import CONTRACT
10
+ from ..types import CompletedTextToVideoResponse, TextToVideoResponse
11
+
12
+
13
+ class TextToVideo(Resource):
14
+ """Generate videos from text prompts with PixVerse models."""
15
+
16
+ ENDPOINT = "/api/v1/pixverse/text_to_video"
17
+
18
+ RESPONSE_CLASS = TextToVideoResponse
19
+ COMPLETED_RESPONSE_CLASS = CompletedTextToVideoResponse
20
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
21
+ """Create a text-to-video task and poll until it completes.
22
+
23
+ Args:
24
+ **params: Text-to-video parameters (model, prompt, ...).
25
+
26
+ Returns:
27
+ The completed task with videos.
28
+ """
29
+ task = self.create(options=options, **params)
30
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
31
+
32
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
33
+ """Create a text-to-video task and return immediately with an ``id``.
34
+
35
+ Args:
36
+ **params: Text-to-video parameters (model, prompt, ...).
37
+
38
+ Returns:
39
+ The task creation result with an id.
40
+ """
41
+ compacted = self._compact_params(params)
42
+ self._validate_contract(CONTRACT["text-to-video"], compacted)
43
+ return self._request("post", self.ENDPOINT, body=compacted, options=options)
44
+
45
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
46
+ """Fetch the current status of a text-to-video task.
47
+
48
+ Args:
49
+ id: The task id.
50
+
51
+ Returns:
52
+ The current task status.
53
+ """
54
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -0,0 +1,20 @@
1
+ """PixVerse transition-video resource."""
2
+
3
+ from typing import Any, Optional
4
+ from runapi.core import Resource, RequestOptions
5
+ from ..contract_gen import CONTRACT
6
+ from ..types import CompletedTransitionVideoResponse, TransitionVideoResponse
7
+
8
+ class TransitionVideo(Resource):
9
+ ENDPOINT = "/api/v1/pixverse/transition_video"
10
+ RESPONSE_CLASS = TransitionVideoResponse
11
+ COMPLETED_RESPONSE_CLASS = CompletedTransitionVideoResponse
12
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
13
+ task = self.create(options=options, **params)
14
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
15
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
16
+ body = self._compact_params(params)
17
+ self._validate_contract(CONTRACT["transition-video"], body)
18
+ return self._request("post", self.ENDPOINT, body=body, options=options)
19
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
20
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -0,0 +1,32 @@
1
+ """PixVerse response models."""
2
+
3
+ from runapi.core import BaseModel, TaskResponse, optional, required
4
+
5
+ MODEL = "pixverse-v6"
6
+ CHARACTER_MODEL = MODEL
7
+ DURATION_RANGE = range(1, 16)
8
+ SEED_RANGE = range(0, 2_147_483_648)
9
+
10
+ class MediaUrl(BaseModel):
11
+ url = optional(str)
12
+
13
+ class VideoTaskResponse(TaskResponse):
14
+ id = required(str)
15
+ status = optional(str, enum=lambda: TaskResponse.Status.ALL)
16
+ videos = optional([lambda: MediaUrl])
17
+ source_task_id = optional(str)
18
+ error = optional(str)
19
+
20
+ class CompletedVideoTaskResponse(VideoTaskResponse):
21
+ videos = required([lambda: MediaUrl])
22
+
23
+ TextToVideoResponse = VideoTaskResponse
24
+ CompletedTextToVideoResponse = CompletedVideoTaskResponse
25
+ ImageToVideoResponse = VideoTaskResponse
26
+ CompletedImageToVideoResponse = CompletedVideoTaskResponse
27
+ EditVideoResponse = VideoTaskResponse
28
+ CompletedEditVideoResponse = CompletedVideoTaskResponse
29
+ TransitionVideoResponse = VideoTaskResponse
30
+ CompletedTransitionVideoResponse = CompletedVideoTaskResponse
31
+ ExtendVideoResponse = VideoTaskResponse
32
+ CompletedExtendVideoResponse = CompletedVideoTaskResponse
@@ -0,0 +1,74 @@
1
+ import pytest
2
+
3
+ from runapi.core import config
4
+ from runapi.core.errors import AuthenticationError, ValidationError
5
+ from runapi.pixverse import PixVerseClient
6
+ from runapi.pixverse.resources import EditVideo, ExtendVideo, ImageToVideo, TextToVideo, TransitionVideo
7
+
8
+
9
+ class FakeHttp:
10
+ def __init__(self, *responses):
11
+ self._responses = list(responses)
12
+ self.calls = []
13
+
14
+ def request(self, method, path, body=None, options=None):
15
+ self.calls.append((method, path, body))
16
+ if self._responses:
17
+ return self._responses.pop(0)
18
+ return {"id": "task_1", "status": "processing"}
19
+
20
+
21
+ @pytest.fixture(autouse=True)
22
+ def reset_config(monkeypatch):
23
+ monkeypatch.delenv("RUNAPI_API_KEY", raising=False)
24
+ monkeypatch.setattr(config, "api_key", None)
25
+ yield
26
+
27
+
28
+ def common_params():
29
+ return {
30
+ "model": "pixverse-v6",
31
+ "prompt": "A lantern crosses the night sky",
32
+ "output_resolution": "720p",
33
+ "duration_seconds": 5,
34
+ }
35
+
36
+
37
+ def test_auth_and_resource_accessors():
38
+ with pytest.raises(AuthenticationError, match="API key is required"):
39
+ PixVerseClient()
40
+ client = PixVerseClient(api_key="k", http_client=FakeHttp())
41
+ assert isinstance(client.text_to_video, TextToVideo)
42
+ assert isinstance(client.image_to_video, ImageToVideo)
43
+ assert isinstance(client.edit_video, EditVideo)
44
+ assert isinstance(client.transition_video, TransitionVideo)
45
+ assert isinstance(client.extend_video, ExtendVideo)
46
+
47
+
48
+ @pytest.mark.parametrize(
49
+ ("resource_name", "endpoint", "extra", "expected_key"),
50
+ [
51
+ ("text_to_video", "text_to_video", {"aspect_ratio": "16:9"}, "aspect_ratio"),
52
+ ("image_to_video", "image_to_video", {"first_frame_image_url": "https://cdn.runapi.ai/public/samples/first.png"}, "first_frame_image_url"),
53
+ ("edit_video", "edit_video", {"reference_image_urls": ["https://cdn.runapi.ai/public/samples/reference.png"], "aspect_ratio": "16:9"}, "reference_image_urls"),
54
+ ("transition_video", "transition_video", {"first_frame_image_url": "https://cdn.runapi.ai/public/samples/first.png", "last_frame_image_url": "https://cdn.runapi.ai/public/samples/last.png"}, "last_frame_image_url"),
55
+ ("extend_video", "extend_video", {"source_task_id": "source_123"}, "source_task_id"),
56
+ ],
57
+ )
58
+ def test_create_and_get_request_shape(resource_name, endpoint, extra, expected_key):
59
+ fake = FakeHttp({"id": "task_123", "status": "processing"}, {"id": "task_123", "status": "completed", "videos": [{"url": "https://cdn.runapi.ai/output.mp4"}]})
60
+ resource = getattr(PixVerseClient(api_key="k", http_client=fake), resource_name)
61
+ params = {**common_params(), **extra}
62
+
63
+ resource.create(**params)
64
+ resource.get("task_123")
65
+
66
+ assert fake.calls[0] == ("post", f"/api/v1/pixverse/{endpoint}", params)
67
+ assert expected_key in fake.calls[0][2]
68
+ assert fake.calls[1] == ("get", f"/api/v1/pixverse/{endpoint}/task_123", None)
69
+
70
+
71
+ def test_contract_validation_rejects_missing_required_field():
72
+ client = PixVerseClient(api_key="k", http_client=FakeHttp())
73
+ with pytest.raises(ValidationError, match="aspect_ratio is required"):
74
+ client.text_to_video.create(**common_params())