runapi-runway 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/runway/__init__.py +24 -0
- runapi/runway/client.py +32 -0
- runapi/runway/contract_gen.py +41 -0
- runapi/runway/py.typed +0 -0
- runapi/runway/resources/__init__.py +4 -0
- runapi/runway/resources/extend_video.py +60 -0
- runapi/runway/resources/text_to_video.py +60 -0
- runapi/runway/types.py +35 -0
- runapi_runway-0.1.0.dist-info/METADATA +90 -0
- runapi_runway-0.1.0.dist-info/RECORD +11 -0
- runapi_runway-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Runway 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 RunwayClient
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"RunwayClient",
|
|
17
|
+
"AuthenticationError",
|
|
18
|
+
"RateLimitError",
|
|
19
|
+
"InsufficientCreditsError",
|
|
20
|
+
"NotFoundError",
|
|
21
|
+
"ValidationError",
|
|
22
|
+
"TaskFailedError",
|
|
23
|
+
"TaskTimeoutError",
|
|
24
|
+
]
|
runapi/runway/client.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Runway client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import ClientOptions, HttpClient, resolve_api_key
|
|
8
|
+
|
|
9
|
+
from .resources.extend_video import ExtendVideo
|
|
10
|
+
from .resources.text_to_video import TextToVideo
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RunwayClient:
|
|
14
|
+
"""Runway text-to-video and extend-video client.
|
|
15
|
+
|
|
16
|
+
Example::
|
|
17
|
+
|
|
18
|
+
client = RunwayClient(api_key="sk-...")
|
|
19
|
+
result = client.text_to_video.run(
|
|
20
|
+
model="...",
|
|
21
|
+
prompt="A drone shot over a coastal city at sunset",
|
|
22
|
+
duration_seconds=5,
|
|
23
|
+
output_resolution="720p",
|
|
24
|
+
)
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
|
|
28
|
+
resolved_api_key = resolve_api_key(api_key)
|
|
29
|
+
client_options = ClientOptions(api_key=resolved_api_key, **options)
|
|
30
|
+
http = client_options.http_client or HttpClient(client_options)
|
|
31
|
+
self.text_to_video = TextToVideo(http)
|
|
32
|
+
self.extend_video = ExtendVideo(http)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
CONTRACT = {
|
|
2
|
+
"extend-video": {
|
|
3
|
+
"models": ["runway"],
|
|
4
|
+
"fields_by_model": {
|
|
5
|
+
"runway": {
|
|
6
|
+
"output_resolution": {
|
|
7
|
+
"enum": ["720p", "1080p"],
|
|
8
|
+
"required": True
|
|
9
|
+
},
|
|
10
|
+
"prompt": {
|
|
11
|
+
"required": True
|
|
12
|
+
},
|
|
13
|
+
"source_task_id": {
|
|
14
|
+
"required": True
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"text-to-video": {
|
|
20
|
+
"models": ["runway"],
|
|
21
|
+
"fields_by_model": {
|
|
22
|
+
"runway": {
|
|
23
|
+
"aspect_ratio": {
|
|
24
|
+
"enum": ["16:9", "9:16", "1:1", "4:3", "3:4"]
|
|
25
|
+
},
|
|
26
|
+
"duration_seconds": {
|
|
27
|
+
"enum": [5, 10],
|
|
28
|
+
"required": True,
|
|
29
|
+
"type": "integer"
|
|
30
|
+
},
|
|
31
|
+
"output_resolution": {
|
|
32
|
+
"enum": ["720p", "1080p"],
|
|
33
|
+
"required": True
|
|
34
|
+
},
|
|
35
|
+
"prompt": {
|
|
36
|
+
"required": True
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
runapi/runway/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Runway extend-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource
|
|
8
|
+
|
|
9
|
+
from ..contract_gen import CONTRACT
|
|
10
|
+
from ..types import (
|
|
11
|
+
CompletedTaskResponse,
|
|
12
|
+
TaskCreateResponse,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ExtendVideo(Resource):
|
|
17
|
+
"""Extend an existing Runway video task."""
|
|
18
|
+
|
|
19
|
+
ENDPOINT = "/api/v1/runway/extend_video"
|
|
20
|
+
|
|
21
|
+
RESPONSE_CLASS = TaskCreateResponse
|
|
22
|
+
COMPLETED_RESPONSE_CLASS = CompletedTaskResponse
|
|
23
|
+
|
|
24
|
+
MODEL = "runway"
|
|
25
|
+
|
|
26
|
+
def run(self, **params: Any) -> Any:
|
|
27
|
+
"""Append footage to a previous video and poll until it completes.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
**params: extend-video parameters (model, ...).
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
The completed (narrowed) extend-video response.
|
|
34
|
+
"""
|
|
35
|
+
task = self.create(**params)
|
|
36
|
+
return self._poll_until_complete(lambda: self.get(task.id))
|
|
37
|
+
|
|
38
|
+
def create(self, **params: Any) -> Any:
|
|
39
|
+
"""Create an extend-video task and return immediately with an id.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
**params: extend-video parameters (model, ...).
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
The task creation result with an id.
|
|
46
|
+
"""
|
|
47
|
+
compacted = self._compact_params(params)
|
|
48
|
+
self._validate_contract(CONTRACT["extend-video"], {**compacted, "model": self.MODEL})
|
|
49
|
+
return self._request("post", self.ENDPOINT, body=compacted)
|
|
50
|
+
|
|
51
|
+
def get(self, id: str) -> Any:
|
|
52
|
+
"""Fetch the current status of an extend-video task.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
id: The task id returned by ``create``.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
The current task status.
|
|
59
|
+
"""
|
|
60
|
+
return self._request("get", f"{self.ENDPOINT}/{id}")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Runway text-to-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource
|
|
8
|
+
|
|
9
|
+
from ..contract_gen import CONTRACT
|
|
10
|
+
from ..types import (
|
|
11
|
+
CompletedTaskResponse,
|
|
12
|
+
TaskCreateResponse,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TextToVideo(Resource):
|
|
17
|
+
"""Generate videos from text prompts with Runway models."""
|
|
18
|
+
|
|
19
|
+
ENDPOINT = "/api/v1/runway/text_to_video"
|
|
20
|
+
|
|
21
|
+
RESPONSE_CLASS = TaskCreateResponse
|
|
22
|
+
COMPLETED_RESPONSE_CLASS = CompletedTaskResponse
|
|
23
|
+
|
|
24
|
+
MODEL = "runway"
|
|
25
|
+
|
|
26
|
+
def run(self, **params: Any) -> Any:
|
|
27
|
+
"""Create a text-to-video task and poll until it completes.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
**params: text-to-video parameters (model, ...).
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
The completed (narrowed) text-to-video response.
|
|
34
|
+
"""
|
|
35
|
+
task = self.create(**params)
|
|
36
|
+
return self._poll_until_complete(lambda: self.get(task.id))
|
|
37
|
+
|
|
38
|
+
def create(self, **params: Any) -> Any:
|
|
39
|
+
"""Create a text-to-video task and return immediately with an id.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
**params: text-to-video parameters (model, ...).
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
The task creation result with an id.
|
|
46
|
+
"""
|
|
47
|
+
compacted = self._compact_params(params)
|
|
48
|
+
self._validate_contract(CONTRACT["text-to-video"], {**compacted, "model": self.MODEL})
|
|
49
|
+
return self._request("post", self.ENDPOINT, body=compacted)
|
|
50
|
+
|
|
51
|
+
def get(self, id: str) -> Any:
|
|
52
|
+
"""Fetch the current status of a text-to-video task.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
id: The task id returned by ``create``.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
The current task status.
|
|
59
|
+
"""
|
|
60
|
+
return self._request("get", f"{self.ENDPOINT}/{id}")
|
runapi/runway/types.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Runway enums and response models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from runapi.core import BaseModel, TaskResponse, optional, required
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Video(BaseModel):
|
|
9
|
+
id = optional(str)
|
|
10
|
+
url = required(str)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Image(BaseModel):
|
|
14
|
+
url = required(str)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TaskResponseModel(TaskResponse):
|
|
18
|
+
"""Runway task status response."""
|
|
19
|
+
|
|
20
|
+
id = required(str)
|
|
21
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
22
|
+
videos = optional([lambda: Video])
|
|
23
|
+
images = optional([lambda: Image])
|
|
24
|
+
source_task_id = optional(str)
|
|
25
|
+
error = optional(str)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TaskCreateResponse(TaskResponseModel):
|
|
29
|
+
"""Runway task creation response with an id."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class CompletedTaskResponse(TaskResponseModel):
|
|
33
|
+
"""Narrowed response from ``run()`` once polling observes completion."""
|
|
34
|
+
|
|
35
|
+
videos = required([lambda: Video])
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runapi-runway
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Runway text-to-video and extend-video client for RunAPI
|
|
5
|
+
Project-URL: Homepage, https://runapi.ai/models/runway
|
|
6
|
+
Project-URL: Documentation, https://runapi.ai/docs#sdk-runway
|
|
7
|
+
Author-email: RunAPI <contact@runapi.ai>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Keywords: ai,extend-video,runapi,runway,sdk,text-to-video
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: runapi-core
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Runway Python SDK for RunAPI
|
|
15
|
+
|
|
16
|
+
The Runway Python SDK is the language-specific package for Runway on RunAPI.
|
|
17
|
+
Use it for text-to-video and extend-video flows when your application needs JSON
|
|
18
|
+
request bodies, task status lookup, and consistent RunAPI errors in Python.
|
|
19
|
+
|
|
20
|
+
For model details, use https://runapi.ai/models/runway; for API reference, use
|
|
21
|
+
https://runapi.ai/docs#runway; for SDK docs, use https://runapi.ai/docs#sdk-runway.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install runapi-runway
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from runapi.runway import RunwayClient
|
|
33
|
+
|
|
34
|
+
client = RunwayClient() # reads RUNAPI_API_KEY, or pass api_key="sk-..."
|
|
35
|
+
|
|
36
|
+
task = client.text_to_video.create(
|
|
37
|
+
model="...",
|
|
38
|
+
prompt="A drone shot over a coastal city at sunset, cinematic",
|
|
39
|
+
duration_seconds=5,
|
|
40
|
+
output_resolution="720p",
|
|
41
|
+
aspect_ratio="16:9",
|
|
42
|
+
)
|
|
43
|
+
status = client.text_to_video.get(task.id)
|
|
44
|
+
|
|
45
|
+
extended = client.extend_video.create(
|
|
46
|
+
model="...",
|
|
47
|
+
source_task_id=task.id,
|
|
48
|
+
prompt="Continue the camera push toward the harbor",
|
|
49
|
+
output_resolution="720p",
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use `create` to submit a task and return quickly, `get` to fetch the latest task
|
|
54
|
+
state, and `run` to create and poll until completion:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
result = client.text_to_video.run(
|
|
58
|
+
model="...",
|
|
59
|
+
prompt="A serene mountain lake at dawn, slow pan",
|
|
60
|
+
duration_seconds=5,
|
|
61
|
+
output_resolution="720p",
|
|
62
|
+
)
|
|
63
|
+
print(result.videos[0].url)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In web request handlers, prefer `create` plus webhook or later `get` polling so a
|
|
67
|
+
worker is not held open.
|
|
68
|
+
|
|
69
|
+
RunAPI-generated file URLs are temporary. Download and store generated videos in
|
|
70
|
+
your own durable storage within 7 days; do not treat returned URLs as long-term
|
|
71
|
+
assets.
|
|
72
|
+
|
|
73
|
+
## Language notes
|
|
74
|
+
|
|
75
|
+
Pass parameters as keyword arguments and catch the `runapi.runway` error classes
|
|
76
|
+
when building video jobs or scripts. The available resources are `text_to_video`
|
|
77
|
+
and `extend_video`. Keep `RUNAPI_API_KEY` in the environment or your secret
|
|
78
|
+
manager; never commit API keys or callback secrets.
|
|
79
|
+
|
|
80
|
+
## Links
|
|
81
|
+
|
|
82
|
+
- Model page: https://runapi.ai/models/runway
|
|
83
|
+
- SDK docs: https://runapi.ai/docs#sdk-runway
|
|
84
|
+
- Product docs: https://runapi.ai/docs#runway
|
|
85
|
+
- Pricing and rate limits: https://runapi.ai/models/runway
|
|
86
|
+
- Full catalog: https://runapi.ai/models
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
runapi/runway/__init__.py,sha256=nlUjGEriMVCmUDkbGPu1S0fjcDWbaHFlJYZg9iTE0N0,460
|
|
2
|
+
runapi/runway/client.py,sha256=Teoru5O4mtJOjxn45BAjWA__ejGPVlJ0FSsdy7xTgmw,990
|
|
3
|
+
runapi/runway/contract_gen.py,sha256=wLi6dhVJWfQhAJnf0KWX_Odp0BfUxMPN_iFYh150Y_4,1118
|
|
4
|
+
runapi/runway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
runapi/runway/types.py,sha256=NY12mC-U4PP5vDoWes-Uqy5ll63lYxt70wF-D7RZ28k,842
|
|
6
|
+
runapi/runway/resources/__init__.py,sha256=IgMxZ4v5xl_GRNGY9o4408CAAMD65UeliI78lSX6pt4,119
|
|
7
|
+
runapi/runway/resources/extend_video.py,sha256=BA2o2FEnEShync7xUOmZf1OHbXmclAa8bSUY8cf65Do,1646
|
|
8
|
+
runapi/runway/resources/text_to_video.py,sha256=YLwuMcBXD9eG5fU3psGZf_Na4Bu7TMYVQjiUxb02Z9c,1661
|
|
9
|
+
runapi_runway-0.1.0.dist-info/METADATA,sha256=g_lME_X_6e2EKDbUGtrNuTphoh9qKXv_oQT6ZOZWEqM,2746
|
|
10
|
+
runapi_runway-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
11
|
+
runapi_runway-0.1.0.dist-info/RECORD,,
|