Start

Use it in LangChain or LlamaIndex

Install the wikivectors Python package from PyPI and WikiVectors becomes a retriever: fresh Wikipedia paragraphs, each with its link and revision. Put your key in WIKIVECTORS_KEY. Each call is one Search.

# pip install "wikivectors[langchain]"
from wikivectors.langchain import WikiVectorsRetriever

retriever = WikiVectorsRetriever(k=3)
for doc in retriever.invoke("who won the 2026 FIFA World Cup"):
    print(doc.metadata["title"], doc.metadata["permalink"])

The same package covers the whole API: wv.search, wv.answer, wv.pages, wv.facts, wv.similar, wv.changes and more. Plain install: pip install wikivectors (PyPI)

JavaScript and TypeScript

For Node 18+, Next.js, the Vercel AI SDK, Deno, Bun or edge code: npm install wikivectors (npm). No other packages, types included, same calls as Python.

import { WikiVectors } from "wikivectors";

const wv = new WikiVectors(); // reads WIKIVECTORS_KEY
for (const p of await wv.search("who won the 2026 FIFA World Cup", { limit: 3 })) {
  console.log(p.title, p.permalink);
}

Also wv.answer, wv.pages, wv.facts, wv.identify, wv.titles, wv.similar, wv.changes and wv.watch.

LangChain.js: the same package has a retriever. Add @langchain/core and import it from wikivectors/langchain.

// npm install wikivectors @langchain/core
import { WikiVectorsRetriever } from "wikivectors/langchain";

const retriever = new WikiVectorsRetriever({ k: 3 }); // reads WIKIVECTORS_KEY
for (const doc of await retriever.invoke("who was the first woman in space")) {
  console.log(doc.metadata.title, doc.metadata.permalink);
}

No install: paste one small class

Rather not add a package? This class does the same with requests.

# pip install langchain-core requests
import os, requests
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever

class WikiVectorsRetriever(BaseRetriever):
    """Fresh English Wikipedia paragraphs, each with its link and revision."""
    api_key: str = os.environ.get("WIKIVECTORS_KEY", "")
    k: int = 5

    def _get_relevant_documents(self, query, *, run_manager=None):
        r = requests.post(
            "https://wikivectors.com/v1/search",
            headers={"Authorization": f"Bearer {self.api_key}"},
            json={"query": query, "limit": self.k},
            timeout=30,
        )
        r.raise_for_status()
        return [
            Document(page_content=p["text"], metadata={
                "title": p["title"], "url": p["url"],
                "permalink": p["permalink"], "revision_id": p["revision_id"],
                "attribution": p["attribution"], "score": p["score"]})
            for p in r.json()["results"]
        ]

retriever = WikiVectorsRetriever(k=3)
for doc in retriever.invoke("who won the 2026 FIFA World Cup"):
    print(doc.metadata["title"], doc.metadata["permalink"])

What you get back

A list of paragraphs, best first. The text is the paragraph. The metadata holds the page title, its url, a permalink to the exact revision, and an attribution line. Wikipedia text is CC BY-SA 4.0, so show the attribution, or at least the link, wherever you show the text. All fields: Result fields.

Tips

Use it like any other retriever: in a chain, or as a tool for an agent. Keep k between 3 and 10; more paragraphs cost no more, but they make the prompt longer. Want a short answer with sources instead of paragraphs? Call Answer. Tested on November 28, 2026 with langchain-core 1.8 and llama-index-core 0.14.

Using Claude, Cursor or another AI tool instead? See Use it in Claude or Cursor.