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

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

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

File metadata

  • Download URL: pinecone-9.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3ca2dc3dd7f72102ac6387dd727192fa9c4bfcf08acf6f8c68218d91ca1b9b66
MD5 c732cd9ffcee379a7ccb45b870665d2e
BLAKE2b-256 1e40964536e8440c418412d55671feb62199c9de2443501047fc7f25c266ade3

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pinecone-9.0.1-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.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6d291a767d187acb2c80ab5746f072a38fd40b4995cac7645241ac22e1014c3e
MD5 7be3606d47f2ef52920263efc9f39a4a
BLAKE2b-256 554971462de806e9d10dfbad4870b3f0686763715409b522bdf4aebc39a66825

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e705dd84e7143e736a6de73447c2a69768d7bbe51175cd41a802e9d82b4274b6
MD5 23aa7a21b63562821ab7495b6179ea97
BLAKE2b-256 766749222ad53d4b6aad353c0128aacba482e167ac57de03399077580f5d557f

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 3f900ac25a09a630a87f1f3d9b07d97eacd78d3a98916aca611df348a1f320ab
MD5 cae72055e734d15cd75c58273f4c2f1e
BLAKE2b-256 3e6c8e55dbaf0e4c5375144e1db436e1dccef08880e38d80da967ffa670c8a67

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 403fd82fd28735cff63b078b1f237f3f12babc761603f84dbf71b8d253c8268b
MD5 83ce4e785471df28ef8d394c2eca58a0
BLAKE2b-256 ecf286b948ca45f106d5db408946abff98f42d8a59f83701140988066f529dca

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 32ccf427a15864035775a506b6d514d197c5f28d53519827230f0190f048fbed
MD5 c9abbd4611cdea34d2c51acac9f7750d
BLAKE2b-256 9a462331c797273a0a3162a1ff3774ac9b2d12807484d650789f4c5c4c0bdc39

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 158d8b0dafc9e48231c83c12f96cb76337136a29e588991aa630dff73f21eedc
MD5 5b22871a7dad94c2ad56097e51e8ccd3
BLAKE2b-256 a490f935ac0ae87be265640442ac6dc5a5f5954014d1efc4b3d0de8aa8120715

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pinecone-9.0.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 142a938d19c985782e8a488cb23e15443de8aa5bc3407d3c1807159cc3949822
MD5 959b6f351272d2810306b026848c15ea
BLAKE2b-256 f90defe019ec87cab7270cc3b222b890db35ad62fb8d4416f98b06499f0e178f

See more details on using hashes here.

Provenance

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

Publisher: release-prod.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