pinecone. By default, the pinecone package has a minimal set of dependencies and interacts with Pinecone via HTTP requests. However, you can install the following extras to unlock additional functionality:
-
pinecone[grpc]adds dependencies ongrpcioand related libraries needed to run data operations such as upserts and queries over gRPC for a modest performance improvement. -
pinecone[asyncio]adds a dependency onaiohttpand enables usage ofasyncmethods for use with asyncio. For more details, see Asyncio support.
See the Pinecone Python SDK
documentation
for full installation instructions, usage examples, and reference information.To make a feature request or report an issue, please file an issue.
Requirements
The Pinecone Python SDK requires Python 3.9 or later. It has been tested with CPython versions from 3.9 to 3.13.SDK versions
SDK versions are pinned to specific API versions. When a new API version is released, a new version of the SDK is also released. The mappings between API versions and Python SDK versions are as follows:| API version | SDK version |
|---|---|
2025-04 (latest) | v7.x |
2025-01 | v6.x |
2024-10 | v5.3.x |
2024-07 | v5.0.x-v5.2.x |
2024-04 | v4.x |
Install
To install the latest version of the Python SDK, run the following command:pip
pip
To use the Inference API, you must be on version 5.0.0 or later.
Install the Pinecone Assistant Python plugin
As of Python SDK v7.0.0, thepinecone-plugin-assistant package is included by default. It is only necessary to install the package if you are using a version of the Python SDK prior to v7.0.0.
HTTP
Upgrade
Before upgrading to
v6.0.0, update all relevant code to account for the breaking changes explained here.Also, make sure to upgrade using the pinecone package name instead of pinecone-client; upgrading with the latter will not work as of v6.0.0.Initialize
Once installed, you can import the library and then use an API key to initialize a client instance:ServerlessSpec or PodSpec class as well:
Proxy configuration
If your network setup requires you to interact with Pinecone through a proxy, you will need to pass additional configuration using optional keyword parameters:proxy_url: The location of your proxy. This could be an HTTP or HTTPS URL depending on your proxy setup.proxy_headers: Accepts a python dictionary which can be used to pass any custom headers required by your proxy. If your proxy is protected by authentication, use this parameter to pass basic authentication headers with a digest of your username and password. Themake_headersutility fromurllib3can be used to help construct the dictionary. Note: Not supported with Asyncio.ssl_ca_certs: By default, the client will perform SSL certificate verification using the CA bundle maintained by Mozilla in thecertifipackage. If your proxy is using self-signed certicates, use this parameter to specify the path to the certificate (PEM format).ssl_verify: SSL verification is enabled by default, but it is disabled when set toFalse. It is not recommened to go into production with SSL verification disabled.
Async requests
Pinecone Python SDK versions 6.0.0 and later provideasync methods for use with asyncio. Asyncio support makes it possible to use Pinecone with modern async web frameworks such as FastAPI, Quart, and Sanic, and should significantly increase the efficiency of running requests in parallel.
Use the PineconeAsyncio class to create and manage indexes and the IndexAsyncio class to read and write index data. To ensure that sessions are properly closed, use the async with syntax when creating PineconeAsyncio and IndexAsyncio objects.
Query across namespaces
Each query is limited to a single namespace. However, the Pinecone Python SDK provides aquery_namespaces utility method to run a query in parallel across multiple namespaces in an index and then merge the result sets into a single ranked result set with the top_k most relevant results.
The query_namespaces method accepts most of the same arguments as query with the addition of a required namespaces parameter.
- Python SDK without gRPC
- Python SDK with gRPC
When using the Python SDK without gRPC extras, to get good performance, it is important to set values for the
pool_threads and connection_pool_maxsize properties on the index client. The pool_threads setting is the number of threads available to execute requests, while connection_pool_maxsize is the number of cached http connections that will be held. Since these tasks are not computationally heavy and are mainly i/o bound, it should be okay to have a high ratio of threads to cpus.The combined results include the sum of all read unit usage used to perform the underlying queries for each namespace.Python
Upsert from a dataframe
To quickly ingest data when using the Python SDK, use theupsert_from_dataframe method. The method includes retry logic andbatch_size, and is performant especially with Parquet file data sets.
The following example upserts the uora_all-MiniLM-L6-bm25 dataset as a dataframe.
Python