AI Framework Integration · Quickstart Guide

LlamaIndex + xBind: Identity-Based RAG

Build secure retrieval-augmented generation systems with zero-config identity. LlamaIndex handles vector search and document retrieval; xBind eliminates API keys with Ed25519-based DIDs and XorIDA threshold sharing for encrypted document storage.

01. Installation

Install the Package

Install the LlamaIndex xBind adapter via npm:

npm install @private.me/llamaindex-xbind

Or using pnpm:

pnpm add @private.me/llamaindex-xbind

Dependencies are resolved automatically in monorepo workspaces:

@private.me/xbind
@private.me/xregistry
@private.me/crypto
@private.me/shared
02. Quick Start

Basic RAG Agent with Identity

Create a secure RAG system in four steps:

import { LlamaIndexxBindAgent } from '@private.me/llamaindex-xbind';

// 1. Create RAG agent
const agent = new LlamaIndexxBindAgent({
  name: 'ResearchAssistant',
  description: 'RAG system for scientific papers',
  chunkSize: 512,
  chunkOverlap: 50,
  similarityTopK: 3,
  verbose: true,
});

// 2. Initialize identity (zero-config)
await agent.initialize();
console.log('Agent DID:', agent.getDID());

// 3. Ingest documents (encrypted)
await agent.ingestDocument({
  documentId: 'paper-001',
  content: 'Quantum computing research paper...',
  metadata: { author: 'Smith et al.', year: 2024 },
  encrypted: true,
});

// 4. Query with secure retrieval
const result = await agent.query({
  queryId: 'query-001',
  agentDid: agent.getDID(),
  query: 'What are the latest advances in quantum error correction?',
  timestamp: Date.now(),
});

if (result.ok) {
  console.log('Response:', result.value.response);
  console.log('Sources:', result.value.sources);
}

Zero-config identity: No API keys, no OAuth flows, no credential management. The agent generates an Ed25519 DID automatically on first initialization.

Multi-Agent RAG Collaboration

Multiple specialized RAG agents can securely share query results:

import { LlamaIndexxBindAgent } from '@private.me/llamaindex-xbind';

// Create specialized RAG agents
const legalAgent = new LlamaIndexxBindAgent({
  name: 'LegalRAG',
  description: 'Legal document retrieval',
  chunkSize: 1024,
});

const medicalAgent = new LlamaIndexxBindAgent({
  name: 'MedicalRAG',
  description: 'Medical research retrieval',
  chunkSize: 512,
});

// Initialize all agents
await Promise.all([
  legalAgent.initialize(),
  medicalAgent.initialize(),
]);

// Medical agent performs query
const medicalQuery = await medicalAgent.query({
  queryId: 'med-001',
  agentDid: medicalAgent.getDID(),
  query: 'Latest cancer treatment protocols',
  timestamp: Date.now(),
});

if (medicalQuery.ok) {
  // Share results with legal agent (for compliance review)
  const sharedResult = await medicalAgent.shareQueryResult(
    legalAgent.getDID(),
    medicalQuery.value.response,
  );

  // Legal agent receives and verifies
  const received = await legalAgent.receiveSharedResult(
    sharedResult.value.shares,
    sharedResult.value.hmacKeys,
    sharedResult.value.hmacSignatures,
  );

  console.log('Legal agent received:', received.value);
}

Encrypted Document Ingestion Pipeline

Ingest documents with XorIDA threshold sharing for information-theoretic security:

const agent = new LlamaIndexxBindAgent({
  name: 'SecureIngestor',
  description: 'Encrypted document ingestion',
  chunkSize: 512,
  chunkOverlap: 50,
});

await agent.initialize();

// Ingest with XorIDA encryption
const documents = [
  { id: 'doc-001', content: 'Confidential report...' },
  { id: 'doc-002', content: 'Internal memo...' },
  { id: 'doc-003', content: 'Strategic plan...' },
];

for (const doc of documents) {
  const result = await agent.ingestDocument({
    documentId: doc.id,
    content: doc.content,
    encrypted: true, // XorIDA-split storage
  });

  if (result.ok) {
    console.log(`✓ ${doc.id} ingested securely`);
  }
}

// Query encrypted index
const queryResult = await agent.query({
  queryId: 'secure-001',
  agentDid: agent.getDID(),
  query: 'Summarize strategic objectives',
  timestamp: Date.now(),
});

console.log('Secure query result:', queryResult.value?.response);
03. Key Benefits

Why xBind for LlamaIndex?

Zero-Config Identity

Ed25519 DIDs generated automatically. No API keys, no tokens, no credential rotation.

Encrypted Document Storage

Documents split into chunks, each chunk XorIDA-encrypted. Information-theoretic security.

Secure Retrieval

Query results threshold-shared (2-of-3, 3-of-5). Any k shares reconstruct, fewer than k reveal nothing.

HMAC-Verified Results

All shares have HMAC-SHA256 signatures. Verification happens before reconstruction (fail closed).

Audit Trails

Every query and ingestion logged with HMAC-chained entries. Tamper-evident audit history.

Multi-Agent Collaboration

Specialized RAG agents can securely share query results without exposing underlying documents.

04. Migration Guide

From Traditional LlamaIndex

Before (API keys):

import { VectorStoreIndex, OpenAI } from 'llamaindex';

const llm = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const index = await VectorStoreIndex.fromDocuments(docs, { llm });
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query('What is...?');

After (xBind identity):

import { LlamaIndexxBindAgent } from '@private.me/llamaindex-xbind';

const agent = new LlamaIndexxBindAgent({
  name: 'RAGAgent',
  description: 'Secure RAG system',
});

await agent.initialize(); // Zero-config identity

for (const doc of docs) {
  await agent.ingestDocument({
    documentId: doc.id,
    content: doc.content,
    encrypted: true,
  });
}

const result = await agent.query({
  queryId: 'q1',
  agentDid: agent.getDID(),
  query: 'What is...?',
  timestamp: Date.now(),
});

Key Differences

1. No API keys: Identity is cryptographically generated (Ed25519).

2. Encrypted storage: Documents are XorIDA-split by default.

3. Secure retrieval: Query results can be threshold-shared between agents.

4. Built-in audit: Every query and ingestion is logged with HMAC verification.

05. Security Model

XorIDA Threshold Sharing

Query results split into n shares where any k can reconstruct:

2-of-3: Protects against 1 share compromise
3-of-5: Protects against 2 share compromises
Information-theoretic: Fewer than k shares reveal NOTHING

Encrypted Document Storage

Documents are split into chunks, each chunk is XorIDA-encrypted:

Document → Chunks → XorIDA Split → Encrypted Index

Retrieval requires reconstructing shares from multiple sources.

HMAC Verification

All shares have HMAC-SHA256 signatures. Verification happens BEFORE reconstruction (fail closed). If any share fails verification, the entire reconstruction is rejected.

Ed25519 DIDs

Agent identities use Ed25519:

256-bit security · Fast signing/verification · Standard DID format: did:key:z...

AI AGENT BENEFITS

Why AI Agents Choose xBind

xBind reduces cognitive load for AI agents by consolidating authentication into a single package. Instead of navigating 36 error surfaces across 5-10 fragmented packages, agents work with one unified interface.

Lower Cognitive Load
1 error surface instead of 36. AI agents spend less time debugging authentication failures.
Fewer Integration Points
2 steps (quickstart + connect) instead of 9-step OAuth dance. Faster time to first successful call.
70% Lower Token Cost
240 tokens to debug xBind errors vs 800 tokens for fragmented packages. Better economics for LLM-driven workflows.
Actionable Errors
RFC 7807 structured errors with field-level validation. AI agents receive machine-readable guidance, not generic messages.

Integration Complexity Comparison

Metric Fragmented (5-10 packages) xBind (1 package) Improvement
Token Cost to Debug 800 tokens 240 tokens 70% lower
Error Surfaces 36 1 97% reduction
Recovery Time 132.8ms 45.9ms 65% faster
Setup Steps 9 2 77% fewer
AI AGENT OPTIMIZATION

xBind was designed from the ground up for AI agent consumption. Structured errors, minimal setup, and zero credential rotation make it the natural choice for LLM-driven workflows.

06. Purchase & Subscription

Purchase & Subscription

Pricing

Standard pricing: $5/month Basic • $10/month Pro • $15/month Enterprise

Tier Price Features
Basic $5/month LlamaIndex integration, identity-based RAG, encrypted document storage
Pro $10/month Everything in Basic + multi-agent collaboration, advanced access control
Enterprise $15/month Everything in Pro + air-gapped deployment + white-label

3-month trial - No credit card required

Start Free Trial

API Purchase Endpoint

curl -X POST https://private.me/api/purchase \
  -H "Content-Type: application/json" \
  -d '{
    "product": "llamaindex-xbind",
    "tier": "basic",
    "customer": {
      "email": "user@example.com",
      "connection_id": "conn_abc123"
    }
  }'

Error Handling

All errors follow RFC 7807 Problem Details format:

{
  "type": "https://private.me/errors/invalid-tier",
  "title": "Invalid subscription tier",
  "status": 400,
  "fields": {
    "tier": "Provided value 'premium' is not valid"
  }
}
07. Resources

Next Steps

Package Documentation: @private.me/llamaindex-xbind README

xBind Core: xBind White Paper — Machine-to-machine identity layer

Pricing: 3-month free trial → $5/month Basic, $10/month Pro, $15/month Enterprise

Examples: See packages/llamaindex-xbind/examples/ for quickstart and production setups

Support: contact@private.me