How to build a text summarizer with Vikasit AI
A summarizer condenses long text into a short, faithful summary. For very long inputs, summarize in chunks and then summarize the summaries (map-reduce) to stay within the context window.
Recommended model
Vikasit 3 Flash
Fast and cheap for high-volume summarization. Move to Vikasit 3 when you need more nuanced, abstractive summaries.
Steps
- 1
Decide the summary style: length, bullet vs paragraph, and audience.
- 2
If the text fits in context, summarize it in a single call.
- 3
For long text, split into chunks and summarize each (the map step).
- 4
Concatenate the chunk summaries and summarize them again (the reduce step).
- 5
Add a system prompt that enforces faithfulness — no invented facts.
- 6
Cap output length with max_tokens for predictable cost.
Code
The Vikasit Inference API is OpenAI-compatible, so this uses the standard OpenAI Python SDK pointed at https://api.vikasit.ai/v1.
from openai import OpenAI
client = OpenAI(
base_url="https://api.vikasit.ai/v1",
api_key="sk-vikasit-...", # get one at vikasit.ai/auth
)
def summarize(text: str, words: int = 100) -> str:
resp = client.chat.completions.create(
model="vikasit-3-flash",
messages=[
{
"role": "system",
"content": f"Summarize faithfully in about {words} words. No new facts.",
},
{"role": "user", "content": text},
],
)
return resp.choices[0].message.contentBuild your text summarizer today
Get an API key and 2M free tokens a day on Vikasit Nova. Pay-as-you-go, no minimums, OpenAI-compatible.