← Blog

How to Build a Claude-Powered Research Assistant App

2026-11-05 · 5 min read · SubToAPI Team

Building a Claude-powered research assistant app means combining a reasoning model with retrieval, tool use, and a structured conversation flow so it can gather information, synthesize it, and cite sources instead of just producing a confident-sounding paragraph. The core architecture is simpler than it looks: you need a search or retrieval layer, a way for Claude to call that layer as a tool, a system prompt that constrains how it reasons over results, and an API layer that handles streaming and usage tracking.

This article walks through the full stack — from defining the research loop to wiring up tool calls and streaming responses to a frontend — using patterns that work whether you're building a browser extension, an internal knowledge tool, or a public SaaS product.

What a research assistant actually needs to do

A research assistant is not just a chatbot with a longer system prompt. It needs to:

Claude handles the decomposition and synthesis well out of the box, but the retrieval and iteration loop is something you build around it using tool use.

Step 1: Design the tool schema for retrieval

The cleanest way to give Claude research capability is through a search tool (web search, vector DB lookup, or an internal API) and optionally a fetch_page tool for pulling full content from a specific URL.

{
  "name": "search",
  "description": "Search the web or knowledge base for relevant sources on a topic",
  "input_schema": {
    "type": "object",
    "properties": {
      "query": { "type": "string", "description": "The search query" },
      "max_results": { "type": "integer", "default": 5 }
    },
    "required": ["query"]
  }
}

Keep the schema minimal. Claude will call search multiple times across a conversation if the first set of results isn't sufficient — that's expected behavior, not a bug to suppress. Your job is to make each tool call cheap and fast on your backend so multiple round trips don't feel slow to the user.

Step 2: Write a system prompt that enforces research discipline

Without guidance, models tend to answer from memory even when a search tool is available. Be explicit:

You are a research assistant. For any factual claim that could be
outdated or requires a source, use the search tool before answering.
Always cite sources inline using [1], [2] format, and list full
references at the end of your response. If search results conflict,
say so explicitly rather than picking one silently.

This single instruction block is responsible for most of the quality difference between "a chatbot that sounds smart" and "an assistant that actually did research."

Step 3: Wire up the tool-use loop

The research loop is a standard tool-use pattern: send the user's question, let Claude decide whether to call search, execute the search server-side, return the results as a tool result, and repeat until Claude produces a final text answer.

async function runResearchTurn(messages) {
  const res = await fetch("https://api.subtoapi.app/v1/messages", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "claude-sonnet-4-5",
      max_tokens: 1024,
      system: RESEARCH_SYSTEM_PROMPT,
      tools: [searchTool, fetchPageTool],
      messages
    })
  });

  const data = await res.json();

  if (data.stop_reason === "tool_use") {
    const toolCall = data.content.find(b => b.type === "tool_use");
    const result = await executeSearch(toolCall.input.query);

    messages.push({ role: "assistant", content: data.content });
    messages.push({
      role: "user",
      content: [{
        type: "tool_result",
        tool_use_id: toolCall.id,
        content: JSON.stringify(result)
      }]
    });

    return runResearchTurn(messages); // recurse until final answer
  }

  return data;
}

This recursive loop is the whole engine. Everything else — UI, memory, citation formatting — is built around it.

Step 4: Stream the final synthesis to the frontend

Tool calls themselves don't need to stream (they're fast, internal steps), but the final synthesis — where Claude writes the actual research summary — should stream so users see progress instead of staring at a spinner for 10+ seconds.

const stream = await fetch("https://api.subtoapi.app/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    max_tokens: 1024,
    stream: true,
    system: RESEARCH_SYSTEM_PROMPT,
    messages
  })
});

Details on handling the event stream and reconnecting on drops are covered in the streaming docs.

Step 5: Handle multi-turn memory and follow-up questions

Research assistants are almost always used conversationally — a user asks a follow-up, challenges a claim, or asks to go deeper on one source. Keep the full message history (including prior tool calls and results) in context rather than summarizing it away; Claude uses the trail of searches it already performed to avoid repeating queries.

If conversations get long, trim older tool-result blocks first (they're usually large JSON blobs) while keeping the assistant's text summaries, which carry most of the useful signal at a fraction of the token cost.

Where SubToAPI fits

If you're building this as a real product rather than a prototype, you still need API keys, usage metering per user or team, and a way to track how many research queries (and tokens) each customer burns through. SubToAPI turns your Claude access into a standard HTTPS API with application keys (sub_live_...), per-key usage metadata, and built-in streaming and tool-use support, so you're not building billing and key management infrastructure on top of your research logic. Check the tool use guide and the quickstart to see the request format, or start with the messages docs if you're wiring up the core loop described above. Plans start at €9/month with a free trial — see pricing or go straight to signup.

Common mistakes to avoid

Questions

Does Claude need a dedicated search API to act as a research assistant? Yes, for anything beyond its training knowledge. Pair it with any search or retrieval API via tool use — Claude decides when to call it and how to use the results.

How many tool-use round trips should a research query take? Most questions resolve in 1–3 search calls. If Claude is looping more than 4–5 times, tighten the system prompt or check that your search results are actually relevant.

Can this run as a real-time chat experience? Yes — tool calls run quickly server-side, and the final synthesized answer streams token by token, so the UX feels responsive even with multiple search steps happening underneath.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →