Proxy servers with Pinecone?

A customer question: My team is looking into using Pinecone as a vector database. However, your python code doesn’t allow for passing in a proxy server. Would you be willing to add in the ability to pass in a proxy as an argument within pinecone.init()?

1 Like

Yes, we can pass a proxy via pinecone.init(). Since our REST client is based on an OpenAPI spec, you can pass your own OpenAPI configuration and modify defaults, including proxies. Here is an example to use an insecure local proxy running on my system:

from pinecone.core.client.configuration import Configuration as OpenApiConfiguration

openapi_config = OpenApiConfiguration.get_default_copy()
# Here I am trying to connect to an insecure local proxy at 0.0.0.0:8081, 
#however you can keep the verify_ssl=True if you are using a secure connection
openapi_config.verify_ssl = False
openapi_config.proxy = "http://0.0.0.0:8081"
pinecone.init(api_key="API_KEY",openapi_config=openapi_config)
index = pinecone.Index("test")
print(index.describe_index_stats())

Note: This is only configurable for the REST client as of now, we will add similar support for gRPC soon.

1 Like

Hello! How would we do this with the new API?
I’m trying to update an old project which used a proxy but I can’t figure out how to pass this argument in the new configuration.

Are you able to set the proxy with the new API. Looking for the same info.

@rajat - any suggestions as you have helped with the original query of this post

Version 3 of the python SDK had a issue with proxies, where the openapi_config was not being passed down to the data connection. Leading to a number of different errors, like timeouts and To be honest we never expected users to be using the openapi_config.

The good news is that we have made proxy a top level feature in v3.2.0. There is no need to touch the openapi_config.

The recommended way to use a proxy with the Python SDK client is:

from pinecone import Pinecone
import urllib3 import make_headers

pc = Pinecone(
    api_key="YOUR_API_KEY",
    proxy_url='https://your-proxy.com',
    proxy_headers=make_headers(proxy_basic_auth='username:password'),
    ssl_ca_certs='path/to/cert-bundle.pem'
)

pc.list_indexes()