Skip to main content
VoltAgent is an open-source TypeScript framework for building AI agents with modular tools, LLM orchestration, and flexible multi-agent systems. It features a built-in, n8n-style observability console that lets you visually inspect agent behavior, trace actions, and debug with ease.

Installation

Create a new VoltAgent project with Chroma integration:
This creates a complete VoltAgent + Chroma setup with sample data and two different agent configurations. Install the dependencies:
Next, you’ll need to launch a Chroma server instance.
The server will be available at http://localhost:8000. Note: For production deployments, you might prefer Chroma Cloud, a fully managed hosted service. See the Environment Setup section below for cloud configuration.

Environment Setup

Create a .env file with your configuration:

Option 1: Local Chroma Server

Option 2: Chroma Cloud

The code will automatically detect which configuration to use based on the presence of CHROMA_API_KEY.

Run Your Application

Start your VoltAgent application:
You’ll see:

Interact with Your Agents

Your agents are now running! To interact with them:
  1. Open the Console: Click the https://console.voltagent.dev link in your terminal output (or copy-paste it into your browser).
  2. Find Your Agents: On the VoltOps LLM Observability Platform page, you should see both agents listed:
    • “Assistant with Retriever”
    • “Assistant with Tools”
  3. Open Agent Details: Click on either agent’s name.
  4. Start Chatting: On the agent detail page, click the chat icon in the bottom right corner to open the chat window.
  5. Test RAG Capabilities: Try questions like:
    • “What is VoltAgent?”
    • “Tell me about vector databases”
    • “How does TypeScript help with development?”
VoltAgent with Chroma Demo Your AI agents will provide answers containing pertinent details from your Chroma knowledge base, accompanied by citations that reveal which source materials were referenced during response generation.

How It Works

A quick look under the hood and how to customize it.

Create the Chroma Retriever

Create src/retriever/index.ts:
Essential Elements Breakdown:
  • ChromaClient/CloudClient: Connects to your local Chroma server or Chroma Cloud
  • Automatic Detection: Uses CloudClient if CHROMA_API_KEY is set, otherwise falls back to local ChromaClient
  • OpenAIEmbeddingFunction: Uses OpenAI’s embedding models to convert text into vectors
  • Collection: A named container for your documents and their embeddings

Initialize Sample Data

Add sample documents to get started:
What This Does:
  • Establishes a collection using OpenAI’s embedding functionality
  • Adds sample documents with metadata
  • Uses upsert to avoid duplicate documents
  • Automatically generates embeddings for each document

Implement the Retriever Class

Create the main retriever class:
Key Features:
  • Input Handling: Supports both string and message array inputs
  • Semantic Search: Uses Chroma’s vector similarity search
  • User Context: Tracks references for transparency
  • Error Handling: Graceful fallbacks for search failures

Create Your Agents

Now create agents using different retrieval patterns in src/index.ts:

Usage Patterns

Automatic Retrieval

The first agent automatically searches before every response:

Tool-Based Retrieval

The second agent only searches when it determines it’s necessary:

Accessing Sources in Your Code

You can access the sources that were used in the retrieval from the response:
Or when using streamText:
This integration provides a solid foundation for adding semantic search capabilities to your VoltAgent applications. The combination of VoltAgent’s flexible architecture and Chroma’s powerful vector search creates a robust RAG system that can handle real-world knowledge retrieval needs.