Implementation:Elevenlabs Elevenlabs python ConversationalAIRawClient
| Field | Value |
|---|---|
| Sources | src/elevenlabs/conversational_ai/raw_client.py, src/elevenlabs/conversational_ai/client.py
|
| Domains | Conversational AI, Knowledge Base, RAG Indexing |
| Last Updated | 2026-02-15 |
Overview
The RawConversationalAiClient provides the low-level HTTP implementation for the Conversational AI namespace in the ElevenLabs API. It handles knowledge base document management and RAG (Retrieval-Augmented Generation) index operations. Unlike the high-level ConversationalAiClient which returns parsed model objects, the raw client returns HttpResponse wrapper objects that include both the parsed data and the full HTTP response metadata (status code, headers, etc.).
The raw client is accessible via client.conversational_ai.with_raw_response. The high-level ConversationalAiClient also serves as a namespace that provides lazy access to 17 sub-clients: conversations, twilio, whatsapp, agents, tests, phone_numbers, llm_usage, knowledge_base, tools, settings, secrets, batch_calls, sip_trunk, mcp_servers, whatsapp_accounts, analytics, and dashboard.
Both synchronous (RawConversationalAiClient) and asynchronous (AsyncRawConversationalAiClient) variants are provided.
API Endpoints
| Method | HTTP | Endpoint |
|---|---|---|
add_to_knowledge_base() |
POST | v1/convai/knowledge-base
|
rag_index_overview() |
GET | v1/convai/knowledge-base/rag-index
|
get_document_rag_indexes() |
GET | v1/convai/knowledge-base/{documentation_id}/rag-index
|
delete_document_rag_index() |
DELETE | v1/convai/knowledge-base/{documentation_id}/rag-index/{rag_index_id}
|
Code Reference
Source Location
- Raw client:
src/elevenlabs/conversational_ai/raw_client.py - High-level client:
src/elevenlabs/conversational_ai/client.py
Class Signatures
class RawConversationalAiClient:
def __init__(self, *, client_wrapper: SyncClientWrapper): ...
class AsyncRawConversationalAiClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper): ...
Import
The raw client is accessed through the high-level client's with_raw_response property:
from elevenlabs import ElevenLabs
client = ElevenLabs(api_key="YOUR_API_KEY")
raw_client = client.conversational_ai.with_raw_response # RawConversationalAiClient instance
I/O Contract
add_to_knowledge_base()
Upload a file or webpage URL to create a knowledge base document. After creating the document, update the agent's knowledge base by calling the Update agent endpoint.
Input Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id |
typing.Optional[str] |
No | The agent ID to associate this document with (passed as query parameter) |
name |
typing.Optional[str] |
No | A custom, human-readable name for the document |
url |
typing.Optional[str] |
No | URL to a page of documentation that the agent will have access to |
file |
typing.Optional[core.File] |
No | File to upload as a knowledge base document |
request_options |
typing.Optional[RequestOptions] |
No | Request-specific configuration |
Output:
| Type (Raw) | Type (High-level) | Description |
|---|---|---|
HttpResponse[AddKnowledgeBaseResponseModel] |
AddKnowledgeBaseResponseModel |
Created knowledge base document details |
rag_index_overview()
Provides total size and other information of RAG indexes used by knowledgebase documents.
Input Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
request_options |
typing.Optional[RequestOptions] |
No | Request-specific configuration |
Output:
| Type (Raw) | Type (High-level) | Description |
|---|---|---|
HttpResponse[RagIndexOverviewResponseModel] |
RagIndexOverviewResponseModel |
Overview of RAG index usage and total sizes |
get_document_rag_indexes()
Provides information about all RAG indexes of the specified knowledgebase document.
Input Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
documentation_id |
str |
Yes | The id of a document from the knowledge base. Returned on document addition. |
request_options |
typing.Optional[RequestOptions] |
No | Request-specific configuration |
Output:
| Type (Raw) | Type (High-level) | Description |
|---|---|---|
HttpResponse[RagDocumentIndexesResponseModel] |
RagDocumentIndexesResponseModel |
All RAG indexes for the specified document |
delete_document_rag_index()
Delete a RAG index for a knowledgebase document.
Input Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
documentation_id |
str |
Yes | The id of a document from the knowledge base. Returned on document addition. |
rag_index_id |
str |
Yes | The id of the RAG index of the document from the knowledge base. |
request_options |
typing.Optional[RequestOptions] |
No | Request-specific configuration |
Output:
| Type (Raw) | Type (High-level) | Description |
|---|---|---|
HttpResponse[RagDocumentIndexResponseModel] |
RagDocumentIndexResponseModel |
Deleted RAG index details |
Error Handling
All methods may raise:
UnprocessableEntityError(HTTP 422) -- contains anHttpValidationErrorbody with validation details.ApiError-- for all other non-2xx HTTP status codes.
Sub-Client Properties (High-Level Client)
The ConversationalAiClient provides lazy access to the following sub-clients:
| Property | Description |
|---|---|
conversations |
Manage conversations |
twilio |
Twilio integration |
whatsapp |
WhatsApp integration |
agents |
Manage conversational AI agents |
tests |
Test conversational AI agents |
phone_numbers |
Manage phone numbers |
llm_usage |
LLM usage tracking |
knowledge_base |
Knowledge base management |
tools |
Manage agent tools |
settings |
Conversational AI settings |
secrets |
Manage secrets |
batch_calls |
Batch call operations |
sip_trunk |
SIP trunk configuration |
mcp_servers |
MCP server management |
whatsapp_accounts |
WhatsApp account management |
analytics |
Analytics and reporting |
dashboard |
Dashboard data access |
Usage Examples
Add a Document to Knowledge Base (High-Level)
from elevenlabs import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
response = client.conversational_ai.add_to_knowledge_base(
agent_id="agent_id",
)
Add a Document via URL
from elevenlabs import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
response = client.conversational_ai.add_to_knowledge_base(
agent_id="agent_id",
name="Product Documentation",
url="https://docs.example.com/product-guide",
)
Get RAG Index Overview
from elevenlabs import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
overview = client.conversational_ai.rag_index_overview()
Get Document RAG Indexes
from elevenlabs import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
indexes = client.conversational_ai.get_document_rag_indexes(
documentation_id="21m00Tcm4TlvDq8ikWAM",
)
Delete a Document RAG Index
from elevenlabs import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
result = client.conversational_ai.delete_document_rag_index(
documentation_id="21m00Tcm4TlvDq8ikWAM",
rag_index_id="21m00Tcm4TlvDq8ikWAM",
)
Raw Response Access
from elevenlabs import ElevenLabs
client = ElevenLabs(api_key="YOUR_API_KEY")
# Use the raw client to get full HTTP response metadata
raw_response = client.conversational_ai.with_raw_response.rag_index_overview()
print(raw_response.response.status_code)
print(raw_response.response.headers)
print(raw_response.data)
Async Usage
import asyncio
from elevenlabs import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
async def main() -> None:
# Add document to knowledge base
response = await client.conversational_ai.add_to_knowledge_base(
agent_id="agent_id",
)
# Get RAG index overview
overview = await client.conversational_ai.rag_index_overview()
# Get document RAG indexes
indexes = await client.conversational_ai.get_document_rag_indexes(
documentation_id="21m00Tcm4TlvDq8ikWAM",
)
# Delete a document RAG index
result = await client.conversational_ai.delete_document_rag_index(
documentation_id="21m00Tcm4TlvDq8ikWAM",
rag_index_id="21m00Tcm4TlvDq8ikWAM",
)
asyncio.run(main())
Related Pages
- Elevenlabs_Elevenlabs_python_WebhooksClient -- Webhook management for workspace events
- Elevenlabs_Elevenlabs_python_TextToVoiceRawClient -- Voice design and generation from text descriptions
- Elevenlabs_Elevenlabs_python_Environment -- Environment and base URL configuration