From 8b7d1abf48ca50bc6f70eb852cacb6860d23d40f Mon Sep 17 00:00:00 2001 From: Louis Jordan Date: Sun, 15 Dec 2024 21:47:28 +0000 Subject: [PATCH] feat: align default env keys with js --- README.md | 14 +++++++------- src/elevenlabs/base_client.py | 4 ++-- src/elevenlabs/client.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e00eb6a..32d915a 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ from elevenlabs import play from elevenlabs.client import ElevenLabs client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) audio = client.generate( @@ -70,7 +70,7 @@ List all your available voices with `voices()`. from elevenlabs.client import ElevenLabs client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) response = client.voices.get_all() @@ -88,7 +88,7 @@ from elevenlabs import Voice, VoiceSettings, play from elevenlabs.client import ElevenLabs client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) audio = client.generate( @@ -113,7 +113,7 @@ from elevenlabs.client import ElevenLabs from elevenlabs import play client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) voice = client.clone( @@ -136,7 +136,7 @@ from elevenlabs.client import ElevenLabs from elevenlabs import stream client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) audio_stream = client.generate( @@ -159,7 +159,7 @@ from elevenlabs.client import ElevenLabs from elevenlabs import stream client = ElevenLabs( - api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY + api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) def text_stream(): @@ -189,7 +189,7 @@ import asyncio from elevenlabs.client import AsyncElevenLabs eleven = AsyncElevenLabs( - api_key="MY_API_KEY" # Defaults to ELEVEN_API_KEY + api_key="MY_API_KEY" # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY ) async def print_models() -> None: diff --git a/src/elevenlabs/base_client.py b/src/elevenlabs/base_client.py index a67c7e0..dd5a5db 100644 --- a/src/elevenlabs/base_client.py +++ b/src/elevenlabs/base_client.py @@ -88,7 +88,7 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION, - api_key: typing.Optional[str] = os.getenv("ELEVEN_API_KEY"), + api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY") or os.getenv("ELEVEN_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.Client] = None, @@ -167,7 +167,7 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION, - api_key: typing.Optional[str] = os.getenv("ELEVEN_API_KEY"), + api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY") or os.getenv("ELEVEN_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.AsyncClient] = None, diff --git a/src/elevenlabs/client.py b/src/elevenlabs/client.py index f4f66bc..75fd3ab 100644 --- a/src/elevenlabs/client.py +++ b/src/elevenlabs/client.py @@ -68,7 +68,7 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION, - api_key: typing.Optional[str] = os.getenv("ELEVEN_API_KEY"), + api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY") or os.getenv("ELEVEN_API_KEY"), timeout: typing.Optional[float] = 60, httpx_client: typing.Optional[httpx.Client] = None ):