mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
A way to set OLLAMA_API_KEY for web_search #302
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BELKHIR on GitHub (Oct 9, 2025).
Hi,
To call web_search or web_fetch, on have to set the environment variable OLLAMA_API_KEY before launching a python code.
I you want to set the environment variable OLLAMA_API_KEY inside the code, you have to set it (via os.environ["OLLAMA_API_KEY"] = key) before importing ollama !
This is set in _client.py which is loaded during module initialization.
Any way to let functions requiring an Ollama api key to be called with the key instead of relying on environment variable ?
Many thanks,
@ParthSareen commented on GitHub (Oct 15, 2025):
Yes! You can instantiate a client yourself like: