Llama-Index Managed Llama Cloud Indices

0.11.1 · active · verified Thu Apr 09

This library provides integration for LlamaIndex to create, manage, and query indices hosted on Llama Cloud. It enables persistent, scalable, and production-ready Retrieval-Augmented Generation (RAG) solutions without needing to manage vector databases or other infrastructure directly. The current version is `0.11.1`, and it follows the frequent release cadence of the broader LlamaIndex ecosystem, often tied to Llama Cloud service updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `LlamaCloudIndex`, optionally providing documents for ingestion, and then querying it. It assumes the `LLAMA_CLOUD_API_KEY` environment variable is set for authentication with Llama Cloud.

import os
from llama_index.indices.managed.llama_cloud import LlamaCloudIndex
from llama_index.core.schema import Document

# Set your Llama Cloud API key as an environment variable
# You can obtain one from app.llamacloud.ai
api_key = os.environ.get("LLAMA_CLOUD_API_KEY", "")
if not api_key:
    print("Warning: LLAMA_CLOUD_API_KEY environment variable not set. The example will not fully function without it.")

# Define some documents to be indexed
documents = [
    Document(text="The quick brown fox jumps over the lazy dog."),
    Document(text="LlamaIndex helps build LLM applications with external data.")
]

# Create a new managed index or connect to an existing one by name.
# If the index 'my_managed_index_example' doesn't exist, it will be created.
# If it exists, the documents will be upserted.
print(f"Attempting to create/connect to Llama Cloud Index 'my_managed_index_example'...")
index = LlamaCloudIndex.from_documents(
    documents,
    name="my_managed_index_example", # Use a unique name for your index
    api_key=api_key
)
print(f"Successfully connected to Llama Cloud Index: {index.index_name}")

# Query the index using a query engine
query_engine = index.as_query_engine()
query_text = "What does LlamaIndex help with?"
print(f"\nQuery: {query_text}")
response = query_engine.query(query_text)
print(f"Response: {response}")

view raw JSON →