#How to query the Eleven labs Knowledge base through API
1 messages · Page 1 of 1 (latest)
AI-generated Answer for kishore_vb
Short answer: you don’t “query the Knowledge Base” directly. You attach KB documents to an Agent and send the Agent a message (text or voice). The Agent retrieves relevant snippets from the KB (optionally via RAG) and returns an answer.
Implement it via API:
- Add documents to the Knowledge Base
- File/URL upload: POST /v1/convai/knowledge-base (multipart form; name, file, or url). After creation, you’ll update the Agent to use this doc. (elevenlabs.io)
- Text document: POST /v1/convai/knowledge-base/text (JSON: { text, name? }). (elevenlabs.io)
- List/inspect docs: GET /v1/convai/knowledge-base and GET /v1/convai/knowledge-base/{documentation_id}. (elevenlabs.io)
- (Optional but recommended for large KB) Enable RAG indexing on the doc
- Start or check indexing: POST /v1/convai/knowledge-base/{documentation_id}/rag-index (model: e5_mistral_7b_instruct or multilingual_e5_large_instruct). (elevenlabs.io)
- View a doc’s indexes: GET /v1/convai/knowledge-base/{documentation_id}/rag-index; workspace usage overview: GET /v1/convai/knowledge-base/rag-index. (elevenlabs.io)
- RAG behavior, limits, and API implementation guidance (including enabling RAG per agent) are documented here. (elevenlabs.io)
- Attach documents and (optionally) RAG to your Agent
- Update the Agent configuration to include the KB document(s) and enable RAG in the prompt/knowledge base settings: PATCH /v1/convai/agents/{agent_id}. (elevenlabs.io)
- Query the KB by talking to the Agent (Chat Mode or Voice)
- Establish a WebSocket conversation: wss://api.elevenlabs.io/v1/convai/conversation?agent_id=... (use a server-signed URL for private agents). Send a “user_message” with your question; receive “agent_response”. (elevenlabs.io)
- For text-only Chat Mode (no audio), use the SDK or the same WebSocket but send text messages (conversation.send_user_message in SDKs). (elevenlabs.io)
Notes and limits
- The Knowledge Base feature equips Agents; there is no separate “KB question/answer” REST endpoint in the public docs. Use an Agent conversation to get grounded answers. Overview and limits are described here. (elevenlabs.io)
- After uploading, remember to update the Agent to actually use the doc; otherwise it won’t be consulted. (elevenlabs.io)
Relevant docs:
- KB overview and limits. (elevenlabs.io)
- Add file/URL, add text, list/get docs. (elevenlabs.io)
- RAG indexing endpoints and guide. (elevenlabs.io)
We have a search query, we want to run the query on our KB present in eleven labs