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",
)

# 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 = 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-8.2.0rc2.tar.gz (247.1 kB view details)

Uploaded Source

Built Distributions

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

pinecone-8.2.0rc2-cp310-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

pinecone-8.2.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-8.2.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

pinecone-8.2.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-8.2.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-8.2.0rc2-cp310-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pinecone-8.2.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-8.2.0rc2.tar.gz.

File metadata

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

File hashes

Hashes for pinecone-8.2.0rc2.tar.gz
Algorithm Hash digest
SHA256 ca10b417ef0cbe5a4bf8a626480a655dfd32abdc7a71d4d57c23766e30b9e34a
MD5 c1850df43140862f36c78b3dc6d18969
BLAKE2b-256 d738e29e9ef566e6adf6f8ec500fdd69183b3ea106800ae3a1f8e67a86239ac1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pinecone-8.2.0rc2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.5 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-8.2.0rc2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 429fcb4aebf5e4c95ca7c9573e83587dd2ef5d4dad729734c5cba791694cf9f8
MD5 88ee50bf4144c0b45ec244ffa122ac2e
BLAKE2b-256 bcd4c3d219971e9f63f0c891862e38381ed7589213133a1c33e0b9cfd78c5df1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5464be4fe3e14c1ba2fbcad2ec0f358bf73641859c671df2561620cb930c9325
MD5 14be617448d6cc167163947f27286c3a
BLAKE2b-256 d150f000fe0b5f670467f4ba35a10352a6fa303e3a17c98b9a9348f14ab4574e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e2abf7dff36a4749ebcee5dfe2fc6f96ea96f6c699d2fac2a311227b5c9c8168
MD5 2c44e1f22017124fca75301c7e54923c
BLAKE2b-256 068620c50614c95dacf9a055168523c38e1a8b365ec774d467a0b8baac98618a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b7bce860aaf396e09b7ed7f79949bbdd68f4124519afd6a3f983096cbd9ac12
MD5 58e45477e9b221218e5707529d3ef524
BLAKE2b-256 8e75817f599cd984a21889a1b56e8f7e200ab4710d00c9aa724854e3f357655b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 93209769f5dedfd4bde77379aa006c01ee1f31550d4e903aa06ec20cd4a8fa8a
MD5 6e20907a9c6c9629553c1e9914f40896
BLAKE2b-256 3244a32da0fa28e7ee83851028de6aecaf5e1aeffc0df000e3a0993b530e8a27

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7dacd3c6ab8a486c352afe97ce3ea08137f4de73417a51adba41de540f68a48
MD5 5e531165e7400577627f087745cde8a6
BLAKE2b-256 ad3e5aa9cd8effb6138d30c9a8ea6de86f73008e266168e29ce487f580d764d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinecone-8.2.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-8.2.0rc2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-8.2.0rc2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 53faf355dbdf03e1cc060c3434485163bc462a8501e1170d5dc0f5f9f29efcde
MD5 6aa67a09b5813b511115632e80d0592d
BLAKE2b-256 3a315f989591ac2d566ed1fe8eda236794323646689ef3371f789acdab0ead38

See more details on using hashes here.

Provenance

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