Skip to content

Commit 18b1573

Browse files
feat(api): add avatar, voice, document, and realtime session endpoints
1 parent 84988e1 commit 18b1573

38 files changed

Lines changed: 6337 additions & 11 deletions

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-b3276a8508268090b14e297f5cb18448da7a763653c6d38c23f0eea0984d8008.yml
3-
openapi_spec_hash: 95ae975f17217c8d144c4ba80846beca
4-
config_hash: 803d5c0aa94eea0a7981b91728218d3f
1+
configured_endpoints: 31
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-4ddc8e3d83c8601fc378c702bbcb5af2976b481db513bd389a5f57645a20cd04.yml
3+
openapi_spec_hash: 5795c6af9e9404765bda670e781fe500
4+
config_hash: 3c88fcd4dd6f3a7d7f6e94b57b430243

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,77 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
121121

122122
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
123123

124+
## Pagination
125+
126+
List methods in the RunwayML API are paginated.
127+
128+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
129+
130+
```python
131+
from runwayml import RunwayML
132+
133+
client = RunwayML()
134+
135+
all_avatars = []
136+
# Automatically fetches more pages as needed.
137+
for avatar in client.avatars.list(
138+
limit=1,
139+
):
140+
# Do something with avatar here
141+
all_avatars.append(avatar)
142+
print(all_avatars)
143+
```
144+
145+
Or, asynchronously:
146+
147+
```python
148+
import asyncio
149+
from runwayml import AsyncRunwayML
150+
151+
client = AsyncRunwayML()
152+
153+
154+
async def main() -> None:
155+
all_avatars = []
156+
# Iterate through items across all pages, issuing requests as needed.
157+
async for avatar in client.avatars.list(
158+
limit=1,
159+
):
160+
all_avatars.append(avatar)
161+
print(all_avatars)
162+
163+
164+
asyncio.run(main())
165+
```
166+
167+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
168+
169+
```python
170+
first_page = await client.avatars.list(
171+
limit=1,
172+
)
173+
if first_page.has_next_page():
174+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
175+
next_page = await first_page.get_next_page()
176+
print(f"number of items we just fetched: {len(next_page.data)}")
177+
178+
# Remove `await` for non-async usage.
179+
```
180+
181+
Or just work directly with the returned data:
182+
183+
```python
184+
first_page = await client.avatars.list(
185+
limit=1,
186+
)
187+
188+
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
189+
for avatar in first_page.data:
190+
print(avatar)
191+
192+
# Remove `await` for non-async usage.
193+
```
194+
124195
## Nested params
125196

126197
Nested parameters are dictionaries, typed using `TypedDict`, for example:

api.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,74 @@ Methods:
143143

144144
- <code title="get /v1/organization">client.organization.<a href="./src/runwayml/resources/organization.py">retrieve</a>() -> <a href="./src/runwayml/types/organization_retrieve_response.py">OrganizationRetrieveResponse</a></code>
145145
- <code title="post /v1/organization/usage">client.organization.<a href="./src/runwayml/resources/organization.py">retrieve_usage</a>(\*\*<a href="src/runwayml/types/organization_retrieve_usage_params.py">params</a>) -> <a href="./src/runwayml/types/organization_retrieve_usage_response.py">OrganizationRetrieveUsageResponse</a></code>
146+
147+
# Avatars
148+
149+
Types:
150+
151+
```python
152+
from runwayml.types import (
153+
AvatarCreateResponse,
154+
AvatarRetrieveResponse,
155+
AvatarUpdateResponse,
156+
AvatarListResponse,
157+
)
158+
```
159+
160+
Methods:
161+
162+
- <code title="post /v1/avatars">client.avatars.<a href="./src/runwayml/resources/avatars.py">create</a>(\*\*<a href="src/runwayml/types/avatar_create_params.py">params</a>) -> <a href="./src/runwayml/types/avatar_create_response.py">AvatarCreateResponse</a></code>
163+
- <code title="get /v1/avatars/{id}">client.avatars.<a href="./src/runwayml/resources/avatars.py">retrieve</a>(id) -> <a href="./src/runwayml/types/avatar_retrieve_response.py">AvatarRetrieveResponse</a></code>
164+
- <code title="patch /v1/avatars/{id}">client.avatars.<a href="./src/runwayml/resources/avatars.py">update</a>(id, \*\*<a href="src/runwayml/types/avatar_update_params.py">params</a>) -> <a href="./src/runwayml/types/avatar_update_response.py">AvatarUpdateResponse</a></code>
165+
- <code title="get /v1/avatars">client.avatars.<a href="./src/runwayml/resources/avatars.py">list</a>(\*\*<a href="src/runwayml/types/avatar_list_params.py">params</a>) -> <a href="./src/runwayml/types/avatar_list_response.py">SyncCursorPage[AvatarListResponse]</a></code>
166+
- <code title="delete /v1/avatars/{id}">client.avatars.<a href="./src/runwayml/resources/avatars.py">delete</a>(id) -> None</code>
167+
168+
# Documents
169+
170+
Types:
171+
172+
```python
173+
from runwayml.types import DocumentCreateResponse, DocumentRetrieveResponse, DocumentListResponse
174+
```
175+
176+
Methods:
177+
178+
- <code title="post /v1/documents">client.documents.<a href="./src/runwayml/resources/documents.py">create</a>(\*\*<a href="src/runwayml/types/document_create_params.py">params</a>) -> <a href="./src/runwayml/types/document_create_response.py">DocumentCreateResponse</a></code>
179+
- <code title="get /v1/documents/{id}">client.documents.<a href="./src/runwayml/resources/documents.py">retrieve</a>(id) -> <a href="./src/runwayml/types/document_retrieve_response.py">DocumentRetrieveResponse</a></code>
180+
- <code title="get /v1/documents">client.documents.<a href="./src/runwayml/resources/documents.py">list</a>(\*\*<a href="src/runwayml/types/document_list_params.py">params</a>) -> <a href="./src/runwayml/types/document_list_response.py">SyncCursorPage[DocumentListResponse]</a></code>
181+
- <code title="delete /v1/documents/{id}">client.documents.<a href="./src/runwayml/resources/documents.py">delete</a>(id) -> None</code>
182+
183+
# RealtimeSessions
184+
185+
Types:
186+
187+
```python
188+
from runwayml.types import RealtimeSessionCreateResponse, RealtimeSessionRetrieveResponse
189+
```
190+
191+
Methods:
192+
193+
- <code title="post /v1/realtime_sessions">client.realtime_sessions.<a href="./src/runwayml/resources/realtime_sessions.py">create</a>(\*\*<a href="src/runwayml/types/realtime_session_create_params.py">params</a>) -> <a href="./src/runwayml/types/realtime_session_create_response.py">RealtimeSessionCreateResponse</a></code>
194+
- <code title="get /v1/realtime_sessions/{id}">client.realtime_sessions.<a href="./src/runwayml/resources/realtime_sessions.py">retrieve</a>(id) -> <a href="./src/runwayml/types/realtime_session_retrieve_response.py">RealtimeSessionRetrieveResponse</a></code>
195+
- <code title="delete /v1/realtime_sessions/{id}">client.realtime_sessions.<a href="./src/runwayml/resources/realtime_sessions.py">delete</a>(id) -> None</code>
196+
197+
# Voices
198+
199+
Types:
200+
201+
```python
202+
from runwayml.types import (
203+
VoiceCreateResponse,
204+
VoiceRetrieveResponse,
205+
VoiceListResponse,
206+
VoicePreviewResponse,
207+
)
208+
```
209+
210+
Methods:
211+
212+
- <code title="post /v1/voices">client.voices.<a href="./src/runwayml/resources/voices.py">create</a>(\*\*<a href="src/runwayml/types/voice_create_params.py">params</a>) -> <a href="./src/runwayml/types/voice_create_response.py">VoiceCreateResponse</a></code>
213+
- <code title="get /v1/voices/{id}">client.voices.<a href="./src/runwayml/resources/voices.py">retrieve</a>(id) -> <a href="./src/runwayml/types/voice_retrieve_response.py">VoiceRetrieveResponse</a></code>
214+
- <code title="get /v1/voices">client.voices.<a href="./src/runwayml/resources/voices.py">list</a>(\*\*<a href="src/runwayml/types/voice_list_params.py">params</a>) -> <a href="./src/runwayml/types/voice_list_response.py">SyncCursorPage[VoiceListResponse]</a></code>
215+
- <code title="delete /v1/voices/{id}">client.voices.<a href="./src/runwayml/resources/voices.py">delete</a>(id) -> None</code>
216+
- <code title="post /v1/voices/preview">client.voices.<a href="./src/runwayml/resources/voices.py">preview</a>(\*\*<a href="src/runwayml/types/voice_preview_params.py">params</a>) -> <a href="./src/runwayml/types/voice_preview_response.py">VoicePreviewResponse</a></code>

src/runwayml/_client.py

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@
4444
video_to_video,
4545
voice_isolation,
4646
speech_to_speech,
47+
realtime_sessions,
4748
character_performance,
4849
)
4950
from .resources.tasks import TasksResource, AsyncTasksResource
50-
from .resources.uploads import UploadsResource, AsyncUploadsResource
51+
5152
from .resources.organization import OrganizationResource, AsyncOrganizationResource
5253
from .resources.sound_effect import SoundEffectResource, AsyncSoundEffectResource
5354
from .resources.text_to_image import TextToImageResource, AsyncTextToImageResource
@@ -58,6 +59,7 @@
5859
from .resources.video_to_video import VideoToVideoResource, AsyncVideoToVideoResource
5960
from .resources.voice_isolation import VoiceIsolationResource, AsyncVoiceIsolationResource
6061
from .resources.speech_to_speech import SpeechToSpeechResource, AsyncSpeechToSpeechResource
62+
from .resources.realtime_sessions import RealtimeSessionsResource, AsyncRealtimeSessionsResource
6163
from .resources.character_performance import CharacterPerformanceResource, AsyncCharacterPerformanceResource
6264

6365
__all__ = [
@@ -222,6 +224,30 @@ def organization(self) -> OrganizationResource:
222224

223225
return OrganizationResource(self)
224226

227+
@cached_property
228+
def avatars(self) -> AvatarsResource:
229+
from .resources.avatars import AvatarsResource
230+
231+
return AvatarsResource(self)
232+
233+
@cached_property
234+
def documents(self) -> DocumentsResource:
235+
from .resources.documents import DocumentsResource
236+
237+
return DocumentsResource(self)
238+
239+
@cached_property
240+
def realtime_sessions(self) -> RealtimeSessionsResource:
241+
from .resources.realtime_sessions import RealtimeSessionsResource
242+
243+
return RealtimeSessionsResource(self)
244+
245+
@cached_property
246+
def voices(self) -> VoicesResource:
247+
from .resources.voices import VoicesResource
248+
249+
return VoicesResource(self)
250+
225251
@cached_property
226252
def with_raw_response(self) -> RunwayMLWithRawResponse:
227253
return RunwayMLWithRawResponse(self)
@@ -488,6 +514,30 @@ def organization(self) -> AsyncOrganizationResource:
488514

489515
return AsyncOrganizationResource(self)
490516

517+
@cached_property
518+
def avatars(self) -> AsyncAvatarsResource:
519+
from .resources.avatars import AsyncAvatarsResource
520+
521+
return AsyncAvatarsResource(self)
522+
523+
@cached_property
524+
def documents(self) -> AsyncDocumentsResource:
525+
from .resources.documents import AsyncDocumentsResource
526+
527+
return AsyncDocumentsResource(self)
528+
529+
@cached_property
530+
def realtime_sessions(self) -> AsyncRealtimeSessionsResource:
531+
from .resources.realtime_sessions import AsyncRealtimeSessionsResource
532+
533+
return AsyncRealtimeSessionsResource(self)
534+
535+
@cached_property
536+
def voices(self) -> AsyncVoicesResource:
537+
from .resources.voices import AsyncVoicesResource
538+
539+
return AsyncVoicesResource(self)
540+
491541
@cached_property
492542
def with_raw_response(self) -> AsyncRunwayMLWithRawResponse:
493543
return AsyncRunwayMLWithRawResponse(self)
@@ -699,6 +749,30 @@ def organization(self) -> organization.OrganizationResourceWithRawResponse:
699749

700750
return OrganizationResourceWithRawResponse(self._client.organization)
701751

752+
@cached_property
753+
def avatars(self) -> avatars.AvatarsResourceWithRawResponse:
754+
from .resources.avatars import AvatarsResourceWithRawResponse
755+
756+
return AvatarsResourceWithRawResponse(self._client.avatars)
757+
758+
@cached_property
759+
def documents(self) -> documents.DocumentsResourceWithRawResponse:
760+
from .resources.documents import DocumentsResourceWithRawResponse
761+
762+
return DocumentsResourceWithRawResponse(self._client.documents)
763+
764+
@cached_property
765+
def realtime_sessions(self) -> realtime_sessions.RealtimeSessionsResourceWithRawResponse:
766+
from .resources.realtime_sessions import RealtimeSessionsResourceWithRawResponse
767+
768+
return RealtimeSessionsResourceWithRawResponse(self._client.realtime_sessions)
769+
770+
@cached_property
771+
def voices(self) -> voices.VoicesResourceWithRawResponse:
772+
from .resources.voices import VoicesResourceWithRawResponse
773+
774+
return VoicesResourceWithRawResponse(self._client.voices)
775+
702776

703777
class AsyncRunwayMLWithRawResponse:
704778
_client: AsyncRunwayML
@@ -795,6 +869,30 @@ def organization(self) -> organization.AsyncOrganizationResourceWithRawResponse:
795869

796870
return AsyncOrganizationResourceWithRawResponse(self._client.organization)
797871

872+
@cached_property
873+
def avatars(self) -> avatars.AsyncAvatarsResourceWithRawResponse:
874+
from .resources.avatars import AsyncAvatarsResourceWithRawResponse
875+
876+
return AsyncAvatarsResourceWithRawResponse(self._client.avatars)
877+
878+
@cached_property
879+
def documents(self) -> documents.AsyncDocumentsResourceWithRawResponse:
880+
from .resources.documents import AsyncDocumentsResourceWithRawResponse
881+
882+
return AsyncDocumentsResourceWithRawResponse(self._client.documents)
883+
884+
@cached_property
885+
def realtime_sessions(self) -> realtime_sessions.AsyncRealtimeSessionsResourceWithRawResponse:
886+
from .resources.realtime_sessions import AsyncRealtimeSessionsResourceWithRawResponse
887+
888+
return AsyncRealtimeSessionsResourceWithRawResponse(self._client.realtime_sessions)
889+
890+
@cached_property
891+
def voices(self) -> voices.AsyncVoicesResourceWithRawResponse:
892+
from .resources.voices import AsyncVoicesResourceWithRawResponse
893+
894+
return AsyncVoicesResourceWithRawResponse(self._client.voices)
895+
798896

799897
class RunwayMLWithStreamedResponse:
800898
_client: RunwayML
@@ -891,6 +989,30 @@ def organization(self) -> organization.OrganizationResourceWithStreamingResponse
891989

892990
return OrganizationResourceWithStreamingResponse(self._client.organization)
893991

992+
@cached_property
993+
def avatars(self) -> avatars.AvatarsResourceWithStreamingResponse:
994+
from .resources.avatars import AvatarsResourceWithStreamingResponse
995+
996+
return AvatarsResourceWithStreamingResponse(self._client.avatars)
997+
998+
@cached_property
999+
def documents(self) -> documents.DocumentsResourceWithStreamingResponse:
1000+
from .resources.documents import DocumentsResourceWithStreamingResponse
1001+
1002+
return DocumentsResourceWithStreamingResponse(self._client.documents)
1003+
1004+
@cached_property
1005+
def realtime_sessions(self) -> realtime_sessions.RealtimeSessionsResourceWithStreamingResponse:
1006+
from .resources.realtime_sessions import RealtimeSessionsResourceWithStreamingResponse
1007+
1008+
return RealtimeSessionsResourceWithStreamingResponse(self._client.realtime_sessions)
1009+
1010+
@cached_property
1011+
def voices(self) -> voices.VoicesResourceWithStreamingResponse:
1012+
from .resources.voices import VoicesResourceWithStreamingResponse
1013+
1014+
return VoicesResourceWithStreamingResponse(self._client.voices)
1015+
8941016

8951017
class AsyncRunwayMLWithStreamedResponse:
8961018
_client: AsyncRunwayML
@@ -987,6 +1109,30 @@ def organization(self) -> organization.AsyncOrganizationResourceWithStreamingRes
9871109

9881110
return AsyncOrganizationResourceWithStreamingResponse(self._client.organization)
9891111

1112+
@cached_property
1113+
def avatars(self) -> avatars.AsyncAvatarsResourceWithStreamingResponse:
1114+
from .resources.avatars import AsyncAvatarsResourceWithStreamingResponse
1115+
1116+
return AsyncAvatarsResourceWithStreamingResponse(self._client.avatars)
1117+
1118+
@cached_property
1119+
def documents(self) -> documents.AsyncDocumentsResourceWithStreamingResponse:
1120+
from .resources.documents import AsyncDocumentsResourceWithStreamingResponse
1121+
1122+
return AsyncDocumentsResourceWithStreamingResponse(self._client.documents)
1123+
1124+
@cached_property
1125+
def realtime_sessions(self) -> realtime_sessions.AsyncRealtimeSessionsResourceWithStreamingResponse:
1126+
from .resources.realtime_sessions import AsyncRealtimeSessionsResourceWithStreamingResponse
1127+
1128+
return AsyncRealtimeSessionsResourceWithStreamingResponse(self._client.realtime_sessions)
1129+
1130+
@cached_property
1131+
def voices(self) -> voices.AsyncVoicesResourceWithStreamingResponse:
1132+
from .resources.voices import AsyncVoicesResourceWithStreamingResponse
1133+
1134+
return AsyncVoicesResourceWithStreamingResponse(self._client.voices)
1135+
9901136

9911137
Client = RunwayML
9921138

0 commit comments

Comments
 (0)