diff --git a/src/config.py b/src/config.py index e5f580e..b959a4e 100644 --- a/src/config.py +++ b/src/config.py @@ -84,6 +84,7 @@ class Settings(BaseSettings): # Only used when explicitly enabled and query complexity warrants it. grok_enabled: bool = False xai_api_key: str = "" + xai_base_url: str = "https://api.x.ai/v1" grok_default_model: str = "grok-3-fast" grok_max_sats_per_query: int = 200 grok_free: bool = False # Skip Lightning invoice when user has own API key diff --git a/src/infrastructure/router/cascade.py b/src/infrastructure/router/cascade.py index e9ec675..050a7c4 100644 --- a/src/infrastructure/router/cascade.py +++ b/src/infrastructure/router/cascade.py @@ -759,7 +759,7 @@ class CascadeRouter: client = openai.AsyncOpenAI( api_key=provider.api_key, - base_url=provider.base_url or "https://api.x.ai/v1", + base_url=provider.base_url or settings.xai_base_url, timeout=httpx.Timeout(300.0), ) diff --git a/src/timmy/backends.py b/src/timmy/backends.py index 02a90db..2ec05ed 100644 --- a/src/timmy/backends.py +++ b/src/timmy/backends.py @@ -99,23 +99,27 @@ class GrokBackend: def _get_client(self): """Create OpenAI client configured for xAI endpoint.""" + from config import settings + import httpx from openai import OpenAI return OpenAI( api_key=self._api_key, - base_url="https://api.x.ai/v1", + base_url=settings.xai_base_url, timeout=httpx.Timeout(300.0), ) async def _get_async_client(self): """Create async OpenAI client configured for xAI endpoint.""" + from config import settings + import httpx from openai import AsyncOpenAI return AsyncOpenAI( api_key=self._api_key, - base_url="https://api.x.ai/v1", + base_url=settings.xai_base_url, timeout=httpx.Timeout(300.0), )