runapi-kie 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/kie/__init__.py ADDED
@@ -0,0 +1,24 @@
1
+ """Kie 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 KieClient
14
+
15
+ __all__ = [
16
+ "KieClient",
17
+ "AuthenticationError",
18
+ "RateLimitError",
19
+ "InsufficientCreditsError",
20
+ "NotFoundError",
21
+ "ValidationError",
22
+ "TaskFailedError",
23
+ "TaskTimeoutError",
24
+ ]
runapi/kie/client.py ADDED
@@ -0,0 +1,30 @@
1
+ """Kie 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.upscale_image import UpscaleImage
10
+ from .resources.upscale_video import UpscaleVideo
11
+
12
+
13
+ class KieClient(ProviderClient):
14
+ """Kie image and video upscale client.
15
+
16
+ Example::
17
+
18
+ client = KieClient(api_key="sk-...")
19
+ result = client.upscale_image.run(
20
+ model="kie-upscale-image",
21
+ source_image_url="https://runapi.ai/in.jpg",
22
+ upscale_factor="4",
23
+ )
24
+ """
25
+
26
+ def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
27
+ super().__init__(api_key, **options)
28
+ http = self._http
29
+ self.upscale_image = UpscaleImage(http)
30
+ self.upscale_video = UpscaleVideo(http)
runapi/kie/py.typed ADDED
File without changes
@@ -0,0 +1,4 @@
1
+ from .upscale_image import UpscaleImage
2
+ from .upscale_video import UpscaleVideo
3
+
4
+ __all__ = ["UpscaleImage", "UpscaleVideo"]
@@ -0,0 +1,56 @@
1
+ """Kie upscale-image 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
+ CompletedUpscaleImageResponse,
11
+ UpscaleImageResponse,
12
+ )
13
+
14
+
15
+ class UpscaleImage(Resource):
16
+ """Upscale images with Kie."""
17
+
18
+ ENDPOINT = "/api/v1/kie/upscale_image"
19
+
20
+ RESPONSE_CLASS = UpscaleImageResponse
21
+ COMPLETED_RESPONSE_CLASS = CompletedUpscaleImageResponse
22
+
23
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
24
+ """Upscale an image and poll until it completes.
25
+
26
+ Args:
27
+ **params: image upscale parameters (model, ...).
28
+
29
+ Returns:
30
+ The completed (narrowed) image upscale response.
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 upscale task and return immediately with an id.
37
+
38
+ Args:
39
+ **params: image upscale parameters (model, ...).
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 upscale task.
49
+
50
+ Args:
51
+ id: The task id returned by ``create``.
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
+ """Kie upscale-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
+ CompletedUpscaleVideoResponse,
11
+ UpscaleVideoResponse,
12
+ )
13
+
14
+
15
+ class UpscaleVideo(Resource):
16
+ """Upscale videos with Kie."""
17
+
18
+ ENDPOINT = "/api/v1/kie/upscale_video"
19
+
20
+ RESPONSE_CLASS = UpscaleVideoResponse
21
+ COMPLETED_RESPONSE_CLASS = CompletedUpscaleVideoResponse
22
+
23
+ def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
24
+ """Upscale a video and poll until it completes.
25
+
26
+ Args:
27
+ **params: video upscale parameters (model, ...).
28
+
29
+ Returns:
30
+ The completed (narrowed) video upscale response.
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 a video upscale task and return immediately with an id.
37
+
38
+ Args:
39
+ **params: video upscale parameters (model, ...).
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 a video upscale task.
49
+
50
+ Args:
51
+ id: The task id returned by ``create``.
52
+
53
+ Returns:
54
+ The current task status.
55
+ """
56
+ return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
runapi/kie/types.py ADDED
@@ -0,0 +1,43 @@
1
+ """Kie response models."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from runapi.core import BaseModel, TaskResponse, optional, required
6
+
7
+
8
+ class Image(BaseModel):
9
+ url = optional(str)
10
+
11
+
12
+ class Video(BaseModel):
13
+ url = optional(str)
14
+
15
+
16
+ class UpscaleImageResponse(TaskResponse):
17
+ """Kie image upscale task status response."""
18
+
19
+ id = required(str)
20
+ status = optional(str, enum=lambda: TaskResponse.Status.ALL)
21
+ images = optional([lambda: Image])
22
+ error = optional(str)
23
+
24
+
25
+ class UpscaleVideoResponse(TaskResponse):
26
+ """Kie video upscale task status response."""
27
+
28
+ id = required(str)
29
+ status = optional(str, enum=lambda: TaskResponse.Status.ALL)
30
+ videos = optional([lambda: Video])
31
+ error = optional(str)
32
+
33
+
34
+ class CompletedUpscaleImageResponse(UpscaleImageResponse):
35
+ """Narrowed response from ``run()`` once polling observes completion."""
36
+
37
+ images = required([lambda: Image])
38
+
39
+
40
+ class CompletedUpscaleVideoResponse(UpscaleVideoResponse):
41
+ """Narrowed response from ``run()`` once polling observes completion."""
42
+
43
+ videos = required([lambda: Video])
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.5
2
+ Name: runapi-kie
3
+ Version: 0.1.0
4
+ Summary: RunAPI KIE SDK for image and video upscaling workflows in JavaScript, Python, Ruby, Go, Java, and PHP
5
+ Project-URL: Homepage, https://runapi.ai/models/kie
6
+ Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
7
+ Project-URL: Source, https://github.com/runapi-ai/kie-sdk
8
+ Project-URL: Issues, https://github.com/runapi-ai/kie-sdk/issues
9
+ Project-URL: Changelog, https://github.com/runapi-ai/kie-sdk/blob/main/CHANGELOG.md
10
+ Project-URL: Release Notes, https://github.com/runapi-ai/kie-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,image-upscaling,java,kie,kie-api,maven,python,ruby,runapi,runapi-ai,sdk,typescript,upscaling,video-upscaling
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: runapi-core~=0.12.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # KIE Python SDK for RunAPI
25
+
26
+ The KIE Python SDK is the language-specific package for KIE on RunAPI. Use this package for image and video upscaling workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Python.
27
+
28
+ This README is the Python package guide inside the public `kie-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kie; for API reference, use https://runapi.ai/docs/api/kie/upscale-image; for SDK docs, use https://runapi.ai/docs/resources/sdks.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install runapi-kie
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ from runapi.kie import KieClient
40
+
41
+ client = KieClient() # reads RUNAPI_API_KEY, or pass api_key="sk-..."
42
+
43
+ task = client.upscale_image.create(
44
+ model="kie-upscale-image",
45
+ source_image_url="https://cdn.runapi.ai/public/samples/upscale.jpg",
46
+ upscale_factor="4",
47
+ )
48
+ status = client.upscale_image.get(task.id)
49
+
50
+ video = client.upscale_video.create(
51
+ model="kie-upscale-video",
52
+ source_video_url="https://cdn.runapi.ai/public/samples/video-lowres.mp4",
53
+ resolution="2K",
54
+ )
55
+ ```
56
+
57
+ Use `create` to submit a task and return quickly, `get` to fetch the latest task state, and `run` when a script should create and poll until completion:
58
+
59
+ ```python
60
+ result = client.upscale_image.run(
61
+ model="kie-upscale-image",
62
+ source_image_url="https://cdn.runapi.ai/public/samples/upscale.jpg",
63
+ upscale_factor="4",
64
+ )
65
+ print(result.images[0].url)
66
+ ```
67
+
68
+ In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
69
+
70
+ RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
71
+
72
+ ## Language notes
73
+
74
+ Pass parameters as keyword arguments and catch the `runapi.kie` error classes when building upscaling jobs or scripts. The available resources are `upscale_image` and `upscale_video`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
75
+
76
+ ## Links
77
+
78
+ - Model page: https://runapi.ai/models/kie
79
+ - SDK docs: https://runapi.ai/docs/resources/sdks
80
+ - Product docs: https://runapi.ai/docs/api/kie/upscale-image
81
+ - Pricing and rate limits: https://runapi.ai/models/kie/upscale-image
82
+ - Provider comparison: https://runapi.ai/providers/kie
83
+ - Full catalog: https://runapi.ai/models
84
+ - Repository: https://github.com/runapi-ai/kie-sdk
85
+
86
+ ## License
87
+
88
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,10 @@
1
+ runapi/kie/__init__.py,sha256=SRlCR63DHnqBwryzpKvHh5hivWcrTnLW1kK1ZyKwTAA,451
2
+ runapi/kie/client.py,sha256=nhMT50b5CkLNt-FyZ6Ocq3siY67HZFDK5g_aYWIerFA,804
3
+ runapi/kie/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ runapi/kie/types.py,sha256=rYgdpKrLvTH-yJ4AeM1NxC9AzTubAT1kxIzBdeqg5tA,1084
5
+ runapi/kie/resources/__init__.py,sha256=0ALsFeXvjqJCaqpTFNWGdDHcA944GGEIVMTJ-0TK50M,124
6
+ runapi/kie/resources/upscale_image.py,sha256=5IG1NAK3Avezhfjp8flLCsZKUI6cw8UUQ9faRfCDoWg,1705
7
+ runapi/kie/resources/upscale_video.py,sha256=gPpF3vYleqScofDsUq104FmAHpbLSjmtzBFk9ezxtVQ,1702
8
+ runapi_kie-0.1.0.dist-info/METADATA,sha256=1XLQqwZZlB4ZXOaQVkSaH7LMWHAYTSuWVPMkpz6avOw,3761
9
+ runapi_kie-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
10
+ runapi_kie-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any