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.1rc1.tar.gz (268.4 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.1rc1-cp310-abi3-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.10+Windows x86-64

pinecone-9.0.1rc1-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.1rc1-cp310-abi3-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

pinecone-9.0.1rc1-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.1rc1-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.1rc1-cp310-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pinecone-9.0.1rc1-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.1rc1.tar.gz.

File metadata

  • Download URL: pinecone-9.0.1rc1.tar.gz
  • Upload date:
  • Size: 268.4 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.1rc1.tar.gz
Algorithm Hash digest
SHA256 ce3349ff0d71d43ecefd4704b41c7e09dca52ff397984fb602cba9dd6ca93663
MD5 9be2ee5dc574144e093cbc0377005a56
BLAKE2b-256 199c95b95d8ce8b10b1d15835a5d056d06f7659ad9a02b882d82d0cdff84c3a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1.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.1rc1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pinecone-9.0.1rc1-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.1rc1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a42b30a598c7cca9fcd77bb635288a00a1ad3ac5ba4e2f643183ff55e1cbf2a
MD5 c710f7d69ee876c7dced3990229e89b0
BLAKE2b-256 a3d8ab21539903d95d175bd28bccc09d91638718a3f9004ecca87d8fb690fc2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e7595c5f0ff838c495b6a8f13c7413aae5222ab3e80374a302006b9477057217
MD5 6581a36860da158a5dfad5e5c0c1fe9e
BLAKE2b-256 4abfdd80a86c3ae6b4a64d6605ed5daec7c06ae76a6bd813617f55c4a2526e56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 50cb5a9ebcfa1c1dacdd17c326ff38d6ecefd1df6d9031d6997f64d708157b15
MD5 6fd486939942d4f377ef9877da7a8138
BLAKE2b-256 706a2df2d729f05dfdb996234a3009e83876dc6cbbdcbc35e917d9594cb7a24c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b068e711ea49d5134d7437c5900700d377c0be79ee8e56a873ccaafa49d2a858
MD5 de8be136adaed854eb40497243ca21d5
BLAKE2b-256 8bacdd997f7d6da05d70ac4eefd2061eef7cae94d285821c43249dabbb2b0836

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2ecce367495f92decb13ff452ebe17d0db96d463984e080d32bb93cb58db4cfc
MD5 e3b9966e3fb61867ecbd66db52b097de
BLAKE2b-256 b0f43432aea9e2849b7889b021e95b0a91b87292fd5e73cfcb1848e659e8aa0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0878249c2e70569abec498157bafe1f8a90f55fa03524bcdf5d8421877392d8c
MD5 c2e1f3de7151d1597c0bcb66c9de0428
BLAKE2b-256 bfe087b2c0b1d6d024b22ade235bcec87bf19b10f0de2b243fb3442834f49f10

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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.1rc1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1rc1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4becdef2605ec0e34df93f6a2517f479e8883e6998b1a14f1f4c854ea5c13752
MD5 2766f826d7bc464030fb1b9d67f76c3b
BLAKE2b-256 845c4fd5da35f821934c4bbb6bade6b1dfd1e3f75fc61afd3ee49c01e9fd10f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-9.0.1rc1-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