Menu

Integrations / Model APIs

OpenRouter

MillionShort search for any OpenRouter model that takes tools, as a function tool in Python or a tool and the hosted MCP server in OpenRouter's TypeScript Agent SDK.

Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)

RecipePython and TypeScriptNothing of ours to installWorks with no keyChecked 2026-11-19

OpenRouter's API is compatible with OpenAI's, so in Python the OpenAI SDK runs a function tool loop against it. In TypeScript, OpenRouter's Agent SDK (@openrouter/agent) runs the loop for you, and its @openrouter/mcp package connects our hosted MCP server. Either way, pick a model that supports tool calling: OpenRouter's model list filters for them.

1Install

Choose one
Shell
pip install openai requests
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

The examples read your OpenRouter key from OPENROUTER_API_KEY. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

2Minimal example

Choose one
Python
import json
import os

import requests
from openai import OpenAI


def millionshort_search(query: str) -> str:
    r = requests.post(
        "https://api.millionshort.com/v1/search",
        headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        json={"query": query, "remove_top_sites": 1000, "num_results": 5},
        timeout=30,
    )
    r.raise_for_status()
    return json.dumps([{"title": x["title"], "url": x["url"], "snippet": x.get("snippet")} for x in r.json()["data"]["results"]])


tools = [{
    "type": "function",
    "name": "millionshort_search",
    "description": "Search the web with MillionShort, leaving out the 1,000 most popular sites.",
    "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
}]
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=os.environ["OPENROUTER_API_KEY"])
items = [{"role": "user", "content": "Find independent blogs about home espresso."}]
while True:
    response = client.responses.create(model="google/gemini-3-flash-preview", tools=tools, input=items)
    items += response.output
    calls = [item for item in response.output if item.type == "function_call"]
    if not calls:
        break
    for call in calls:
        items.append({"type": "function_call_output", "call_id": call.call_id, "output": millionshort_search(**json.loads(call.arguments))})
print(response.output_text)

The Agent SDK calls the tool and feeds the result back for as many turns as the model needs.

OpenRouter's own web search is a server tool (openrouter:web_search) that runs only when you list it in tools, so leave it out. Then put a line like this in instructions (a field of both responses.create and callModel):

Use the MillionShort search tool for anything recent, niche, or that needs a source. To reach lesser-known sites, set remove_top_sites (for example 1000). Cite the URLs it returns.

4Check it works

Run the example, then ask:

Search MillionShort for forum threads about restoring a cast iron skillet, with the 1,000 most popular sites removed. List the five most useful with their links.

In Python, the first response's output has a function_call item named millionshort_search. In TypeScript, await result.getToolCalls() lists the calls from the first response, with their parsed arguments.

With MCP: the hosted server

@openrouter/mcp connects to a remote MCP server over streamable HTTP and turns its tools into Agent SDK tools, so the model gets the server's tools: search, get_domain_info, list_sources and the tools of the other endpoints (the MCP page lists them all). OpenRouter documents this for TypeScript only. Without a key, leave auth out.

TypeScript
import { OpenRouter } from '@openrouter/agent';
import { callModel } from '@openrouter/agent/call-model';
import { createMCPTools } from '@openrouter/mcp';

const client = new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });
const mcp = await createMCPTools({
  url: 'https://mcp.millionshort.com/mcp',
  auth: { kind: 'bearer', token: process.env.MILLIONSHORT_API_KEY ?? '' },
});

const result = callModel(client, {
  model: 'google/gemini-3-flash-preview',
  input: 'Find independent blogs about home espresso, without the 1,000 most popular sites.',
  tools: mcp.tools,
});
console.log(await result.getText());
await mcp.close();

MCP configuration

The same address for every client: https://mcp.millionshort.com/mcp, streamable HTTP.

ModeHowWhat the agent gets
API keySend Authorization: Bearer ms-YOUR_API_KEYEvery tool, at your plan's limits; calls use your credits
No keySend no Authorization headersearch, list_sources and a few more; one source and up to 5 results a search, 10 free searches a day

Tools

ToolWhat it doesWithout a keyCost
searchSearches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filtersYes: one source, up to 5 results1 credit per source searched, first 10 results
get_domain_infoPopularity and risk for up to 25 sitesNo1 credit
list_sourcesThe sources, page types and topics search acceptsYes: source namesFree
The tools of the other endpointsextract, map, crawl, places and more: the MCP page lists themA few, such as placesWhat the API call behind each costs

The function tool in step 2 is search alone; the MCP handle gives the model every tool of the server.

Settings

VariableMeaning
MILLIONSHORT_API_KEYYour key, read by the examples above
OPENROUTER_API_KEYYour OpenRouter key, read by the examples above

Costs and limits

A tool call costs what the API call behind it costs: 1 credit per source searched for the first 10 results, 1 credit for a domain lookup, nothing for the list of sources, the price of the endpoint for the other tools, and nothing at all in the no-key mode. An agent that loops can make many calls: give it a step limit, and ask for fewer results when a few will do. Credits and limits has the numbers.

When it fails

What you seeWhyFix
401 AUTH_MISSING_KEY or AUTH_INVALID_KEYThe key is missing or wrongSet MILLIONSHORT_API_KEY; keys start with ms-
400 INVALID_PARAMA field name or value the API does not takeThe message names the field; the search reference lists them all
429 RATE_LIMITED or CAPACITYToo many calls a minute, or no free capacity right nowWait the Retry-After seconds, then retry
429 INSUFFICIENT_CREDITSThe plan's credits are used upStop and add credits; do not retry
The model never calls the toolThe model does not support tool calling, or nothing told it when to searchPick one from the model list filtered for tools, and add the line from step 3

This page as Markdown ยท llms.txt