Web Search
LibreChat's web search feature allows you to search the internet and retrieve relevant information to enhance your conversations. The feature consists of three main components that work together to provide comprehensive search results.
Quick Start
To get started with web search, configure a search provider and scraper. Most providers require API keys; Keenable works without one for both search and page fetch, with an optional key to raise its public rate limits. Reranking can use Jina or Cohere, or be disabled with rerankerType: "none". You can configure the stack in two ways:
Private self-hosted endpoints
Web search, scrape, and rerank connections block private, loopback, link-local, and cloud-metadata destinations by default. If SearXNG, Firecrawl, Jina, or another configured provider endpoint is private, add its exact host and port to webSearch.allowedAddresses.
-
Environment Variables (Recommended for admins):
# Search Provider (choose one) SERPER_API_KEY=your_serper_api_key # or SEARXNG_INSTANCE_URL=your_searxng_instance_url SEARXNG_API_KEY=your_searxng_api_key # Optional # or TAVILY_API_KEY=your_tavily_api_key # or use Keenable keyless; this optional key raises public rate limits KEENABLE_API_KEY=your_keenable_api_key # Scraper (choose one) FIRECRAWL_API_KEY=your_firecrawl_api_key # Optional: Custom Firecrawl API URL FIRECRAWL_API_URL=your_firecrawl_api_url # Optional: Firecrawl API version (v0 or v1) # FIRECRAWL_VERSION=v1 # or TAVILY_API_KEY=your_tavily_api_key # or use Keenable keyless with the same optional key # Reranker (Optional - choose one, or set rerankerType: "none") JINA_API_KEY=your_jina_api_key # Optional: Custom Jina API URL JINA_API_URL=your_jina_api_url # or COHERE_API_KEY=your_cohere_api_keyUsing Keenable without an environment key still requires provider selection in
librechat.yaml:webSearch: searchProvider: keenable scraperProvider: keenable rerankerType: noneSee the full Keenable configuration for optional search, fetch, and rate-limit settings.
-
User Interface (If environment variables are not set):
- Users will be prompted to enter the required API keys when they first use the web search feature
- They can choose which search provider (Serper, SearXNG, Tavily, or Keenable), scraper, and reranker service (Jina, Cohere, or none) to use
Obtaining API Keys
Each enabled external service requires its own API key. Here's how to obtain them:
Search Providers
Serper
- Visit Serper.dev
- Sign up for an account
- Navigate to the API Key section
- Copy your API key
- Set it in your environment variables or provide it through the UI
SearXNG
- Follow the setup instructions in the Web Search Configuration documentation
- Set
SEARXNG_INSTANCE_URLto your instance URL - Optionally set
SEARXNG_API_KEYif your instance requires authentication - Add your instance's exact
host:porttoallowedAddressesif it is on a private or loopback address, otherwise LibreChat blocks the connection - Optionally tune which engines your instance queries with
searxngSearchOptions. The default set is only three engines and includes DuckDuckGo, which serves CAPTCHAs to most self-hosted instances, so widening it helps if searches come back empty
Tavily
- Visit Tavily
- Sign up for an account
- Copy your API key
- Set
TAVILY_API_KEYin your environment variables or provide it through the UI - Tavily can be used as both a search provider and a scraper provider
Keenable
- Select Keenable as the search provider, scraper, or both
- No API key is required for the public search and fetch endpoints
- Optionally set
KEENABLE_API_KEYto raise the public rate limits - Use
KEENABLE_API_URLonly to override the search endpoint andKEENABLE_FETCH_URLonly to override the page-fetch endpoint
Scraper: Firecrawl
- Visit Firecrawl.dev
- Sign up for an account
- Navigate to the API Key section
- Copy your API key
- Set it in your environment variables or provide it through the UI
- (Optional) If you're using a custom Firecrawl instance, you'll also need to set the API URL
Rerankers
Jina
- Visit Jina.ai
- Sign up for an account
- Navigate to the API Dashboard
- Copy your API key
- Set it in your environment variables or provide it through the UI
Cohere
- Visit Cohere Dashboard
- Sign up for an account
- Navigate to the API Keys section
- Copy your API key
- Set it in your environment variables or provide it through the UI
Components
1. Search Providers
Search providers are responsible for performing the initial web search and returning relevant results.
Available Providers:
- Serper: A Google Search API that provides high-quality search results
- Get your API key from Serper.dev
- SearXNG: Open-source, self-hosted meta search engine
- Self-host your own instance
- Privacy-focused search results
- Configurable engines, result language, time range, and request timeout
- Tavily: AI-optimized search API
- Get your API key from Tavily
- Supports configurable search depth, topic filtering, domain filtering, and more
- Can also serve as a scraper provider
- Keenable: Keyless web search with optional higher-rate authentication
- Supports domain-restricted search, result limits, attribution titles, and request timeouts
- Can also serve as a scraper provider
2. Scrapers
Scrapers extract the actual content from web pages returned by the search provider.
Available Scrapers:
-
Firecrawl: A powerful web scraping service that extracts content from web pages
- Get your API key from Firecrawl.dev
- API URL is optional (defaults to Firecrawl's hosted service)
-
Tavily: Batch URL extraction via Tavily Extract API
- Uses the same
TAVILY_API_KEYas the search provider - Supports configurable extract depth, image extraction, and favicon extraction
- Uses the same
-
Keenable: Keyless page fetch
- Uses the same optional API key as Keenable search
- Supports attribution titles and request timeouts
Planned Scrapers:
- Local Firecrawl: Self-hosted version of Firecrawl
- Additional third-party scraping services
3. Rerankers
Rerankers analyze the scraped content to determine the most relevant parts and reorder them for better results.
Available Rerankers:
- Jina: AI-powered reranking service
- Get your API key from Jina.ai
- API URL is optional (defaults to Jina's hosted service)
- Cohere: Advanced reranking service
- Get your API key from Cohere Dashboard
- None: Skips reranking when
rerankerTypeis set to"none"
Planned Rerankers:
- RAG API: Open-source reranking using RAG (Retrieval-Augmented Generation)
- Additional third-party reranking services
Configuration
Admin Configuration
Admins can configure the web search feature using environment variables. The YAML configuration allows you to specify custom environment variable names for each component.
⚠️ Important: Never put actual API keys or values in the YAML file (they won't work)- only use environment variable names.
webSearch:
# Search Provider Configuration
serperApiKey: "${CUSTOM_SERPER_API_KEY}" # ✅ Correct: Using environment variable name
# serperApiKey: "sk-123..." # ❌ Wrong: Never put actual API keys here
# or
searxngInstanceUrl: "${CUSTOM_SEARXNG_INSTANCE_URL}" # ✅ Correct: Using environment variable name
searxngApiKey: "${CUSTOM_SEARXNG_API_KEY}" # ✅ Correct: Using environment variable name
# searxngInstanceUrl: "http://..." # ❌ Wrong: Never put actual URLs here
# searxngApiKey: "sk-123..." # ❌ Wrong: Never put actual API keys here
searxngSearchOptions: # Query options, not secrets, so real values belong here
engines: "google,bing,startpage"
language: "en"
# Tavily Configuration (search and/or scraper)
tavilyApiKey: "${CUSTOM_TAVILY_API_KEY}"
tavilySearchUrl: "${CUSTOM_TAVILY_SEARCH_URL}"
tavilyExtractUrl: "${CUSTOM_TAVILY_EXTRACT_URL}"
# Keenable Configuration (search and/or scraper; keyless by default)
keenableApiKey: "${CUSTOM_KEENABLE_API_KEY}" # Optional; raises rate limits
keenableApiUrl: "${CUSTOM_KEENABLE_API_URL}" # Optional search URL override
keenableSearchOptions:
maxResults: 8
site: "example.com"
attributionTitle: "LibreChat"
timeout: 15000
keenableScraperOptions:
attributionTitle: "LibreChat"
timeout: 15000
# Scraper Configuration
firecrawlApiKey: "${CUSTOM_FIRECRAWL_API_KEY}"
firecrawlApiUrl: "${CUSTOM_FIRECRAWL_API_URL}"
# firecrawlApiKey: "fc-123..." # ❌ Wrong: Never put actual API keys here
# firecrawlApiUrl: "https://..." # ❌ Wrong: Never put actual URLs here
# Reranker Configuration
jinaApiKey: "${CUSTOM_JINA_API_KEY}"
jinaApiUrl: "${CUSTOM_JINA_API_URL}"
cohereApiKey: "${CUSTOM_COHERE_API_KEY}"
# jinaApiKey: "jn-123..." # ❌ Wrong: Never put actual API keys here
# jinaApiUrl: "https://..." # ❌ Wrong: Never put actual URLs here
# cohereApiKey: "ch-123..." # ❌ Wrong: Never put actual API keys here
# General Settings
safeSearch: 1 # Options: 0 (OFF), 1 (MODERATE - default), 2 (STRICT)Note: The YAML configuration should only contain environment variable names (in the format ${VARIABLE_NAME}). This flexibility enables:
- Using different variable names in different environments
- Supporting multiple configurations for different user groups
- Future integration with role-based configurations
If you want to restrict the system to use only specific services, you can specify the service types:
webSearch:
# ... variable configurations ...
searchProvider: "serper" # Only use Serper for search
# searchProvider: "searxng" # Only use SearXNG for search
# searchProvider: "tavily" # Only use Tavily for search
# searchProvider: "keenable" # Use keyless Keenable search
scraperProvider: "firecrawl" # Only use Firecrawl for scraping
# scraperProvider: "tavily" # Only use Tavily for scraping
# scraperProvider: "keenable" # Use keyless Keenable page fetch
rerankerType: "jina" # Options: "jina", "cohere", "none"User Configuration
If the admin hasn't configured all the necessary API keys, users will be prompted to provide them through the UI. The interface allows users to:
- Choose their preferred reranker (Jina, Cohere, or none)
- Enter API keys for the required services
- Configure the Firecrawl API URL if needed (optional)
- Configure the Jina API URL if needed (optional)
- Configure Tavily or Keenable endpoint overrides if needed (optional)
Usage
Once configured, you can use web search in two ways:
- Chat Interface: Click the web search button in the chat interface to enable web search for your conversation
- Agents: Use the
web_searchcapability in agents to allow them to search the web
Notes
- Search provider and scraper configuration are required; reranking can be disabled with
rerankerType: "none" - The Firecrawl API URL is optional and defaults to their hosted service
- The Jina API URL is optional and defaults to their hosted service
- The Tavily Search and Extract API URLs are optional and default to Tavily's hosted services
- Keenable search and page fetch are keyless by default; an optional key raises public rate limits
KEENABLE_API_URLoverrides only search, whileKEENABLE_FETCH_URLoverrides only page fetch- Pair
searchProvider: "keenable",scraperProvider: "keenable", andrerankerType: "none"for a fully keyless stack - Safe search provides three levels of content filtering: OFF (0), MODERATE (1 - default), and STRICT (2)
- Tavily does not inherit the global
safeSearchsetting by default; usetavilySearchOptions.safeSearchonly if your Tavily account supportssafe_search - The scraper timeout is set to 7.5 seconds (7500ms) by default
- API keys can be revoked at any time through the UI
- Future updates will include more open-source, self-hosted options for all components
- Additional customization options are planned, including:
- Control over the number of links to scrape
- Domain allowlist/blocklist for scraping
- Custom scraping rules and filters
- Advanced result filtering and ranking options
- Rate limiting and request throttling controls
How is this guide?