runapi-hailuo 0.2.3__tar.gz → 0.4.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,18 +1,18 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: runapi-hailuo
3
- Version: 0.2.3
3
+ Version: 0.4.0
4
4
  Summary: RunAPI Hailuo SDK for text-to-video and image-to-video workflows in JavaScript, Python, Ruby, Go, Java, and PHP
5
5
  Project-URL: Homepage, https://runapi.ai/models/hailuo
6
6
  Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
7
7
  Project-URL: Source, https://github.com/runapi-ai/hailuo-sdk
8
8
  Project-URL: Issues, https://github.com/runapi-ai/hailuo-sdk/issues
9
9
  Project-URL: Changelog, https://github.com/runapi-ai/hailuo-sdk/blob/main/CHANGELOG.md
10
- Project-URL: Release Notes, https://github.com/runapi-ai/hailuo-sdk/releases/tag/python%2Fv0.2.3
10
+ Project-URL: Release Notes, https://github.com/runapi-ai/hailuo-sdk/releases/tag/python%2Fv0.4.0
11
11
  Author-email: RunAPI <contact@runapi.ai>
12
12
  License-Expression: Apache-2.0
13
13
  Keywords: api,golang,gradle,hailuo,hailuo-ai-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.5.1
15
+ Requires-Dist: runapi-core~=0.10.0
16
16
  Description-Content-Type: text/markdown
17
17
 
18
18
  # Hailuo API Python SDK for RunAPI
@@ -4,14 +4,14 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "runapi-hailuo"
7
- version = "0.2.3"
7
+ version = "0.4.0"
8
8
  description = "RunAPI Hailuo SDK for text-to-video and image-to-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", "hailuo", "api", "sdk", "typescript", "python", "ruby", "golang", "java", "maven", "gradle", "video-generation", "text-to-video", "video-api", "hailuo-ai-api"]
14
- dependencies = ["runapi-core>=0.5.1"]
14
+ dependencies = ["runapi-core~=0.10.0"]
15
15
 
16
16
  [project.urls]
17
17
  Homepage = "https://runapi.ai/models/hailuo"
@@ -19,7 +19,7 @@ Documentation = "https://runapi.ai/docs/resources/sdks"
19
19
  Source = "https://github.com/runapi-ai/hailuo-sdk"
20
20
  Issues = "https://github.com/runapi-ai/hailuo-sdk/issues"
21
21
  Changelog = "https://github.com/runapi-ai/hailuo-sdk/blob/main/CHANGELOG.md"
22
- "Release Notes" = "https://github.com/runapi-ai/hailuo-sdk/releases/tag/python%2Fv0.2.3"
22
+ "Release Notes" = "https://github.com/runapi-ai/hailuo-sdk/releases/tag/python%2Fv0.4.0"
23
23
 
24
24
  [tool.hatch.build.targets.wheel]
25
25
  packages = ["src/runapi"]
@@ -2,11 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any, Dict, Optional
5
+ from typing import Any, Optional
6
6
 
7
- from runapi.core import Resource, ValidationError, RequestOptions
7
+ from runapi.core import Resource, RequestOptions
8
8
 
9
- from ..contract_gen import CONTRACT
10
9
  from ..types import (
11
10
  CompletedVideoTaskResponse,
12
11
  VideoTaskResponse,
@@ -43,7 +42,6 @@ class ImageToVideo(Resource):
43
42
  The task creation result with an id.
44
43
  """
45
44
  compacted = self._compact_params(params)
46
- self._validate_params(compacted)
47
45
  return self._request("post", self.ENDPOINT, body=compacted, options=options)
48
46
 
49
47
  def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
@@ -56,26 +54,3 @@ class ImageToVideo(Resource):
56
54
  The current task status.
57
55
  """
58
56
  return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
59
-
60
- def _validate_params(self, params: Dict[str, Any]) -> None:
61
- self._validate_contract(CONTRACT["image-to-video"], params)
62
-
63
- if not params.get("prompt"):
64
- raise ValidationError("prompt is required")
65
-
66
- model = params.get("model")
67
- duration_seconds = params.get("duration_seconds")
68
- output_resolution = params.get("output_resolution")
69
-
70
- if model == "hailuo-02-image-to-video-pro":
71
- if duration_seconds:
72
- raise ValidationError(f"duration_seconds is not supported for {model}")
73
- if output_resolution:
74
- raise ValidationError(f"output_resolution is not supported for {model}")
75
- elif model in ("hailuo-2.3-image-to-video-pro", "hailuo-2.3-image-to-video-standard"):
76
- if params.get("last_frame_image_url"):
77
- raise ValidationError(f"last_frame_image_url is not supported for {model}")
78
- if params.get("prompt_optimizer"):
79
- raise ValidationError(f"prompt_optimizer is not supported for {model}")
80
- if duration_seconds == 10 and str(output_resolution) == "1080p":
81
- raise ValidationError("1080p does not support 10-second duration")
@@ -2,11 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any, Dict, Optional
5
+ from typing import Any, Optional
6
6
 
7
- from runapi.core import Resource, ValidationError, RequestOptions
7
+ from runapi.core import Resource, RequestOptions
8
8
 
9
- from ..contract_gen import CONTRACT
10
9
  from ..types import (
11
10
  CompletedVideoTaskResponse,
12
11
  VideoTaskResponse,
@@ -43,7 +42,6 @@ class TextToVideo(Resource):
43
42
  The task creation result with an id.
44
43
  """
45
44
  compacted = self._compact_params(params)
46
- self._validate_params(compacted)
47
45
  return self._request("post", self.ENDPOINT, body=compacted, options=options)
48
46
 
49
47
  def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
@@ -56,13 +54,3 @@ class TextToVideo(Resource):
56
54
  The current task status.
57
55
  """
58
56
  return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
59
-
60
- def _validate_params(self, params: Dict[str, Any]) -> None:
61
- self._validate_contract(CONTRACT["text-to-video"], params)
62
-
63
- if not params.get("prompt"):
64
- raise ValidationError("prompt is required")
65
-
66
- model = params.get("model")
67
- if model == "hailuo-02-text-to-video-pro" and params.get("duration_seconds"):
68
- raise ValidationError(f"duration_seconds is not supported for {model}")
@@ -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.hailuo import HailuoClient
6
6
  from runapi.hailuo.resources.image_to_video import ImageToVideo
7
7
  from runapi.hailuo.resources.text_to_video import TextToVideo
@@ -82,8 +82,7 @@ def test_create_posts_compacted_body():
82
82
  "post",
83
83
  "/api/v1/hailuo/text_to_video",
84
84
  {"model": "hailuo-02-text-to-video-standard", "prompt": "hello world", "duration_seconds": 6},
85
- ),
86
- ]
85
+ )]
87
86
  assert isinstance(result, VideoTaskResponse)
88
87
 
89
88
 
@@ -104,10 +103,8 @@ def test_image_to_video_create_posts_compacted_body():
104
103
  "model": "hailuo-2.3-image-to-video-standard",
105
104
  "prompt": "pan the camera",
106
105
  "first_frame_image_url": "https://x/a.png",
107
- "output_resolution": "768p",
108
- },
109
- ),
110
- ]
106
+ "output_resolution": "768p"},
107
+ )]
111
108
 
112
109
 
113
110
  def test_get_fetches_by_id():
@@ -120,7 +117,7 @@ def test_get_fetches_by_id():
120
117
  def test_run_narrows_completed_type():
121
118
  fake = FakeHttp(
122
119
  {"id": "t1", "status": "pending"},
123
- {"id": "t1", "status": "completed", "videos": [{"url": "https://x/y.mp4"}]},
120
+ {"id": "t1", "status": "completed", "usage": {"cost": 0.05}, "videos": [{"url": "https://x/y.mp4"}]},
124
121
  )
125
122
  client = HailuoClient(api_key="k", http_client=fake)
126
123
  result = client.text_to_video.run(
@@ -128,87 +125,3 @@ def test_run_narrows_completed_type():
128
125
  )
129
126
  assert isinstance(result, CompletedVideoTaskResponse)
130
127
  assert result.videos[0].url == "https://x/y.mp4"
131
-
132
-
133
- # --- validation -----------------------------------------------------------
134
-
135
-
136
- def test_rejects_unknown_model():
137
- client = HailuoClient(api_key="k", http_client=FakeHttp())
138
- with pytest.raises(ValidationError, match="model must be one of: "):
139
- client.text_to_video.create(model="nope", prompt="hi there")
140
-
141
-
142
- def test_requires_prompt():
143
- client = HailuoClient(api_key="k", http_client=FakeHttp())
144
- with pytest.raises(ValidationError, match="prompt is required"):
145
- client.text_to_video.create(model="hailuo-02-text-to-video-standard")
146
-
147
-
148
- def test_text_to_video_duration_enum():
149
- client = HailuoClient(api_key="k", http_client=FakeHttp())
150
- with pytest.raises(ValidationError, match="duration_seconds must be one of: 6, 10"):
151
- client.text_to_video.create(
152
- model="hailuo-02-text-to-video-standard", prompt="hi there", duration_seconds=7
153
- )
154
-
155
-
156
- def test_text_to_video_pro_rejects_duration():
157
- client = HailuoClient(api_key="k", http_client=FakeHttp())
158
- with pytest.raises(ValidationError, match="duration_seconds is not supported"):
159
- client.text_to_video.create(
160
- model="hailuo-02-text-to-video-pro", prompt="hi there", duration_seconds=6
161
- )
162
-
163
-
164
- def test_image_to_video_requires_first_frame():
165
- client = HailuoClient(api_key="k", http_client=FakeHttp())
166
- with pytest.raises(ValidationError, match="first_frame_image_url is required"):
167
- client.image_to_video.create(
168
- model="hailuo-02-image-to-video-standard", prompt="hi there"
169
- )
170
-
171
-
172
- def test_image_to_video_pro_rejects_resolution():
173
- client = HailuoClient(api_key="k", http_client=FakeHttp())
174
- with pytest.raises(ValidationError, match="output_resolution is not supported"):
175
- client.image_to_video.create(
176
- model="hailuo-02-image-to-video-pro",
177
- prompt="hi there",
178
- first_frame_image_url="https://x/a.png",
179
- output_resolution="512p",
180
- )
181
-
182
-
183
- def test_image_to_video_02_standard_resolution_enum():
184
- client = HailuoClient(api_key="k", http_client=FakeHttp())
185
- with pytest.raises(ValidationError, match="output_resolution must be one of: 512p, 768p"):
186
- client.image_to_video.create(
187
- model="hailuo-02-image-to-video-standard",
188
- prompt="hi there",
189
- first_frame_image_url="https://x/a.png",
190
- output_resolution="1080p",
191
- )
192
-
193
-
194
- def test_image_to_video_23_rejects_last_frame():
195
- client = HailuoClient(api_key="k", http_client=FakeHttp())
196
- with pytest.raises(ValidationError, match="last_frame_image_url is not supported"):
197
- client.image_to_video.create(
198
- model="hailuo-2.3-image-to-video-standard",
199
- prompt="hi there",
200
- first_frame_image_url="https://x/a.png",
201
- last_frame_image_url="https://x/b.png",
202
- )
203
-
204
-
205
- def test_image_to_video_23_1080p_no_10_second():
206
- client = HailuoClient(api_key="k", http_client=FakeHttp())
207
- with pytest.raises(ValidationError, match="1080p does not support 10-second duration"):
208
- client.image_to_video.create(
209
- model="hailuo-2.3-image-to-video-standard",
210
- prompt="hi there",
211
- first_frame_image_url="https://x/a.png",
212
- duration_seconds=10,
213
- output_resolution="1080p",
214
- )
@@ -1,67 +0,0 @@
1
- CONTRACT = {
2
- "image-to-video": {
3
- "models": ["hailuo-02-image-to-video-pro", "hailuo-02-image-to-video-standard", "hailuo-2.3-image-to-video-pro", "hailuo-2.3-image-to-video-standard"],
4
- "fields_by_model": {
5
- "hailuo-02-image-to-video-pro": {
6
- "duration_seconds": {
7
- "type": "integer"
8
- },
9
- "first_frame_image_url": {
10
- "required": True
11
- }
12
- },
13
- "hailuo-02-image-to-video-standard": {
14
- "duration_seconds": {
15
- "enum": [6, 10],
16
- "type": "integer"
17
- },
18
- "first_frame_image_url": {
19
- "required": True
20
- },
21
- "output_resolution": {
22
- "enum": ["512p", "768p"]
23
- }
24
- },
25
- "hailuo-2.3-image-to-video-pro": {
26
- "duration_seconds": {
27
- "enum": [6, 10],
28
- "type": "integer"
29
- },
30
- "first_frame_image_url": {
31
- "required": True
32
- },
33
- "output_resolution": {
34
- "enum": ["768p", "1080p"]
35
- }
36
- },
37
- "hailuo-2.3-image-to-video-standard": {
38
- "duration_seconds": {
39
- "enum": [6, 10],
40
- "type": "integer"
41
- },
42
- "first_frame_image_url": {
43
- "required": True
44
- },
45
- "output_resolution": {
46
- "enum": ["768p", "1080p"]
47
- }
48
- }
49
- }
50
- },
51
- "text-to-video": {
52
- "models": ["hailuo-02-text-to-video-pro", "hailuo-02-text-to-video-standard"],
53
- "fields_by_model": {
54
- "hailuo-02-text-to-video-pro": {
55
- "duration_seconds": {
56
- "type": "integer"
57
- }
58
- },
59
- "hailuo-02-text-to-video-standard": {
60
- "duration_seconds": {
61
- "enum": [6, 10],
62
- "type": "integer"
63
- }
64
- }
65
- }
66
- }
67
- }
File without changes