diff --git a/ollama/_client.py b/ollama/_client.py index 18cb0fb4..bc154338 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -801,7 +801,12 @@ async def web_search(self, query: str, max_results: int = 3) -> WebSearchRespons Returns: WebSearchResponse with the search results + Raises: + ValueError: If OLLAMA_API_KEY environment variable is not set """ + if not self._client.headers.get('authorization', '').startswith('Bearer '): + raise ValueError('Authorization header with Bearer token is required for web search') + return await self._request( WebSearchResponse, 'POST', @@ -821,7 +826,12 @@ async def web_fetch(self, url: str) -> WebFetchResponse: Returns: WebFetchResponse with the fetched result + Raises: + ValueError: If OLLAMA_API_KEY environment variable is not set """ + if not self._client.headers.get('authorization', '').startswith('Bearer '): + raise ValueError('Authorization header with Bearer token is required for web fetch') + return await self._request( WebFetchResponse, 'POST',