Install search dependencies
SerpAPI setup
SerpAPI provides structured search results. Free accounts include a limited number of searches per month.Create a SerpAPI account
Sign up at serpapi.com. Free accounts include a quota of searches at no cost.
Set the environment variable
Export the key before starting h2oGPT:To make this persistent, add it to your shell profile (
~/.bashrc, ~/.zshrc, etc.).DuckDuckGo fallback
IfSERPAPI_API_KEY is not set, h2oGPT falls back to DuckDuckGo search. No API key or account is required.
DuckDuckGo is the default search backend. SerpAPI is preferred for production use due to more consistent result quality and structured output.
Enabling web search per query in the UI
Once h2oGPT is running with search configured:Enable web search
You will see a web search toggle. Enable it to include search results in the next response.
How it works
When web search is enabled for a query, h2oGPT:- Sends the user’s question to the search provider (SerpAPI or DuckDuckGo)
- Retrieves the top results
- Injects the result snippets into the LLM’s context window alongside the original question
- The LLM generates a response informed by both its training data and the live search results
Configuration reference
| Parameter | Description |
|---|---|
SERPAPI_API_KEY | Environment variable. When set, enables SerpAPI as the search backend. |
--enable_serpapi | CLI flag to explicitly enable or disable SerpAPI (requires key in env). |