pinecone.grpc

Connecting to Pinecone with GRPC

The pinecone.grpc submodule provides an alternative version of the Pinecone client that uses gRPC instead of HTTP for data operations. This provides a significant performance boost for data operations.

Installing the gRPC client

You must install extra dependencies in order to install the GRPC client.

Installing with pip

# Install the latest version
pip3 install pinecone[grpc]

# Install a specific version
pip3 install "pinecone[grpc]"==3.0.0

Installing with poetry

# Install the latest version
poetry add pinecone --extras grpc

# Install a specific version
poetry add pinecone==3.0.0 --extras grpc

Using the gRPC client

import os
from pinecone.grpc import PineconeGRPC

client = PineconeGRPC(api_key=os.environ.get("PINECONE_API_KEY"))

# From this point on, usage is identical to the HTTP client.
index = client.Index(host=os.environ("PINECONE_INDEX_HOST"))
index.query(vector=[...], top_k=10)
 1"""
 2Connecting to Pinecone with GRPC
 3
 4The `pinecone.grpc` submodule provides an alternative version of the Pinecone 
 5client that uses gRPC instead of HTTP for data operations. This provides a 
 6significant performance boost for data operations.
 7
 8### Installing the gRPC client
 9
10You must install extra dependencies in order to install the GRPC client.
11
12#### Installing with pip
13
14```bash
15# Install the latest version
16pip3 install pinecone[grpc]
17
18# Install a specific version
19pip3 install "pinecone[grpc]"==3.0.0
20```
21
22#### Installing with poetry
23
24```bash
25# Install the latest version
26poetry add pinecone --extras grpc
27
28# Install a specific version
29poetry add pinecone==3.0.0 --extras grpc
30```
31
32### Using the gRPC client
33
34```python
35import os
36from pinecone.grpc import PineconeGRPC
37
38client = PineconeGRPC(api_key=os.environ.get("PINECONE_API_KEY"))
39
40# From this point on, usage is identical to the HTTP client.
41index = client.Index(host=os.environ("PINECONE_INDEX_HOST"))
42index.query(vector=[...], top_k=10)
43```
44
45"""
46
47from .index_grpc import GRPCIndex
48from .pinecone import PineconeGRPC
49from .config import GRPCClientConfig
50
51from pinecone.core.grpc.protos.vector_service_pb2 import (
52    Vector as GRPCVector,
53    SparseValues as GRPCSparseValues,
54    Vector,
55    SparseValues,
56)