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

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

pinecone-9.0.0rc1-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.0rc1.tar.gz.

File metadata

  • Download URL: pinecone-9.0.0rc1.tar.gz
  • Upload date:
  • Size: 248.1 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.0rc1.tar.gz
Algorithm Hash digest
SHA256 e8d87f2bf4d66823ff3a5b02ca180bd02e4915f19f471ceb426ba014a3c7ff90
MD5 af119600f7cf0b19c27ca1092a99bb1d
BLAKE2b-256 1630d897a5254ac62c74d3fc97ec6693274cbf5f0b8f769029285be57a0f65e6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pinecone-9.0.0rc1-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.0rc1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4cb9bf87cb14a65eae842baed91c708ad43c78b75a1aad47f537bcc58046174f
MD5 74beaea957b448fcdc6beeac2c9dbca8
BLAKE2b-256 93a8df6842a18a7b7d21a31c95ceb8162b04656ca1c2da3bdce79a680de1d334

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 034d5115401c8478e0ef52942c3ec0bdfff4b2169df83d102338d246fb6bec06
MD5 86e0586c0b30f7c28f4af56826d3400d
BLAKE2b-256 a908537f4524a03d2458a5c59443db4c451059c86b984170d51dd1310ba006df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 873dbef8ed5af8de655189f5d5c071cb9fc802542c643ec5aa1c67b7c2c0c853
MD5 29136a9bc76e23c00ef8a330749e2e0d
BLAKE2b-256 cbcdea6ccabb46254ce3cbd259c838a8d7f59ce8b61e20ffa9007b8373ec1230

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eadf0f22edef961ace68167cc72ea66bbb57d53f81352b289f55fc126161c0a0
MD5 be93cd1fe3bee26b4d9db7f72e9ade20
BLAKE2b-256 b9d91138d497a29126ef370a5ce3e86cb405e3adc63f1e71d3671ad253f9dcfc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f5bc2ab442bb5aa7b72ed546e45a9a93181bdeb443712eb1005824ead0ed7a7b
MD5 2226225613e754956167241ddc430c16
BLAKE2b-256 eaa70d69968cda2a67802d851227f49906b42c1a568fa43a68263b4df48f83d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe1fd24808717b8a714240b770dea644e5f7b06a4828463a00e5d0f1cdcf75d1
MD5 4f70b4086762f3afad1ec54d7727dd74
BLAKE2b-256 d36332fe11e89859814c8b1939f24e49f9ce1bbbd37c15625eb86d54d27f1027

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.0.0rc1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a46380ea9ac06759bc6b3e6ea8f6a719660898cb05c96d792d1f1d10b7690b03
MD5 c358dc24d20be19f0b5e7cb0aabd29f9
BLAKE2b-256 62e1065150d7a99c6865d6768f52d4122e17a36ca6ce4cde7a5f2b3ead0fcf86

See more details on using hashes here.

Provenance

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