Pinecone Integration Guide

Technology: pinecone · Category: database · Last reviewed: 2026-10-20

Source: https://tech-stack.codeamanilabs.org/guide/pinecone

Insight:

This directly solves the stated gap ("lots of AI, no retrieval layer"). Pinecone's integrated inference is still the key: pc.indexes.createForModel binds an embedding model to the index, so you upsertRecords/searchRecords with raw text and Pinecone embeds server-side, with zero embeddings infrastructure to run. Two codeAmani wins: hosted multilingual-e5-large embeds Swahili + English in one space, and retrieved chunks feed straight into a Claude call via the Vercel AI SDK. New in 2026: the GA Documents API adds BM25 full-text search for exact tokens (SKUs, M-Pesa receipt codes), and SDK v9 needs Node.js 22.

██████╗ ██╗███╗   ██╗███████╗ ██████╗ ██████╗ ███╗   ██╗███████╗
██╔══██╗██║████╗  ██║██╔════╝██╔════╝██╔═══██╗████╗  ██║██╔════╝
██████╔╝██║██╔██╗ ██║█████╗  ██║     ██║   ██║██╔██╗ ██║█████╗
██╔═══╝ ██║██║╚██╗██║██╔══╝  ██║     ██║   ██║██║╚██╗██║██╔══╝
██║     ██║██║ ╚████║███████╗╚██████╗╚██████╔╝██║ ╚████║███████╗
╚═╝     ╚═╝╚═╝  ╚═══╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚══════╝

Pinecone Integration Guide

Focus: The retrieval layer for codeAmani's AI. Pinecone is a serverless vector database for RAG: store knowledge, retrieve the most relevant chunks, and feed them into a Claude prompt. With integrated inference you skip running an embedding model entirely, because Pinecone embeds text server-side (including multilingual-e5-large for Swahili + English).

What changed in 2026 (read this first)

Change Date What to do
Node SDK v9.0.0 targets API 2026-07 and requires Node.js ≥ 22 2026-09-09 Pin @pinecone-database/pinecone@9.0.0. Stay on 8.x only if a runtime is stuck on Node 20.
Control plane moved to resource clients (pc.indexes.*, pc.backups.*, pc.backupSchedules.*, pc.assistants.*) v9 Flat pc.createIndexForModel(), pc.listIndexes() and friends still work but are deprecated. New code uses pc.indexes.createForModel() and pc.indexes.list().
Python SDK v10.0.0 (API 2026-07, Python 3.10 to 3.14), pinecone.preview removed 2026-09-03 pip install pinecone==10.0.0. pc.create_index(dimension=..., spec=...) is unchanged.
Full-text search + Documents API generally available 2026-09-02 New schema-based "document indexes" combine BM25 text, dense and sparse fields. See §5.
Index responses expose schema + deployment; dimension/metric/spec are compatibility getters that can throw v9 Don't spread or serialize IndexModel. Read model.host and model.schema.
Egress metering: 1 GB/mo Starter, 10 GB Builder, 100 GB Standard/Enterprise, then $0.10/GB 2026-09-01 Return only the fields you need. Starter/Builder reads are blocked at the cap.
New Builder plan, $20/month flat with no overages 2026-05-04 Middle step between Starter and Standard.
Dedicated Read Nodes GA (Standard/Enterprise) 2026-04-15 Provisioned read hardware at an hourly rate instead of read units. See §6.
Scheduled backups (pc.backupSchedules) and namespace aliases v9 / 2026-09-29 Nightly backups; blue/green namespace swaps. See §6.
cohere-rerank-3.5 deprecated → cohere-rerank-4-fast 2026-07-01 Codeamani uses bge-reranker-v2-m3, so no action needed.
Pinecone Local (Docker emulator) end of life 2026-10-07 Test against a separate dev project or mock the API.

Overview

Pinecone (API 2026-07) gives you three kinds of index. Pick one per knowledge base:

Index kind Create with (TS v9) Read/write with Use when
Integrated embedding (codeAmani default for RAG) pc.indexes.createForModel({ embed: { model, fieldMap } }) upsertRecords / searchRecords (Records API) You want to send raw text and never handle vectors. Supports server-side rerank, and it is the only kind the Pinecone MCP can drive.
Vector index (bring your own vectors) pc.indexes.create({ dimension, metric, spec }) upsert / query / fetch (Vectors API) You need a specific embedding model (e.g. OpenAI text-embedding-3-small).
Document index (new, GA) pc.indexes.create({ schema: { fields } }) index.documents.* (Documents API) You need BM25 full-text and/or Lucene query syntax on the same data as dense vectors.

An index's data plane is fixed when it is created. Upgrading the SDK never moves an existing index to a different API.

Here is the integrated-inference path at a glance. The embedding happens server-side, so your app never touches a vector:

flowchart LR
  A["Raw text records"] -->|"upsertRecords"| B["Index bound to<br/>multilingual-e5-large"]
  B --> C["Vectors stored<br/>server-side"]
  Q["Text query"] -->|"searchRecords topK"| C
  C --> D["Optional rerank<br/>bge-reranker-v2-m3 topN"]
  D --> E["Top matching chunks"]

RAG decision notes

The headline trade-off (Pinecone's integrated inference vs. running your own embeddings) is summarized in the Insight callout at the top of this page. A few more decision points worth knowing:

Chunking strategy

Since chunking dominates retrieval quality (see the note above), here is concrete guidance. All sizes are in tokens, not characters.

Size: start fixed, then iterate. Pinecone's chunking guide recommends starting with fixed-size chunking and only moving to fancier strategies once it proves insufficient. For sizing, the guide says to "start by exploring a variety of chunk sizes, including smaller chunks (e.g. 128 or 256 tokens) ... and larger chunks (e.g. 512 or 1024 tokens)" (pinecone.io/learn/chunking-strategies). With multilingual-e5-large the hard ceiling is 507 tokens, so the practical default for FAQ/support docs is ~400–450 tokens. Smaller chunks give sharper, more precise matches. Larger chunks carry more context per hit but dilute the embedding.

Overlap: 10–20% is the commonly documented range. Pinecone's guide itself does not prescribe a fixed overlap percentage. It instead favours chunk expansion (pulling neighbouring chunks at query time) to recover context. Across the broader RAG literature, a 10–20% overlap (e.g. 50–80 tokens on a 450-token chunk) is the widely cited starting point to avoid splitting a sentence's meaning across a boundary. Treat it as a knob to tune, not gospel. Some recent benchmarks find overlap adds indexing cost with little gain, so measure on your own corpus.

Semantic vs fixed splitting: when to switch.

Keep chunk_text (the field in your index fieldMap) as the only text field per record, and store source metadata (doc_id, section, chunk_index) so you can rebuild context.

// Fixed-size, overlapping chunker. Run BEFORE upsertRecords (§2).
// Approximate tokens with a chars-per-token ratio (English ~4; tune for Swahili).
const CHARS_PER_TOKEN = 4;

function chunkText(
  text: string,
  { chunkTokens = 450, overlapTokens = 60 } = {},
): string[] {
  const size = chunkTokens * CHARS_PER_TOKEN;        // ~1800 chars
  const overlap = overlapTokens * CHARS_PER_TOKEN;    // ~240 chars
  const stride = Math.max(size - overlap, 1);         // guard: overlap < size
  const chunks: string[] = [];
  for (let start = 0; start < text.length; start += stride) {
    const slice = text.slice(start, start + size).trim();
    if (slice) chunks.push(slice);
  }
  return chunks;
}

// Wire chunks into the §2 integrated-inference upsert (max 96 text records per call):
const records = chunkText(sourceDoc).map((chunk, i) => ({
  id: `faq-mpesa#${i}`,           // stable id = doc + chunk index
  chunk_text: chunk,             // must match the index fieldMap
  doc_id: "faq-mpesa",
  chunk_index: i,
  topic: "payments",
}));
for (let i = 0; i < records.length; i += 96) {
  await index.upsertRecords({ records: records.slice(i, i + 96) });
}

Gotcha: chunk sizes are measured in tokens, but most splitters (including the char-based helper above) cut on characters. The ~4-chars-per-token ratio is an English approximation. Swahili and other non-English text often run fewer chars per token, so a "450-token" char window can silently overshoot the embedding model's context limit and get truncated server-side. For production, count with a real tokenizer (e.g. js-tiktoken) instead of a fixed ratio, and verify against your model's window (multilingual-e5-large = 507 tokens; llama-text-embed-v2 = 2048 tokens).

flowchart TD
  A["Source doc"] --> B{"Structured doc<br/>headings · sections"}
  B -->|"No · uniform prose"| C["Fixed-size<br/>~450 tok · 10-20% overlap"]
  B -->|"Yes"| D{"Topics shift<br/>a lot"}
  D -->|"No"| E["Content-aware<br/>recursive split"]
  D -->|"Yes · long PDF"| F["Semantic<br/>split on topic shift"]
  C --> G["upsertRecords<br/>chunk_text field"]
  E --> G
  F --> G

Official Documentation

Resource URL
Docs home https://docs.pinecone.io/
Quickstart https://docs.pinecone.io/guides/get-started/quickstart
Integrated inference https://docs.pinecone.io/guides/inference/understanding-inference
Adopt the Documents API (2026-07) https://docs.pinecone.io/guides/index-data/adopt-the-documents-api
Full-text search https://docs.pinecone.io/guides/search/full-text-search
2026 changelog https://docs.pinecone.io/release-notes/2026
TS SDK v9 migration guide https://github.com/pinecone-io/pinecone-ts-client/blob/main/guides/upgrading/v9-migration.md
Chunking strategies https://www.pinecone.io/learn/chunking-strategies/
Pricing https://www.pinecone.io/pricing/

1. Install + credentials

npm install @pinecone-database/pinecone@9.0.0   # JS/TS. Requires Node.js >= 22
pip install pinecone==10.0.0                     # Python 3.10 to 3.14
PINECONE_API_KEY=pcsk_...    # server-side only (.env.local / Vercel env / Hazina vault)

Non-secret settings (keep these in config, not in the vault):

Setting Value Notes
Cloud / region aws / us-east-1 Starter is us-east-1 only. Builder and above can use any GA region (e.g. eu-central-1, ap-southeast-1).
Embedding model multilingual-e5-large 1024-dim, 507-token window
Rerank model bge-reranker-v2-m3 The only rerank model on Starter/Builder
API version header 2026-07 Only for raw REST calls (X-Pinecone-Api-Version). The SDKs set it for you.
Debug logging PINECONE_DEBUG Logs requests with Api-Key redacted (v9)

new Pinecone() with no arguments reads PINECONE_API_KEY from the environment. The v9 client uses globalThis.fetch and no longer eagerly loads Node built-ins, so it constructs in Edge/Workers runtimes. Assistant file uploads and streaming still need Node.js.

Optional: the pc CLI (scripting index/project ops outside the app):

brew tap pinecone-io/tap && brew install pinecone-io/tap/pinecone   # macOS
# Windows/Linux: download a binary from https://github.com/pinecone-io/cli/releases
pc auth login                                                        # browser auth
pc index create -n kb -d 1024 -m cosine -c aws -r us-east-1
pc index list

2. RAG with integrated inference (no embedding layer): TypeScript

import { Pinecone } from "@pinecone-database/pinecone";

const pc = new Pinecone(); // reads PINECONE_API_KEY

// 2a. Create an index bound to an embedding model (multilingual = Swahili + English)
const model = await pc.indexes.createForModel({
  name: "kb",
  cloud: "aws",
  region: "us-east-1",
  embed: { model: "multilingual-e5-large", fieldMap: { text: "chunk_text" } },
  waitUntilReady: true,
});
const index = pc.index({ host: model.host, namespace: "tenant-acme" });

// 2b. Upsert RAW TEXT (max 96 records per call). Pinecone embeds it server-side.
await index.upsertRecords({
  records: [
    { id: "doc1", chunk_text: "M-Pesa STK Push prompts the user on their phone.", topic: "payments" },
    { id: "doc2", chunk_text: "Daraja tokens expire after one hour.", topic: "payments" },
  ],
});

// 2c. Search with a text query (+ optional rerank)
const res = await index.searchRecords({
  query: { topK: 10, inputs: { text: "how does M-Pesa checkout work?" }, filter: { topic: { $eq: "payments" } } },
  rerank: { model: "bge-reranker-v2-m3", topN: 3, rankFields: ["chunk_text"] },
  fields: ["chunk_text", "topic"],
});
// hit.fields is typed `object` in v9, so narrow it before reading
const chunks = res.result.hits.map((h) => String((h.fields as Record<string, unknown>).chunk_text));

Writes are eventually consistent. waitUntilReady covers index creation only, so seed scripts should poll a search (with a timeout) before asserting on freshly upserted data.

3. Close the RAG loop (Pinecone → Claude via the AI SDK)

You are one short hop from a full answer. Retrieved chunks become Claude's context, with Pinecone as memory and Claude as generator:

sequenceDiagram
  participant U as "User"
  participant App as "Server action"
  participant P as "Pinecone"
  participant C as "Claude · AI SDK"
  U->>App: "Question"
  App->>P: "searchRecords · text query"
  P-->>App: "Top-k chunks"
  App->>C: "Prompt with context"
  C-->>App: "Grounded answer"
  App-->>U: "Reply"
import { generateText } from "ai";

const context = chunks.map((c, i) => `[${i + 1}] ${c}`).join("\n---\n");
const { text } = await generateText({
  model: "anthropic/claude-sonnet-5",               // via Vercel AI Gateway (Claude 5 family)
  system: "Answer ONLY from the numbered context and cite like [1].",
  prompt: `Context:\n${context}\n\nQ: How does M-Pesa checkout work?`,
});

Full version: examples/rag-answer.ts.

4. Bring-your-own-vectors (Python v10, explicit dimension)

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone()  # reads PINECONE_API_KEY
pc.create_index(name="kb-byov", dimension=1536, metric="cosine",
                spec=ServerlessSpec(cloud="aws", region="us-east-1"))  # unchanged in v10
index = pc.index("kb-byov")   # lowercase pc.index(); capital pc.Index() is the old form
index.upsert(vectors=[("id1", embedding_1536d)], namespace="tenant-a")
res = index.query(vector=query_vec, top_k=10, namespace="tenant-a")  # top_k must be 1..10,000

In TypeScript, pc.indexes.create({ dimension, metric, spec }) still works. The SDK translates it to a schema with the reserved _values field, and the index stays on the classic Vectors API. See examples/byov-backups.ts. On v10, an empty filter={} now raises PineconeValueError client-side, so omit the filter instead.

5. Full-text + hybrid search (Documents API, GA on 2026-07)

A document index declares its fields in a schema: string fields with fullTextSearch (BM25), at most one dense_vector and one sparse_vector. Undeclared fields are stored as filterable metadata. Documents use _id and top-level fields.

const model = await pc.indexes.create({
  name: "support-docs",
  deployment: { deploymentType: "managed", cloud: "aws", region: "us-east-1" },
  schema: {
    fields: {
      body: { type: "string", fullTextSearch: {} },
      embedding: { type: "dense_vector", dimension: 1536, metric: "cosine" },
    },
  },
  waitUntilReady: true,
});
const docs = pc.index({ host: model.host, namespace: "tenant-acme" }).documents;

// Keyword (BM25). Also: { type: "query_string", query: "body:refund~1" } for Lucene + fuzzy
const kw = await docs.search({
  scoreBy: [{ type: "text", fields: ["body"], query: "QK12AB34CD refund" }],
  topK: 5,
  includeFields: ["body"],
});

// Hybrid in ONE request: exact-phrase filter, then dense ranking
const hy = await docs.search({
  scoreBy: [{ type: "dense_vector", fields: ["embedding"], values: queryEmbedding }],
  filter: { body: { $match_phrase: "original card" } },
  topK: 5,
});

Rules worth knowing (from the 2026-07 docs):

6. Production operations

7. Pricing snapshot (pinecone.io/pricing, 2026-10-20)

Starter Builder Standard Enterprise
Price Free $20/mo flat (blocked, not billed, past quota) $50/mo minimum, then pay as you go $500/mo minimum
Indexes 5 (us-east-1 only) 10 per project 20 per project 200 per project
Storage 2 GB 10 GB $0.33/GB/mo $0.33/GB/mo
Read units 1M/mo 2M/mo $16–$18 per M $24–$27 per M
Write units 2M/mo 5M/mo $4–$4.50 per M $6–$6.75 per M
Egress 1 GB/mo 10 GB/mo 100 GB incl., then $0.10/GB same
Embedding 5M tokens/mo 10M tokens/mo e5-large $0.08/M, llama-v2 $0.16/M same
Rerank 500 req/mo (bge only) 1,000 req/mo $2 per 1k requests same

How usage is metered: a query costs 1 RU per GB of namespace (minimum 0.25 RU), regardless of topK. A fetch costs 1 RU per 10 records. An upsert costs 1 WU per KB (minimum 5 WU). Unit prices vary by cloud and region. The HIPAA add-on on Standard is $190/mo. Full table: reference/limits-and-pricing.md.

8. Claude Code: MCP servers, plugin and troubleshooting

Pinecone ships three different MCP servers. Don't mix them up:

Server Transport / launch Tools Use for
Developer MCP @pinecone-database/mcp (v0.3.0) stdio, npx -y @pinecone-database/mcp search-docs, list-indexes, describe-index, describe-index-stats, create-index-for-model, upsert-records, search-records, cascading-search, rerank-documents Building/inspecting integrated-embedding indexes from the editor. BYOV and document indexes, assistants, and raw vector search are not supported.
Assistant MCP (one per assistant) Remote streamable HTTP https://<ASSISTANT_HOST>/mcp/assistants/<NAME> with Authorization: Bearer <key>, or Docker ghcr.io/pinecone-io/assistant-mcp context-snippet retrieval Giving an agent grounded context from a Pinecone Assistant's files
Nexus MCP Remote streamable HTTP https://<WORKSPACE_HOST>/mcp via mcp-remote list_contexts, query_context, get_query Querying Pinecone Nexus contexts (GA 2026-08-06)

Install the developer MCP. Either install the official plugin (claude plugin install pinecone, which bundles the MCP server and the /pinecone:* skills) or add only the server:

claude mcp add-json pinecone-mcp '{"type":"stdio","command":"npx","args":["-y","@pinecone-database/mcp"],"env":{"PINECONE_API_KEY":"<from vault>"}}'
claude mcp add --transport http my-assistant https://<ASSISTANT_HOST>/mcp/assistants/<NAME> --header "Authorization: Bearer <key>"

Troubleshooting: "MCP server plugin:pinecone:pinecone connection timed out after 30000ms"

Measured on this Windows machine on 2026-10-20: a cold npx -y @pinecone-database/mcp took 40.8 s to print Pinecone MCP Server running on stdio. A warm run (package already in the npx cache) took 10.8 s. Claude Code's MCP startup budget gave up at 30 s, so the first launch of a session (or after an npm cache clean) times out. Fixes, in order of preference:

  1. Warm the cache once, then restart Claude Code: run npx -y @pinecone-database/mcp in a terminal, wait for running on stdio, then press Ctrl+C.
  2. Raise the startup timeout before launching Claude Code (PowerShell): $env:MCP_TIMEOUT = "60000"; claude.
  3. Skip npx entirely: npm install -g @pinecone-database/mcp, then point a user-scoped server at the pinecone-mcp binary ("command": "pinecone-mcp") instead of npx. On Windows, if npx itself isn't found, use "command": "cmd", "args": ["/c", "npx", "-y", "@pinecone-database/mcp"].
  4. Set PINECONE_API_KEY in the environment that launches Claude Code. The plugin passes ${PINECONE_API_KEY} through. Without it the server still starts, but every database tool errors ("Database tools will return an error until it is provided") and only search-docs works.
  5. Check node --version (the MCP needs ≥ 20; SDK v9 apps need ≥ 22), then run /mcp to confirm ✓ connected.
  6. Behind a corporate firewall, allow api.pinecone.io and the index hosts (*.pinecone.io).

9. Pinecone Assistant (managed RAG)

Upload files to an assistant, then chat with it (citations included) or pull context snippets for your own LLM. It is fully usage-based since 2026-04-01, with no per-assistant hourly fee. On Standard: $8/M input tokens, $15/M output tokens, $5/M context tokens, $3/GB/mo storage and $0.0005 per ingestion unit (~400 tokens). Starter includes 500k input, 300k output and 500k context tokens plus 1,000 ingestion units per month. Chat models include claude-sonnet-4-5, gpt-5 and gemini-3.5-flash. Use it for quick internal doc Q&A. For product RAG, codeAmani keeps the generator in its own Claude call (§3) so routing, prompting and cost stay under our control.

codeAmani notes

Official docs: