> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Pinecone

> Vector database for semantic search and RAG applications

## Overview

Pinecone is a fully managed vector database that enables semantic search and RAG (Retrieval-Augmented Generation) applications. The Pinecone tool allows you to query vector indexes for similar vectors using semantic similarity.

## Key Features

* `PINECONE_CREATE_INDEX`
  * Create new serverless vector indexes
  * Configure vector dimension and distance metric
  * Select cloud provider and deployment region
  * Optional deletion protection
  * Wait-until-ready option for immediate use

* `PINECONE_QUERY`
  * Search for similar vectors using semantic similarity
  * **Dual-mode operation**: Vector query OR text query with integrated inference
  * Support for top-K results retrieval
  * Metadata filtering with Pinecone filter syntax
  * Namespace isolation for data partitioning
  * Similarity threshold filtering (minScore)
  * Optional inclusion of metadata and vector values

* `PINECONE_UPSERT`
  * Insert or update vectors in Pinecone index
  * **Dual-mode operation**: Vector upsert OR document upsert with integrated inference
  * Batch operations (up to 100 vectors/documents per request)
  * Metadata support for rich vector annotations
  * Namespace isolation for data organization

## Authentication

You need a Pinecone API key to use this tool. You can obtain one from the [Pinecone Console](https://app.pinecone.io/).

**Note**: Treat API keys as sensitive information and never commit them to public repositories.

## Examples

### Example: Create Index and Upsert Documents (Integrated Inference)

This example shows the complete workflow using Pinecone's integrated inference feature - no external embedding tool needed!

```yaml theme={null}
# Step 1: Create a serverless index
- id: create_index
  name: create_index
  tool: PINECONE_CREATE_INDEX
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: knowledge-base
    - name: dimension
      value: 1024
    - name: metric
      value: cosine
    - name: cloud
      value: aws
    - name: region
      value: us-east-1
    - name: waitUntilReady
      value: true

# Step 2: Upload documents with automatic embedding
- id: upload_docs
  name: upload_docs
  tool: PINECONE_UPSERT
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: knowledge-base
    - name: documents
      value: |
        [
          {
            "id": "doc1",
            "text": "Pinecone is a vector database optimized for AI applications.",
            "metadata": {"category": "intro", "source": "docs"}
          },
          {
            "id": "doc2",
            "text": "Integrated inference automatically generates embeddings from your text.",
            "metadata": {"category": "features", "source": "docs"}
          }
        ]

# Step 3: Query with text (automatic embedding)
- id: search
  name: search
  tool: PINECONE_QUERY
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: knowledge-base
    - name: query
      value: "How does Pinecone handle embeddings?"
    - name: topK
      value: 3
    - name: includeMetadata
      value: true
```

### Example: Query with Reranking for Improved Relevance

Reranking re-scores initial results to improve relevance. This is especially useful for complex queries.

```yaml theme={null}
- id: search_with_rerank
  name: search_with_rerank
  tool: PINECONE_QUERY
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: knowledge-base
    - name: query
      value: "How does Pinecone handle embeddings?"
    - name: topK
      value: 10
    - name: includeMetadata
      value: true
    - name: rerankModel
      value: bge-reranker-v2-m3  # Options: cohere-rerank-3.5, bge-reranker-v2-m3, pinecone-rerank-v0
    - name: rerankTopN
      value: 3
    - name: rerankRankFields
      value: '["text"]'
    - name: fields
      value: '["category", "text"]'
```

### Example: Traditional Semantic Search with OpenAI Embeddings

```yaml theme={null}
- id: generate_embeddings
  name: generate_embeddings
  tool: OPENAI_CREATE_EMBEDDING
  config:
    - name: api_key
      value: "{{secrets.OPENAI_API_KEY}}"
  input:
    - name: input
      value: What is semantic search?
    - name: model
      value: text-embedding-3-large

- id: search_pinecone
  name: search_pinecone
  tool: PINECONE_QUERY
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: my-docs-index
    - name: vector
      value: "{{steps.generate_embeddings.result.data[0].embedding}}"
    - name: topK
      value: 5
    - name: minScore
      value: 0.7
    - name: includeMetadata
      value: true

- id: generate_answer
  name: generate_answer
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Answer the following question based on the context provided.

        Context:
        {{steps.search_pinecone.result.matches[0].metadata.text}}
        {{steps.search_pinecone.result.matches[1].metadata.text}}

        Question: What is semantic search?
```

### Example: Search with Metadata Filtering

```yaml theme={null}
- id: filtered_search
  name: filtered_search
  tool: PINECONE_QUERY
  config:
    - name: apiKey
      value: "{{secrets.PINECONE_API_KEY}}"
  input:
    - name: indexName
      value: my-docs-index
    - name: vector
      value: "[0.1, 0.2, 0.3, ...]"
    - name: topK
      value: 10
    - name: filter
      value: '{"category": {"$eq": "technology"}, "year": {"$gte": 2020}}'
    - name: namespace
      value: production
```

## Parameters

### PINECONE\_CREATE\_INDEX

| Parameter            | Type    | Required | Default  | Description                                                          |
| -------------------- | ------- | -------- | -------- | -------------------------------------------------------------------- |
| `indexName`          | string  | Yes      | -        | Name of the index (lowercase alphanumeric and hyphens, max 45 chars) |
| `dimension`          | number  | Yes      | -        | Vector dimension (e.g., 1536 for OpenAI ada-002)                     |
| `metric`             | string  | No       | cosine   | Distance metric: cosine, euclidean, or dotproduct                    |
| `cloud`              | string  | No       | aws      | Cloud provider: aws, gcp, or azure                                   |
| `region`             | string  | Yes      | -        | Deployment region (e.g., us-east-1)                                  |
| `deletionProtection` | string  | No       | disabled | Enable deletion protection: enabled or disabled                      |
| `waitUntilReady`     | boolean | No       | true     | Wait until index is ready before returning                           |

### PINECONE\_QUERY

| Parameter         | Type      | Required | Default | Description                                               |
| ----------------- | --------- | -------- | ------- | --------------------------------------------------------- |
| `indexName`       | string    | Yes      | -       | The name of the Pinecone index to query                   |
| `vector`          | number\[] | No\*     | -       | Query vector as array of numbers                          |
| `query`           | string    | No\*     | -       | Text query for integrated inference (automatic embedding) |
| `topK`            | number    | No       | 10      | Number of results to return (1-100)                       |
| `namespace`       | string    | No       | -       | Namespace to query within the index                       |
| `filter`          | object    | No       | -       | Metadata filter using Pinecone filter syntax              |
| `minScore`        | number    | No       | -       | Minimum similarity score threshold (0-1)                  |
| `includeMetadata` | boolean   | No       | true    | Include metadata in results                               |
| `includeValues`   | boolean   | No       | false   | Include vector values in results                          |

\*Either `vector` or `query` must be provided, but not both.

### PINECONE\_UPSERT

| Parameter   | Type   | Required | Default | Description                                                             |
| ----------- | ------ | -------- | ------- | ----------------------------------------------------------------------- |
| `indexName` | string | Yes      | -       | The name of the Pinecone index                                          |
| `vectors`   | array  | No\*     | -       | Array of vector objects (id, values, metadata)                          |
| `documents` | array  | No\*     | -       | Array of document objects for integrated inference (id, text, metadata) |
| `namespace` | string | No       | -       | Namespace for data organization                                         |

\*Either `vectors` or `documents` must be provided, but not both.

### Output

The tool returns an object with the following structure:

```json theme={null}
{
  "matches": [
    {
      "id": "vec1",
      "score": 0.95,
      "metadata": {
        "title": "Document Title",
        "text": "Document content...",
        "category": "technology"
      }
    }
  ],
  "namespace": "production",
  "usage": {
    "readUnits": 5
  }
}
```

## Use Cases

### RAG (Retrieval-Augmented Generation)

Combine Pinecone with OpenAI to build RAG applications:

1. Generate embeddings from user query
2. Search Pinecone for relevant documents
3. Use retrieved context in LLM prompts

### Semantic Search

Search documents by meaning rather than keywords:

* Find similar articles
* Recommend related content
* Discover relevant information

### Question Answering

Build Q\&A systems with context retrieval:

* Technical documentation search
* Customer support knowledge base
* Research paper discovery

## Resources

* [Pinecone Documentation](https://docs.pinecone.io/)
* [Pinecone Console](https://app.pinecone.io/)
* [Vector Embeddings Guide](https://www.pinecone.io/learn/vector-embeddings/)
* [RAG Best Practices](https://www.pinecone.io/learn/retrieval-augmented-generation/)
