PDF VectorPDF Vector
Back to all articles

Build an AI Research Assistant With Paper APIs

Build a research assistant that cites real papers: multi-database search, metadata, full text as Markdown, citation graphs and grounded answers, with code.

Build an AI Research Assistant With Paper APIs

An AI research assistant is only as good as the papers it reads. A chat model asked about the literature will name plausible papers that do not exist, misquote real ones and miss anything published after its training data ends. The fix is to retrieve real papers first and make the model answer from them. This guide walks through that pipeline step by step: search, metadata, full text, citation expansion and grounded answers, with working TypeScript code and an honest look at what to build yourself and what to buy.

The pipeline at a glance

  1. Search several databases for candidate papers.
  2. Resolve metadata for the papers you keep: DOI, authors, year, abstract, citation counts, open-access PDF link.
  3. Get the full text of the most relevant papers as Markdown, split by page.
  4. Expand through citations, references and similar papers to find what keyword search missed.
  5. Answer questions only from the retrieved text, citing paper and page.

Each step maps to one endpoint of PDF Vector's academic API, so the code stays short. The same structure works if you wire the sources yourself; the build-vs-buy section at the end covers that.

Step 1: Search across databases

No single database covers everything. Semantic Scholar and OpenAlex are broad, PubMed and Europe PMC cover biomedicine, arXiv covers preprints in physics, maths and computer science, ERIC covers education, Crossref covers DOI metadata and Google Scholar adds another broad index. Academic Search queries any combination of these in one call:

import { createClient } from "@pdfvector/client";

const client = createClient({ apiKey: process.env.PDFVECTOR_API_KEY! });

const question = "Does retrieval augmentation reduce hallucination in LLM question answering?";

const search = await client.academic.search({
  query: "retrieval augmented generation hallucination",
  providers: ["semantic-scholar", "openalex", "arxiv"],
  limit: 10, // per provider
  yearFrom: 2021,
  fields: ["title", "authors", "year", "doi", "abstract", "totalCitations", "pdfURL", "provider"],
});

if (search.errors?.length) {
  console.warn("Partial results:", search.errors.map((e) => `${e.provider}: ${e.message}`));
}

// The same paper can come back from several providers: keep one per DOI (or title).
const seen = new Set<string>();
const candidates = search.results.filter((p) => {
  const key = (p.doi ?? p.title ?? "").toLowerCase();
  if (!key || seen.has(key)) return false;
  seen.add(key);
  return true;
});
console.log(`${candidates.length} unique candidates`);

Three things to know. limit applies per provider, and results are merged and ranked by relevance to the query. Duplicates across providers are not removed for you, hence the filter. If a provider fails or is rate limited, you still get the others' results and an errors list.

Step 2: Choose papers and resolve metadata

Rank the candidates before spending money on full text. Abstracts are usually enough to decide; you can score them with simple keyword overlap, embeddings, or a cheap model call that rates relevance to the question.

When you start from identifiers instead (a reading list, a bibliography, DOIs pasted by a user), Academic Fetch resolves up to 100 mixed IDs per request: DOIs, PubMed IDs, arXiv IDs, Semantic Scholar IDs, ERIC IDs, Europe PMC IDs and OpenAlex IDs.

const fetched = await client.academic.fetch({
  ids: ["10.48550/arXiv.2005.11401", "2312.10997"],
  fields: ["title", "authors", "year", "doi", "abstract", "pdfURL"],
});
for (const err of fetched.errors ?? []) console.warn(`Could not resolve ${err.id}: ${err.error}`);

Store the metadata. It does not change often, and it gives every answer a proper reference.

Step 3: Get the full text

Abstracts state conclusions but not methods, sample sizes or limitations, which is what a careful answer needs. Academic Parse takes a paper ID or provider URL, finds the open-access PDF and returns Markdown. With includePages: true you also get one entry per page, which is the natural unit for retrieval and for citations.

type Chunk = { title: string; doi?: string | null; page: number; text: string };
const chunks: Chunk[] = [];

for (const paper of candidates.slice(0, 3)) {
  const id = paper.doi ?? paper.pdfURL;
  if (!id) continue;
  try {
    const parsed = await client.academic.parse(
      paper.doi ? { id: paper.doi, model: "auto", includePages: true } : { url: paper.pdfURL!, model: "auto", includePages: true },
    );
    for (const page of parsed.pages ?? []) {
      chunks.push({ title: parsed.title ?? paper.title ?? "Untitled", doi: parsed.doi, page: page.pageNumber, text: page.markdown });
    }
    console.log(`Parsed "${parsed.title}" (${parsed.pageCount} pages, ${parsed.credits} credits)`);
  } catch (error) {
    // No open-access PDF, or the PDF could not be downloaded: skip, and fall back to the abstract.
    console.warn(`Skipping ${id}:`, (error as Error).message);
  }
}

Not every paper has a legally downloadable copy. When none is found, the request fails with a clear error and no credits are charged, so your code should fall back to the abstract and say so in the answer.

Step 4: Expand through citations and similar papers

Keyword search misses papers that use different terms. Citation links do not. Two endpoints help:

  • Paper Graph returns the papers that cite a seed paper and the papers it references, as full publication records (up to 1,000 of each).
  • Similar Papers ranks related papers by citation-network similarity and returns a similarity score for each.
const seed = candidates[0]?.doi;
if (seed) {
  const graph = await client.academic.paperGraph({
    id: seed,
    citationsLimit: 50,
    referencesLimit: 50,
    fields: ["title", "year", "doi", "totalCitations"],
  });
  console.log(`${graph.paper.title}: cited by ${graph.totalCitations}, ${graph.totalReferences} references`);

  const similar = await client.academic.similarPapers({ id: seed, limit: 10 });
  for (const item of similar.results) {
    console.log(`[${item.similarity.toFixed(2)}] ${item.publication.title}`);
  }
}

A good heuristic: newer papers that cite your best seed are often the most useful follow-ups, and highly cited references are the background you should not skip.

Step 5: Answer only from retrieved text

Grounding is a prompt and a data-flow decision, not a model feature. The rules that matter:

  1. Retrieve first. Select the page chunks most relevant to the question (embeddings plus a keyword filter work well).
  2. Give the model only those chunks, each labelled with title, DOI and page.
  3. Require a citation for every claim in the form [Title, p. N], and tell the model to say "not found in the provided papers" when the sources do not answer.
  4. Check citations after generation. Every cited title and page must exist in the chunks you sent. Drop or flag anything that does not.

Here is a minimal version. Swap callModel for the LLM SDK you use:

const terms = question.toLowerCase().split(/\W+/).filter((t) => t.length > 3);
const score = (c: Chunk) => terms.filter((t) => c.text.toLowerCase().includes(t)).length;
const top = [...chunks].sort((a, b) => score(b) - score(a)).slice(0, 8);

const context = top
  .map((c) => `[${c.title}, p. ${c.page}]${c.doi ? ` (doi:${c.doi})` : ""}\n${c.text}`)
  .join("\n\n---\n\n");

const prompt = `Answer the question using ONLY the sources below.
Cite every claim as [Title, p. N]. If the sources do not answer it, say so.

Question: ${question}

Sources:
${context}`;

// const answer = await callModel(prompt);
// Then verify that each [Title, p. N] in the answer matches a chunk in `top`.

For a question about one specific paper, you can skip the retrieval step and use Document Ask on the paper's pdfURL. It answers from the whole document, at 2 to 16 credits per page depending on the tier.

The reverse direction is useful too. When a user drafts text and needs sources, Find Citations splits a paragraph into sentences and suggests papers for each, with a relevance score. It costs 2 credits per sentence.

What it costs per question

Using the credit table, one research question through this pipeline costs roughly:

StepCredits
One search (any number of providers)2
One fetch (up to 100 IDs)2
Parse three 12-page papers on mini3 x 12 x 2 = 72
Paper graph with 50 citations + 50 references2
Similar papers3

Full text dominates. Parse is billed per page at the tier used (1 on nano up to 8 on max), and with auto, a text PDF read without OCR is billed at most at the mini rate. Cache parsed papers by DOI so each one is paid for once. Your own LLM calls for the final answer are billed by your model provider. The free plan includes 100 credits per month.

Build vs buy: an honest comparison

Every source in this pipeline has a public API, and you can wire them yourself. What that involves:

  • Per-source clients. arXiv returns Atom XML and asks for one request every three seconds. Semantic Scholar wants an API key for predictable throughput, with a 1 request per second introductory rate. PubMed uses the E-utilities, OpenAlex and Crossref return JSON in their own shapes. Each needs paging, retries and a mapping to your schema.
  • Identifier resolution. Turning a DOI, PMID or arXiv ID into the right record, and the right open-access PDF, is fiddly and source-specific.
  • PDF parsing. Scientific PDFs have two columns, equations, tables and figures. Reading order and tables are where simple extractors fail.
  • Maintenance. Rate limits, response formats and terms change, and you own the breakage.

Building it yourself makes sense when you need one or two sources deeply, need fields a unified schema does not expose (Semantic Scholar embeddings, for example), run very large crawls better served by bulk datasets, or cannot send documents to a third party. Buying makes sense when you need several sources, full text and citation data quickly and prefer to spend your time on retrieval quality and the user experience. Many teams mix both: a unified API for discovery and parsing, and a direct integration for the one source they use most.

FAQ

What APIs do I need to build an AI research assistant?

At minimum: paper search, metadata lookup by identifier, full-text retrieval and parsing, and an LLM for the final answer. Citation graph and similar-paper data improve recall.

How do I stop the assistant from inventing papers?

Never let the model name papers from memory. Retrieve papers through an API, pass only their text to the model, require citations to that text, and verify each citation after generation.

Which academic databases can PDF Vector search?

Semantic Scholar, PubMed, arXiv, Google Scholar, ERIC, Europe PMC, OpenAlex and Crossref, alone or combined in one request.

Can I get the full text of any paper?

Only papers with a downloadable open-access copy. When no copy can be found, Academic Parse returns an error, no credits are charged, and you can fall back to the abstract.

How much does one research question cost?

Search, fetch and citation steps cost a few credits each. Full-text parsing is the main cost: 1 to 8 credits per page depending on the tier, so caching parsed papers matters.

Should I build my own pipeline or use an API?

Build when you depend on one or two sources deeply or need source-specific data. Use a unified API when you need many sources, full text and citations without maintaining each integration.


Sources (checked 2026-11-11): https://www.pdfvector.com/academic-search, https://www.npmjs.com/package/@pdfvector/client, https://info.arxiv.org/help/api/tou.html, https://www.semanticscholar.org/product/api