syncsdk 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.
Files changed (52) hide show
  1. sync/__init__.py +63 -0
  2. sync/client.py +144 -0
  3. sync/common/__init__.py +46 -0
  4. sync/common/errors/__init__.py +8 -0
  5. sync/common/errors/bad_request_error.py +9 -0
  6. sync/common/errors/internal_server_error.py +9 -0
  7. sync/common/errors/not_found_error.py +9 -0
  8. sync/common/errors/unauthorized_error.py +9 -0
  9. sync/common/types/__init__.py +39 -0
  10. sync/common/types/audio.py +27 -0
  11. sync/common/types/create_generation_dto.py +44 -0
  12. sync/common/types/estimated_generation_cost.py +33 -0
  13. sync/common/types/generation.py +77 -0
  14. sync/common/types/generation_error.py +35 -0
  15. sync/common/types/generation_error_message.py +5 -0
  16. sync/common/types/generation_id.py +3 -0
  17. sync/common/types/generation_options.py +28 -0
  18. sync/common/types/generation_status.py +7 -0
  19. sync/common/types/input.py +8 -0
  20. sync/common/types/model.py +7 -0
  21. sync/common/types/segment_frames.py +5 -0
  22. sync/common/types/segment_secs.py +5 -0
  23. sync/common/types/sync_mode.py +5 -0
  24. sync/common/types/tts.py +28 -0
  25. sync/common/types/tts_provider_config.py +34 -0
  26. sync/common/types/video.py +35 -0
  27. sync/core/__init__.py +50 -0
  28. sync/core/api_error.py +15 -0
  29. sync/core/client_wrapper.py +55 -0
  30. sync/core/datetime_utils.py +28 -0
  31. sync/core/file.py +67 -0
  32. sync/core/http_client.py +497 -0
  33. sync/core/http_response.py +47 -0
  34. sync/core/jsonable_encoder.py +100 -0
  35. sync/core/pydantic_utilities.py +294 -0
  36. sync/core/query_encoder.py +58 -0
  37. sync/core/remove_none_from_dict.py +11 -0
  38. sync/core/request_options.py +35 -0
  39. sync/core/serialization.py +276 -0
  40. sync/environment.py +7 -0
  41. sync/generate/__init__.py +2 -0
  42. sync/generate/client.py +446 -0
  43. sync/generate/raw_client.py +648 -0
  44. sync/py.typed +0 -0
  45. sync/version.py +3 -0
  46. sync/webhooks/__init__.py +5 -0
  47. sync/webhooks/types/__init__.py +6 -0
  48. sync/webhooks/types/generation_notification.py +73 -0
  49. sync/webhooks/types/webhook_status.py +5 -0
  50. syncsdk-0.1.0.dist-info/METADATA +190 -0
  51. syncsdk-0.1.0.dist-info/RECORD +52 -0
  52. syncsdk-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,446 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from .raw_client import RawGenerateClient
6
+ from ..common.types.model import Model
7
+ from ..common.types.input import Input
8
+ from ..common.types.generation_options import GenerationOptions
9
+ from ..core.request_options import RequestOptions
10
+ from ..common.types.generation import Generation
11
+ from ..common.types.generation_id import GenerationId
12
+ from ..common.types.generation_status import GenerationStatus
13
+ from ..common.types.estimated_generation_cost import EstimatedGenerationCost
14
+ from ..core.client_wrapper import AsyncClientWrapper
15
+ from .raw_client import AsyncRawGenerateClient
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class GenerateClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._raw_client = RawGenerateClient(client_wrapper=client_wrapper)
24
+
25
+ @property
26
+ def with_raw_response(self) -> RawGenerateClient:
27
+ """
28
+ Retrieves a raw implementation of this client that returns raw responses.
29
+
30
+ Returns
31
+ -------
32
+ RawGenerateClient
33
+ """
34
+ return self._raw_client
35
+
36
+ def create_generation(
37
+ self,
38
+ *,
39
+ model: Model,
40
+ input: typing.Sequence[Input],
41
+ options: typing.Optional[GenerationOptions] = OMIT,
42
+ webhook_url: typing.Optional[str] = OMIT,
43
+ request_options: typing.Optional[RequestOptions] = None,
44
+ ) -> Generation:
45
+ """
46
+ Parameters
47
+ ----------
48
+ model : Model
49
+ name of the model to use for generation.
50
+
51
+ input : typing.Sequence[Input]
52
+ Array of input objects. Must include one video input item and one audio input item. Audio input items can be provided as either: recorded/captured audio url or a text-to-speech input with tts provider configuration.
53
+
54
+ options : typing.Optional[GenerationOptions]
55
+ additional options available for generation.
56
+
57
+ webhook_url : typing.Optional[str]
58
+ webhook url for generation status updates. once the generation completes we will send a POST request to the webhook url with the generation data.
59
+
60
+ request_options : typing.Optional[RequestOptions]
61
+ Request-specific configuration.
62
+
63
+ Returns
64
+ -------
65
+ Generation
66
+ Job created successfully
67
+
68
+ Examples
69
+ --------
70
+ from sync import Sync
71
+ from sync.common import Audio, GenerationOptions, Video
72
+
73
+ client = Sync(
74
+ api_key="YOUR_API_KEY",
75
+ )
76
+ client.generate.create_generation(
77
+ input=[
78
+ Video(
79
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
80
+ ),
81
+ Audio(
82
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
83
+ ),
84
+ ],
85
+ model="lipsync-2",
86
+ options=GenerationOptions(
87
+ sync_mode="loop",
88
+ ),
89
+ )
90
+ """
91
+ response = self._raw_client.create_generation(
92
+ model=model, input=input, options=options, webhook_url=webhook_url, request_options=request_options
93
+ )
94
+ return response.data
95
+
96
+ def get_generation(
97
+ self, id: GenerationId, *, request_options: typing.Optional[RequestOptions] = None
98
+ ) -> Generation:
99
+ """
100
+ Parameters
101
+ ----------
102
+ id : GenerationId
103
+
104
+ request_options : typing.Optional[RequestOptions]
105
+ Request-specific configuration.
106
+
107
+ Returns
108
+ -------
109
+ Generation
110
+ Job status retrieved successfully
111
+
112
+ Examples
113
+ --------
114
+ from sync import Sync
115
+
116
+ client = Sync(
117
+ api_key="YOUR_API_KEY",
118
+ )
119
+ client.generate.get_generation(
120
+ id="6533643b-acbe-4c40-967e-d9ba9baac39e",
121
+ )
122
+ """
123
+ response = self._raw_client.get_generation(id, request_options=request_options)
124
+ return response.data
125
+
126
+ def list_generations(
127
+ self,
128
+ *,
129
+ status: typing.Optional[GenerationStatus] = None,
130
+ request_options: typing.Optional[RequestOptions] = None,
131
+ ) -> typing.List[Generation]:
132
+ """
133
+ Parameters
134
+ ----------
135
+ status : typing.Optional[GenerationStatus]
136
+ Filter generations by status
137
+
138
+ request_options : typing.Optional[RequestOptions]
139
+ Request-specific configuration.
140
+
141
+ Returns
142
+ -------
143
+ typing.List[Generation]
144
+ Generations retrieved successfully
145
+
146
+ Examples
147
+ --------
148
+ from sync import Sync
149
+
150
+ client = Sync(
151
+ api_key="YOUR_API_KEY",
152
+ )
153
+ client.generate.list_generations()
154
+ """
155
+ response = self._raw_client.list_generations(status=status, request_options=request_options)
156
+ return response.data
157
+
158
+ def estimate_cost(
159
+ self,
160
+ *,
161
+ model: Model,
162
+ input: typing.Sequence[Input],
163
+ options: typing.Optional[GenerationOptions] = OMIT,
164
+ webhook_url: typing.Optional[str] = OMIT,
165
+ request_options: typing.Optional[RequestOptions] = None,
166
+ ) -> typing.List[EstimatedGenerationCost]:
167
+ """
168
+ Parameters
169
+ ----------
170
+ model : Model
171
+ name of the model to use for generation.
172
+
173
+ input : typing.Sequence[Input]
174
+ Array of input objects. Must include one video input item and one audio input item. Audio input items can be provided as either: recorded/captured audio url or a text-to-speech input with tts provider configuration.
175
+
176
+ options : typing.Optional[GenerationOptions]
177
+ additional options available for generation.
178
+
179
+ webhook_url : typing.Optional[str]
180
+ webhook url for generation status updates. once the generation completes we will send a POST request to the webhook url with the generation data.
181
+
182
+ request_options : typing.Optional[RequestOptions]
183
+ Request-specific configuration.
184
+
185
+ Returns
186
+ -------
187
+ typing.List[EstimatedGenerationCost]
188
+ Generations retrieved successfully
189
+
190
+ Examples
191
+ --------
192
+ from sync import Sync
193
+ from sync.common import Audio, GenerationOptions, Video
194
+
195
+ client = Sync(
196
+ api_key="YOUR_API_KEY",
197
+ )
198
+ client.generate.estimate_cost(
199
+ input=[
200
+ Video(
201
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
202
+ ),
203
+ Audio(
204
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
205
+ ),
206
+ ],
207
+ model="lipsync-2",
208
+ options=GenerationOptions(
209
+ sync_mode="loop",
210
+ ),
211
+ )
212
+ """
213
+ response = self._raw_client.estimate_cost(
214
+ model=model, input=input, options=options, webhook_url=webhook_url, request_options=request_options
215
+ )
216
+ return response.data
217
+
218
+
219
+ class AsyncGenerateClient:
220
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
221
+ self._raw_client = AsyncRawGenerateClient(client_wrapper=client_wrapper)
222
+
223
+ @property
224
+ def with_raw_response(self) -> AsyncRawGenerateClient:
225
+ """
226
+ Retrieves a raw implementation of this client that returns raw responses.
227
+
228
+ Returns
229
+ -------
230
+ AsyncRawGenerateClient
231
+ """
232
+ return self._raw_client
233
+
234
+ async def create_generation(
235
+ self,
236
+ *,
237
+ model: Model,
238
+ input: typing.Sequence[Input],
239
+ options: typing.Optional[GenerationOptions] = OMIT,
240
+ webhook_url: typing.Optional[str] = OMIT,
241
+ request_options: typing.Optional[RequestOptions] = None,
242
+ ) -> Generation:
243
+ """
244
+ Parameters
245
+ ----------
246
+ model : Model
247
+ name of the model to use for generation.
248
+
249
+ input : typing.Sequence[Input]
250
+ Array of input objects. Must include one video input item and one audio input item. Audio input items can be provided as either: recorded/captured audio url or a text-to-speech input with tts provider configuration.
251
+
252
+ options : typing.Optional[GenerationOptions]
253
+ additional options available for generation.
254
+
255
+ webhook_url : typing.Optional[str]
256
+ webhook url for generation status updates. once the generation completes we will send a POST request to the webhook url with the generation data.
257
+
258
+ request_options : typing.Optional[RequestOptions]
259
+ Request-specific configuration.
260
+
261
+ Returns
262
+ -------
263
+ Generation
264
+ Job created successfully
265
+
266
+ Examples
267
+ --------
268
+ import asyncio
269
+
270
+ from sync import AsyncSync
271
+ from sync.common import Audio, GenerationOptions, Video
272
+
273
+ client = AsyncSync(
274
+ api_key="YOUR_API_KEY",
275
+ )
276
+
277
+
278
+ async def main() -> None:
279
+ await client.generate.create_generation(
280
+ input=[
281
+ Video(
282
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
283
+ ),
284
+ Audio(
285
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
286
+ ),
287
+ ],
288
+ model="lipsync-2",
289
+ options=GenerationOptions(
290
+ sync_mode="loop",
291
+ ),
292
+ )
293
+
294
+
295
+ asyncio.run(main())
296
+ """
297
+ response = await self._raw_client.create_generation(
298
+ model=model, input=input, options=options, webhook_url=webhook_url, request_options=request_options
299
+ )
300
+ return response.data
301
+
302
+ async def get_generation(
303
+ self, id: GenerationId, *, request_options: typing.Optional[RequestOptions] = None
304
+ ) -> Generation:
305
+ """
306
+ Parameters
307
+ ----------
308
+ id : GenerationId
309
+
310
+ request_options : typing.Optional[RequestOptions]
311
+ Request-specific configuration.
312
+
313
+ Returns
314
+ -------
315
+ Generation
316
+ Job status retrieved successfully
317
+
318
+ Examples
319
+ --------
320
+ import asyncio
321
+
322
+ from sync import AsyncSync
323
+
324
+ client = AsyncSync(
325
+ api_key="YOUR_API_KEY",
326
+ )
327
+
328
+
329
+ async def main() -> None:
330
+ await client.generate.get_generation(
331
+ id="6533643b-acbe-4c40-967e-d9ba9baac39e",
332
+ )
333
+
334
+
335
+ asyncio.run(main())
336
+ """
337
+ response = await self._raw_client.get_generation(id, request_options=request_options)
338
+ return response.data
339
+
340
+ async def list_generations(
341
+ self,
342
+ *,
343
+ status: typing.Optional[GenerationStatus] = None,
344
+ request_options: typing.Optional[RequestOptions] = None,
345
+ ) -> typing.List[Generation]:
346
+ """
347
+ Parameters
348
+ ----------
349
+ status : typing.Optional[GenerationStatus]
350
+ Filter generations by status
351
+
352
+ request_options : typing.Optional[RequestOptions]
353
+ Request-specific configuration.
354
+
355
+ Returns
356
+ -------
357
+ typing.List[Generation]
358
+ Generations retrieved successfully
359
+
360
+ Examples
361
+ --------
362
+ import asyncio
363
+
364
+ from sync import AsyncSync
365
+
366
+ client = AsyncSync(
367
+ api_key="YOUR_API_KEY",
368
+ )
369
+
370
+
371
+ async def main() -> None:
372
+ await client.generate.list_generations()
373
+
374
+
375
+ asyncio.run(main())
376
+ """
377
+ response = await self._raw_client.list_generations(status=status, request_options=request_options)
378
+ return response.data
379
+
380
+ async def estimate_cost(
381
+ self,
382
+ *,
383
+ model: Model,
384
+ input: typing.Sequence[Input],
385
+ options: typing.Optional[GenerationOptions] = OMIT,
386
+ webhook_url: typing.Optional[str] = OMIT,
387
+ request_options: typing.Optional[RequestOptions] = None,
388
+ ) -> typing.List[EstimatedGenerationCost]:
389
+ """
390
+ Parameters
391
+ ----------
392
+ model : Model
393
+ name of the model to use for generation.
394
+
395
+ input : typing.Sequence[Input]
396
+ Array of input objects. Must include one video input item and one audio input item. Audio input items can be provided as either: recorded/captured audio url or a text-to-speech input with tts provider configuration.
397
+
398
+ options : typing.Optional[GenerationOptions]
399
+ additional options available for generation.
400
+
401
+ webhook_url : typing.Optional[str]
402
+ webhook url for generation status updates. once the generation completes we will send a POST request to the webhook url with the generation data.
403
+
404
+ request_options : typing.Optional[RequestOptions]
405
+ Request-specific configuration.
406
+
407
+ Returns
408
+ -------
409
+ typing.List[EstimatedGenerationCost]
410
+ Generations retrieved successfully
411
+
412
+ Examples
413
+ --------
414
+ import asyncio
415
+
416
+ from sync import AsyncSync
417
+ from sync.common import Audio, GenerationOptions, Video
418
+
419
+ client = AsyncSync(
420
+ api_key="YOUR_API_KEY",
421
+ )
422
+
423
+
424
+ async def main() -> None:
425
+ await client.generate.estimate_cost(
426
+ input=[
427
+ Video(
428
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
429
+ ),
430
+ Audio(
431
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
432
+ ),
433
+ ],
434
+ model="lipsync-2",
435
+ options=GenerationOptions(
436
+ sync_mode="loop",
437
+ ),
438
+ )
439
+
440
+
441
+ asyncio.run(main())
442
+ """
443
+ response = await self._raw_client.estimate_cost(
444
+ model=model, input=input, options=options, webhook_url=webhook_url, request_options=request_options
445
+ )
446
+ return response.data