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

Retry/throttle smoke tests (opt-in)

A suite of live-API smoke tests verifies that the retry stack and AIMD adaptive concurrency hold up against real Pinecone rate limits. These are not run in normal CI because they require real credentials, create a live serverless index, and take 1–3 minutes per run.

Required environment variables:

Variable Description
PINECONE_API_KEY A valid Pinecone API key
PINECONE_RETRY_SMOKE Set to 1 to enable the smoke tests

Running the smoke tests:

PINECONE_API_KEY=your-api-key PINECONE_RETRY_SMOKE=1 \
  uv run pytest tests/integration/test_retry_smoke.py -x -v -s

Cost: Each run creates three serverless indexes, upserts ~100K vectors per index, then deletes all indexes. Total cost is under $3 per run.

When to run: Before any release that touches retry logic, HTTP transport, the AIMD adaptive-concurrency limiter (pinecone._internal.adaptive), or the batch-upsert path. The unit tests mock HTTP responses; this test catches divergence between the synthetic model and real API behavior (e.g., 503 instead of 429).

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

This version

9.1.0

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

Uploaded CPython 3.10+Windows x86-64

pinecone-9.1.0-cp310-abi3-musllinux_1_2_x86_64.whl (3.3 MB view details)

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

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

pinecone-9.1.0-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.1.0-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.1.0-cp310-abi3-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pinecone-9.1.0-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.1.0.tar.gz.

File metadata

  • Download URL: pinecone-9.1.0.tar.gz
  • Upload date:
  • Size: 282.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.1.0.tar.gz
Algorithm Hash digest
SHA256 d53fe6f4978ab0642eb2d3a0ee3b2576ccfeebaa11e0690b18e67dac4e057047
MD5 7cdfacecac9cce047b3e373363067ddf
BLAKE2b-256 f7f73e0226172561149c7ae5eb08c2168eef7634bf117b017dd03b404b385235

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pinecone-9.1.0-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.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ffae8fb7cbb4056b920586629f15b08107350be4802a5637d10b31e2ad841f9c
MD5 6c6008d3c192bc5331ed0dc822d4bc8c
BLAKE2b-256 c5e84f4e6570650904ff71383b404e667382c92d54b31c5f56a4f037cc17c57f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6c3a6dfa577dc11aed3197e1b221e65522603e9e1f6bd27a1b504a0909b3559f
MD5 6f36dbda42942fb78eb48eb6a83fd5f0
BLAKE2b-256 bcde0a4e4ca28ff305625710288d224600026fe79657e278f9c137368ccdee65

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fe6aeaf6515e9021984755ebc162f643c79d98056059aab2e765962a7538818c
MD5 cc5c45d696741b257b667b9d839365d7
BLAKE2b-256 4f2b0e4f26cdd3051b8bfae158a410ae6242b3b92d21f221072f88dc84ba8cdc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc71ec431108de2df1a1978d3a24ac16f74ba3d8f3265c3760f969386e8742b8
MD5 01656853c1746825f105b778804498df
BLAKE2b-256 5ed9a90614e7501b05fddc5a483054df1f1e76fb272fe431f0c7fc17678e2c37

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 461632bb07919da32b943100b8a047c74be53a6aa15c8b7679bff7a0f834c939
MD5 4cda44f9f5f8d6ecd6ab91b1983b9b6f
BLAKE2b-256 1c77ba204cda329ab8046291f7305177a8aa7dcabf6e337183b8af093dd02de4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e930ba819f5b7e20aac688d04c840a8b6fbc6d12630d71303bb2130881a9d169
MD5 039ea1cb797ff8c286ac3d6d97df1717
BLAKE2b-256 d78f29c8bb484bfb4e7409bf33caba6dce63436698a2b56cf2a82fde994dd59a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pinecone-9.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d3871bd3f39cb430ae8470158dc9c5dcffbac5ae31d144d9a7c3b351ac51755f
MD5 8de28a8d454101247b286478e7fe9f9a
BLAKE2b-256 3cfffc321e1eeca5c71394577022758962c40abc4be161070cc4c0587a7930fa

See more details on using hashes here.

Provenance

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