EN ▾
Get API key

LLM Search Summarization With an OpenAI-Compatible API

LLM search summarization means taking a pile of search results and turning them into one short, sourced answer. This page shows a working pipeline with streaming, citations and sane limits.

Updated

Document tiles funneled into one compact summary block on a glowing conveyor

How the pipeline works

LLM search summarization is a two-stage job. First your code gets results from a search source: a metasearch instance, a search API you already pay for, or a list of URLs you fetched yourself. Then you send the titles and snippets to a language model and ask it to condense them. The model never touches the web. It reads what you give it and writes text, which is why the quality of the answer depends so much on what goes into the prompt.

The endpoint here is OpenAI-compatible, so you can use the official OpenAI SDK for Python or Node and change only the base URL, the key and the model. The base URL is https://api.uncensoredsearch.cc/v1 and the model ID is uncensored. The model is tuned to answer without content refusals for lawful adult use, which helps when your sources contain material that other models refuse to summarize: forum threads, fiction, raw interview transcripts, moderation queues. It is text only, with no image, audio or embedding support.

Step 1: collect and shape the results

Whatever search source you use, reduce each hit to the same small record: a number, a title, a URL and a snippet. Uniform records make the prompt predictable and let you map citations back to links later.

def to_context(results, max_chars=700):
    lines = []
    for i, r in enumerate(results, start=1):
        snippet = (r.get("snippet") or "").strip().replace("\n", " ")
        lines.append(f"[{i}] {r['title']} ({r['url']})\n{snippet[:max_chars]}")
    return "\n\n".join(lines)

A few rules keep this stage healthy. Drop duplicates by URL before numbering. Trim each snippet to a fixed length so one long page cannot crowd out the rest. Keep the order your search source returned, because rank is a useful hint. If you have full page text and not only snippets, extract the main body first and cut it down to the passages that matter, since sending whole pages burns tokens on navigation menus and footers.

Step 2: write the prompt

The instruction decides whether you get a faithful summary or a pleasant-sounding invention. Be explicit about three things: use only the sources, cite by number, and say so when the sources do not answer the question.

SYSTEM = (
    "You summarize search results. Use only the numbered sources provided. "
    "After each claim add the source number in square brackets, like [2]. "
    "If sources disagree, say so and name both. "
    "If the sources do not contain the answer, reply: Not found in the sources."
)

def build_messages(question, context):
    return [
        {"role": "system", "content": SYSTEM},
        {"role": "user", "content": f"Question: {question}\n\nSources:\n{context}"},
    ]

Set a low temperature for this task. Values around 0.2 to 0.4 keep the wording close to the sources. The API passes through temperature, top_p, stop, seed and the penalties, so you can also fix a seed when you want repeatable output in tests.

Step 3: call the API and stream the answer

Streaming makes a summarizer feel fast, because the first words show up while the rest is still being written. The API supports server-sent events with stream: true and returns usage at the end of the stream.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.uncensoredsearch.cc/v1",
    api_key="YOUR_KEY",
)

def summarize(question, results):
    stream = client.chat.completions.create(
        model="uncensored",
        messages=build_messages(question, to_context(results)),
        temperature=0.3,
        stream=True,
        stream_options={"include_usage": True},
    )
    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="", flush=True)
        if getattr(chunk, "usage", None):
            print("\n\ntokens:", chunk.usage.prompt_tokens, chunk.usage.completion_tokens)

The same request in Node:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.uncensoredsearch.cc/v1",
  apiKey: process.env.API_KEY,
});

const stream = await client.chat.completions.create({
  model: "uncensored",
  messages: [
    { role: "system", content: "Summarize using only the numbered sources. Cite like [1]." },
    { role: "user", content: "Question: ...\n\nSources:\n[1] ...\n[2] ..." },
  ],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

If you want structured output, for example a summary plus a list of key claims, add response_format: {"type": "json_object"} and describe the keys in the prompt. JSON mode is easier to parse than free text, though you should still handle the occasional malformed reply.

Using the 100,000-token window sensibly

The context window is 100,000 tokens, shared between the prompt and the completion. That is plenty for a summarizer, but bigger is not automatically better. A prompt stuffed with fifty snippets tends to produce a vague answer that mentions everything and commits to nothing.

Two patterns work well. For a normal query, send the top ten to fifteen results with snippets of a few hundred characters each, which usually lands between 3,000 and 6,000 tokens. For a research task over long documents, use two passes: summarize each document on its own, then send the short summaries to a second call that merges them. The second pass sees a clean, small input, and the intermediate summaries are easy to log and inspect when an answer looks wrong.

The request body can be up to 8 MB, which you will not reach with text snippets. The practical limit is the token window, and you can estimate it at roughly four characters per token for English text. Treat that as a rule of thumb only, and read the real figures from the usage block in the response.

Limits, errors and cost

A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent requests and 60 per minute. A streamed request holds its concurrency slot until the stream finishes, so a slow client that reads a stream lazily can block its own parallel work. If you exceed a limit, the API returns HTTP 429 with the error code rate_limited for requests per minute or concurrency for too many at once. On temporary overload you also get a 429 with a Retry-After: 5 header. Honor that header and retry with a short backoff.

import time
from openai import RateLimitError

def with_retry(fn, tries=4):
    for attempt in range(tries):
        try:
            return fn()
        except RateLimitError:
            time.sleep(5 if attempt == 0 else 5 * (attempt + 1))
    raise RuntimeError("still rate limited")

Now the math. Take a job with 10 results at about 400 tokens each plus the instructions, so 4,500 input tokens, and an answer of 350 output tokens. Input costs 4,500 x $0.15 / 1,000,000 = $0.000675. Output costs 350 x $0.50 / 1,000,000 = $0.000175. The total is $0.00085 per summary, so 1,000 summaries cost $0.85. Failed or refused requests are not charged. The pricing page has the full table of top-ups from $20 to $500.

The response headers help with monitoring: X-Request-Id for support, X-Balance-USD for your remaining credit, and the two rate-limit headers for your ceilings.

Checking quality before you ship

A summarizer can look fine on three hand-picked queries and still fail in production, so build a small test set early. Collect thirty real questions, save the search results for each so they do not change between runs, and write down by hand what a good answer must contain. Run the pipeline against that frozen set after every change to the prompt, the snippet length or the temperature. Because the API passes a seed through, repeated runs are easy to compare.

Score three things. First, coverage: does the answer include the points you listed? Second, support: does every bracketed number point to a snippet that really says that? Third, restraint: when you include a question the sources cannot answer, does the model say so, or does it improvise? The third check catches the most embarrassing failures, and it costs little to run. At the typical price of $0.00085 per summary, a full pass over thirty questions costs about 2.6 cents.

Common mistakes

  • Asking for facts the sources lack. Without a fallback sentence the model will fill the gap. Keep the "Not found in the sources" rule.
  • Trusting citations blindly. A bracket number proves nothing by itself. Spot-check a sample of claims against the snippet it cites, and automate a check that every cited number exists in your list.
  • Mixing instructions with source text. A page may contain text that looks like a command. Keep your rules in the system message and tell the model that source text is data.
  • Ignoring the concurrency slot. If you run a worker pool larger than 8 on a full key, you will see concurrency errors. Size the pool to the limit.

To get started, claim the trial from the API key page and run the Python example above against a few real queries. The documentation covers tool calling too, which is useful if you want the model to decide when to run another search.

Questions and answers

Does the API do the searching?

No. It is a text-only chat completions endpoint. You get results from your own search source and send them in the prompt.

How many results can I send at once?

The window is 100,000 tokens for prompt and completion together. In practice ten to fifteen well-trimmed results give better summaries than a very large pile.

Can I get the summary as JSON?

Yes. Set response_format to json_object and describe the keys you want in the prompt. Validate the output before using it.

How do I avoid invented details?

Tell the model to use only the numbered sources, to cite by number, and to answer that nothing was found when the sources are silent. Use a low temperature.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.