Agent / LLM? Start here
If you’re an AI agent or LLM reading this page to generate Pinecone code, here’s the full working pattern as a single runnable script.Get set up
To get started, you’ll need a Pinecone account and API key.1. Create a Pinecone account
If you’re new to Pinecone, sign up at app.pinecone.io and choose a plan:- Starter plan (free): Free access to most features, but you’re limited to one cloud region and need to stay under Starter plan limits.
- Builder plan ($20/month): Higher quotas than Starter and predictable flat pricing with no usage overages, plus the ability to create indexes in any supported cloud region. Ideal for small production apps.
- Standard plan trial: 21 days and $300 in credits with access to Standard plan features and higher limits that let you test Pinecone at scale.
If you’re already on a Starter plan, you can upgrade to Builder at any time, or activate a Standard plan trial (one trial per organization).
2. Get a Pinecone API key
Create a new API key in the Pinecone console, or use the widget below to generate a key. If you don’t have a Pinecone account, the widget will sign you up for the free Starter plan.Fastest: use your AI coding tool
Install the Pinecone plugin for your AI coding tool, then run the quickstart command. The plugin gives your agent up-to-date Pinecone API references, skills, and a bundled MCP server. The quickstart command walks you through setup with the official Pinecone CLI before generating and running sample code, so you end up with a reproducible setup instead of pasted snippets.- Claude Code
- Cursor
- Other IDEs
Set your API key, then install the Pinecone plugin for Claude Code:Start Claude Code and run the quickstart command:The plugin also includes other slash commands, such as
/pinecone:query, for interactively querying your indexes.Choose your path
Records or documents? There are two ways to model data in Pinecone, and the choice is made when you create the index. An index created with a dense or sparse vector type holds records, the path the steps below follow using integrated embedding (
create_index_for_model + upsert_records + search). An index created with a document schema holds documents and supports full-text search with BM25 ranking and Lucene queries (public preview, with REST and Python SDK support). If keyword and phrase matching matters to your search, or you need more than one ranking signal in a single index, start from full-text search instead. To compare the two models, see Data modeling.Agent
Build a knowledge retrieval agent with Pinecone as a tool. ~80 lines of Python.
IDE assistant
Let Claude Code, Cursor, or Gemini CLI build it for you.
SDK
Integrate Pinecone directly with Python, JavaScript, Java, or Go.
No-code
Build a workflow in n8n without writing code.
Build a knowledge retrieval agent
Build an AI agent that uses Pinecone to retrieve knowledge and answer questions accurately. This demo shows Pinecone as a tool inside an agent, which is the same pattern you’d use in production.This path requires an Anthropic or OpenAI API key alongside your Pinecone API key. If you don’t have one, try the IDE assistant or SDK path instead.
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.
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
Wire the tool into your agent
Give your LLM the ability to call the search function when it needs information.
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
Build a RAG chatbot
Add conversation history, streaming, and a web UI
Search methods
Explore semantic, hybrid, and full-text search
Data modeling
Model your data for efficient retrieval
Integrate the SDK directly
Integrate Pinecone directly into your application. Use these SDK calls wherever your code needs knowledge retrieval, whether that’s an agent, a backend service, or a standalone script.1. Install an SDK
2. Create an index
Create an index with integrated embedding so you can upsert and search with text. Pinecone generates the vectors for you.If you prefer to use external embedding models, see Bring your own vectors.
Python
JavaScript, Java, and Go
JavaScript, Java, and Go
3. Upsert data
Load records into your index. Each record has an ID, text content, and optional metadata. Pinecone converts the text to vectors automatically using the integrated embedding model.Python
JavaScript, Java, and Go
JavaScript, Java, and Go
Pinecone is eventually consistent. New records may take a few seconds to become searchable.
4. Search and rerank
Search the index for records semantically similar to a query, then rerank for more accurate results.Python
Output
JavaScript, Java, and Go
JavaScript, Java, and Go
5. Clean up
When you no longer need the example index, delete it:Python
JavaScript, Java, and Go
JavaScript, Java, and Go
Next steps
Index data
Learn more about storing data in Pinecone
Search
Explore different forms of vector search
Optimize
Find out how to improve performance
No-code with n8n
Create an AI workflow that uses Pinecone for knowledge retrieval without writing any code. Use n8n to create a workflow that downloads files via HTTP and lets you chat with them using Pinecone Database and OpenAI.1. Get an OpenAI API key
Create a new API key in the OpenAI console.2. Create an index
Create an index in the Pinecone console:- Name your index
n8n-dense-index - Under Configuration, check Custom settings and set Dimension to 1536.
- Leave everything else as default.
3. Set up n8n
Create a new workflow
In your n8n account, create a new workflow.
Import a workflow template
Copy this workflow template URL:Paste the URL into the workflow editor and then click Import to add the workflow.
Add credentials to the workflow
-
Add your Pinecone credentials:
- In the Pinecone Vector Store node, select Credential to connect with > Create new credential and paste in your Pinecone API key.
- Name the credential Pinecone so that other nodes reference it.
-
Add your OpenAI credentials:
- In the OpenAI Chat Model, select Credential to connect with > Create new credential and paste in your OpenAI API key.
4. Chat with your docs
Once the workflow is activated, ask it for the latest changes to Pinecone Database:Next steps
- Use your own data:
- Change the urls in Set file urls node to use your own files.
- You may need to adjust the chunk sizes in the Recursive Character Text Splitter node or use a different chunking strategy. See Chunking Strategies for LLM Applications for more info.
- Customize the system message of the AI Agent node to reflect what the Pinecone Vector Store Tool will be used for.
- Customize the description of the Pinecone Vector Store Tool to reflect what data you are storing in the Pinecone index.
- Use n8n, Pinecone Assistant, and OpenAI to chat with your Google Drive documents.
- Get help in the Pinecone Discord community.