GrpcIndex¶
Obtain a GrpcIndex instance via pinecone.Pinecone.index() with
grpc=True, or construct one directly.
from pinecone import Pinecone
pc = Pinecone(api_key="your-api-key")
# Resolve host automatically by index name
idx = pc.index("my-index", grpc=True)
# — or — construct directly with a host URL
from pinecone.grpc import GrpcIndex
idx = GrpcIndex(host="my-index-abc123.svc.pinecone.io", api_key="your-api-key")
GrpcIndex exposes the same data-plane operations as
Index but uses gRPC transport (backed by a Rust
extension) and returns PineconeFuture objects
from the *_async() methods.
Method groups:
Vectors —
upsert(),upsert_from_dataframe(),upsert_records(),query(),fetch(),update(),delete(),list(),list_paginated()Stats —
describe_index_stats()Integrated Inference —
search(),search_records()Async variants —
upsert_async(),query_async(),fetch_async(),delete_async()Lifecycle —
close()
- class pinecone.grpc.GrpcIndex(*, host, api_key=None, api_version='2026-07', source_tag=None, secure=True, timeout=20.0, connect_timeout=1.0, retry_config=None, proxy_url=None, on_throttle=None, limiter_registry=None)[source]¶
Bases:
objectSynchronous gRPC data plane client targeting a specific Pinecone index.
Provides the same interface as
Indexbut routes data-plane operations through a gRPC transport (via the Rust-backedGrpcChannel) instead of HTTP/REST.- Parameters:
host (str) – The index-specific data plane host URL.
api_key (str | None) – Pinecone API key. Falls back to
PINECONE_API_KEYenv var.api_version (str) – API version string. Defaults to the current data plane version.
source_tag (str | None) – Tag appended to the User-Agent string for request attribution.
secure (bool) – Whether to use TLS encryption. Defaults to
True.timeout (float) – Request timeout in seconds. Defaults to
20.0.connect_timeout (float) – Connection timeout in seconds. Defaults to
1.0.retry_config (RetryConfig | None) – Retry policy for transient gRPC errors. Accepts the same
RetryConfigREST uses.None(default) uses the gRPC defaults:max_retries=5,backoff_factor=0.1,max_wait=60.0.retryable_status_codesis ignored on this transport — it carries HTTP statuses, while gRPC retries a fixed set oftonic::Codevalues (UNAVAILABLE, RESOURCE_EXHAUSTED, ABORTED).proxy_url (str | None) – HTTP proxy URL. gRPC traffic is tunnelled through it with HTTP CONNECT.
limiter_registry (_AdaptiveLimiterRegistry | None) – SDK-internal. Registry the bulk paths consult to back off under throttling. Wired by
Pinecone.index(); not intended for user configuration.on_throttle (Callable[[str], None] | None)
- Raises:
PineconeValueError – If no API key can be resolved or the host is invalid.
Note
Four timeout layers apply to every gRPC call, and only the first three bound a single request:
Connect —
connect_timeout, default1.0s.Per attempt —
timeout(or a per-calltimeout=), default20.0s. This is a deadline on one attempt, not on the call.Retry budget —
retry_config.max_retriesattempts after the first, with backoff between them.Whole job — for bulk methods only,
total_timeout.
Layers 2 and 3 multiply.
timeout=120is not a 120s bound: with the defaultmax_retries=5it is up to 6 attempts × 120s plus backoff, so a worst case near 17 minutes. Lowermax_retriesto shrink that, or bound the whole operation withtotal_timeout.Examples
from pinecone.grpc import GrpcIndex idx = GrpcIndex(host="movie-recs-abc123.svc.pinecone.io", api_key="...")
- __init__(*, host, api_key=None, api_version='2026-07', source_tag=None, secure=True, timeout=20.0, connect_timeout=1.0, retry_config=None, proxy_url=None, on_throttle=None, limiter_registry=None)[source]¶
- Parameters:
- Return type:
None
- upsert(*, vectors, namespace='', batch_size=None, max_concurrency=4, show_progress=True, timeout=None)[source]¶
Upsert a batch of vectors into a namespace.
If a vector with the same ID already exists in the namespace, it is overwritten.
One request is capped both on the number of vectors it carries and on its encoded size, and with wide vectors or heavy metadata the size cap is usually the one reached first. Pass
batch_sizeto split a long sequence into requests that stay under both.- Parameters:
vectors (Sequence[Vector | tuple[str, Sequence[float]] | tuple[str, Sequence[float], Mapping[str, Any]] | Mapping[str, Any]]) – Sequence of vectors to upsert. Each element can be a
Vectorinstance, a tuple of(id, values)or(id, values, metadata), or a dict withid,values, and optionalsparse_values/metadatakeys.namespace (str) – Target namespace. Defaults to the default (empty-string) namespace.
batch_size (int | None) – If set, splits
vectorsinto batches of this size and submits them in parallel.None(default) sends all vectors in a single request. Must be a positive integer when set.max_concurrency (int) – Number of parallel threads used when
batch_sizeis set. Default4, range[1, 64]. Ignored whenbatch_sizeisNone.show_progress (bool) – If
Trueandtqdmis installed, display a progress bar while submitting batches. Ignored whenbatch_sizeisNone. Defaults toTrue.timeout (float | None) – Per-call timeout in seconds. Applied per batch when batching. None uses the client-level default.
- Returns:
UpsertResponsewith the count of vectors upserted.- Raises:
PineconeTypeError – If a vector element is not a recognized format.
PineconeValueError – If a vector element is malformed, if
batch_sizeis not a positive integer, or ifmax_concurrencyis outside[1, 64].ApiError – If one request exceeds the server’s cap on vectors per request or on encoded request size. Lower
batch_sizeand retry.PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Notes
When
batch_sizeis set, up tomax_concurrencybatches run at once (default 4, range 1-64), each retried independently on transient errors. Partial failures do not raise — the returnedUpsertResponsecarriesupserted_count,failed_item_count,errors, andfailed_itemsfor inspection or retry. Passresponse.failed_itemsback toupsert(...)to retry only the failures.Examples
from pinecone.grpc import GrpcIndex from pinecone.models.vectors.vector import Vector idx = GrpcIndex(host="article-search-abc123.svc.pinecone.io", api_key="...") response = idx.upsert( vectors=[ Vector( id="article-101", values=[0.012, -0.087, 0.153, ...], # 1536-dim ), ("article-102", [0.045, 0.021, -0.064, ...]), {"id": "article-103", "values": [0.091, -0.032, 0.178, ...]}, ], namespace="articles-en", ) print(response.upserted_count)
- query(*, top_k, vector=None, id=None, namespace='', filter=None, include_values=False, include_metadata=False, sparse_vector=None, scan_factor=None, max_candidates=None, timeout=None)[source]¶
Query a namespace for the nearest neighbors of a vector.
Note
Vector operations remain available for indexes created before 2026-07, where you supply your own vectors. An index created at 2026-07 carries a document schema instead, and its reads and writes go through the document operations.
- Parameters:
top_k (int) – Number of results to return, 1-10000.
id (str | None) – ID of a stored vector to use as the query.
namespace (str) – Namespace to query. Defaults to the default namespace.
filter (dict[str, Any] | None) – Metadata filter expression.
include_values (bool) – Whether to include vector values in results.
include_metadata (bool) – Whether to include metadata in results.
sparse_vector (SparseValues | dict[str, Any] | None) – Sparse query vector with indices and values.
scan_factor (float | None) – Recall/latency trade for dedicated read node (DRN) indexes — a multiplier on how much of the index is scanned. Above 1 scans more and favours recall; below 1 scans less and favours latency. Omit to let the server choose.
max_candidates (int | None) – Recall/latency trade for dedicated read node (DRN) indexes — caps how many candidates are reranked before
top_kis taken. Must be at leasttop_k: a smaller value is rejected rather than clamped, since it could not fill the page.timeout (float | None) – Per-call timeout in seconds. None uses the client-level default.
- Returns:
QueryResponsewith matches, namespace, and usage info.- Raises:
PineconeValueError – If top_k is not between 1 and 10000,
idis combined withvectororsparse_vector, none ofvector,id, orsparse_vectoris provided, oridis not a legal vector ID.ApiError – If
scan_factorormax_candidatesis out of range, or the index is not a dense DRN index — both knobs are rejected on on-demand indexes and on sparse indexes.PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
response = idx.query( top_k=10, vector=[0.012, -0.087, 0.153, ...], # 1536-dim embedding ) for match in response.matches: print(match.id, match.score)
- query_namespaces(*, vector=None, namespaces, metric, top_k=None, filter=None, include_values=False, include_metadata=False, sparse_vector=None, scan_factor=None, max_candidates=None, timeout=None)[source]¶
Query multiple namespaces in parallel and return merged top results.
Fans out individual
query()calls across all given namespaces using a thread pool, then merges results via a heap-based aggregator that returns the overall top-k matches ranked by the specified metric.- Parameters:
vector (Sequence[float] | None) – Dense query vector values. Required for dense and hybrid indexes; omit for sparse-only indexes (use sparse_vector instead).
namespaces (Sequence[str]) – Namespaces to query (must be non-empty). Duplicates are removed while preserving order.
metric (str) – Distance metric —
"cosine","euclidean", or"dotproduct".top_k (int | None) – Maximum number of results to return. Defaults to 10.
filter (Mapping[str, Any] | None) – Metadata filter expression applied to every namespace.
include_values (bool) – Whether to include vector values in results.
include_metadata (bool) – Whether to include metadata in results.
sparse_vector (SparseValues | Mapping[str, Any] | None) – Sparse query vector with indices and values. Required for sparse-only indexes when vector is omitted.
scan_factor (float | None) – Recall/latency trade for dedicated read node (DRN) indexes — a multiplier on how much of the index is scanned. Above 1 scans more and favours recall; below 1 scans less and favours latency. Applied to every namespace queried.
max_candidates (int | None) – Recall/latency trade for dedicated read node (DRN) indexes — caps how many candidates are reranked before
top_kis taken, per namespace. Must be at leasttop_k.timeout (float | None)
- Returns:
QueryNamespacesResultswith the merged top-k matches, total usage, and per-namespace usage.- Raises:
PineconeValueError – If namespaces is empty, if both vector and sparse_vector are absent/empty, or if metric is not a recognized value.
ApiError – If any individual namespace query fails.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before the configured timeout elapses.
- Return type:
Examples
# Dense query results = idx.query_namespaces( vector=[0.012, -0.087, 0.153], # truncated; use your actual dimension namespaces=["articles-en", "articles-fr", "articles-de"], metric="cosine", top_k=10, ) # Sparse-only query (sparse index) results = idx.query_namespaces( sparse_vector={"indices": [0, 1, 2], "values": [0.1, 0.2, 0.3]}, namespaces=["docs-en", "docs-fr"], metric="dotproduct", top_k=10, ) for match in results.matches: print(match.id, match.score)
- fetch(*, ids, namespace='', timeout=None)[source]¶
Fetch vectors by their IDs from a namespace.
- Parameters:
- Returns:
FetchResponsewith a map of vector IDs to Vector objects, namespace, and usage info.- Raises:
PineconeValueError – If ids is empty or any ID is not 1-512 ASCII characters without a NUL.
PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
response = idx.fetch(ids=["article-101", "article-102"]) for vid, vec in response.vectors.items(): print(vid, vec.values)
- fetch_by_metadata(*, filter, namespace='', limit=None, pagination_token=None, timeout=None)[source]¶
Fetch vectors matching a metadata filter expression.
- Parameters:
filter (Mapping[str, Any]) – Metadata filter expression (required, at least one condition).
namespace (str) – Namespace to fetch from. Defaults to the default namespace.
limit (int | None) – Maximum number of vectors to return per page, 1-10000. Omit to let the server choose the page size.
pagination_token (str | None) – Token from a previous response to fetch the next page.
timeout (float | None) – Per-call timeout in seconds.
- Returns:
FetchByMetadataResponsewith matched vectors, namespace, usage, and pagination token for the next page (if any).- Raises:
PineconeValueError – If
filteris empty orlimitfalls outside 1-10000.ApiError – If the API returns an error response.
PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
response = idx.fetch_by_metadata( filter={"category": {"$eq": "science"}}, limit=50, ) for vid, vec in response.vectors.items(): print(vid, vec.metadata)
- delete(*, ids=None, delete_all=False, filter=None, namespace='', timeout=None)[source]¶
Delete vectors from a namespace by ID, filter, or delete-all flag.
Exactly one of
ids,delete_all, orfiltermust be specified.A by-filter delete selects on metadata alone, so a text-match operator (
$match_phrase,$match_all,$match_any) in the filter is rejected rather than ignored — evaluated there it would match everything and widen the delete to every record the rest of the filter admits. Text matching belongs insearch().A by-filter delete also reads before it writes, so a dedicated index scaled to zero replicas refuses it; add replicas first. Deleting by ID or with
delete_allis unaffected.- Parameters:
delete_all (bool) – If True, delete all vectors in the namespace.
filter (dict[str, Any] | None) – Metadata filter expression selecting vectors to delete.
namespace (str) – Namespace to delete from. Defaults to the default namespace.
timeout (float | None) – Per-call timeout in seconds. None uses the client-level default.
- Returns:
None
- Raises:
PineconeValueError – If zero or more than one deletion mode is specified, any ID is not a legal vector ID, or
filteris empty.ApiError – If a by-filter delete uses a text-match operator, or the index is a dedicated index scaled to zero replicas.
PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
None
Examples
# Delete by IDs idx.delete(ids=["article-101", "article-102"]) # Delete all vectors in a namespace idx.delete(delete_all=True, namespace="articles-deprecated") # Delete by metadata filter idx.delete(filter={"category": {"$eq": "obsolete"}})
- update(*, id=None, values=None, sparse_values=None, set_metadata=None, namespace='', filter=None, dry_run=False, timeout=None)[source]¶
Update vectors by ID or metadata filter.
A by-filter update selects on metadata alone, so a text-match operator (
$match_phrase,$match_all,$match_any) in the filter is rejected rather than ignored — evaluated there it would match everything and widen the patch to every record the rest of the filter admits. Text matching belongs insearch().A by-filter update also reads before it writes, so a dedicated index scaled to zero replicas refuses it; add replicas first. Updating by ID is unaffected.
- Parameters:
id (str | None) – ID of the vector to update.
sparse_values (SparseValues | dict[str, Any] | None) – New sparse vector.
set_metadata (dict[str, Any] | None) – Metadata fields to set or overwrite.
namespace (str) – Namespace to target. Defaults to the default namespace.
filter (dict[str, Any] | None) – Metadata filter expression selecting vectors to update.
dry_run (bool) – If True, return the count of records that would be affected without applying changes.
timeout (float | None) – Per-call timeout in seconds. None uses the client-level default.
- Returns:
UpdateResponsewith matched_records count (when available).- Raises:
PineconeValueError – If both or neither of id and filter are provided, if
filteris combined withvaluesorsparse_values, iffilteris empty, or ifidis not a legal vector ID.ApiError – If a by-filter update uses a text-match operator, or the index is a dedicated index scaled to zero replicas.
PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
# Update by ID idx.update(id="article-101", values=[0.012, -0.087, 0.153, ...]) # Bulk-update metadata by filter idx.update( filter={"genre": {"$eq": "drama"}}, set_metadata={"year": 2020}, )
- list_paginated(*, prefix=None, limit=None, pagination_token=None, namespace='', timeout=None)[source]¶
Fetch a single page of vector IDs from a namespace.
- Parameters:
prefix (str | None) – Return only IDs starting with this prefix.
limit (int | None) – Maximum number of IDs to return in this page, 1-100.
pagination_token (str | None) – Token from a previous response to fetch the next page.
namespace (str) – Namespace to list from. Defaults to the default namespace.
timeout (float | None) – Per-call timeout in seconds. None uses the client-level default.
- Returns:
ListResponsewith vector IDs, pagination info, namespace, and usage.- Raises:
PineconeValueError – If
prefixis not legal orlimitfalls outside 1-100.PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
response = idx.list_paginated(prefix="doc1#", limit=50) for item in response.vectors: print(item.id)
- list(*, prefix=None, limit=None, namespace='', timeout=None)[source]¶
List vector IDs in a namespace, automatically following pagination.
Yields one
ListResponseper page.- Parameters:
prefix (str | None) – Return only IDs starting with this prefix.
limit (int | None) – Maximum number of IDs to return per page.
namespace (str) – Namespace to list from. Defaults to the default namespace.
timeout (float | None) – Per-call timeout in seconds applied to each page request. None uses the client-level default.
- Yields:
ListResponsefor each page of results.- Raises:
PineconeValueError – If
prefixis not legal orlimitfalls outside 1-100.PineconeTimeoutError – If a page request does not complete before timeout elapses.
- Return type:
Examples
for page in idx.list(prefix="doc1#"): for item in page.vectors: print(item.id)
- describe_index_stats(*, filter=None, timeout=None)[source]¶
Return statistics for this index.
- Parameters:
filter (dict[str, Any] | None) – Metadata filter expression. Accepted for API compatibility, but a non-empty filter is rejected for every index type, so the call fails instead of returning filtered counts. Leave it unset: the statistics returned always describe the whole index.
timeout (float | None) – Per-call timeout in seconds. None uses the client-level default.
- Returns:
DescribeIndexStatsResponsewith namespace summaries, dimension, total vector count, and fullness metrics.- Raises:
ApiError – If a non-empty
filteris provided, since it is rejected for every index type.PineconeTimeoutError – If the call does not complete before timeout elapses.
- Return type:
Examples
stats = idx.describe_index_stats() print(stats.total_vector_count, stats.dimension)
- upsert_from_dataframe(df, namespace='', batch_size=500, show_progress=True, timeout=None, *, max_concurrency=None, total_timeout=None, on_error=None)[source]¶
Upsert vectors from a pandas DataFrame.
Splits the DataFrame into batches of
batch_sizerows, submits batches in parallel, and aggregates the results into a single response.- Parameters:
df (pd.DataFrame) – A
pandas.DataFramewith at leastidandvaluescolumns.sparse_valuesandmetadatacolumns are included when present and non-None.namespace (str) – Target namespace. Defaults to the default namespace.
batch_size (int) – Number of rows per upsert batch. Defaults to 500.
show_progress (bool) – If
Trueandtqdmis installed, display a progress bar. The bar advances as batches complete. Iftqdmis not installed, silently falls back to no progress bar.max_concurrency (int | None) – Number of batches in flight at once, range
[1, 64].None(default) usesmin(32, cpu_count + 4)— pass a value to make throughput reproducible across hosts.on_error (Literal['raise', 'collect'] | None) – What to do when some batches fail.
"collect"returns anUpsertResponsecarryingfailed_item_count,errorsandfailed_items, so the caller can retry only what failed — the same contract the REST client has had since v9.0.0."raise"re-raises the lowest-indexed batch failure, after all batches have settled, with the partial result attached to the exception’sresponseattribute.None(default) behaves as"collect"and additionally warns once per process when a partial failure occurs, since this method used to raise; pass"collect"explicitly to silence that.total_timeout (float | None) – Deadline in seconds for the whole ingest, as opposed to timeout, which bounds a single attempt of a single batch. On expiry no further batches are submitted; batches already in flight are allowed to settle rather than being abandoned, since dropping them client-side would not stop the server from applying them.
PineconeTimeoutErroris then raised carrying the partialUpsertResponseon itsresponseattribute, whosefailed_itemsare the rows that were never sent.None(default) means the ingest is bounded only by the per-batch deadlines.timeout (float | None) –
Server-side deadline in seconds applied to each batch’s upsert request — not to the DataFrame as a whole.
None(default) uses the client’s configured request timeout: thetimeoutpassed toGrpcIndex(20.0sunless you override it). Each attempt of a batch is bounded by this deadline (transient errors may be retried, so a batch’s total wall-clock can exceed it). Result collection then waits for the server, so a large ingest is bounded only by these per-batch deadlines rather than failing prematurely. Raise timeout to give slow batches more time on the server.This is not a bound on the batch. With the default
max_retries=5a batch is up to 6 attempts × timeout, plus backoff between them —timeout=120admits a worst case near 17 minutes for a single batch. See the four timeout layers onGrpcIndex. To shrink the multiplier, pass aretry_configwith a lowermax_retrieswhen constructing the index.
- Returns:
UpsertResponsewith the total count of vectors upserted across all batches.- Raises:
RuntimeError – If
pandasis not installed. It is not an SDK dependency; install it yourself withpip install pandas.PineconeValueError – If df is not a
pandas.DataFrameor batch_size is not a positive integer.PineconeTimeoutError – If a batch exceeds timeout on the server, or if total_timeout expires before every batch is submitted. In the latter case the exception carries the partial
UpsertResponseon itsresponseattribute.
- Return type:
Note
Changed in 9.2.0. Partial failures are aggregated rather than raised, matching
upsert()withbatch_sizeand the REST client. Callers that relied on the raise should passon_error="raise". The old raise discarded the partial count, so no caller could tell what had landed; the new default reports it. Because upserts are idempotent by vector ID, re-running the whole DataFrame after a failure is also still safe.Examples
import pandas as pd from pinecone.grpc import GrpcIndex idx = GrpcIndex( host="article-search-abc123.svc.pinecone.io", api_key="your-api-key", ) df = pd.DataFrame([ {"id": "article-101", "values": [0.012, -0.087, 0.153]}, {"id": "article-102", "values": [0.045, 0.021, -0.064]}, ]) response = idx.upsert_from_dataframe(df) response.upserted_count
df = pd.DataFrame([ { "id": "article-101", "values": [0.012, -0.087, 0.153], "metadata": {"topic": "science", "year": 2024}, }, { "id": "article-102", "values": [0.045, 0.021, -0.064], "metadata": {"topic": "technology", "year": 2024}, }, ]) response = idx.upsert_from_dataframe( df, namespace="articles-en", batch_size=100, )
Give each batch a longer server-side deadline for large or slow ingests:
response = idx.upsert_from_dataframe( df, batch_size=200, timeout=120.0, )
- upsert_async(*, vectors, namespace='', timeout=None)[source]¶
Submit an upsert operation and return a
PineconeFuture.Same parameters as
upsert(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[UpsertResponse] that resolves to the upsert result.- Parameters:
- Return type:
Examples
future = index.upsert_async( vectors=[("doc-42", [0.012, -0.087, 0.153])], ) result = future.result() result.upserted_count # 1
- query_async(*, top_k, vector=None, id=None, namespace='', filter=None, include_values=False, include_metadata=False, sparse_vector=None, scan_factor=None, max_candidates=None, timeout=None)[source]¶
Submit a query operation and return a
PineconeFuture.Same parameters as
query(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[QueryResponse] that resolves to the query result containing scored matches.- Parameters:
- Return type:
Examples
future = index.query_async( vector=[0.012, -0.087, 0.153], top_k=5, ) result = future.result() result.matches[0].id # 'doc-42' result.matches[0].score # 0.95
- fetch_async(*, ids, namespace='', timeout=None)[source]¶
Submit a fetch operation and return a
PineconeFuture.Same parameters as
fetch(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[FetchResponse] that resolves to the fetched vectors keyed by ID.- Parameters:
- Return type:
Examples
future = index.fetch_async(ids=["doc-42", "doc-43"]) result = future.result() result.vectors["doc-42"].values # [0.012, -0.087, 0.153]
- delete_async(*, ids=None, delete_all=False, filter=None, namespace='', timeout=None)[source]¶
Submit a delete operation and return a
PineconeFuture.Same parameters as
delete(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[None] that resolves when the delete operation completes.- Parameters:
- Return type:
PineconeFuture[None]
Examples
future = index.delete_async(ids=["doc-42", "doc-43"]) future.result()
future = index.delete_async(delete_all=True, namespace="docs") future.result()
- update_async(*, id=None, values=None, sparse_values=None, set_metadata=None, filter=None, namespace='', dry_run=False, timeout=None)[source]¶
Submit an update operation and return a
PineconeFuture.Same parameters as
update(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[UpdateResponse] that resolves to the update result.- Parameters:
- Return type:
Examples
future = index.update_async( id="article-101", values=[0.012, -0.087, 0.153] ) result = future.result()
- query_namespaces_async(*, vector=None, namespaces, metric, top_k=None, filter=None, include_values=False, include_metadata=False, sparse_vector=None, scan_factor=None, max_candidates=None, timeout=None)[source]¶
Submit a query_namespaces operation and return a
PineconeFuture.Same parameters as
query_namespaces(), includingtimeout (float | None)which sets a per-call timeout in seconds.- Returns:
PineconeFuture[QueryNamespacesResults] that resolves to the merged top-k matches across namespaces.- Parameters:
- Return type:
Examples
future = idx.query_namespaces_async( vector=[0.012, -0.087, 0.153], # truncated; use your actual dimension namespaces=["articles-en", "articles-fr", "articles-de"], metric="cosine", top_k=10, ) results = future.result() for match in results.matches: print(match.id, match.score)
- upsert_records(*, records, namespace, timeout=None)[source]¶
Upsert records for indexes with integrated inference.
Embeddings are generated server-side from the fields you provide, so each record carries source data (e.g. text) rather than precomputed vector values.
- Parameters:
records (list[dict[str, Any]]) – List of record dicts. Each must contain an
_idoridfield. Additional fields are passed through for server-side embedding.namespace (str) – Target namespace (required). Unlike
upsert(), namespace has no default because the records API requires an explicit namespace (must be non-empty).timeout (float | None)
- Returns:
UpsertRecordsResponsewith the count of records submitted.- Raises:
PineconeValueError – If namespace is not a string or is empty/whitespace, records is empty, or a record is missing an identifier field.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
Examples
pc = Pinecone(api_key="YOUR_API_KEY") idx = pc.index("my-index", grpc=True) response = idx.upsert_records( namespace="articles-en", records=[ {"_id": "article-101", "text": "Vector DBs enable similarity search."}, {"_id": "article-102", "text": "RAG combines search with LLMs."}, ], ) print(response.record_count)
- search(*, namespace, top_k=None, inputs=None, vector=None, id=None, filter=None, fields=None, rerank=None, match_terms=None, query=None, timeout=None)[source]¶
Search records by text, vector, or ID with optional reranking.
Delegates to the REST endpoint because the Pinecone gRPC API does not expose a records search operation for integrated inference indexes.
Note
Use this method for indexes with integrated inference. For classic indexes where you provide your own vectors, use
query().- Parameters:
namespace (str) – Namespace to search in (required).
top_k (int) – Number of results to return (must be >= 1).
inputs (SearchInputs | dict[str, Any] | None) – Inputs for server-side embedding (e.g.
{"text": "query text"}).id (str | None) – ID of an existing record to use as the query.
filter (dict[str, Any] | None) – Metadata filter expression.
fields (list[str] | None) – Field names to include in results. When
None, the server returns all available fields.rerank (RerankConfig | dict[str, Any] | None) – Reranking configuration with
model(required),rank_fields(required), and optionaltop_n,parameters,querykeys. UseRerankConfigfor IDE autocompletion.match_terms (dict[str, Any] | None) – Term-matching constraint for sparse search. Requires keys
"strategy"(currently only"all") and"terms"(list of strings). Valid only on a text query — combined withvectororidit is rejected — and only on a sparse index whose embedding model supports it; the server names the supported model when it refuses.Nonedisables term matching.query (dict[str, Any] | None) – Legacy query body containing
top_kplus one ofinputs,vector, orid. Prefer passing these fields directly.timeout (float | None)
- Returns:
SearchRecordsResponsewith hits and usage statistics.- Raises:
PineconeValueError – If
namespaceis not a string,top_k < 1, orrerankis missing required keys.ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
Examples
response = idx.search( namespace="articles-en", top_k=10, inputs={"text": "benefits of vector databases for search"}, ) for hit in response.result.hits: print(hit.id, hit.score)
Search with reranking:
response = idx.search( namespace="articles-en", top_k=10, inputs={"text": "benefits of vector databases"}, rerank={ "model": "bge-reranker-v2-m3", "rank_fields": ["text"], "top_n": 5, }, ) for hit in response.result.hits: print(hit.id, hit.score)
Note
Use inline
rerankwhen searching and reranking in a single call. Usepc.inference.rerank()when reranking results from a different source or when you need to rerank without searching.
- search_records(*, namespace, top_k=None, inputs=None, vector=None, id=None, filter=None, fields=None, rerank=None, match_terms=None, query=None, timeout=None)[source]¶
Alias for
search(), kept for backwards compatibility.Prefer calling
search()directly.Examples
response = idx.search_records( namespace="articles-en", top_k=10, inputs={"text": "benefits of vector databases for search"}, )
- list_namespaces_paginated(*, prefix=None, limit=None, pagination_token=None, timeout=None)[source]¶
Fetch a single page of namespace descriptions.
- Parameters:
prefix (str | None) – Return only namespaces whose names start with this prefix. Must be ASCII, must not contain the NUL character, and must be at most 512 characters. The empty prefix matches every namespace.
limit (int | None) – Maximum number of namespaces to return in this page, 1-100.
pagination_token (str | None) – Token from a previous response to fetch the next page.
timeout (float | None) – Per-call timeout in seconds.
- Returns:
ListNamespacesResponsewith namespace descriptions, pagination info, and total count. Each description carriessize_bytes.- Raises:
PineconeValueError – If prefix or limit violates the rules above. Raised locally, before the request is sent, with the same message the REST and asyncio clients raise.
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
Examples
page = idx.list_namespaces_paginated(prefix="prod-", limit=50) for ns in page.namespaces: print(ns.name, ns.record_count, ns.size_bytes)
- list_namespaces(*, prefix=None, limit=None, timeout=None)[source]¶
List namespaces, automatically following pagination.
Yields one
ListNamespacesResponseper page. The generator automatically follows pagination tokens until all pages have been retrieved.- Parameters:
prefix (str | None) – Return only namespaces whose names start with this prefix. Must be ASCII, must not contain the NUL character, and must be at most 512 characters. The empty prefix matches every namespace.
limit (int | None) – Maximum number of namespaces to return per page, 1-100.
timeout (float | None) – Per-call timeout in seconds.
- Yields:
ListNamespacesResponsefor each page of results. EachNamespaceDescriptioncarriessize_bytes.- Raises:
PineconeValueError – If prefix or limit violates the rules above. Raised on the first iteration, before the request is sent.
PineconeTimeoutError – If a page request does not complete before timeout elapses.
- Return type:
Examples
for page in idx.list_namespaces(prefix="prod-"): for ns in page.namespaces: print(ns.name, ns.record_count, ns.size_bytes)
- create_namespace(*, name, schema=None, timeout=None)[source]¶
Create a named namespace in the index.
- Parameters:
name (str) – Name for the new namespace. Must be ASCII, must not contain the NUL character, and must be 1-512 characters long.
__default__is reserved and cannot be created: it names the namespace requests address when they omit a namespace, so it always exists.schema (dict[str, Any] | None) – Optional metadata-index configuration,
{"fields": {<field>: {"filterable": True}}}. Omitting it does not mean “index everything”: the namespace inherits the index’s own metadata-index configuration, so an index that restricts which fields are indexed passes that restriction on. Supply schema to override the inherited configuration for this namespace, indexing exactly the fields listed.filterableis required on each field and must beTrue— to leave a field unindexed, omit it fromfields.timeout (float | None) – Per-call timeout in seconds.
- Returns:
NamespaceDescriptionwith the namespace name, record count, schema, indexed fields, andsize_bytes.- Raises:
PineconeValueError – If name violates the rules above, or schema is malformed. Raised locally, before the request is sent, with the same message the REST and asyncio clients raise.
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
Examples
ns = idx.create_namespace(name="movies-en") print(ns.name, ns.record_count, ns.size_bytes)
- describe_namespace(*, name=None, timeout=None, **kwargs)[source]¶
Describe a namespace by name.
This operation is rate limited per index, independently of the other namespace operations. Prefer
list_namespaces()when describing more than one namespace: it returns the same information for every namespace in a single request and is not subject to that limit.- Parameters:
- Returns:
NamespaceDescriptionwith the namespace name, record count, schema, indexed fields, andsize_bytes.- Raises:
PineconeValueError – If name violates the rules above. Raised locally, before the request is sent, with the same message the REST and asyncio clients raise.
TypeError – If unexpected keyword arguments are passed.
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
Examples
ns = idx.describe_namespace(name="movies-en") print(ns.name, ns.record_count, ns.size_bytes)
- delete_namespace(*, name=None, timeout=None, **kwargs)[source]¶
Delete a namespace by name, removing all its vectors.
- Parameters:
- Returns:
None — a successful delete returns no payload.
- Raises:
PineconeValueError – If name violates the rules above. Raised locally, before the request is sent, with the same message the REST and asyncio clients raise.
TypeError – If unexpected keyword arguments are passed.
PineconeTimeoutError – If the request does not complete before timeout elapses.
- Return type:
None
Examples
idx.delete_namespace(name="movies-en")
- start_import(uri, *, error_mode=None, integration_id=None)[source]¶
Start a bulk import operation from an external data source.
Initiates an asynchronous bulk import of vectors from cloud storage into the index. The import runs server-side; use
describe_import()to poll for progress and completion.Note
The import URI must point to a directory of Parquet files in cloud storage. Each Parquet file must follow the Pinecone-required schema. See Pinecone import docs for the required Parquet schema and supported storage formats.
- Parameters:
uri (str) – Directory prefix holding the Parquet files, not a single file. Three forms are accepted:
s3://for Amazon S3,gs://for Google Cloud Storage, and anhttps://URL naming an Azure Blob Storage container.s3://additionally requires that the index itself be hosted on AWS.error_mode (str | None) – How to handle a record the import cannot read.
"continue"skips it and imports the rest;"abort"ends the whole import at the first such record. Case-insensitive. Defaults to"abort"when omitted, so an unreadable record fails the import unless you opt into skipping.integration_id (str | None) – Optional integration ID for the import.
- Returns:
StartImportResponsewith the ID of the created import operation.- Raises:
PineconeValueError – If
error_modeis supplied but not"continue"or"abort".ApiError – If
uriis empty or longer than the server accepts, uses an unsupported scheme, is ans3://URI on an index not hosted on AWS, or names an S3 directory bucket, which imports do not support, or if the API otherwise returns an error response.PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before the configured timeout elapses.
- Return type:
Examples
# Start an import and poll until complete import time response = idx.start_import(uri="s3://my-bucket/vectors/") import_id = response.id # Poll until the import finishes import_op = idx.describe_import(import_id) while import_op.status not in ("Completed", "Failed", "Cancelled"): time.sleep(10) import_op = idx.describe_import(import_id) print(f"Status: {import_op.status}, records imported: {import_op.records_imported}") # Skip unreadable records instead of failing the import response = idx.start_import( uri="s3://my-bucket/vectors/", error_mode="continue", )
See also
upsert()— for upserting vectors directly in small batches (single request per call).upsert_records()— for indexes with integrated inference (text in, server-side embedding).upsert_from_dataframe()— for loading vectors from a pandas DataFrame with automatic batching.
- describe_import(id)[source]¶
Describe a bulk import operation by ID.
- Parameters:
id (str | int) – Import operation ID. Integers are converted to strings silently.
- Returns:
ImportModelwith the import operation details.- Raises:
PineconeValueError – If the ID is empty or exceeds 1000 characters.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before the configured timeout elapses.
- Return type:
Examples
import_op = idx.describe_import("import-123") print(import_op.status, import_op.percent_complete)
- cancel_import(id)[source]¶
Cancel a running bulk import operation by ID.
- Parameters:
id (str | int) – ID of the import to cancel, as returned by
start_import(). Integers are converted to strings silently.- Returns:
None — a successful cancellation returns no payload.
- Raises:
PineconeValueError – If the ID is empty or exceeds 1000 characters.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before the configured timeout elapses.
- Return type:
None
Examples
idx.cancel_import("import-123")
- list_imports(*, limit=None, pagination_token=None)[source]¶
List bulk import operations, automatically following pagination.
Yields individual
ImportModelobjects, fetching additional pages transparently until all results have been returned. Preferlist_imports_paginated()to control pagination yourself.- Parameters:
- Yields:
ImportModelfor each import operation.- Raises:
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If a page request does not complete before the configured timeout elapses.
- Return type:
Examples
for imp in idx.list_imports(): print(imp.id, imp.status)
- list_imports_paginated(*, limit=None, pagination_token=None)[source]¶
Fetch a single page of bulk import operations.
Returns an
ImportListfor one page. The caller is responsible for managing the pagination token. Preferlist_imports()to have pagination handled automatically.- Parameters:
- Returns:
ImportListfor the requested page, iterable over itsImportModelentries. Itspagination.nextfield holds the token for the next page, orNoneonce there are no more.- Raises:
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request does not complete before the configured timeout elapses.
- Return type:
Examples
page = idx.list_imports_paginated(limit=10) for imp in page: print(imp.id, imp.status) next_token = page.pagination.next if page.pagination else None
- close()[source]¶
Close the connection to the index and release background resources.
Waits for any in-flight
*_asyncsubmissions to finish, then shuts down the worker pools used for batch upserts and closes the network connection. Call this when you are done issuing requests through this client and are not using it as a context manager.Examples
idx = pc.index("my-index", grpc=True) idx.upsert(vectors=[...]) idx.close()
- Return type:
None
PineconeFuture¶
*_async() methods on GrpcIndex return a
PineconeFuture which is fully compatible with
concurrent.futures.as_completed() and concurrent.futures.wait().
- class pinecone.grpc.future.PineconeFuture(underlying)[source]¶
Bases:
Future[_T]Future returned by
GrpcIndex.*_async()methods.Wraps a
concurrent.futures.Futureand is fully compatible withconcurrent.futures.as_completed()andconcurrent.futures.wait().The default
result()timeout is 5 seconds. When the timeout elapses,PineconeTimeoutErroris raised with the message"deadline exceeded".Examples
from pinecone.grpc import GrpcIndex idx = GrpcIndex(host="article-search-abc123.svc.pinecone.io", api_key="your-api-key") future = idx.upsert_async(vectors=[("article-101", [0.012, -0.087, 0.153, ...])]) result = future.result() # blocks up to 5 seconds result.upserted_count # 1
from concurrent.futures import as_completed futures = [ idx.upsert_async(vectors=[("article-101", [0.012, -0.087, 0.153, ...])]), idx.upsert_async(vectors=[("article-102", [0.045, 0.021, -0.064, ...])]), ] for future in as_completed(futures): print(future.result().upserted_count)
- Parameters:
underlying (Future[_T])
- __init__(underlying)[source]¶
Initializes the future. Should not be called by clients.
- Parameters:
underlying (Future[_T])
- Return type:
None
- add_done_callback(fn)[source]¶
Attach a callable to be called when the future finishes.
The callable will be called with the future as its only argument.
- cancel()[source]¶
Attempt to cancel the underlying call.
Returns
Trueif the call was successfully cancelled,Falseif the call has already completed or is running.- Return type:
- exception(timeout=5.0)[source]¶
Return the exception raised by the call, or
None.- Parameters:
timeout (float | None) – Maximum seconds to wait. Defaults to 5.0.
- Raises:
PineconeTimeoutError – If timeout seconds elapse.
- Return type:
BaseException | None
- result(timeout=5.0)[source]¶
Return the result of the call that the future represents.
- Parameters:
timeout (float | None) – Maximum seconds to wait. Defaults to 5.0. Pass
Noneto block indefinitely.- Returns:
The result value set by the underlying future.
- Raises:
PineconeTimeoutError – If timeout seconds elapse before the result is available.
- Return type:
_T
Examples
future = idx.upsert_async(vectors=[("article-101", [0.012, -0.087, 0.153, ...])]) result = future.result() result.upserted_count # 1
future = idx.upsert_async(vectors=large_batch) result = future.result(timeout=30.0)
result = future.result(timeout=None)