syncsdk 0.1.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.
Files changed (52) hide show
  1. syncsdk-0.1.0/PKG-INFO +190 -0
  2. syncsdk-0.1.0/README.md +163 -0
  3. syncsdk-0.1.0/pyproject.toml +64 -0
  4. syncsdk-0.1.0/src/sync/__init__.py +63 -0
  5. syncsdk-0.1.0/src/sync/client.py +144 -0
  6. syncsdk-0.1.0/src/sync/common/__init__.py +46 -0
  7. syncsdk-0.1.0/src/sync/common/errors/__init__.py +8 -0
  8. syncsdk-0.1.0/src/sync/common/errors/bad_request_error.py +9 -0
  9. syncsdk-0.1.0/src/sync/common/errors/internal_server_error.py +9 -0
  10. syncsdk-0.1.0/src/sync/common/errors/not_found_error.py +9 -0
  11. syncsdk-0.1.0/src/sync/common/errors/unauthorized_error.py +9 -0
  12. syncsdk-0.1.0/src/sync/common/types/__init__.py +39 -0
  13. syncsdk-0.1.0/src/sync/common/types/audio.py +27 -0
  14. syncsdk-0.1.0/src/sync/common/types/create_generation_dto.py +44 -0
  15. syncsdk-0.1.0/src/sync/common/types/estimated_generation_cost.py +33 -0
  16. syncsdk-0.1.0/src/sync/common/types/generation.py +77 -0
  17. syncsdk-0.1.0/src/sync/common/types/generation_error.py +35 -0
  18. syncsdk-0.1.0/src/sync/common/types/generation_error_message.py +5 -0
  19. syncsdk-0.1.0/src/sync/common/types/generation_id.py +3 -0
  20. syncsdk-0.1.0/src/sync/common/types/generation_options.py +28 -0
  21. syncsdk-0.1.0/src/sync/common/types/generation_status.py +7 -0
  22. syncsdk-0.1.0/src/sync/common/types/input.py +8 -0
  23. syncsdk-0.1.0/src/sync/common/types/model.py +7 -0
  24. syncsdk-0.1.0/src/sync/common/types/segment_frames.py +5 -0
  25. syncsdk-0.1.0/src/sync/common/types/segment_secs.py +5 -0
  26. syncsdk-0.1.0/src/sync/common/types/sync_mode.py +5 -0
  27. syncsdk-0.1.0/src/sync/common/types/tts.py +28 -0
  28. syncsdk-0.1.0/src/sync/common/types/tts_provider_config.py +34 -0
  29. syncsdk-0.1.0/src/sync/common/types/video.py +35 -0
  30. syncsdk-0.1.0/src/sync/core/__init__.py +50 -0
  31. syncsdk-0.1.0/src/sync/core/api_error.py +15 -0
  32. syncsdk-0.1.0/src/sync/core/client_wrapper.py +55 -0
  33. syncsdk-0.1.0/src/sync/core/datetime_utils.py +28 -0
  34. syncsdk-0.1.0/src/sync/core/file.py +67 -0
  35. syncsdk-0.1.0/src/sync/core/http_client.py +497 -0
  36. syncsdk-0.1.0/src/sync/core/http_response.py +47 -0
  37. syncsdk-0.1.0/src/sync/core/jsonable_encoder.py +100 -0
  38. syncsdk-0.1.0/src/sync/core/pydantic_utilities.py +294 -0
  39. syncsdk-0.1.0/src/sync/core/query_encoder.py +58 -0
  40. syncsdk-0.1.0/src/sync/core/remove_none_from_dict.py +11 -0
  41. syncsdk-0.1.0/src/sync/core/request_options.py +35 -0
  42. syncsdk-0.1.0/src/sync/core/serialization.py +276 -0
  43. syncsdk-0.1.0/src/sync/environment.py +7 -0
  44. syncsdk-0.1.0/src/sync/generate/__init__.py +2 -0
  45. syncsdk-0.1.0/src/sync/generate/client.py +446 -0
  46. syncsdk-0.1.0/src/sync/generate/raw_client.py +648 -0
  47. syncsdk-0.1.0/src/sync/py.typed +0 -0
  48. syncsdk-0.1.0/src/sync/version.py +3 -0
  49. syncsdk-0.1.0/src/sync/webhooks/__init__.py +5 -0
  50. syncsdk-0.1.0/src/sync/webhooks/types/__init__.py +6 -0
  51. syncsdk-0.1.0/src/sync/webhooks/types/generation_notification.py +73 -0
  52. syncsdk-0.1.0/src/sync/webhooks/types/webhook_status.py +5 -0
syncsdk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.1
2
+ Name: syncsdk
3
+ Version: 0.1.0
4
+ Summary:
5
+ Requires-Python: >=3.8,<4.0
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Operating System :: POSIX
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: httpx (>=0.21.2)
22
+ Requires-Dist: pydantic (>=1.9.2)
23
+ Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
24
+ Requires-Dist: typing_extensions (>=4.0.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Sync Python Library
28
+
29
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsynchronicity-labs%2Fsync-python-sdk)
30
+ [![pypi](https://img.shields.io/pypi/v/syncsdk)](https://pypi.python.org/pypi/syncsdk)
31
+
32
+ The Sync Python library provides convenient access to the Sync API from Python.
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ pip install syncsdk
38
+ ```
39
+
40
+ ## Reference
41
+
42
+ A full reference for this library is available [here](./reference.md).
43
+
44
+ ## Usage
45
+
46
+ Instantiate and use the client with the following:
47
+
48
+ ```python
49
+ from sync import Sync
50
+ from sync.common import Audio, GenerationOptions, Video
51
+
52
+ client = Sync(
53
+ api_key="YOUR_API_KEY",
54
+ )
55
+ client.generate.create_generation(
56
+ input=[
57
+ Video(
58
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
59
+ ),
60
+ Audio(
61
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
62
+ ),
63
+ ],
64
+ model="lipsync-2",
65
+ options=GenerationOptions(
66
+ sync_mode="loop",
67
+ ),
68
+ )
69
+ ```
70
+
71
+ ## Async Client
72
+
73
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API.
74
+
75
+ ```python
76
+ import asyncio
77
+
78
+ from sync import AsyncSync
79
+ from sync.common import Audio, GenerationOptions, Video
80
+
81
+ client = AsyncSync(
82
+ api_key="YOUR_API_KEY",
83
+ )
84
+
85
+
86
+ async def main() -> None:
87
+ await client.generate.create_generation(
88
+ input=[
89
+ Video(
90
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
91
+ ),
92
+ Audio(
93
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
94
+ ),
95
+ ],
96
+ model="lipsync-2",
97
+ options=GenerationOptions(
98
+ sync_mode="loop",
99
+ ),
100
+ )
101
+
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ ## Exception Handling
107
+
108
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
109
+ will be thrown.
110
+
111
+ ```python
112
+ from sync.core.api_error import ApiError
113
+
114
+ try:
115
+ client.generate.create_generation(...)
116
+ except ApiError as e:
117
+ print(e.status_code)
118
+ print(e.body)
119
+ ```
120
+
121
+ ## Advanced
122
+
123
+ ### Retries
124
+
125
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
126
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
127
+ retry limit (default: 2).
128
+
129
+ A request is deemed retryable when any of the following HTTP status codes is returned:
130
+
131
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
132
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
133
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
134
+
135
+ Use the `max_retries` request option to configure this behavior.
136
+
137
+ ```python
138
+ client.generate.create_generation(..., request_options={
139
+ "max_retries": 1
140
+ })
141
+ ```
142
+
143
+ ### Timeouts
144
+
145
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
146
+
147
+ ```python
148
+
149
+ from sync import Sync
150
+
151
+ client = Sync(
152
+ ...,
153
+ timeout=20.0,
154
+ )
155
+
156
+
157
+ # Override timeout for a specific method
158
+ client.generate.create_generation(..., request_options={
159
+ "timeout_in_seconds": 1
160
+ })
161
+ ```
162
+
163
+ ### Custom Client
164
+
165
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
166
+ and transports.
167
+
168
+ ```python
169
+ import httpx
170
+ from sync import Sync
171
+
172
+ client = Sync(
173
+ ...,
174
+ httpx_client=httpx.Client(
175
+ proxies="http://my.test.proxy.example.com",
176
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
177
+ ),
178
+ )
179
+ ```
180
+
181
+ ## Contributing
182
+
183
+ While we value open-source contributions to this SDK, this library is generated programmatically.
184
+ Additions made directly to this library would have to be moved over to our generation code,
185
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
186
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
187
+ an issue first to discuss with us!
188
+
189
+ On the other hand, contributions to the README are always very welcome!
190
+
@@ -0,0 +1,163 @@
1
+ # Sync Python Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsynchronicity-labs%2Fsync-python-sdk)
4
+ [![pypi](https://img.shields.io/pypi/v/syncsdk)](https://pypi.python.org/pypi/syncsdk)
5
+
6
+ The Sync Python library provides convenient access to the Sync API from Python.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ pip install syncsdk
12
+ ```
13
+
14
+ ## Reference
15
+
16
+ A full reference for this library is available [here](./reference.md).
17
+
18
+ ## Usage
19
+
20
+ Instantiate and use the client with the following:
21
+
22
+ ```python
23
+ from sync import Sync
24
+ from sync.common import Audio, GenerationOptions, Video
25
+
26
+ client = Sync(
27
+ api_key="YOUR_API_KEY",
28
+ )
29
+ client.generate.create_generation(
30
+ input=[
31
+ Video(
32
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
33
+ ),
34
+ Audio(
35
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
36
+ ),
37
+ ],
38
+ model="lipsync-2",
39
+ options=GenerationOptions(
40
+ sync_mode="loop",
41
+ ),
42
+ )
43
+ ```
44
+
45
+ ## Async Client
46
+
47
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API.
48
+
49
+ ```python
50
+ import asyncio
51
+
52
+ from sync import AsyncSync
53
+ from sync.common import Audio, GenerationOptions, Video
54
+
55
+ client = AsyncSync(
56
+ api_key="YOUR_API_KEY",
57
+ )
58
+
59
+
60
+ async def main() -> None:
61
+ await client.generate.create_generation(
62
+ input=[
63
+ Video(
64
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
65
+ ),
66
+ Audio(
67
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
68
+ ),
69
+ ],
70
+ model="lipsync-2",
71
+ options=GenerationOptions(
72
+ sync_mode="loop",
73
+ ),
74
+ )
75
+
76
+
77
+ asyncio.run(main())
78
+ ```
79
+
80
+ ## Exception Handling
81
+
82
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
83
+ will be thrown.
84
+
85
+ ```python
86
+ from sync.core.api_error import ApiError
87
+
88
+ try:
89
+ client.generate.create_generation(...)
90
+ except ApiError as e:
91
+ print(e.status_code)
92
+ print(e.body)
93
+ ```
94
+
95
+ ## Advanced
96
+
97
+ ### Retries
98
+
99
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
100
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
101
+ retry limit (default: 2).
102
+
103
+ A request is deemed retryable when any of the following HTTP status codes is returned:
104
+
105
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
106
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
107
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
108
+
109
+ Use the `max_retries` request option to configure this behavior.
110
+
111
+ ```python
112
+ client.generate.create_generation(..., request_options={
113
+ "max_retries": 1
114
+ })
115
+ ```
116
+
117
+ ### Timeouts
118
+
119
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
120
+
121
+ ```python
122
+
123
+ from sync import Sync
124
+
125
+ client = Sync(
126
+ ...,
127
+ timeout=20.0,
128
+ )
129
+
130
+
131
+ # Override timeout for a specific method
132
+ client.generate.create_generation(..., request_options={
133
+ "timeout_in_seconds": 1
134
+ })
135
+ ```
136
+
137
+ ### Custom Client
138
+
139
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
140
+ and transports.
141
+
142
+ ```python
143
+ import httpx
144
+ from sync import Sync
145
+
146
+ client = Sync(
147
+ ...,
148
+ httpx_client=httpx.Client(
149
+ proxies="http://my.test.proxy.example.com",
150
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
151
+ ),
152
+ )
153
+ ```
154
+
155
+ ## Contributing
156
+
157
+ While we value open-source contributions to this SDK, this library is generated programmatically.
158
+ Additions made directly to this library would have to be moved over to our generation code,
159
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
160
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
161
+ an issue first to discuss with us!
162
+
163
+ On the other hand, contributions to the README are always very welcome!
@@ -0,0 +1,64 @@
1
+ [project]
2
+ name = "syncsdk"
3
+
4
+ [tool.poetry]
5
+ name = "syncsdk"
6
+ version = "0.1.0"
7
+ description = ""
8
+ readme = "README.md"
9
+ authors = []
10
+ keywords = []
11
+
12
+ classifiers = [
13
+ "Intended Audience :: Developers",
14
+ "Programming Language :: Python",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.8",
17
+ "Programming Language :: Python :: 3.9",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Operating System :: OS Independent",
22
+ "Operating System :: POSIX",
23
+ "Operating System :: MacOS",
24
+ "Operating System :: POSIX :: Linux",
25
+ "Operating System :: Microsoft :: Windows",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Typing :: Typed"
28
+ ]
29
+ packages = [
30
+ { include = "sync", from = "src"}
31
+ ]
32
+
33
+ [project.urls]
34
+ Repository = 'https://github.com/synchronicity-labs/sync-python-sdk'
35
+
36
+ [tool.poetry.dependencies]
37
+ python = "^3.8"
38
+ httpx = ">=0.21.2"
39
+ pydantic = ">= 1.9.2"
40
+ pydantic-core = "^2.18.2"
41
+ typing_extensions = ">= 4.0.0"
42
+
43
+ [tool.poetry.dev-dependencies]
44
+ mypy = "1.0.1"
45
+ pytest = "^7.4.0"
46
+ pytest-asyncio = "^0.23.5"
47
+ python-dateutil = "^2.9.0"
48
+ types-python-dateutil = "^2.9.0.20240316"
49
+ ruff = "^0.5.6"
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = [ "tests" ]
53
+ asyncio_mode = "auto"
54
+
55
+ [tool.mypy]
56
+ plugins = ["pydantic.mypy"]
57
+
58
+ [tool.ruff]
59
+ line-length = 120
60
+
61
+
62
+ [build-system]
63
+ requires = ["poetry-core"]
64
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,63 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from . import common, generate, webhooks
4
+ from .client import AsyncSync, Sync
5
+ from .common import (
6
+ Audio,
7
+ BadRequestError,
8
+ CreateGenerationDto,
9
+ EstimatedGenerationCost,
10
+ Generation,
11
+ GenerationError,
12
+ GenerationErrorMessage,
13
+ GenerationId,
14
+ GenerationOptions,
15
+ GenerationStatus,
16
+ Input,
17
+ InternalServerError,
18
+ Model,
19
+ NotFoundError,
20
+ SegmentFrames,
21
+ SegmentSecs,
22
+ SyncMode,
23
+ Tts,
24
+ TtsProviderConfig,
25
+ UnauthorizedError,
26
+ Video,
27
+ )
28
+ from .environment import SyncEnvironment
29
+ from .version import __version__
30
+ from .webhooks import GenerationNotification, WebhookStatus
31
+
32
+ __all__ = [
33
+ "AsyncSync",
34
+ "Audio",
35
+ "BadRequestError",
36
+ "CreateGenerationDto",
37
+ "EstimatedGenerationCost",
38
+ "Generation",
39
+ "GenerationError",
40
+ "GenerationErrorMessage",
41
+ "GenerationId",
42
+ "GenerationNotification",
43
+ "GenerationOptions",
44
+ "GenerationStatus",
45
+ "Input",
46
+ "InternalServerError",
47
+ "Model",
48
+ "NotFoundError",
49
+ "SegmentFrames",
50
+ "SegmentSecs",
51
+ "Sync",
52
+ "SyncEnvironment",
53
+ "SyncMode",
54
+ "Tts",
55
+ "TtsProviderConfig",
56
+ "UnauthorizedError",
57
+ "Video",
58
+ "WebhookStatus",
59
+ "__version__",
60
+ "common",
61
+ "generate",
62
+ "webhooks",
63
+ ]
@@ -0,0 +1,144 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from .environment import SyncEnvironment
5
+ import httpx
6
+ from .core.client_wrapper import SyncClientWrapper
7
+ from .generate.client import GenerateClient
8
+ from .core.client_wrapper import AsyncClientWrapper
9
+ from .generate.client import AsyncGenerateClient
10
+
11
+
12
+ class Sync:
13
+ """
14
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
15
+
16
+ Parameters
17
+ ----------
18
+ base_url : typing.Optional[str]
19
+ The base url to use for requests from the client.
20
+
21
+ environment : SyncEnvironment
22
+ The environment to use for requests from the client. from .environment import SyncEnvironment
23
+
24
+
25
+
26
+ Defaults to SyncEnvironment.DEFAULT
27
+
28
+
29
+
30
+ api_key : str
31
+ timeout : typing.Optional[float]
32
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
33
+
34
+ follow_redirects : typing.Optional[bool]
35
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
36
+
37
+ httpx_client : typing.Optional[httpx.Client]
38
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
39
+
40
+ Examples
41
+ --------
42
+ from sync import Sync
43
+
44
+ client = Sync(
45
+ api_key="YOUR_API_KEY",
46
+ )
47
+ """
48
+
49
+ def __init__(
50
+ self,
51
+ *,
52
+ base_url: typing.Optional[str] = None,
53
+ environment: SyncEnvironment = SyncEnvironment.DEFAULT,
54
+ api_key: str,
55
+ timeout: typing.Optional[float] = None,
56
+ follow_redirects: typing.Optional[bool] = True,
57
+ httpx_client: typing.Optional[httpx.Client] = None,
58
+ ):
59
+ _defaulted_timeout = (
60
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
61
+ )
62
+ self._client_wrapper = SyncClientWrapper(
63
+ base_url=_get_base_url(base_url=base_url, environment=environment),
64
+ api_key=api_key,
65
+ httpx_client=httpx_client
66
+ if httpx_client is not None
67
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
68
+ if follow_redirects is not None
69
+ else httpx.Client(timeout=_defaulted_timeout),
70
+ timeout=_defaulted_timeout,
71
+ )
72
+ self.generate = GenerateClient(client_wrapper=self._client_wrapper)
73
+
74
+
75
+ class AsyncSync:
76
+ """
77
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
78
+
79
+ Parameters
80
+ ----------
81
+ base_url : typing.Optional[str]
82
+ The base url to use for requests from the client.
83
+
84
+ environment : SyncEnvironment
85
+ The environment to use for requests from the client. from .environment import SyncEnvironment
86
+
87
+
88
+
89
+ Defaults to SyncEnvironment.DEFAULT
90
+
91
+
92
+
93
+ api_key : str
94
+ timeout : typing.Optional[float]
95
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
96
+
97
+ follow_redirects : typing.Optional[bool]
98
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
99
+
100
+ httpx_client : typing.Optional[httpx.AsyncClient]
101
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
102
+
103
+ Examples
104
+ --------
105
+ from sync import AsyncSync
106
+
107
+ client = AsyncSync(
108
+ api_key="YOUR_API_KEY",
109
+ )
110
+ """
111
+
112
+ def __init__(
113
+ self,
114
+ *,
115
+ base_url: typing.Optional[str] = None,
116
+ environment: SyncEnvironment = SyncEnvironment.DEFAULT,
117
+ api_key: str,
118
+ timeout: typing.Optional[float] = None,
119
+ follow_redirects: typing.Optional[bool] = True,
120
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
121
+ ):
122
+ _defaulted_timeout = (
123
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
124
+ )
125
+ self._client_wrapper = AsyncClientWrapper(
126
+ base_url=_get_base_url(base_url=base_url, environment=environment),
127
+ api_key=api_key,
128
+ httpx_client=httpx_client
129
+ if httpx_client is not None
130
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
131
+ if follow_redirects is not None
132
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
133
+ timeout=_defaulted_timeout,
134
+ )
135
+ self.generate = AsyncGenerateClient(client_wrapper=self._client_wrapper)
136
+
137
+
138
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SyncEnvironment) -> str:
139
+ if base_url is not None:
140
+ return base_url
141
+ elif environment is not None:
142
+ return environment.value
143
+ else:
144
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,46 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .types import (
4
+ Audio,
5
+ CreateGenerationDto,
6
+ EstimatedGenerationCost,
7
+ Generation,
8
+ GenerationError,
9
+ GenerationErrorMessage,
10
+ GenerationId,
11
+ GenerationOptions,
12
+ GenerationStatus,
13
+ Input,
14
+ Model,
15
+ SegmentFrames,
16
+ SegmentSecs,
17
+ SyncMode,
18
+ Tts,
19
+ TtsProviderConfig,
20
+ Video,
21
+ )
22
+ from .errors import BadRequestError, InternalServerError, NotFoundError, UnauthorizedError
23
+
24
+ __all__ = [
25
+ "Audio",
26
+ "BadRequestError",
27
+ "CreateGenerationDto",
28
+ "EstimatedGenerationCost",
29
+ "Generation",
30
+ "GenerationError",
31
+ "GenerationErrorMessage",
32
+ "GenerationId",
33
+ "GenerationOptions",
34
+ "GenerationStatus",
35
+ "Input",
36
+ "InternalServerError",
37
+ "Model",
38
+ "NotFoundError",
39
+ "SegmentFrames",
40
+ "SegmentSecs",
41
+ "SyncMode",
42
+ "Tts",
43
+ "TtsProviderConfig",
44
+ "UnauthorizedError",
45
+ "Video",
46
+ ]
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .bad_request_error import BadRequestError
4
+ from .internal_server_error import InternalServerError
5
+ from .not_found_error import NotFoundError
6
+ from .unauthorized_error import UnauthorizedError
7
+
8
+ __all__ = ["BadRequestError", "InternalServerError", "NotFoundError", "UnauthorizedError"]
@@ -0,0 +1,9 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.api_error import ApiError
4
+ from ..types.generation_error import GenerationError
5
+
6
+
7
+ class BadRequestError(ApiError):
8
+ def __init__(self, body: GenerationError):
9
+ super().__init__(status_code=400, body=body)
@@ -0,0 +1,9 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.api_error import ApiError
4
+ from ..types.generation_error import GenerationError
5
+
6
+
7
+ class InternalServerError(ApiError):
8
+ def __init__(self, body: GenerationError):
9
+ super().__init__(status_code=500, body=body)