Skip to content

Commit 41e5fd8

Browse files
authored
Respect base_url (#306)
1 parent a291392 commit 41e5fd8

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/hume/empathic_voice/chat/socket_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ async def _construct_ws_uri(self, options: typing.Optional[ChatConnectOptions]):
231231
elif api_key is not None:
232232
query_params = query_params.add("apiKey", api_key)
233233

234-
return f"wss://api.hume.ai/v0/evi/chat?{query_params}"
234+
base = self.client_wrapper.get_base_url().replace('https://', 'wss://').replace('http://', 'ws://')
235+
return f"{base}/v0/evi/chat?{query_params}"
235236

236237
@asynccontextmanager
237238
async def connect(
@@ -378,7 +379,7 @@ async def _fetch_access_token(self, secret_key: str, api_key: str) -> str:
378379
encoded_auth = base64.b64encode(auth.encode()).decode()
379380
_response = await self.client_wrapper.httpx_client.request(
380381
method="POST",
381-
base_url="https://api.hume.ai/",
382+
base_url=self.client_wrapper.get_base_url(),
382383
path="oauth2-cc/token",
383384
headers={"Authorization": f"Basic {encoded_auth}"},
384385
data={"grant_type": "client_credentials"},

src/hume/expression_measurement/stream/socket_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,10 @@ async def connect(
211211
if api_key is None:
212212
raise ValueError("An API key is required to connect to the streaming API.")
213213

214+
base = self.client_wrapper.get_base_url().replace('https://', 'wss://').replace('http://', 'ws://')
214215
try:
215216
async with websockets.connect( # type: ignore[attr-defined]
216-
"wss://api.hume.ai/v0/stream/models",
217+
f"{base}/v0/stream/models",
217218
extra_headers={
218219
**self.client_wrapper.get_headers(include_auth=False),
219220
"X-Hume-Api-Key": api_key,

0 commit comments

Comments
 (0)