Skip to main content

Pinecone Python SDK

Project description

Pinecone Python SDK

The Pinecone Python SDK provides a client for the Pinecone vector database. Use it to create and manage indexes, upsert and query vectors, and run inference operations from Python.

Requires Python 3.10+.

Installation

pip install pinecone

For development dependencies (testing, type checking, linting):

pip install pinecone[dev]

Quick start

from pinecone import Pinecone, ServerlessSpec

# Initialize the client
pc = Pinecone(api_key="your-api-key")

# Create a serverless index
pc.indexes.create(
    name="movie-recommendations",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(cloud="aws", region="us-east-1"),
)

# Connect to the index
index = pc.index("movie-recommendations")

# Upsert vectors
index.upsert(
    vectors=[
        ("movie-42", [0.012, -0.087, 0.153]),  # 1536-dim embedding
        ("movie-87", [0.045, 0.021, -0.064]),  # 1536-dim embedding
    ],
    namespace="movies-en",
    batch_size=100,  # split larger inputs into parallel batches automatically
)

# Query for similar vectors
results = index.query(
    vector=[0.012, -0.087, 0.153],  # 1536-dim embedding
    top_k=10,
    namespace="movies-en",
)

for match in results.matches:
    print(f"{match.id}: {match.score:.4f}")

Async usage

The SDK provides an async client for use with asyncio:

import asyncio
from pinecone import AsyncPinecone

async def main():
    async with AsyncPinecone(api_key="your-api-key") as pc:
        desc = await pc.indexes.describe("movie-recommendations")
        index = await pc.index(host=desc.host)
        async with index:
            results = await index.query(
                vector=[0.012, -0.087, 0.153],  # 1536-dim vector
                top_k=10,
                namespace="movies-en",
            )
            for match in results.matches:
                print(f"{match.id}: {match.score:.4f}")

asyncio.run(main())

Configuration

API key

Pass the API key directly or set the PINECONE_API_KEY environment variable:

from pinecone import Pinecone

# Explicit API key
pc = Pinecone(api_key="your-api-key")

# From environment variable (PINECONE_API_KEY)
pc = Pinecone()

Custom host

Connect to a specific control plane host:

pc = Pinecone(api_key="your-api-key", host="https://api.pinecone.io")

Timeout

Configure request timeouts in seconds:

pc = Pinecone(api_key="your-api-key", timeout=30)

Debug logging

Enable debug logging by setting the PINECONE_DEBUG environment variable:

export PINECONE_DEBUG=1

Development

Setup

Clone the repository and install dependencies with uv:

uv sync

Tests

uv run pytest tests/unit/ -x -v

Type checking

uv run mypy --strict pinecone/

Linting and formatting

uv run ruff check --fix
uv run ruff format

License

Apache-2.0. See LICENSE for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinecone-9.0.0rc2.tar.gz (255.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pinecone-9.0.0rc2-cp310-abi3-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.10+Windows x86-64

pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

pinecone-9.0.0rc2-cp310-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pinecone-9.0.0rc2-cp310-abi3-macosx_10_12_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file pinecone-9.0.0rc2.tar.gz.

File metadata

  • Download URL: pinecone-9.0.0rc2.tar.gz
  • Upload date:
  • Size: 255.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pinecone-9.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 3a1ad35ff00547d754fb5547347c0a8c17e8106afb8feb8d1d72154763b4a905
MD5 fa0d256a2c2587bc201922c5f2da3b5f
BLAKE2b-256 f5a22aeb8a957f8db478be3a02064267f78bc281d8ca79aebd91d62f0696ba4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2.tar.gz:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pinecone-9.0.0rc2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4fe6598a1a9e21a1cbfc8a06e29554c201cc0735daaca069fd1dd8985ccbf23c
MD5 07d6ff36aced49f6cc1d0dfdb11bfe90
BLAKE2b-256 6da4411bd08ca6cfef3acd33c91ce6067bf3d4612583e74c6b3bd2177801ce4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-win_amd64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 201a65e35d8351b75ba2735661287486971535b348e330a7d94df6f5413eb472
MD5 51ebc2c01e8063eb0cd8773472beaca6
BLAKE2b-256 b44b99ba27ea6c51b2145c1d3521f09a8fdd2edc5d55162c177b319256a2e824

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 03d1e70aa058f7282589935ea5195fd132ab3fd4d5f2d0c47cb4b6f3c8e311b4
MD5 4a7006277464b71daa6988202e884fa9
BLAKE2b-256 a1f5f73b9dccc7d3ea9ec700431982f2b7243fe706bfbbdba614abe12537ebe7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cf7fa5b7310fea96f2ce4206191b805ae23757ecdedba45d2990062f4165138
MD5 a07cac4e65f50299e3772afef0d4c5e0
BLAKE2b-256 b4bb8cdb8e95211fccd235a58c442ade1b48c5401f0313e52ef25dec99f2c078

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ccaba3adefe58a38bde8491181b82683652bae6e4fd51385902162e25de80e65
MD5 ff64e74e1a7855b962b0d766daa80ce7
BLAKE2b-256 f35b1091d6299211ab09167ce35be6e8767b00744254a474f4f9972cd7cd9ecb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b93bcdda22501ae80be3abcf757e2b605b54bfea524c68d18f85e7c8395d291
MD5 9b7927372fe0c119b2b4463643c85667
BLAKE2b-256 b865fabad17027f4f73b8e18a5219be129ef089253cf9d02a538b486db392941

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinecone-9.0.0rc2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.0rc2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ab0fbbef1266659a132a4c9827179b170ea6e38b0e371af82573d878d851879f
MD5 a1ac68d0e7cb85e08673cc21965c0f9c
BLAKE2b-256 157c928385e36577df9fa32f7178d8c9218495e04322c5e8560cd037e67a09ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.0rc2-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release-rc.yaml on pinecone-io/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page