decolua/9router · error
You.com Search requires an API key
Error message
You.com Search requires an API key
What it means
buildYouComRequest builds the request for the You.com search API, which requires a bearer API key. The builder validates params.token up front and throws this error when it is missing so the failure is immediate and self-explanatory rather than a 401 from You.com's servers.
Source
Thrown at open-sse/handlers/search/callers.js:293
});
if (params.country) qp.set("gl", params.country.toLowerCase());
if (params.language) qp.set("hl", params.language);
const page = toPageNumber(params.offset, params.maxResults);
if (page) qp.set("page", String(page));
return {
url: `${resolveBaseUrl(config, params)}?${qp}`,
init: {
method: "GET",
headers: { Accept: "application/json" },
},
};
}
function buildYouComRequest(config, params) {
const apiKey = params.token;
if (!apiKey) throw new Error("You.com Search requires an API key");
const { includes, excludes } = parseDomainFilter(params.domainFilter);
const qp = new URLSearchParams({
query: params.query,
count: String(Math.min(params.maxResults, 100)),
});
if (params.timeRange && params.timeRange !== "any") qp.set("freshness", params.timeRange);
if (typeof params.offset === "number" && params.offset > 0 && params.maxResults > 0) {
qp.set("offset", String(Math.min(Math.floor(params.offset / params.maxResults), 9)));
}
if (params.country) qp.set("country", params.country);
if (params.language) qp.set("language", params.language);
if (includes.length) qp.set("include_domains", includes.join(","));
if (excludes.length) qp.set("exclude_domains", excludes.join(","));
if (params.contentOptions?.full_page) {
qp.set("livecrawl", params.searchType === "news" ? "news" : "web");View on GitHub (pinned to 90b52e06ff)
Solutions
- Obtain a You.com API key (ydc-index) and store it for the You.com provider in the dashboard
- Ensure the call site passes token: '...' in params
- Verify the key is non-empty and not whitespace (builder only checks falsy)
- Check provider id spelling so the credential lookup resolves
Example fix
// before
await search({ provider: 'youcom', query: 'rust async', maxResults: 10 });
// after
await search({ provider: 'youcom', query: 'rust async', maxResults: 10, token: process.env.YOU_API_KEY }); Defensive patterns
Strategy: validation
Validate before calling
if (!params?.token || typeof params.token !== 'string' || !params.token.trim()) {
throw new Error('You.com search requires a non-empty token');
} Type guard
function hasYouComToken(params) {
return typeof params?.token === 'string' && params.token.trim().length > 0;
} Try / catch
try {
const res = await search({ provider: 'youcom', query, token });
} catch (err) {
if (err.message.includes('requires an API key')) {
// configure the You.com key, then retry
} else throw err;
} Prevention
- Set the You.com (ydc-index) key in your env and load it before calls
- Validate credentials for the selected provider before dispatch
- Keep one credential store so keys aren't scattered under wrong ids
When it happens
Trigger: Calling the You.com search route with params.token undefined, null, or empty — no You.com API key configured for the account, or a hand-built params object omitting `token`.
Common situations: Provider enabled without obtaining a key from api.ydc-index.io; key saved to the wrong provider slot; env var not set when constructing params in scripts; account cleanup removed the credential.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- Linkup Search requires an API key
- SearchAPI requires an API key
- Xquik requires an API key
- Invalid baseUrl: ${override}
- Google Programmable Search requires both apiKey and cx
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/1cd3e104b3f9a9e5.
Report an issue: GitHub.