What is get_rag_client()?
After set_rag_config(...) runs at process startup, get_rag_client() hands back the concrete client object CrewAI uses internally for knowledge sources, RagTool, and memory backends that share the same vector infrastructure. That escape hatch matters when you need operations the high-level adapters do not expose: bulk deletes, collection cloning, hybrid sparse+dense queries, or health checks before you admit traffic.
The returned type is backend-specific — a Qdrant client wrapper, Chroma persistent client, or similar — so pin your imports to the same optional extras you installed (for example crewai[qdrant]). Treat the client as a singleton: concurrent crews share the connection pool you configure at the driver level. Calling get_rag_client before set_rag_config raises or returns a default depending on version; always initialize configuration in a deterministic module import path or FastAPI lifespan hook.
Do not bypass CrewAI's knowledge abstractions for routine per-task retrieval unless you measure a real latency win. Custom queries can desynchronize chunk metadata Crew expects, especially if you mutate collections while agents are reading. Prefer read-only introspection, batch maintenance windows, or separate collections for offline analytics.
Use Cases
- • Custom retrieval
- • Bulk loads
- • Schema introspection
Key Features
- ✓ Returns provider-specific client
When NOT to Use
Routine retrieval — let knowledge sources handle it.
Notes
Call order
Always invoke after set_rag_config in the same process. Tests should pair get_rag_client assertions with clear_rag_config fixtures to avoid bleed between cases.
Thread and asyncio safety
Some vector drivers are not asyncio-safe. If you await kickoff_async while touching the raw client concurrently, verify the vendor's thread guidance.
Credential rotation
Long-lived clients cache API keys. After rotating secrets, rebuild the process or re-run set_rag_config so handles pick up new auth headers.
Escape hatch discipline
Document why custom queries exist. Otherwise the next maintainer duplicates CrewAI's chunking logic and drifts from framework upgrades.
Code Examples
Direct query
client = get_rag_client()
results = client.search(...)
After Qdrant setup
from crewai.rag.config.utils import get_rag_client, set_rag_config
from crewai.rag.qdrant.config import QdrantConfig
set_rag_config(QdrantConfig(
qdrant_url='http://localhost:6333',
collection_name='kb',
))
client = get_rag_client()
When to Use
Advanced retrieval, schema inspection, bulk operations.
Common Mistakes
❌ Calling before configuration
✅ Call set_rag_config once at import or startup, then cache the client reference your services inject.
Related: @tool decorator reference, Agent class reference, and the first Crew tutorial.
get_rag_client() FAQ
What is get_rag_client() in CrewAI?
Returns the currently-configured RAG client (vector store handle). After set_rag_config(...) runs at process startup, get_rag_client() hands back the concrete client object CrewAI uses internally for knowledge sources, RagTool, and memory backends that share the same vector infrastructure. That escape hatch matters when you need operations the high-level adapters do not expose: bulk deletes, collection cloning, hybrid sparse+dense queries, or health checks before you admit traffic. The returned type is backend-specific — a Qdrant client wra…
Which CrewAI types expose the method get_rag_client()?
DevShelfHub documents get_rag_client() on RAG. The reference maps it to Python module crewai.rag.config.utils — pin your installed crewai version and match imports to the snippet on this page.
When should I use get_rag_client()?
Advanced retrieval, schema inspection, bulk operations.
When should I avoid get_rag_client()?
Routine retrieval — let knowledge sources handle it.
How do I call get_rag_client() from Python?
client = get_rag_client()
Where can I explore more CrewAI API reference pages?
Open the CrewAI API reference index on DevShelfHub to search classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.