Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Elevenlabs Elevenlabs python RagConfig

From Leeroopedia
Field Value
source Elevenlabs_Elevenlabs_python
domains Conversational AI, RAG, Knowledge Retrieval, Embeddings
last_updated 2026-02-15

Overview

Description

RagConfig is a Pydantic model that defines the Retrieval-Augmented Generation (RAG) configuration for a conversational AI agent in the ElevenLabs platform. It controls how knowledge base documents are retrieved and used during conversations, including the embedding model, vector distance thresholds, document chunk limits, and custom query rewriting prompts.

This model is auto-generated by Fern from the ElevenLabs API definition and inherits from UncheckedBaseModel. It enables fine-grained control over the RAG pipeline to optimize relevance and performance of knowledge-grounded responses.

Usage

RagConfig is used within PromptAgentApiModelInput to configure how an agent retrieves and utilizes knowledge base content during conversations. It is essential for agents that need to answer questions based on uploaded documents or knowledge bases.

Code Reference

Source Location

src/elevenlabs/types/rag_config.py

Class Signature

class RagConfig(UncheckedBaseModel):
    ...

Import Statement

from elevenlabs.types import RagConfig

I/O Contract

Field Type Required Description
enabled Optional[bool] No Whether RAG is enabled for the agent.
embedding_model Optional[EmbeddingModelEnum] No The embedding model to use for vector search.
max_vector_distance Optional[float] No Maximum vector distance of retrieved chunks.
max_documents_length Optional[int] No Maximum total length of document chunks retrieved from RAG.
max_retrieved_rag_chunks_count Optional[int] No Maximum number of RAG document chunks to initially retrieve from the vector store. These are then further filtered by vector distance and total length.
query_rewrite_prompt_override Optional[str] No Custom prompt for rewriting user queries before RAG retrieval. The conversation history will be automatically appended at the end. If not set, the default prompt will be used.

Usage Examples

Basic RAG Configuration

from elevenlabs.types import RagConfig

rag = RagConfig(
    enabled=True,
    max_documents_length=5000,
    max_vector_distance=0.8,
)

Advanced RAG with Custom Query Rewriting

from elevenlabs.types import RagConfig

rag = RagConfig(
    enabled=True,
    max_documents_length=10000,
    max_retrieved_rag_chunks_count=20,
    max_vector_distance=0.7,
    query_rewrite_prompt_override=(
        "Given the conversation history, rewrite the user's latest query "
        "into a standalone search query that captures the user's intent. "
        "Focus on key entities and concepts."
    ),
)

Using RAG in Agent Prompt Configuration

from elevenlabs.types import PromptAgentApiModelInput, RagConfig

prompt_config = PromptAgentApiModelInput(
    prompt="You are a support agent. Use the knowledge base to answer questions.",
    rag=RagConfig(
        enabled=True,
        max_documents_length=8000,
        max_retrieved_rag_chunks_count=15,
    ),
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment