File size: 31,851 Bytes
9410704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import os
import typing

import httpx
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .core.logging import LogConfig, Logger
from .environment import ElevenLabsEnvironment

if typing.TYPE_CHECKING:
    from .assets.client import AssetsClient, AsyncAssetsClient
    from .audio_effects.client import AsyncAudioEffectsClient, AudioEffectsClient
    from .audio_isolation.client import AsyncAudioIsolationClient, AudioIsolationClient
    from .audio_native.client import AsyncAudioNativeClient, AudioNativeClient
    from .conversational_ai.client import AsyncConversationalAiClient, ConversationalAiClient
    from .dubbing.client import AsyncDubbingClient, DubbingClient
    from .environment_variables.client import AsyncEnvironmentVariablesClient, EnvironmentVariablesClient
    from .environments.client import AsyncEnvironmentsClient, EnvironmentsClient
    from .flows.client import AsyncFlowsClient, FlowsClient
    from .forced_alignment.client import AsyncForcedAlignmentClient, ForcedAlignmentClient
    from .history.client import AsyncHistoryClient, HistoryClient
    from .models.client import AsyncModelsClient, ModelsClient
    from .music.client import AsyncMusicClient, MusicClient
    from .productions.client import AsyncProductionsClient, ProductionsClient
    from .pronunciation_dictionaries.client import AsyncPronunciationDictionariesClient, PronunciationDictionariesClient
    from .samples.client import AsyncSamplesClient, SamplesClient
    from .service_accounts.client import AsyncServiceAccountsClient, ServiceAccountsClient
    from .speech_engine.client import AsyncSpeechEngineClient, SpeechEngineClient
    from .speech_to_speech.client import AsyncSpeechToSpeechClient, SpeechToSpeechClient
    from .speech_to_text.client import AsyncSpeechToTextClient, SpeechToTextClient
    from .studio.client import AsyncStudioClient, StudioClient
    from .text_to_dialogue.client import AsyncTextToDialogueClient, TextToDialogueClient
    from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient, TextToSoundEffectsClient
    from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient
    from .text_to_voice.client import AsyncTextToVoiceClient, TextToVoiceClient
    from .tokens.client import AsyncTokensClient, TokensClient
    from .usage.client import AsyncUsageClient, UsageClient
    from .user.client import AsyncUserClient, UserClient
    from .voices.client import AsyncVoicesClient, VoicesClient
    from .webhooks.client import AsyncWebhooksClient, WebhooksClient
    from .workspace.client import AsyncWorkspaceClient, WorkspaceClient
    from .workspaces.client import AsyncWorkspacesClient, WorkspacesClient


class BaseElevenLabs:
    """
    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.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : ElevenLabsEnvironment
        The environment to use for requests from the client. from .environment import ElevenLabsEnvironment



        Defaults to ElevenLabsEnvironment.PRODUCTION



    api_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 240 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        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.

    logging : typing.Optional[typing.Union[LogConfig, Logger]]
        Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.

    Examples
    --------
    from elevenlabs import ElevenLabs

    client = ElevenLabs(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION,
        api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.Client] = None,
        logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 240 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = SyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            api_key=api_key,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.Client(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
            logging=logging,
        )
        self._history: typing.Optional[HistoryClient] = None
        self._text_to_sound_effects: typing.Optional[TextToSoundEffectsClient] = None
        self._audio_isolation: typing.Optional[AudioIsolationClient] = None
        self._audio_effects: typing.Optional[AudioEffectsClient] = None
        self._samples: typing.Optional[SamplesClient] = None
        self._text_to_speech: typing.Optional[TextToSpeechClient] = None
        self._text_to_dialogue: typing.Optional[TextToDialogueClient] = None
        self._speech_to_speech: typing.Optional[SpeechToSpeechClient] = None
        self._text_to_voice: typing.Optional[TextToVoiceClient] = None
        self._user: typing.Optional[UserClient] = None
        self._voices: typing.Optional[VoicesClient] = None
        self._studio: typing.Optional[StudioClient] = None
        self._dubbing: typing.Optional[DubbingClient] = None
        self._models: typing.Optional[ModelsClient] = None
        self._audio_native: typing.Optional[AudioNativeClient] = None
        self._usage: typing.Optional[UsageClient] = None
        self._pronunciation_dictionaries: typing.Optional[PronunciationDictionariesClient] = None
        self._workspace: typing.Optional[WorkspaceClient] = None
        self._service_accounts: typing.Optional[ServiceAccountsClient] = None
        self._webhooks: typing.Optional[WebhooksClient] = None
        self._music: typing.Optional[MusicClient] = None
        self._speech_to_text: typing.Optional[SpeechToTextClient] = None
        self._forced_alignment: typing.Optional[ForcedAlignmentClient] = None
        self._conversational_ai: typing.Optional[ConversationalAiClient] = None
        self._speech_engine: typing.Optional[SpeechEngineClient] = None
        self._environment_variables: typing.Optional[EnvironmentVariablesClient] = None
        self._environments: typing.Optional[EnvironmentsClient] = None
        self._assets: typing.Optional[AssetsClient] = None
        self._flows: typing.Optional[FlowsClient] = None
        self._productions: typing.Optional[ProductionsClient] = None
        self._tokens: typing.Optional[TokensClient] = None
        self._workspaces: typing.Optional[WorkspacesClient] = None

    @property
    def history(self):
        if self._history is None:
            from .history.client import HistoryClient  # noqa: E402

            self._history = HistoryClient(client_wrapper=self._client_wrapper)
        return self._history

    @property
    def text_to_sound_effects(self):
        if self._text_to_sound_effects is None:
            from .text_to_sound_effects.client import TextToSoundEffectsClient  # noqa: E402

            self._text_to_sound_effects = TextToSoundEffectsClient(client_wrapper=self._client_wrapper)
        return self._text_to_sound_effects

    @property
    def audio_isolation(self):
        if self._audio_isolation is None:
            from .audio_isolation.client import AudioIsolationClient  # noqa: E402

            self._audio_isolation = AudioIsolationClient(client_wrapper=self._client_wrapper)
        return self._audio_isolation

    @property
    def audio_effects(self):
        if self._audio_effects is None:
            from .audio_effects.client import AudioEffectsClient  # noqa: E402

            self._audio_effects = AudioEffectsClient(client_wrapper=self._client_wrapper)
        return self._audio_effects

    @property
    def samples(self):
        if self._samples is None:
            from .samples.client import SamplesClient  # noqa: E402

            self._samples = SamplesClient(client_wrapper=self._client_wrapper)
        return self._samples

    @property
    def text_to_speech(self):
        if self._text_to_speech is None:
            from .text_to_speech.client import TextToSpeechClient  # noqa: E402

            self._text_to_speech = TextToSpeechClient(client_wrapper=self._client_wrapper)
        return self._text_to_speech

    @property
    def text_to_dialogue(self):
        if self._text_to_dialogue is None:
            from .text_to_dialogue.client import TextToDialogueClient  # noqa: E402

            self._text_to_dialogue = TextToDialogueClient(client_wrapper=self._client_wrapper)
        return self._text_to_dialogue

    @property
    def speech_to_speech(self):
        if self._speech_to_speech is None:
            from .speech_to_speech.client import SpeechToSpeechClient  # noqa: E402

            self._speech_to_speech = SpeechToSpeechClient(client_wrapper=self._client_wrapper)
        return self._speech_to_speech

    @property
    def text_to_voice(self):
        if self._text_to_voice is None:
            from .text_to_voice.client import TextToVoiceClient  # noqa: E402

            self._text_to_voice = TextToVoiceClient(client_wrapper=self._client_wrapper)
        return self._text_to_voice

    @property
    def user(self):
        if self._user is None:
            from .user.client import UserClient  # noqa: E402

            self._user = UserClient(client_wrapper=self._client_wrapper)
        return self._user

    @property
    def voices(self):
        if self._voices is None:
            from .voices.client import VoicesClient  # noqa: E402

            self._voices = VoicesClient(client_wrapper=self._client_wrapper)
        return self._voices

    @property
    def studio(self):
        if self._studio is None:
            from .studio.client import StudioClient  # noqa: E402

            self._studio = StudioClient(client_wrapper=self._client_wrapper)
        return self._studio

    @property
    def dubbing(self):
        if self._dubbing is None:
            from .dubbing.client import DubbingClient  # noqa: E402

            self._dubbing = DubbingClient(client_wrapper=self._client_wrapper)
        return self._dubbing

    @property
    def models(self):
        if self._models is None:
            from .models.client import ModelsClient  # noqa: E402

            self._models = ModelsClient(client_wrapper=self._client_wrapper)
        return self._models

    @property
    def audio_native(self):
        if self._audio_native is None:
            from .audio_native.client import AudioNativeClient  # noqa: E402

            self._audio_native = AudioNativeClient(client_wrapper=self._client_wrapper)
        return self._audio_native

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import UsageClient  # noqa: E402

            self._usage = UsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def pronunciation_dictionaries(self):
        if self._pronunciation_dictionaries is None:
            from .pronunciation_dictionaries.client import PronunciationDictionariesClient  # noqa: E402

            self._pronunciation_dictionaries = PronunciationDictionariesClient(client_wrapper=self._client_wrapper)
        return self._pronunciation_dictionaries

    @property
    def workspace(self):
        if self._workspace is None:
            from .workspace.client import WorkspaceClient  # noqa: E402

            self._workspace = WorkspaceClient(client_wrapper=self._client_wrapper)
        return self._workspace

    @property
    def service_accounts(self):
        if self._service_accounts is None:
            from .service_accounts.client import ServiceAccountsClient  # noqa: E402

            self._service_accounts = ServiceAccountsClient(client_wrapper=self._client_wrapper)
        return self._service_accounts

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import WebhooksClient  # noqa: E402

            self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks

    @property
    def music(self):
        if self._music is None:
            from .music.client import MusicClient  # noqa: E402

            self._music = MusicClient(client_wrapper=self._client_wrapper)
        return self._music

    @property
    def speech_to_text(self):
        if self._speech_to_text is None:
            from .speech_to_text.client import SpeechToTextClient  # noqa: E402

            self._speech_to_text = SpeechToTextClient(client_wrapper=self._client_wrapper)
        return self._speech_to_text

    @property
    def forced_alignment(self):
        if self._forced_alignment is None:
            from .forced_alignment.client import ForcedAlignmentClient  # noqa: E402

            self._forced_alignment = ForcedAlignmentClient(client_wrapper=self._client_wrapper)
        return self._forced_alignment

    @property
    def conversational_ai(self):
        if self._conversational_ai is None:
            from .conversational_ai.client import ConversationalAiClient  # noqa: E402

            self._conversational_ai = ConversationalAiClient(client_wrapper=self._client_wrapper)
        return self._conversational_ai

    @property
    def speech_engine(self):
        if self._speech_engine is None:
            from .speech_engine.client import SpeechEngineClient  # noqa: E402

            self._speech_engine = SpeechEngineClient(client_wrapper=self._client_wrapper)
        return self._speech_engine

    @property
    def environment_variables(self):
        if self._environment_variables is None:
            from .environment_variables.client import EnvironmentVariablesClient  # noqa: E402

            self._environment_variables = EnvironmentVariablesClient(client_wrapper=self._client_wrapper)
        return self._environment_variables

    @property
    def environments(self):
        if self._environments is None:
            from .environments.client import EnvironmentsClient  # noqa: E402

            self._environments = EnvironmentsClient(client_wrapper=self._client_wrapper)
        return self._environments

    @property
    def assets(self):
        if self._assets is None:
            from .assets.client import AssetsClient  # noqa: E402

            self._assets = AssetsClient(client_wrapper=self._client_wrapper)
        return self._assets

    @property
    def flows(self):
        if self._flows is None:
            from .flows.client import FlowsClient  # noqa: E402

            self._flows = FlowsClient(client_wrapper=self._client_wrapper)
        return self._flows

    @property
    def productions(self):
        if self._productions is None:
            from .productions.client import ProductionsClient  # noqa: E402

            self._productions = ProductionsClient(client_wrapper=self._client_wrapper)
        return self._productions

    @property
    def tokens(self):
        if self._tokens is None:
            from .tokens.client import TokensClient  # noqa: E402

            self._tokens = TokensClient(client_wrapper=self._client_wrapper)
        return self._tokens

    @property
    def workspaces(self):
        if self._workspaces is None:
            from .workspaces.client import WorkspacesClient  # noqa: E402

            self._workspaces = WorkspacesClient(client_wrapper=self._client_wrapper)
        return self._workspaces


class AsyncBaseElevenLabs:
    """
    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.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : ElevenLabsEnvironment
        The environment to use for requests from the client. from .environment import ElevenLabsEnvironment



        Defaults to ElevenLabsEnvironment.PRODUCTION



    api_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 240 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        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.

    logging : typing.Optional[typing.Union[LogConfig, Logger]]
        Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.

    Examples
    --------
    from elevenlabs import AsyncElevenLabs

    client = AsyncElevenLabs(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION,
        api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.AsyncClient] = None,
        logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 240 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = AsyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            api_key=api_key,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
            logging=logging,
        )
        self._history: typing.Optional[AsyncHistoryClient] = None
        self._text_to_sound_effects: typing.Optional[AsyncTextToSoundEffectsClient] = None
        self._audio_isolation: typing.Optional[AsyncAudioIsolationClient] = None
        self._audio_effects: typing.Optional[AsyncAudioEffectsClient] = None
        self._samples: typing.Optional[AsyncSamplesClient] = None
        self._text_to_speech: typing.Optional[AsyncTextToSpeechClient] = None
        self._text_to_dialogue: typing.Optional[AsyncTextToDialogueClient] = None
        self._speech_to_speech: typing.Optional[AsyncSpeechToSpeechClient] = None
        self._text_to_voice: typing.Optional[AsyncTextToVoiceClient] = None
        self._user: typing.Optional[AsyncUserClient] = None
        self._voices: typing.Optional[AsyncVoicesClient] = None
        self._studio: typing.Optional[AsyncStudioClient] = None
        self._dubbing: typing.Optional[AsyncDubbingClient] = None
        self._models: typing.Optional[AsyncModelsClient] = None
        self._audio_native: typing.Optional[AsyncAudioNativeClient] = None
        self._usage: typing.Optional[AsyncUsageClient] = None
        self._pronunciation_dictionaries: typing.Optional[AsyncPronunciationDictionariesClient] = None
        self._workspace: typing.Optional[AsyncWorkspaceClient] = None
        self._service_accounts: typing.Optional[AsyncServiceAccountsClient] = None
        self._webhooks: typing.Optional[AsyncWebhooksClient] = None
        self._music: typing.Optional[AsyncMusicClient] = None
        self._speech_to_text: typing.Optional[AsyncSpeechToTextClient] = None
        self._forced_alignment: typing.Optional[AsyncForcedAlignmentClient] = None
        self._conversational_ai: typing.Optional[AsyncConversationalAiClient] = None
        self._speech_engine: typing.Optional[AsyncSpeechEngineClient] = None
        self._environment_variables: typing.Optional[AsyncEnvironmentVariablesClient] = None
        self._environments: typing.Optional[AsyncEnvironmentsClient] = None
        self._assets: typing.Optional[AsyncAssetsClient] = None
        self._flows: typing.Optional[AsyncFlowsClient] = None
        self._productions: typing.Optional[AsyncProductionsClient] = None
        self._tokens: typing.Optional[AsyncTokensClient] = None
        self._workspaces: typing.Optional[AsyncWorkspacesClient] = None

    @property
    def history(self):
        if self._history is None:
            from .history.client import AsyncHistoryClient  # noqa: E402

            self._history = AsyncHistoryClient(client_wrapper=self._client_wrapper)
        return self._history

    @property
    def text_to_sound_effects(self):
        if self._text_to_sound_effects is None:
            from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient  # noqa: E402

            self._text_to_sound_effects = AsyncTextToSoundEffectsClient(client_wrapper=self._client_wrapper)
        return self._text_to_sound_effects

    @property
    def audio_isolation(self):
        if self._audio_isolation is None:
            from .audio_isolation.client import AsyncAudioIsolationClient  # noqa: E402

            self._audio_isolation = AsyncAudioIsolationClient(client_wrapper=self._client_wrapper)
        return self._audio_isolation

    @property
    def audio_effects(self):
        if self._audio_effects is None:
            from .audio_effects.client import AsyncAudioEffectsClient  # noqa: E402

            self._audio_effects = AsyncAudioEffectsClient(client_wrapper=self._client_wrapper)
        return self._audio_effects

    @property
    def samples(self):
        if self._samples is None:
            from .samples.client import AsyncSamplesClient  # noqa: E402

            self._samples = AsyncSamplesClient(client_wrapper=self._client_wrapper)
        return self._samples

    @property
    def text_to_speech(self):
        if self._text_to_speech is None:
            from .text_to_speech.client import AsyncTextToSpeechClient  # noqa: E402

            self._text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
        return self._text_to_speech

    @property
    def text_to_dialogue(self):
        if self._text_to_dialogue is None:
            from .text_to_dialogue.client import AsyncTextToDialogueClient  # noqa: E402

            self._text_to_dialogue = AsyncTextToDialogueClient(client_wrapper=self._client_wrapper)
        return self._text_to_dialogue

    @property
    def speech_to_speech(self):
        if self._speech_to_speech is None:
            from .speech_to_speech.client import AsyncSpeechToSpeechClient  # noqa: E402

            self._speech_to_speech = AsyncSpeechToSpeechClient(client_wrapper=self._client_wrapper)
        return self._speech_to_speech

    @property
    def text_to_voice(self):
        if self._text_to_voice is None:
            from .text_to_voice.client import AsyncTextToVoiceClient  # noqa: E402

            self._text_to_voice = AsyncTextToVoiceClient(client_wrapper=self._client_wrapper)
        return self._text_to_voice

    @property
    def user(self):
        if self._user is None:
            from .user.client import AsyncUserClient  # noqa: E402

            self._user = AsyncUserClient(client_wrapper=self._client_wrapper)
        return self._user

    @property
    def voices(self):
        if self._voices is None:
            from .voices.client import AsyncVoicesClient  # noqa: E402

            self._voices = AsyncVoicesClient(client_wrapper=self._client_wrapper)
        return self._voices

    @property
    def studio(self):
        if self._studio is None:
            from .studio.client import AsyncStudioClient  # noqa: E402

            self._studio = AsyncStudioClient(client_wrapper=self._client_wrapper)
        return self._studio

    @property
    def dubbing(self):
        if self._dubbing is None:
            from .dubbing.client import AsyncDubbingClient  # noqa: E402

            self._dubbing = AsyncDubbingClient(client_wrapper=self._client_wrapper)
        return self._dubbing

    @property
    def models(self):
        if self._models is None:
            from .models.client import AsyncModelsClient  # noqa: E402

            self._models = AsyncModelsClient(client_wrapper=self._client_wrapper)
        return self._models

    @property
    def audio_native(self):
        if self._audio_native is None:
            from .audio_native.client import AsyncAudioNativeClient  # noqa: E402

            self._audio_native = AsyncAudioNativeClient(client_wrapper=self._client_wrapper)
        return self._audio_native

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import AsyncUsageClient  # noqa: E402

            self._usage = AsyncUsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def pronunciation_dictionaries(self):
        if self._pronunciation_dictionaries is None:
            from .pronunciation_dictionaries.client import AsyncPronunciationDictionariesClient  # noqa: E402

            self._pronunciation_dictionaries = AsyncPronunciationDictionariesClient(client_wrapper=self._client_wrapper)
        return self._pronunciation_dictionaries

    @property
    def workspace(self):
        if self._workspace is None:
            from .workspace.client import AsyncWorkspaceClient  # noqa: E402

            self._workspace = AsyncWorkspaceClient(client_wrapper=self._client_wrapper)
        return self._workspace

    @property
    def service_accounts(self):
        if self._service_accounts is None:
            from .service_accounts.client import AsyncServiceAccountsClient  # noqa: E402

            self._service_accounts = AsyncServiceAccountsClient(client_wrapper=self._client_wrapper)
        return self._service_accounts

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import AsyncWebhooksClient  # noqa: E402

            self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks

    @property
    def music(self):
        if self._music is None:
            from .music.client import AsyncMusicClient  # noqa: E402

            self._music = AsyncMusicClient(client_wrapper=self._client_wrapper)
        return self._music

    @property
    def speech_to_text(self):
        if self._speech_to_text is None:
            from .speech_to_text.client import AsyncSpeechToTextClient  # noqa: E402

            self._speech_to_text = AsyncSpeechToTextClient(client_wrapper=self._client_wrapper)
        return self._speech_to_text

    @property
    def forced_alignment(self):
        if self._forced_alignment is None:
            from .forced_alignment.client import AsyncForcedAlignmentClient  # noqa: E402

            self._forced_alignment = AsyncForcedAlignmentClient(client_wrapper=self._client_wrapper)
        return self._forced_alignment

    @property
    def conversational_ai(self):
        if self._conversational_ai is None:
            from .conversational_ai.client import AsyncConversationalAiClient  # noqa: E402

            self._conversational_ai = AsyncConversationalAiClient(client_wrapper=self._client_wrapper)
        return self._conversational_ai

    @property
    def speech_engine(self):
        if self._speech_engine is None:
            from .speech_engine.client import AsyncSpeechEngineClient  # noqa: E402

            self._speech_engine = AsyncSpeechEngineClient(client_wrapper=self._client_wrapper)
        return self._speech_engine

    @property
    def environment_variables(self):
        if self._environment_variables is None:
            from .environment_variables.client import AsyncEnvironmentVariablesClient  # noqa: E402

            self._environment_variables = AsyncEnvironmentVariablesClient(client_wrapper=self._client_wrapper)
        return self._environment_variables

    @property
    def environments(self):
        if self._environments is None:
            from .environments.client import AsyncEnvironmentsClient  # noqa: E402

            self._environments = AsyncEnvironmentsClient(client_wrapper=self._client_wrapper)
        return self._environments

    @property
    def assets(self):
        if self._assets is None:
            from .assets.client import AsyncAssetsClient  # noqa: E402

            self._assets = AsyncAssetsClient(client_wrapper=self._client_wrapper)
        return self._assets

    @property
    def flows(self):
        if self._flows is None:
            from .flows.client import AsyncFlowsClient  # noqa: E402

            self._flows = AsyncFlowsClient(client_wrapper=self._client_wrapper)
        return self._flows

    @property
    def productions(self):
        if self._productions is None:
            from .productions.client import AsyncProductionsClient  # noqa: E402

            self._productions = AsyncProductionsClient(client_wrapper=self._client_wrapper)
        return self._productions

    @property
    def tokens(self):
        if self._tokens is None:
            from .tokens.client import AsyncTokensClient  # noqa: E402

            self._tokens = AsyncTokensClient(client_wrapper=self._client_wrapper)
        return self._tokens

    @property
    def workspaces(self):
        if self._workspaces is None:
            from .workspaces.client import AsyncWorkspacesClient  # noqa: E402

            self._workspaces = AsyncWorkspacesClient(client_wrapper=self._client_wrapper)
        return self._workspaces


def _get_base_url(*, base_url: typing.Optional[str] = None, environment: ElevenLabsEnvironment) -> str:
    if base_url is not None:
        return base_url
    elif environment is not None:
        return environment.value
    else:
        raise Exception("Please pass in either base_url or environment to construct the client")