musistudio/claude-code-router · warning
[gateway] Bing web search API key is not configured.
Error message
[gateway] Bing web search API key is not configured.
What it means
The hosted web search feature selected the Bing provider, but BING_SEARCH_API_KEY is not present in the resolved environment. The provider returns empty results instead of throwing, so a missing key degrades into zero search results.
Source
Thrown at packages/core/src/gateway/features/hosted-web-search/discovery.ts:558
if (!apiKey) {
console.warn("[gateway] Brave web search API key is not configured.");
return [];
}
const url = new URL(searchEnv(input, "BRAVE_SEARCH_ENDPOINT") || "https://api.search.brave.com/res/v1/web/search");
url.searchParams.set("q", input.query);
url.searchParams.set("count", String(input.count));
const raw = await fetchJson(url.toString(), {
headers: { "x-subscription-token": apiKey },
signal: AbortSignal.timeout(input.timeoutMs)
});
const items = isRecord(raw) && isRecord(raw.web) && Array.isArray(raw.web.results) ? raw.web.results : [];
return items.map((item) => webSearchResult(item, "title", "url", "description")).filter(isWebSearchProviderResult);
}
async function searchBing(input: WebSearchProviderInput): Promise<WebSearchProviderResult[]> {
const apiKey = searchEnv(input, "BING_SEARCH_API_KEY");
if (!apiKey) {
console.warn("[gateway] Bing web search API key is not configured.");
return [];
}
const url = new URL(searchEnv(input, "BING_SEARCH_ENDPOINT") || "https://api.bing.microsoft.com/v7.0/search");
url.searchParams.set("q", input.query);
url.searchParams.set("count", String(input.count));
url.searchParams.set("mkt", "en-US");
const raw = await fetchJson(url.toString(), {
headers: { "ocp-apim-subscription-key": apiKey },
signal: AbortSignal.timeout(input.timeoutMs)
});
const items = isRecord(raw) && isRecord(raw.webPages) && Array.isArray(raw.webPages.value) ? raw.webPages.value : [];
return items.map((item) => webSearchResult(item, "name", "url", "snippet")).filter(isWebSearchProviderResult);
}
async function searchGoogleCse(input: WebSearchProviderInput): Promise<WebSearchProviderResult[]> {
const apiKey = searchEnv(input, "GOOGLE_SEARCH_API_KEY");
const cx = searchEnv(input, "GOOGLE_SEARCH_CX");
if (!apiKey || !cx) {View on GitHub (pinned to 99f24806c6)
Solutions
- Set BING_SEARCH_API_KEY in the gateway process environment
- Verify the variable is visible: print process.env.BING_SEARCH_API_KEY from the gateway context or check the service unit file
- Restart the gateway after setting the key
Example fix
# before WEB_SEARCH_PROVIDER=bing # after BING_SEARCH_API_KEY=<your-azure-bing-key> WEB_SEARCH_PROVIDER=bing
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.BING_SEARCH_API_KEY) {
throw new Error("BING_SEARCH_API_KEY must be set before enabling the bing web search provider");
} Prevention
- Validate required env vars per provider at boot
- Use a secrets manager to inject keys consistently
- Log resolved provider config at startup
When it happens
Trigger: Configuring web search provider to "bing" without BING_SEARCH_API_KEY; running the gateway in a container/service where the variable was never exported; key present only at build time not runtime.
Common situations: Env var name mismatch (e.g. AZURE_BING_KEY vs BING_SEARCH_API_KEY); .env not loaded; rotating keys and forgetting to update the gateway environment.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- [gateway] Brave web search API key is not configured.
- [gateway] Google CSE web search API key or engine ID is not
- [gateway] Serper web search API key is not configured.
- [gateway] SerpAPI web search API key is not configured.
- [gateway] Tavily web search API key is not configured.
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/db3a7c38736db39c.
Report an issue: GitHub.