1
Install dependencies
2
Create an index and load knowledge
Create a Pinecone index with integrated embedding and load a small knowledge base. These are facts your LLM doesn’t know on its own, so retrieval is the only way to answer accurately.
Pinecone is eventually consistent. New records may take a few seconds to become searchable.
3
Define Pinecone as a tool
Wrap Pinecone search in a function your agent can call. Drop this into any agent codebase to add knowledge retrieval. Run all snippets in the same Python session so
index and llm stay in scope.Agent tool:
search_knowledge_basePython
4
Wire the tool into your agent
Give your LLM the ability to call the search function when it needs information.
5
Ask your agent a question
Output
What just happened: Your LLM received a question, decided it needed more information, and called the
search_knowledge_base tool. Pinecone returned the most relevant records with reranking, and the LLM synthesized an accurate answer from the retrieved context. Production RAG agents use this same pattern, and the search_knowledge_base function works in any agent framework.Next steps
Use the MCP server
Give agents Pinecone access over the Model Context Protocol
Search methods
Explore semantic, hybrid, and full-text search
Data modeling
Model your data for efficient retrieval