Skip to main content

LlamaIndex Managed Integration: Vectara

The Vectara Index provides a simple implementation to Vectara's end-to-end RAG pipeline, including data ingestion, document retrieval, reranking results, summary generation, and hallucination evaluation.

Please note that this documentation applies to versions >= 0.4.0 and will not be the same as for earlier versions of Vectara ManagedIndex.

📌 Setup

First, make sure you have the latest LlamaIndex version installed.

pip install -U llama-index

Next, install the Vectara Index:

pip install -U llama-index-indices-managed-vectara

Finally, set up your Vectara corpus. If you don't have a Vectara account, you can sign up and follow our Quick Start guide to create a corpus and an API key (make sure the api_key has both indexing and query permissions, or use your personal API key).

Once you have your API key, export it as an environment variable:

import os

os.environ["VECTARA_API_KEY"] = "<YOUR_VECTARA_API_KEY>"
os.environ["VECTARA_CORPUS_KEY"] = "<YOUR_VECTARA_CORPUS_KEY>"

🚀 Usage

1. Index Documents

Create an index and add some sample documents:

from llama_index.indices.managed.vectara import VectaraIndex
from llama_index.core.schema import Document, MediaResource

docs = [
    Document(
        id_="doc1",
        text_resource=MediaResource(
            text="""
            This is test text for Vectara integration with LlamaIndex.
            Users should love their experience with this integration
            """,
        ),
    ),
    Document(
        id_="doc2",
        text_resource=MediaResource(
            text="""
            The Vectara index integration with LlamaIndex implements Vectara's RAG pipeline.
            It can be used both as a retriever and query engine.
            """,
        ),
    ),
]
index = VectaraIndex.from_documents(docs)

Make sure to always specify a unique id_ for every document you add to your index. If you don't specify this parameter, a random id will be generated and the document will be separately added to your corpus every time you run your code.

You can now use this index to retrieve documents.

2. Retrieve Documents

Retrieve the top 2 most relevant document for a query:

# Retrieves the top search result
retriever = index.as_retriever(similarity_top_k=2)

results = retriever.retrieve("How will users feel about this new tool?")
print(results[0])

3. Use as a Query Engine

Generate a summary of retrieved results:

query_engine = index.as_query_engine()

results = query_engine.query(
    "Which company has partnered with Vectara to implement their RAG pipeline as an index?"
)
print(f"Generated summary: {results.response}\n")
print("Top sources:")
for node in results.source_nodes[:2]:
    print(node)

📂 Understanding source_nodes structure

Each node object in source_nodes contains a NodeWithScore object with:

  • text: The matched text snippet.
  • id_: The unique identifier of the document.
  • metadata: A dictionary containing:
    • Key-value pairs from the matched part of the document.
    • A document key that stores all document-level metadata.
  • score: The relevance score of the match.

Example Output:

NodeWithScore(
    node=Node(
        text_resource=MediaResource(
            text="This is a test text for Vectara integration with LlamaIndex."
        ),
        id_="doc1",
        metadata={
            "category": "AI",
            "page": 23,
            "document": {
                "url": "https://www.vectara.com/developers/build/integrations/llamaindex",
                "title": "LlamaIndex + Vectara Integration",
                "author": "Ofer Mendelevitch",
                "date": "2025-03-01"
            }
        }
    ),
    score=0.89
)

If you want to see the full features and capabilities of VectaraIndex, check out this Jupyter notebook.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_indices_managed_vectara-0.7.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_indices_managed_vectara-0.7.0.tar.gz.

File metadata

  • Download URL: llama_index_indices_managed_vectara-0.7.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_indices_managed_vectara-0.7.0.tar.gz
Algorithm Hash digest
SHA256 b142a34c3cf9eef4889884236e96e8d23d942c8b78b11531201f999a195cefa3
MD5 649019a20c73083308d8fd72d5aaf41b
BLAKE2b-256 b9b6104b0b8b0eec9a49faf589a401053d1c7cc4ea6f0e89c09a3fb44e5f49f5

See more details on using hashes here.

File details

Details for the file llama_index_indices_managed_vectara-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_indices_managed_vectara-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_indices_managed_vectara-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a7e023bcd7fd8ebc6443f3b5b31379c6a8beae9cd8f00b7e5c607fbed5f36ce
MD5 0e952e144a9ff378630bdda8f1504ddc
BLAKE2b-256 ede988968c524ae87d32d3bfbe268f33b38ef3e1ecac1ca9c659e1a563f324b1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page