Traditional search engine APIs were built for human eyes, returning paginated SERPs packed with SEO boilerplate, unstructured HTML snippets, and messy navigation cruft. When AI engineers wire these legacy search outputs into Retrieval-Augmented Generation (RAG) pipelines or autonomous agents, the architecture breaks down quickly: context windows clog with irrelevant tokens, scraping dynamic pages adds unacceptable latency, and hallucinated attributions compromise factual integrity.
You.com addresses this impedance mismatch through its specialized Web Search API (POST https://ydc-index.io/v1/search). Rather than forcing your application servers to crawl, clean, and chunk raw HTML at runtime, the API offloads query-aware semantic chunking to its web index.
At 365Finds, our benchmark recommendation for live-grounded RAG architectures is decisive: adopt extraction_mode: "highlights" as your primary retrieval primitive and abandon full-page crawling unless downstream document re-indexing is an explicit business requirement. Pairing highlights with strict recency filtering and numbered source injection cuts context consumption by up to 85%, keeps retrieval latency under 450 milliseconds, and establishes an airtight factual audit trail.
1. Core Architecture and Endpoint Specification
To configure web retrieval for production LLM systems, bypass legacy GET patterns and interact exclusively with the authenticated POST endpoint on ydc-index.io.
Endpoint and Authentication
| Property | Production Value | Architectural Context |
|---|---|---|
| Endpoint URL | https://ydc-index.io/v1/search | Core index host; do not confuse with api.you.com (which hosts Answer and Research APIs) |
| HTTP Method | POST | Required for extraction, knowledge, and domain arrays exceeding URL character limits |
| Auth Header | X-API-Key: <YDC_API_KEY> | API key authentication across all web index requests |
| Content-Type | application/json | All request payloads must be structured JSON |
| Base Pricing | $5.00 per 1,000 calls | Includes unified web and news results with up to 100 items per request |
Sending POST requests to ydc-index.io ensures your pipeline receives active feature updates. Calling endpoints reserved for synthesized answers on ydc-index.io returns an HTTP 403 error (Missing Authentication Token), while calling GET /v1/search silently disables advanced content extraction.
2. Extraction Architectures: Highlights vs. Full Page
The central decision in designing a You.com retrieval pipeline is selecting the extraction mode within the request payload.
Architectural Trade-off
| Evaluation Dimension | extraction_mode: "highlights" | extraction_mode: "full_page" |
|---|---|---|
| Primary Output Field | contents.highlights (array of strings) | contents.markdown or contents.html |
| Token Footprint per Result | ~120–250 tokens per hit | 2,000–15,000+ tokens per hit |
Maximum Allowed count | 50 (Values above 50 return HTTP 422) | 100 (Default: 10) |
| Live Crawl Surcharge | None ($0.00 extra) | $1.00 per 1,000 live-crawled pages |
| Latency Profile | Sub-second (typically 300–450 ms) | Variable (up to configured crawl_timeout) |
| Incompatible Parameters | crawl_timeout, extraction_source | None |
| Optimal Application | Real-time RAG, agent tool calling, cited Q&A | Offline indexing, long-form synthesis, archival |
Why 365Finds Favors Highlights
Highlights are query-aware passages extracted directly by You.com's indexing tier. When your user asks a question, the API returns the specific sentences answering that question, rather than the top paragraphs of the page.
Relying on full_page forces you to absorb crawler latency, pay additional per-page extraction surcharges, and run your own token-expensive chunking and reranking pipeline. In contrast, highlights delivers LLM-ready text chunks with zero client-side parsing.
Controlling Token Budgets with total_max_tokens
When running high-throughput production agents, variable prompt sizes can trigger rate limits or spike inference bills. You.com lets you set a response-wide token ceiling using extraction.highlights.total_max_tokens:
{
"query": "Nvidia Q3 GPU data center revenue breakdown",
"count": 5,
"extraction": {
"extraction_mode": "highlights",
"highlights": {
"total_max_tokens": 2048
}
}
}
The total_max_tokens parameter accepts integers between 1024 and 8192 (defaulting to 8192). It dynamically distributes this token budget across all retrieved web results. Submitting values outside this range returns an HTTP 422 validation failure.
When to Configure full_page
If your system requires complete document bodies—such as feeding a multi-document summarization chain or refreshing a local vector store—specify full_page alongside an explicit content source:
blend(Default): Serves cached markdown if available; crawls live on cache miss.cache: Serves cached content only. Incurs zero extraction surcharge and returns immediately, but omitscontentsfor uncached pages.fetch: Bypasses cache entirely to crawl live web pages. Guarantees fresh data at the cost of crawling latency and live-crawl fees.
{
"query": "OpenAI governance board structural changes",
"count": 5,
"crawl_timeout": 5,
"extraction": {
"extraction_mode": "full_page",
"extraction_source": "blend",
"full_page": {
"extraction_formats": ["markdown"]
}
}
}
Critical API Constraint:
crawl_timeout(integer 1–60) andextraction_sourceare valid only whenextraction_modeis"full_page". Including either parameter with"highlights"causes the You.com API to reject the request with HTTP 422 (extraction_source is not supported with extraction_mode highlights).
3. Precision Filtering: Freshness and Domain Governance
Enterprise RAG implementations often fail because retrieved data is either outdated or sourced from unverified publishers. You.com provides granular request-level controls to enforce temporal and domain boundaries.
Temporal Filtering with freshness
To eliminate stale facts during fast-moving events, set the freshness parameter:
"day": Past 24 hours"week": Past 7 days"month": Past 30 days"year": Past 365 days"YYYY-MM-DDtoYYYY-MM-DD": Strict custom calendar window
If your natural-language query contains temporal words (such as "earnings this week") while your request sets freshness="month", You.com resolves the conflict by applying the broader time window. For strict time bounds, maintain neutral query phrasing and enforce recency via the freshness parameter.
Domain Governance: Include, Exclude, and Boost
include_domains: Strict allowlist (up to 500 domains). Results outside this list are completely excluded.exclude_domains: Strict blocklist (up to 5,000 domains). Strips spam farms, social aggregators, or competitor domains.boost_domains: Soft preference list (up to 500 domains). Elevates authoritative domains in ranking without discarding external sources.
Rule:
boost_domainscan be paired withexclude_domains, but attempting to combineboost_domainswithinclude_domainscauses a request validation error.
4. Dissecting the JSON Response Payload
Executing a search with highlights yields a structured JSON envelope containing everything needed for prompt grounding and citation mapping:
{
"results": {
"web": [
{
"url": "https://www.federalreserve.gov/newsevents/pressreleases/monetary20261028a.htm",
"title": "Federal Reserve issues FOMC statement",
"description": "The Federal Open Market Committee decided to maintain...",
"page_age": "2026-10-28T18:00:00",
"thumbnail_url": "https://ydc-index.io/images/...",
"favicon_url": "https://ydc-index.io/favicon?domain=federalreserve.gov&size=128",
"contents": {
"highlights": [
"The Committee decided to maintain the target range for the federal funds rate at 4.25 to 4.50 percent.",
"Recent indicators suggest that economic activity has continued to expand at a solid pace."
]
}
}
]
},
"metadata": {
"search_uuid": "d3b07384-d113-4f24-9b88-29cb68d876a3",
"query": "fomc interest rate decision",
"latency": 0.384
}
}
Key metadata properties for production pipelines:
contents.highlights: Pre-filtered text passages ready for immediate prompt injection.url: Fully qualified canonical URL, used as the citation hyperlink target.page_age: ISO timestamp indicating publication or index recency, vital for downstream chronological sorting.metadata.latency: Server processing time, useful for monitoring network overhead vs. inference latency.
5. End-to-End Implementation: Grounded Prompt Injection
Below is a complete, self-contained Python implementation demonstrating how to query the You.com Search API, build a numbered citation context, and enforce cited answers using OpenAI's client.
import os
import requests
from openai import OpenAI
YDC_API_KEY = os.environ.get("YDC_API_KEY")
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
openai_client = OpenAI(api_key=OPENAI_API_KEY)
def retrieve_you_highlights(query: str, count: int = 5, freshness: str = "month") -> list:
"""Retrieve structured passages and citation metadata from You.com."""
url = "https://ydc-index.io/v1/search"
headers = {
"X-API-Key": YDC_API_KEY,
"Content-Type": "application/json"
}
payload = {
"query": query,
"count": min(count, 50),
"freshness": freshness,
"extraction": {
"extraction_mode": "highlights",
"highlights": {
"total_max_tokens": 4096
}
}
}
response = requests.post(url, headers=headers, json=payload, timeout=10)
response.raise_for_status()
data = response.json()
return data.get("results", {}).get("web", [])
def format_citation_context(web_results: list) -> tuple[str, list]:
"""Format web results into a numbered citation context for LLM grounding."""
context_blocks = []
sources_manifest = []
for idx, item in enumerate(web_results, start=1):
url = item.get("url", "")
title = item.get("title", "Untitled Source")
published = item.get("page_age", "Unknown Date")
contents = item.get("contents", {})
highlights = contents.get("highlights", [])
# Fall back to snippet if highlights are empty
if not highlights and item.get("snippets"):
passages_text = " ".join(item.get("snippets"))
else:
passages_text = " ".join(highlights)
if not passages_text.strip():
continue
context_blocks.append(
f"[{idx}] Source: {title}\nURL: {url}\nPublished: {published}\nContent: {passages_text}"
)
sources_manifest.append({
"citation_id": idx,
"title": title,
"url": url,
"published": published
})
return "\n\n".join(context_blocks), sources_manifest
def generate_cited_answer(question: str) -> dict:
web_results = retrieve_you_highlights(question, count=5, freshness="week")
context_str, sources = format_citation_context(web_results)
system_prompt = (
"You are an enterprise research assistant delivering factual, grounded answers.\n"
"Rules:\n"
"1. Base your answer SOLELY on the numbered sources provided.\n"
"2. For every factual claim, append an inline citation using the source number, e.g., [1] or [1][3].\n"
"3. Do not extrapolate, assume, or cite external training data.\n"
"4. If the provided sources do not contain sufficient evidence, state clearly: "
"'The provided real-time sources do not contain sufficient information to answer this question.'"
)
user_prompt = f"Sources:\n{context_str}\n\nQuestion: {question}"
completion = openai_client.chat.completions.create(
model="gpt-4o",
temperature=0.1,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
)
return {
"question": question,
"answer": completion.choices[0].message.content,
"citations": sources
}
if __name__ == "__main__":
result = generate_cited_answer("What were the latest major commercial updates from TSMC?")
print("ANSWER:\n", result["answer"])
print("\nSOURCES:")
for src in result["citations"]:
print(f"[{src['citation_id']}] {src['title']} ({src['url']})")
6. Framework Integrations: LangChain and LlamaIndex
You.com maintains official integrations across the two dominant AI orchestration frameworks.
LangChain (langchain-youdotcom)
Install the dedicated package:
pip install -U langchain-youdotcom langchain-openai
Configure YouRetriever inside an LCEL (LangChain Expression Language) retrieval chain:
import os
from langchain_youdotcom import YouRetriever
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnablePassthrough
retriever = YouRetriever(
count=5,
freshness="month"
)
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_template(
"""Answer the user inquiry using strictly the retrieved web context.
Cite sources using their index number.
Context:
{context}
Question: {question}"""
)
def format_docs(docs):
formatted = []
for i, doc in enumerate(docs, start=1):
url = doc.metadata.get("url", "unknown")
formatted.append(f"[{i}] {doc.page_content}\nSource URL: {url}")
return "\n\n".join(formatted)
chain = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
response = chain.invoke("What are the key provisions of the latest EU AI Act rollout?")
print(response)
LlamaIndex (llama-index-retrievers-you)
Install the dedicated LlamaIndex retriever package:
pip install -U llama-index-retrievers-you llama-index-core
Integrate into a RetrieverQueryEngine:
import os
from llama_index.retrievers.you import YouRetriever
from llama_index.core.query_engine import RetrieverQueryEngine
from llama_index.llms.openai import OpenAI
retriever = YouRetriever(
api_key=os.environ["YDC_API_KEY"],
count=5,
freshness="week"
)
llm = OpenAI(model="gpt-4o", temperature=0.1)
query_engine = RetrieverQueryEngine.from_args(retriever=retriever, llm=llm)
response = query_engine.query("What are the latest breakthrough efficiency records in perovskite solar cells?")
print(str(response))
7. Production Engineering Patterns
Deploying real-time search in production applications requires defensive system design to prevent runaway costs, citation drift, and latency spikes.
Publisher Deduplication
Search engines frequently return multiple links from the same root domain. Injecting three articles from the same media outlet dilutes perspective and consumes context window space. Deduplicate incoming results by domain, keeping only the highest-ranked hit per hostname before formatting your LLM context block.
Semantic In-Memory Caching
Autonomous agents executing multi-step decomposition often fire duplicate sub-queries within seconds of each other. Implement a shared cache (such as Redis) with a 10-to-15 minute TTL keyed on sha256(query + freshness + extraction_mode). This eliminates redundant billable calls and cuts search retrieval latency to sub-millisecond local network speeds.
Defensive Error Handling
- HTTP 422 Unprocessable Entity: Check whether
crawl_timeoutorextraction_sourcewas sent withextraction_mode="highlights", or ifcountexceeded 50. - HTTP 429 Too Many Requests: Check the
Retry-Afterheader. Wrap API calls in exponential backoff jitter (e.g., usingtenacityin Python) to gracefully handle sudden concurrency spikes. - Citation Post-Validation: Run a lightweight regex over the LLM output to extract cited tokens (such as
\[(\d+)\]). If the model emits a citation index not present in your source manifest, strip it or flag the completion for human review before rendering.
Summary Checklist for Architects
- Point your HTTP client to
POST https://ydc-index.io/v1/searchwith theX-API-Keyheader. - Set
"extraction_mode": "highlights"withcountbetween 3 and 10 for interactive RAG prompts. - Configure
extraction.highlights.total_max_tokens(1024–8192) to lock in context budgets. - Omit
crawl_timeoutandextraction_sourcewhen using highlights to prevent 422 rejections. - Apply
"freshness"(day,week,month) and domain filters (include_domains) to enforce factual accuracy. - Number retrieved passages in your prompt and instruct the LLM to cite strictly by index number.