Knowledge Quickstart
Create a knowledge base for your agent
Give your agent custom knowledge using RAG (Retrieval-Augmented Generation). Upload documents and the agent will use them to answer questions.
Create a knowledge base
Create an empty knowledge base container to hold your documents.
curl -X POST "https://api.d-id.com/knowledge" \
-H "Authorization: Basic <YOUR KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "MyKnowledge",
"description": "Knowledge base for my agent"
}'{
"id": "knl_abc123",
"name": "MyKnowledge",
"description": "Knowledge base for my agent",
"status": "",
"created": "2024-01-15T10:30:00.000Z"
}Save the id — this is your knowledgeId for adding documents.
Add a document
Upload a document to your knowledge base. Supported types: PDF, TXT, DOCX, and more.
curl -X POST "https://api.d-id.com/knowledge/knl_abc123/documents" \
-H "Authorization: Basic <YOUR KEY>" \
-H "Content-Type: application/json" \
-d '{
"title": "Company FAQ",
"documentType": "pdf",
"source_url": "https://your-storage.com/faq.pdf"
}'{
"id": "knl_abc123#doc_xyz789",
"title": "Company FAQ",
"documentType": "pdf",
"status": "processing",
"created": "2024-01-15T10:31:00.000Z"
}The document is now being processed. Add multiple documents by repeating this step.
Check knowledge status
Wait for all documents to finish processing. The knowledge base status becomes done when all documents are ready.
curl -X GET "https://api.d-id.com/knowledge/knl_abc123" \
-H "Authorization: Basic <YOUR KEY>"{
"id": "knl_abc123",
"name": "MyKnowledge",
"status": "done",
"created": "2024-01-15T10:30:00.000Z"
}Update agent
Update your agent to use the knowledge base with the rag-ungrounded template.
curl -X PATCH "https://api.d-id.com/agents/<YOUR AGENT ID>" \
-H "Authorization: Basic <YOUR KEY>" \
-H "Content-Type: application/json" \
-d '{
"knowledge": {
"id": "knl_abc123"
},
"llm": {
"template": "rag-ungrounded"
}
}'{
"id": "agt_xyz789",
"name": "My Agent",
"knowledge": {
"id": "knl_abc123"
},
"llm": {
"provider": "openai",
"template": "rag-ungrounded", // or rag-grounded
"model": "gpt-4o-mini"
}Your agent is now configured to use the knowledge base. The rag-ungrounded template primarily uses your knowledge sources but also relies on general knowledge.
Updated about 10 hours ago
