runapi-infinitetalk 0.2.0__tar.gz → 0.3.0__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.
@@ -1,25 +1,25 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: runapi-infinitetalk
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: RunAPI InfiniteTalk SDK for audio-driven talking video workflows in JavaScript, Python, Ruby, Go, Java, and PHP
5
5
  Project-URL: Homepage, https://runapi.ai/models/infinitetalk
6
- Project-URL: Documentation, https://runapi.ai/docs#sdk-infinitetalk
6
+ Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
7
7
  Project-URL: Source, https://github.com/runapi-ai/infinitetalk-sdk
8
8
  Project-URL: Issues, https://github.com/runapi-ai/infinitetalk-sdk/issues
9
9
  Project-URL: Changelog, https://github.com/runapi-ai/infinitetalk-sdk/blob/main/CHANGELOG.md
10
- Project-URL: Release Notes, https://github.com/runapi-ai/infinitetalk-sdk/releases/tag/python%2Fv0.2.0
10
+ Project-URL: Release Notes, https://github.com/runapi-ai/infinitetalk-sdk/releases/tag/python%2Fv0.3.0
11
11
  Author-email: RunAPI <contact@runapi.ai>
12
12
  License-Expression: Apache-2.0
13
13
  Keywords: api,golang,gradle,infinitetalk,infinitetalk-api,java,maven,python,ruby,runapi,runapi-ai,sdk,text-to-video,typescript,video-api,video-generation
14
14
  Requires-Python: >=3.9
15
- Requires-Dist: runapi-core>=0.3.0
15
+ Requires-Dist: runapi-core~=0.10.0
16
16
  Description-Content-Type: text/markdown
17
17
 
18
18
  # InfiniteTalk Python SDK for RunAPI
19
19
 
20
20
  The InfiniteTalk Python SDK is the language-specific package for InfiniteTalk on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Python.
21
21
 
22
- This README is the Python package guide inside the public `infinitetalk-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/infinitetalk; for API reference, use https://runapi.ai/docs#infinitetalk; for SDK docs, use https://runapi.ai/docs#sdk-infinitetalk.
22
+ This README is the Python package guide inside the public `infinitetalk-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/infinitetalk; for API reference, use https://runapi.ai/docs/api/infinitetalk/audio-to-video; for SDK docs, use https://runapi.ai/docs/resources/sdks.
23
23
 
24
24
  ## Install
25
25
 
@@ -67,8 +67,8 @@ Pass parameters as keyword arguments and catch the `runapi.infinitetalk` error c
67
67
  ## Links
68
68
 
69
69
  - Model page: https://runapi.ai/models/infinitetalk
70
- - SDK docs: https://runapi.ai/docs#sdk-infinitetalk
71
- - Product docs: https://runapi.ai/docs#infinitetalk
70
+ - SDK docs: https://runapi.ai/docs/resources/sdks
71
+ - Product docs: https://runapi.ai/docs/api/infinitetalk/audio-to-video
72
72
  - Pricing and rate limits: https://runapi.ai/models/infinitetalk
73
73
  - Provider comparison: https://runapi.ai/providers/meigen-ai
74
74
  - Full catalog: https://runapi.ai/models
@@ -2,7 +2,7 @@
2
2
 
3
3
  The InfiniteTalk Python SDK is the language-specific package for InfiniteTalk on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Python.
4
4
 
5
- This README is the Python package guide inside the public `infinitetalk-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/infinitetalk; for API reference, use https://runapi.ai/docs#infinitetalk; for SDK docs, use https://runapi.ai/docs#sdk-infinitetalk.
5
+ This README is the Python package guide inside the public `infinitetalk-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/infinitetalk; for API reference, use https://runapi.ai/docs/api/infinitetalk/audio-to-video; for SDK docs, use https://runapi.ai/docs/resources/sdks.
6
6
 
7
7
  ## Install
8
8
 
@@ -50,8 +50,8 @@ Pass parameters as keyword arguments and catch the `runapi.infinitetalk` error c
50
50
  ## Links
51
51
 
52
52
  - Model page: https://runapi.ai/models/infinitetalk
53
- - SDK docs: https://runapi.ai/docs#sdk-infinitetalk
54
- - Product docs: https://runapi.ai/docs#infinitetalk
53
+ - SDK docs: https://runapi.ai/docs/resources/sdks
54
+ - Product docs: https://runapi.ai/docs/api/infinitetalk/audio-to-video
55
55
  - Pricing and rate limits: https://runapi.ai/models/infinitetalk
56
56
  - Provider comparison: https://runapi.ai/providers/meigen-ai
57
57
  - Full catalog: https://runapi.ai/models
@@ -4,22 +4,22 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "runapi-infinitetalk"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "RunAPI InfiniteTalk SDK for audio-driven talking video workflows in JavaScript, Python, Ruby, Go, Java, and PHP"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
11
  license = "Apache-2.0"
12
12
  authors = [{ name = "RunAPI", email = "contact@runapi.ai" }]
13
13
  keywords = ["runapi", "runapi-ai", "infinitetalk", "api", "sdk", "typescript", "python", "ruby", "golang", "java", "maven", "gradle", "video-generation", "text-to-video", "video-api", "infinitetalk-api"]
14
- dependencies = ["runapi-core>=0.3.0"]
14
+ dependencies = ["runapi-core~=0.10.0"]
15
15
 
16
16
  [project.urls]
17
17
  Homepage = "https://runapi.ai/models/infinitetalk"
18
- Documentation = "https://runapi.ai/docs#sdk-infinitetalk"
18
+ Documentation = "https://runapi.ai/docs/resources/sdks"
19
19
  Source = "https://github.com/runapi-ai/infinitetalk-sdk"
20
20
  Issues = "https://github.com/runapi-ai/infinitetalk-sdk/issues"
21
21
  Changelog = "https://github.com/runapi-ai/infinitetalk-sdk/blob/main/CHANGELOG.md"
22
- "Release Notes" = "https://github.com/runapi-ai/infinitetalk-sdk/releases/tag/python%2Fv0.2.0"
22
+ "Release Notes" = "https://github.com/runapi-ai/infinitetalk-sdk/releases/tag/python%2Fv0.3.0"
23
23
 
24
24
  [tool.hatch.build.targets.wheel]
25
25
  packages = ["src/runapi"]
@@ -0,0 +1,35 @@
1
+ """InfiniteTalk audio-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
+ AudioToVideoResponse,
11
+ CompletedAudioToVideoResponse,
12
+ )
13
+
14
+
15
+ class AudioToVideo(Resource):
16
+ """Generate a talking-head video from a source image and audio track."""
17
+
18
+ ENDPOINT = "/api/v1/infinitetalk/audio_to_video"
19
+
20
+ RESPONSE_CLASS = AudioToVideoResponse
21
+ COMPLETED_RESPONSE_CLASS = CompletedAudioToVideoResponse
22
+
23
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
24
+ """Create a task and poll until it completes."""
25
+ task = self.create(options=options, **params)
26
+ return self._poll_until_complete(lambda: self.get(task.id, options=options))
27
+
28
+ def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
29
+ """Create an audio-to-video task and return immediately with an ``id``."""
30
+ compacted = self._compact_params(params)
31
+ return self._request("post", self.ENDPOINT, body=compacted, options=options)
32
+
33
+ def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
34
+ """Fetch the current status of an audio-to-video task."""
35
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
3
  from runapi.core import config
4
- from runapi.core.errors import AuthenticationError, ValidationError
4
+ from runapi.core.errors import AuthenticationError
5
5
  from runapi.infinitetalk import InfinitetalkClient
6
6
  from runapi.infinitetalk.resources.audio_to_video import AudioToVideo
7
7
  from runapi.infinitetalk.types import (
@@ -97,10 +97,8 @@ def test_create_posts_compacted_body():
97
97
  "source_image_url": "https://cdn.runapi.ai/public/samples/portrait.jpg",
98
98
  "source_audio_url": "https://cdn.runapi.ai/public/samples/voice.mp3",
99
99
  "prompt": "A person speaking to the camera",
100
- "output_resolution": "720p",
101
- },
102
- ),
103
- ]
100
+ "output_resolution": "720p"},
101
+ )]
104
102
  assert isinstance(result, AudioToVideoResponse)
105
103
  assert result.id == "t1"
106
104
 
@@ -115,7 +113,7 @@ def test_get_fetches_by_id():
115
113
  def test_run_polls_and_narrows_completed_type():
116
114
  fake = FakeHttp(
117
115
  {"id": "t1", "status": "pending"},
118
- {"id": "t1", "status": "completed", "videos": [{"url": "https://x/y.mp4"}]},
116
+ {"id": "t1", "status": "completed", "usage": {"cost": 0.05}, "videos": [{"url": "https://x/y.mp4"}]},
119
117
  )
120
118
  client = InfinitetalkClient(api_key="k", http_client=fake)
121
119
  result = client.audio_to_video.run(**VALID_PARAMS)
@@ -125,98 +123,8 @@ def test_run_polls_and_narrows_completed_type():
125
123
  assert [call[0] for call in fake.calls] == ["post", "get"]
126
124
 
127
125
 
128
- # --- validation -----------------------------------------------------------
129
-
130
-
131
- def test_create_requires_model():
132
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
133
- params = {k: v for k, v in VALID_PARAMS.items() if k != "model"}
134
- with pytest.raises(ValidationError, match="model must be one of: infinitetalk-from-audio"):
135
- client.audio_to_video.create(**params)
136
-
137
-
138
- def test_create_rejects_unknown_model():
139
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
140
- params = {**VALID_PARAMS, "model": "not-a-model"}
141
- with pytest.raises(ValidationError, match="model must be one of: infinitetalk-from-audio"):
142
- client.audio_to_video.create(**params)
143
-
144
-
145
- def test_create_requires_source_image_url():
146
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
147
- params = {k: v for k, v in VALID_PARAMS.items() if k != "source_image_url"}
148
- with pytest.raises(ValidationError, match="source_image_url is required"):
149
- client.audio_to_video.create(**params)
150
-
151
-
152
- def test_create_requires_source_audio_url():
153
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
154
- params = {k: v for k, v in VALID_PARAMS.items() if k != "source_audio_url"}
155
- with pytest.raises(ValidationError, match="source_audio_url is required"):
156
- client.audio_to_video.create(**params)
157
-
158
-
159
- def test_create_requires_prompt():
160
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
161
- params = {k: v for k, v in VALID_PARAMS.items() if k != "prompt"}
162
- with pytest.raises(ValidationError, match="prompt is required"):
163
- client.audio_to_video.create(**params)
164
-
165
-
166
- def test_create_rejects_overlong_prompt():
167
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
168
- params = {**VALID_PARAMS, "prompt": "x" * 5001}
169
- with pytest.raises(ValidationError, match="prompt must be at most 5000 characters"):
170
- client.audio_to_video.create(**params)
171
-
172
-
173
- def test_create_rejects_invalid_resolution():
174
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
175
- params = {**VALID_PARAMS, "output_resolution": "1080p"}
176
- with pytest.raises(ValidationError, match="output_resolution must be one of: 480p, 720p"):
177
- client.audio_to_video.create(**params)
178
-
179
-
180
- def test_create_rejects_seed_below_range():
181
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
182
- params = {**VALID_PARAMS, "seed": 9999}
183
- with pytest.raises(
184
- ValidationError, match="seed must be an integer between 10000 and 1000000"
185
- ):
186
- client.audio_to_video.create(**params)
187
-
188
-
189
- def test_create_rejects_seed_above_range():
190
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
191
- params = {**VALID_PARAMS, "seed": 1_000_001}
192
- with pytest.raises(
193
- ValidationError, match="seed must be an integer between 10000 and 1000000"
194
- ):
195
- client.audio_to_video.create(**params)
196
-
197
-
198
- def test_create_rejects_non_integer_seed():
199
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
200
- params = {**VALID_PARAMS, "seed": "not-a-number"}
201
- with pytest.raises(ValidationError, match="seed must be an integer"):
202
- client.audio_to_video.create(**params)
203
-
204
-
205
- def test_create_rejects_bool_seed():
206
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
207
- params = {**VALID_PARAMS, "seed": True}
208
- with pytest.raises(ValidationError, match="seed must be an integer"):
209
- client.audio_to_video.create(**params)
210
-
211
-
212
126
  def test_create_accepts_seed_in_range():
213
127
  fake = FakeHttp({"id": "t1", "status": "pending"})
214
128
  client = InfinitetalkClient(api_key="k", http_client=fake)
215
129
  client.audio_to_video.create(**VALID_PARAMS, seed=500_000)
216
130
  assert fake.calls[0][2]["seed"] == 500_000
217
-
218
-
219
- def test_create_rejects_integer_string_seed():
220
- client = InfinitetalkClient(api_key="k", http_client=FakeHttp())
221
- with pytest.raises(ValidationError, match="seed must be an integer"):
222
- client.audio_to_video.create(**VALID_PARAMS, seed="500000")
@@ -1,21 +0,0 @@
1
- CONTRACT = {
2
- "audio-to-video": {
3
- "models": ["infinitetalk-from-audio"],
4
- "fields_by_model": {
5
- "infinitetalk-from-audio": {
6
- "output_resolution": {
7
- "enum": ["480p", "720p"]
8
- },
9
- "seed": {
10
- "type": "integer"
11
- },
12
- "source_audio_url": {
13
- "required": True
14
- },
15
- "source_image_url": {
16
- "required": True
17
- }
18
- }
19
- }
20
- }
21
- }
@@ -1,79 +0,0 @@
1
- """InfiniteTalk audio-to-video resource."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Any, Dict, Optional
6
-
7
- from runapi.core import Resource, ValidationError, RequestOptions
8
-
9
- from ..contract_gen import CONTRACT
10
- from ..types import (
11
- AudioToVideoResponse,
12
- CompletedAudioToVideoResponse,
13
- )
14
-
15
- PROMPT_MAX_LENGTH = 5000
16
- SEED_RANGE = range(10_000, 1_000_001)
17
-
18
-
19
- class AudioToVideo(Resource):
20
- """Generate a talking-head video from a source image and audio track."""
21
-
22
- ENDPOINT = "/api/v1/infinitetalk/audio_to_video"
23
-
24
- RESPONSE_CLASS = AudioToVideoResponse
25
- COMPLETED_RESPONSE_CLASS = CompletedAudioToVideoResponse
26
-
27
- def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
28
- """Create a task and poll until it completes."""
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 audio-to-video task and return immediately with an ``id``."""
34
- compacted = self._compact_params(params)
35
- self._validate_params(compacted)
36
- return self._request("post", self.ENDPOINT, body=compacted, options=options)
37
-
38
- def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
39
- """Fetch the current status of an audio-to-video task."""
40
- return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
41
-
42
- def _validate_params(self, params: Dict[str, Any]) -> None:
43
- self._validate_contract(CONTRACT["audio-to-video"], params)
44
-
45
- prompt = params.get("prompt")
46
- if not (isinstance(prompt, str) and prompt != ""):
47
- raise ValidationError("prompt is required")
48
- if len(prompt) > PROMPT_MAX_LENGTH:
49
- raise ValidationError(f"prompt must be at most {PROMPT_MAX_LENGTH} characters")
50
-
51
- seed = params.get("seed")
52
- if seed is None:
53
- return
54
-
55
- parsed = self._parse_integer(seed)
56
- if parsed is not None and parsed in SEED_RANGE:
57
- return
58
-
59
- raise ValidationError(
60
- f"seed must be an integer between {SEED_RANGE.start} and {SEED_RANGE.stop - 1}"
61
- )
62
-
63
- @staticmethod
64
- def _parse_integer(value: Any) -> Any:
65
- """Mirror Ruby ``Integer(value, exception: false)``.
66
-
67
- Accepts ints and integer-looking strings; rejects bools and anything
68
- non-coercible by returning ``None``.
69
- """
70
- if isinstance(value, bool):
71
- return None
72
- if isinstance(value, int):
73
- return value
74
- if isinstance(value, str):
75
- try:
76
- return int(value.strip(), 10)
77
- except ValueError:
78
- return None
79
- return None