Saurabh
02/10/2026, 7:34 AMVapi Support Bot
02/10/2026, 7:35 AMjs
import { PineconeClient } from '@pinecone-database/pinecone';
import OpenAI from 'openai';
const pinecone = new PineconeClient();
const openai = new OpenAI();
app.post('/kb/search', async (req, res) => {
const { message } = req.body;
const latestQuery = getLatestUserMessage(message);
const embedding = await openai.embeddings.create({
model: 'text-embedding-ada-002',
input: latestQuery
});
const index = pinecone.Index('knowledge-base');
const searchResults = await index.query({
vector: embedding.data[0].embedding,
topK: 5,
includeMetadata: true
});
// Format and return results as needed
});
This approach gives you full control and is production-ready for client projects ([see full guide](https://docs.vapi.ai/knowledge-base/custom-knowledge-base)).
Source:
- [Custom Knowledge Base Documentation](https://docs.vapi.ai/knowledge-base/custom-knowledge-base)Chiranjeet Mishra
02/10/2026, 8:45 AM