Use cases
Search for RAG pipelines
Retrieval decides what your model can say. MillionShort gives a RAG pipeline ranked passages from the web and specialist sources, with controls over which sites are allowed in.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
A RAG pipeline answers a question in two steps: it retrieves text, then a model writes from that text. The model can only be as good as what was retrieved. When the retrieval step is web search, three things usually go wrong.
The problem
- The passages are too short. A one-line snippet tells the model a page exists, not what it says.
- The same sites answer everything. General search favors the most popular sites, so every answer cites the same handful of them, whatever the question.
- Nothing says how far to trust a source. A result list gives a title and a link. Your pipeline has to guess the rest.
How MillionShort addresses it
- Longer snippets.
max_chars_per_resultsets the snippet length, up to 2,000 characters (the default is 800). That is usually enough for a model to quote and cite. - The right source for the question. One call searches 1 to 5 of the 13 sources and returns one merged, ranked list. A medical question can search
medicalandacademic; a question about a library can searchweb,discussionsandhn. Every source costs the same. - Control over the site pool.
remove_top_sitesremoves results from the N most popular sites. The lenses do the rest:include_domainskeeps only sites you name,exclude_domainsblocks them,boost_domainsandbury_domainschange the order without filtering. - Kinds of page.
page_typesandtopicskeep only matching results, for example documentation and tutorials. The slugs come fromGET /v1/sources. - Signals on every result. Each result carries
popularityandriskfor its site, so your code can down-weight a source before the model sees it.exclude_risky: truedrops every result whose site carries a risk label. - A reason for each result.
explain: trueaddswhyandsignalsto each result, at no cost. It is useful when you are tuning retrieval and want to know why a passage was chosen.
A retrieval call
This asks two sources for eight passages of up to 1,500 characters, keeps documentation and tutorials among the web results (the page-type filter acts on web and news, so the response names discussions in a filter_not_applied warning), drops results from sites with a risk label, and blocks one site:
curl https://api.millionshort.com/v1/search \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "rate limiting with a token bucket",
"sources": ["web", "discussions"],
"num_results": 8,
"max_chars_per_result": 1500,
"page_types": ["documentation", "tutorials"],
"exclude_domains": ["example.com"],
"exclude_risky": true
}'import os
from millionshort import MillionShort
client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])
r = client.search(
"rate limiting with a token bucket",
sources=["web", "discussions"],
num_results=8,
max_chars_per_result=1500,
page_types=["documentation", "tutorials"],
exclude_domains=["example.com"],
exclude_risky=True,
)
context = []
for hit in r.results:
context.append(f'[{hit["position"]}] {hit["title"]} ({hit["url"]})\n{hit["snippet"]}')
prompt = "Answer from these sources and cite them by number.\n\n" + "\n\n".join(context)
print(r.usage.credits, "credits")const res = await fetch('https://api.millionshort.com/v1/search', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"query": "rate limiting with a token bucket",
"sources": [
"web",
"discussions"
],
"num_results": 8,
"max_chars_per_result": 1500,
"page_types": [
"documentation",
"tutorials"
],
"exclude_domains": [
"example.com"
],
"exclude_risky": true
}),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);The same call as a tool of the MCP server:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search",
"arguments": {
"query": "rate limiting with a token bucket",
"sources": [
"web",
"discussions"
],
"num_results": 8,
"max_chars_per_result": 1500,
"page_types": [
"documentation",
"tutorials"
],
"exclude_domains": [
"example.com"
],
"exclude_risky": true
}
}
}The call searches two sources, so it costs 2 credits. The Python SDK is not published to a package registry yet; until it is, send the same request with any HTTP client.
What it does not do
- No live fetch in a search. A snippet goes up to 2,000 characters. When that is not enough,
include_content: trueadds the text of the page as we hold it towebandnewsresults, for 1 credit a call (up to 10 results). It is our stored copy, as old as the day we captured it. Fetching a page as it is now is what Extract is for, as a separate call. - No generated answers from a search. A search returns results; your model writes the answer. For an answer written by us, Agent is a separate, metered call: a written answer with a checked quote for every statement.
- Keyword retrieval. Queries that contain the words you expect on the page work well. A question phrased as a long sentence works better when your pipeline first turns it into a search query.
- The web source is not continuously refreshed. It is refreshed periodically and web results carry no date. For recent events, search
news,socialorhn. The date filters work on those sources; they are not applied toweb, and the response says so. See Freshness.
Read next
- RAG with MillionShort, the step-by-step guide.
- Low-noise RAG, when the problem is the quality of what comes back.
- Glossary: What is RAG? and What is RAG noise?
- The Search reference lists every field.