Models¶
All public model types returned by SDK methods. Every model is an immutable
msgspec.Struct subclass — fields are accessed as plain attributes
(e.g. idx.name).
Index Models¶
- class pinecone.models.indexes.index.IndexModel(*, name, metric, host, status, spec, vector_type='dense', dimension=None, deletion_protection='disabled', tags=None, embed=None, created_at=None)[source]¶
Bases:
StructResponse model for a Pinecone index.
- Variables:
name (str) – The name of the index.
metric (str) – Distance metric used for similarity search (e.g.
"cosine","euclidean","dotproduct").host (str) – The hostname where this index is served.
status (pinecone.models.indexes.index.IndexStatus) – Current status of the index.
spec (pinecone.models.indexes.index.IndexSpec) – Deployment specification containing either
serverless,pod, orbyocconfiguration.vector_type (str) – Type of vectors stored (default:
"dense").dimension (int | None) – Dimensionality of vectors in the index, or
Nonefor indexes that infer dimension from the first upsert.deletion_protection (str) – Whether deletion protection is enabled (
"enabled"or"disabled").tags (dict[str, str] | None) – User-defined key-value tags attached to the index, or
Noneif no tags are set.embed (pinecone.models.indexes.index.ModelIndexEmbed | None) – Embedding configuration for model-backed (integrated) indexes, populated for indexes created with integrated inference and
Noneotherwise. SeeModelIndexEmbed.created_at (str | None) – ISO-8601 timestamp of when the index was created, or
Noneif the server response did not include it. Stored as a string; parse withdatetime.fromisoformatif you need adatetimeobject.
- Parameters:
- embed: ModelIndexEmbed | None¶
- status: IndexStatus¶
- to_dict()[source]¶
Return a plain dict representation, recursively converting nested fields.
- Returns:
Dictionary with all top-level fields, where nested
spec,status, andembedstructs are also converted to plain dicts recursively. Optional fields (dimension,tags,embed) that areNoneare included in the output with theirNonevalues.- Return type:
Examples
>>> from pinecone.models.indexes.index import ( ... IndexModel, IndexSpec, IndexStatus, ServerlessSpecInfo ... ) >>> index = IndexModel( ... name="my-index", ... metric="cosine", ... host="my-index-xyz.svc.pinecone.io", ... status=IndexStatus(ready=True, state="Ready"), ... spec=IndexSpec(serverless=ServerlessSpecInfo(cloud="aws", region="us-east-1")), ... ) >>> d = index.to_dict() >>> d["name"] 'my-index' >>> type(d["spec"]) <class 'dict'> >>> d["spec"]["serverless"] {'cloud': 'aws', 'region': 'us-east-1'}
- class pinecone.models.indexes.list.IndexList(indexes)[source]¶
Bases:
objectWrapper around a list of IndexModel with convenience methods.
- Parameters:
indexes (list[IndexModel])
- __init__(indexes)[source]¶
- Parameters:
indexes (list[IndexModel])
- Return type:
None
- property indexes: list[IndexModel]¶
Return the list of indexes.
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of index dicts, each produced byIndexModel.to_dict().- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> indexes = pc.list_indexes() >>> indexes.to_dict() {'data': [{'name': 'movie-recommendations', ...}, {'name': 'product-search', ...}]}
- class pinecone.models.indexes.index.IndexSpec(*, serverless=None, pod=None, byoc=None)[source]¶
Bases:
StructDictMixin,StructDeployment specification for an index.
Exactly one of
serverless,pod, orbyocwill be set.- Variables:
serverless (pinecone.models.indexes.index.ServerlessSpecInfo | None) – Serverless deployment config, or
None.pod (pinecone.models.indexes.index.PodSpecInfo | None) – Pod-based deployment config, or
None.byoc (pinecone.models.indexes.index.ByocSpecInfo | None) – BYOC deployment config, or
None.
- Parameters:
serverless (ServerlessSpecInfo | None)
pod (PodSpecInfo | None)
byoc (ByocSpecInfo | None)
- byoc: ByocSpecInfo | None¶
- pod: PodSpecInfo | None¶
- serverless: ServerlessSpecInfo | None¶
- class pinecone.models.indexes.specs.ServerlessSpec(*, cloud, region, read_capacity=None, schema=None)[source]¶
Bases:
StructDictMixin,StructServerless index deployment spec.
- Variables:
cloud (str) – Cloud provider (e.g.
"aws","gcp","azure").region (str) – Cloud region (e.g.
"us-east-1","eu-west-1").read_capacity (dict[str, Any] | None) – Optional read capacity configuration (OnDemand or Dedicated), or
Noneto use the default.schema (dict[str, Any] | None) – Optional metadata schema configuration mapping field names to their config, or
Nonefor no schema.
- Parameters:
- class pinecone.models.indexes.specs.PodSpec(*, environment, pod_type='p1.x1', replicas=1, shards=1, pods=1, metadata_config=None, source_collection=None)[source]¶
Bases:
StructDictMixin,StructPod-based index deployment spec.
- Variables:
environment (str) – Deployment environment (e.g.
"us-east-1-aws").pod_type (str) – Pod type and size (default:
"p1.x1").replicas (int) – Number of replicas (default: 1).
shards (int) – Number of shards (default: 1).
pods (int) – Total number of pods (default: 1).
metadata_config (dict[str, Any] | None) – Configuration for metadata indexing, or
Noneto use the default configuration.source_collection (str | None) – Name of a collection to create the index from, or
Noneif creating an empty index.
- Parameters:
- class pinecone.models.indexes.specs.ByocSpec(*, environment, read_capacity=None, schema=None)[source]¶
Bases:
StructDictMixin,StructBring-your-own-cloud index deployment spec.
- Variables:
- Parameters:
- class pinecone.models.indexes.specs.IntegratedSpec(*, cloud, region, embed)[source]¶
Bases:
StructDictMixin,StructIntegrated (model-backed) index deployment spec.
Wraps cloud/region and embed config into a single convenience object. On the wire the
embedconfig is sent at the top level alongside the serverless spec — serialization handles the split.- Variables:
cloud (str) – Cloud provider (e.g.
"aws","gcp","azure").region (str) – Cloud region (e.g.
"us-east-1").embed (pinecone.models.indexes.specs.EmbedConfig) – Embedding model configuration.
- Parameters:
cloud (str)
region (str)
embed (EmbedConfig)
- embed: EmbedConfig¶
- class pinecone.models.indexes.specs.EmbedConfig(*, model, field_map, metric=None, read_parameters=None, write_parameters=None)[source]¶
Bases:
StructConfiguration for integrated (model-backed) embedding.
- Variables:
model (str) – Name of the embedding model (e.g.
"multilingual-e5-large").field_map (dict[str, str]) – Maps document field names to embedding inputs (e.g.
{"text": "my_text_field"}).metric (str | None) – Similarity metric override, or
Noneto use the model default.read_parameters (dict[str, Any] | None) – Optional read-time model parameters.
write_parameters (dict[str, Any] | None) – Optional write-time model parameters.
- Parameters:
- class pinecone.models.indexes.index.ServerlessSpecInfo(*, cloud, region, read_capacity=None, source_collection=None, schema=None)[source]¶
Bases:
StructDictMixin,StructResponse-side serverless deployment configuration.
- Variables:
cloud (str) – Cloud provider (e.g.
"aws","gcp","azure").region (str) – Cloud region (e.g.
"us-east-1").read_capacity (dict[str, Any] | None) – Read capacity configuration (
OnDemandorDedicated), orNoneif the server response omits it. When set, contains a"mode"key plus mode-specific fields.source_collection (str | None) – Source collection name if the index was created from a collection, or
None.schema (dict[str, Any] | None) – Metadata indexing schema, or
Noneif all metadata fields are indexed (the default).
- Parameters:
- class pinecone.models.indexes.index.PodSpecInfo(*, environment, pod_type, replicas, shards, pods, metadata_config=None, source_collection=None)[source]¶
Bases:
StructDictMixin,StructResponse-side pod deployment configuration.
- Variables:
environment (str) – Deployment environment (e.g.
"us-east1-gcp").pod_type (str) – Pod type (e.g.
"p1.x1").replicas (int) – Number of replicas.
shards (int) – Number of shards.
pods (int) – Total number of pods.
metadata_config (dict[str, list[str]] | None) – Metadata indexing configuration, or
None.source_collection (str | None) – Source collection name, or
None.
- Parameters:
- class pinecone.models.indexes.index.ByocSpecInfo(*, environment, read_capacity=None)[source]¶
Bases:
StructDictMixin,StructResponse-side BYOC (bring your own cloud) deployment configuration.
- Variables:
- Parameters:
- class pinecone.models.indexes.index.ModelIndexEmbed(*, model, metric=None, dimension=None, vector_type=None, field_map=None, read_parameters=None, write_parameters=None)[source]¶
Bases:
StructDictMixin,StructEmbedding configuration for a model-backed (integrated) index.
- Variables:
model (str) – The name of the embedding model used by this index.
metric (str | None) – Distance metric, or
Noneif inferred from the model.dimension (int | None) – Vector dimension, or
Noneif inferred from the model.vector_type (str | None) – Vector type (
"dense"or"sparse"), orNone.field_map (dict[str, str] | None) – Mapping of document field names to embedding input roles, or
None.read_parameters (dict[str, Any] | None) – Model-specific parameters for read (query) operations, or
None.write_parameters (dict[str, Any] | None) – Model-specific parameters for write (upsert) operations, or
None.
- Parameters:
Vector Models¶
- class pinecone.models.vectors.vector.Vector(id, values=<factory>, sparse_values=None, metadata=None)[source]¶
Bases:
DictLikeStruct,StructA stored vector with optional sparse values and metadata.
- Variables:
id (str) – Unique identifier for the vector.
values (list[float]) – Dense vector values as a list of floats.
sparse_values (SparseValues | None) – Sparse vector component, or
Noneif the vector has no sparse values.metadata (dict[str, Any] | None) – User-defined metadata key-value pairs, or
Noneif no metadata is attached.
- Parameters:
- sparse_values: SparseValues | None¶
- class pinecone.models.vectors.sparse.SparseValues(indices, values)[source]¶
Bases:
DictLikeStruct,StructSparse vector representation with indices and values.
- Variables:
- Parameters:
- class pinecone.models.vectors.responses.QueryResponse(*, matches=<factory>, namespace='', usage=None, response_info=None)[source]¶
Bases:
DictLikeStruct,StructResponse from a query operation.
- Variables:
matches (list[ScoredVector]) – List of scored vectors as returned by the API (ordered from most similar to least similar).
namespace (str) – Namespace that was queried. Defaults to
""(the default namespace).usage (Usage | None) – Read unit usage for this query, or
Noneif not reported.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
matches (list[ScoredVector])
namespace (str | None)
usage (Usage | None)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.FetchResponse(*, vectors=<factory>, namespace='', usage=None, response_info=None)[source]¶
Bases:
DictLikeStruct,StructResponse from a fetch operation.
- Variables:
vectors (dict[str, Vector]) – Mapping of vector ID to
Vectorfor each fetched vector.namespace (str) – Namespace the vectors were fetched from.
usage (Usage | None) – Read unit usage for this fetch, or
Noneif not reported.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
namespace (str)
usage (Usage | None)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.FetchByMetadataResponse(*, vectors=<factory>, namespace='', usage=None, pagination=None, response_info=None)[source]¶
Bases:
DictLikeStruct,StructResponse from a fetch-by-metadata operation.
- Variables:
vectors (dict[str, Vector]) – Mapping of vector ID to Vector for each fetched vector.
namespace (str) – Namespace the vectors were fetched from.
usage (Usage | None) – Read unit usage, or None if not reported.
pagination (Pagination | None) – Pagination token for the next page, or None if this is the last page.
response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
namespace (str)
usage (Usage | None)
pagination (Pagination | None)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.UpsertResponse(*, upserted_count, response_info=None, total_item_count=0, failed_item_count=0, total_batch_count=0, successful_batch_count=0, failed_batch_count=0, errors=<factory>)[source]¶
Bases:
DictLikeStruct,StructResponse from an upsert operation.
- Variables:
upserted_count (int) – Number of vectors successfully upserted. For non-batched calls this equals
total_item_count.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.total_item_count (int) – Total number of items submitted. Defaults to
0for non-batched calls.failed_item_count (int) – Number of items in failed batches. Defaults to
0.total_batch_count (int) – Total number of batches executed. Defaults to
0for non-batched calls.successful_batch_count (int) – Number of batches that succeeded. Defaults to
0.failed_batch_count (int) – Number of batches that failed. Defaults to
0.errors (list[BatchError]) – Per-batch error details. Empty for non-batched calls or when all batches succeed.
- Parameters:
For non-batched calls, all counter fields default to
0anderrorsdefaults to[]; the only meaningful field isupserted_count.For batched calls (
batch_sizeset on the upsert method), the caller can use the partial-success API:>>> response = idx.upsert(vectors=[...], batch_size=100) >>> response.upserted_count 900 >>> response.has_errors True >>> response.failed_item_count 100 >>> retry = idx.upsert(vectors=response.failed_items, batch_size=100)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.UpdateResponse(*, matched_records=None, response_info=None)[source]¶
Bases:
DictLikeStruct,StructResponse from an update operation.
- Variables:
matched_records (int | None) – Number of records matched by the update, or
Noneif not reported by the server.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
matched_records (int | None)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.ListResponse(*, vectors=<factory>, pagination=None, namespace='', usage=None, response_info=None)[source]¶
Bases:
StructDictMixin,StructResponse from a list vectors operation.
- Variables:
vectors (list[ListItem]) – List of vector ID entries in this page.
pagination (Pagination | None) – Pagination token for fetching the next page, or
Noneif there are no more results.namespace (str) – Namespace the vectors were listed from.
usage (Usage | None) – Read unit usage for this list call, or
Noneif not reported.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
vectors (list[ListItem])
pagination (Pagination | None)
namespace (str)
usage (Usage | None)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.DescribeIndexStatsResponse(*, namespaces=<factory>, dimension=None, index_fullness=0.0, total_vector_count=0, metric=None, vector_type=None, memory_fullness=None, storage_fullness=None, response_info=None)[source]¶
Bases:
StructDictMixin,StructResponse from a describe index stats operation.
- Variables:
namespaces (dict[str, NamespaceSummary]) – Mapping of namespace name to
NamespaceSummaryfor each namespace in the index.dimension (int | None) – Dimensionality of vectors in the index, or
Noneif not yet determined.index_fullness (float) – Fraction of the index capacity used, from 0.0 to 1.0.
total_vector_count (int) – Total number of vectors across all namespaces.
metric (str | None) – Distance metric of the index (e.g.
"cosine"), orNoneif not reported.vector_type (str | None) – Type of vectors stored (e.g.
"dense"), orNoneif not reported.memory_fullness (float | None) – Fraction of memory capacity used, or
Noneif not reported.storage_fullness (float | None) – Fraction of storage capacity used, or
Noneif not reported.response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
- response_info: ResponseInfo | None¶
- class pinecone.models.vectors.responses.UpsertRecordsResponse(*, record_count, response_info=None)[source]¶
Bases:
StructDictMixin,StructResponse from an upsert_records operation.
- Variables:
record_count (int) – Number of records submitted by the caller. This is a client-side count, not a server-confirmed count.
response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
record_count (int)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- class pinecone.models.response_info.BatchResponseInfo(*, lsn_reconciled=None, lsn_committed=None)[source]¶
Bases:
StructDictMixin,StructAggregate durability signal across a multi-request batch operation.
A batch operation fans out into N underlying HTTP requests, each with its own response headers.
BatchResponseInfocollapses the reconciliation signal across those requests into a single object that mirrors the read-your-writes API surface ofResponseInfo.Does not carry
raw_headersorrequest_id— there is no single source HTTP response to point at. Individual sub-request diagnostics are available viaBatchError.errorfor failed batches.- Variables:
lsn_reconciled (int | None) – Maximum
lsn_reconciledobserved across successful sub-batches, orNonewhen no successful batch reported this header. Useis_reconciled()for durability checks.lsn_committed (int | None) – Maximum
lsn_committedobserved across successful sub-batches, orNonewhen no successful batch reported this header.
- Parameters:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") index = pc.preview.index(name="articles-en-preview") documents = [ {"_id": f"article-{i:05d}", "content": f"Article {i}"} for i in range(500) ] result = index.documents.batch_upsert( namespace="articles-en", documents=documents, ) if result.response_info is not None: target_lsn = result.response_info.lsn_committed if result.response_info.is_reconciled(target_lsn): pass # all writes durable through target_lsn
- class pinecone.models.response_info.ResponseInfo(*, raw_headers=<factory>)[source]¶
Bases:
StructDictMixin,StructHTTP response metadata carrier.
Stores every HTTP response header returned by the server (keys lowercased) plus typed convenience properties for the headers the SDK promotes to first-class fields.
- Variables:
raw_headers (dict[str, str]) – All HTTP response headers, keys normalized to lowercase. Defaults to an empty dict. Use this to read any header the server returns, including headers not surfaced by the typed properties below. Prefer the typed properties when available — wire header names may change, but property semantics are stable.
request_id (str | None) – Server-assigned request identifier read from
x-pinecone-request-id, orNoneif not present.lsn_reconciled (int | None) – Log sequence number indicating how far the index has reconciled, parsed from
x-pinecone-lsn-reconciled.Nonewhen absent or when the header value is not a valid integer.lsn_committed (int | None) – Log sequence number of the last committed write, parsed from
x-pinecone-lsn-committed.Nonewhen absent or non-integer.
- Parameters:
- is_reconciled(target)[source]¶
Return
Truewhen the reconciled LSN meets or exceeds target.Use this for read-your-writes consistency checks: pass the LSN from a previous write response to verify that the index has caught up to that write before issuing a query.
- Parameters:
target (int) – The LSN threshold to check against. Typically the
lsn_committedvalue returned by a prior upsert or delete response.- Returns:
Trueiflsn_reconciledis notNoneand is greater than or equal to target;Falseotherwise.- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") index = pc.index(host="product-search.svc.pinecone.io") upsert_resp = index.upsert_records( namespace="electronics", records=[{"id": "prod-42", "_text": "wireless headphones"}], ) committed_lsn = upsert_resp.response_info.lsn_committed query_resp = index.search( namespace="electronics", inputs={"text": "headphones"}, ) query_resp.result.response_info.is_reconciled(committed_lsn)
- property lsn_committed: int | None¶
Log sequence number of the last committed write.
Parsed from the
x-pinecone-lsn-committedresponse header.- Returns:
intLSN, orNonewhen the header is absent or its value is not a valid integer.
Search Models¶
- class pinecone.models.vectors.search.Hit(*, id_, score_, fields=<factory>)[source]¶
Bases:
StructDictMixin,StructA single search result hit.
The API returns
_idand_scoreas field names. These are mapped toid_andscore_internally (to avoid Python name mangling), with convenience propertiesidandscorefor clean access.- Variables:
- Parameters:
- class pinecone.models.vectors.search.SearchResult(*, hits=<factory>)[source]¶
Bases:
StructDictMixin,StructThe result wrapper containing hits.
- class pinecone.models.vectors.search.SearchRecordsResponse(*, result, usage, response_info=None)[source]¶
Bases:
StructDictMixin,StructResponse from a search records operation.
- Variables:
result (SearchResult) – Wrapper containing the list of hits.
usage (SearchUsage) – Usage statistics for the search operation.
response_info (ResponseInfo | None) – HTTP response metadata (request ID, LSN values), or
Noneif not populated.
- Parameters:
result (SearchResult)
usage (SearchUsage)
response_info (ResponseInfo | None)
- response_info: ResponseInfo | None¶
- result: SearchResult¶
- usage: SearchUsage¶
- class pinecone.models.vectors.search.SearchInputs[source]¶
Bases:
dictTyped configuration for the
inputsparameter ofsearch().Required keys:
text.- Variables:
text (str) – Text to embed server-side for the search query.
- class pinecone.models.vectors.search.SearchUsage(*, read_units, embed_total_tokens=None, rerank_units=None)[source]¶
Bases:
StructDictMixin,StructUsage statistics for a search operation.
- Variables:
- Parameters:
- class pinecone.models.vectors.search.RerankConfig[source]¶
Bases:
dictTyped configuration for the
rerankparameter ofsearch().Required keys:
model,rank_fields. All other keys are optional.- Variables:
model (str) – Reranking model name (e.g.
"bge-reranker-v2-m3").rank_fields (list[str]) – Record fields to rank on (e.g.
["text"]).top_n (int) – Number of top results to return after reranking. Defaults to the value of
top_kwhen omitted.parameters (dict[str, Any]) – Model-specific parameters forwarded to the reranker. See the model documentation for supported keys.
query (str) – Override query text used for reranking. When omitted the query is inferred from the search inputs.
- class pinecone.models.vectors.query_aggregator.QueryNamespacesResults(*, matches=<factory>, usage=<factory>, ns_usage=<factory>)[source]¶
Bases:
StructDictMixin,StructAggregated results from querying multiple namespaces.
- Variables:
- Parameters:
- usage: Usage¶
- class pinecone.models.vectors.query_aggregator.QueryResultsAggregator(*, metric, top_k=10)[source]¶
Bases:
objectMerges per-namespace QueryResponse objects into a single combined result.
Uses a heap-based algorithm to efficiently merge scored vectors from multiple namespaces. For cosine/dotproduct metrics, higher scores rank first. For euclidean, lower scores rank first. Ties are broken by insertion order.
- Parameters:
- Raises:
ValueError – If metric is not a recognized value or top_k < 1.
- add_results(namespace, response)[source]¶
Add results from a single namespace query.
- Parameters:
namespace (str) – Namespace that was queried.
response (QueryResponse) – Query response from that namespace.
- Raises:
ValueError – If called after
get_results().- Return type:
None
Inference Models¶
- class pinecone.models.inference.embed.DenseEmbedding(*, values, vector_type='dense')[source]¶
Bases:
DictLikeStruct,StructA dense embedding vector.
- Variables:
- Parameters:
- class pinecone.models.inference.embed.SparseEmbedding(*, sparse_values, sparse_indices, sparse_tokens=None, vector_type='sparse')[source]¶
Bases:
StructDictMixin,StructA sparse embedding vector.
- Variables:
- Parameters:
- class pinecone.models.inference.embed.EmbeddingsList(*, model, vector_type, data, usage)[source]¶
Bases:
StructResponse from the embed endpoint.
Supports integer indexing, iteration, and
len()over the embedded data items, as well as bracket access for field names.- Variables:
model (str) – The model used to generate embeddings.
vector_type (str) – The type of embeddings returned (
"dense"or"sparse").data (list[pinecone.models.inference.embed.DenseEmbedding] | list[pinecone.models.inference.embed.SparseEmbedding]) – The list of embedding objects.
usage (pinecone.models.inference.embed.EmbedUsage) – Token usage information.
- Parameters:
model (str)
vector_type (str)
data (list[DenseEmbedding] | list[SparseEmbedding])
usage (EmbedUsage)
- data: list[DenseEmbedding] | list[SparseEmbedding]¶
- usage: EmbedUsage¶
- class pinecone.models.inference.rerank.RerankResult(*, model, data, usage)[source]¶
Bases:
StructResponse from the rerank endpoint.
- Variables:
model (str) – The model used for reranking.
data (list[pinecone.models.inference.rerank.RankedDocument]) – The list of ranked documents, ordered by relevance.
usage (pinecone.models.inference.rerank.RerankUsage) – Rerank usage information.
- Parameters:
model (str)
data (list[RankedDocument])
usage (RerankUsage)
- data: list[RankedDocument]¶
- usage: RerankUsage¶
- class pinecone.models.inference.rerank.RankedDocument(*, index, score, document=None)[source]¶
Bases:
StructDictMixin,StructA document with its relevance score from a rerank operation.
- Variables:
- Parameters:
- class pinecone.models.inference.models.ModelInfo(*, model, short_description, type, supported_parameters, vector_type=None, default_dimension=None, supported_dimensions=None, modality=None, max_sequence_length=None, max_batch_size=None, provider_name=None, supported_metrics=None)[source]¶
Bases:
StructInformation about an inference model.
- Variables:
model (str) – The model identifier (also accessible as
name).short_description (str) – A brief description of the model (also accessible as
description).type (str) – The model type (e.g.
"embed","rerank").supported_parameters (list[pinecone.models.inference.models.ModelInfoSupportedParameter]) – Parameters accepted by the model.
vector_type (str | None) – The type of vectors produced (for embed models).
default_dimension (int | None) – Default output dimension (for embed models).
supported_dimensions (list[int] | None) – Available output dimensions (for embed models).
modality (str | None) – The input modality (e.g.
"text").max_sequence_length (int | None) – Maximum input sequence length.
max_batch_size (int | None) – Maximum batch size for requests.
provider_name (str | None) – The model provider.
supported_metrics (list[str] | None) – Supported similarity metrics.
- Parameters:
- class pinecone.models.inference.model_list.ModelInfoList(models)[source]¶
Bases:
objectWrapper around a list of ModelInfo with convenience methods.
Supports integer indexing, string key access (
["models"]), iteration,len(), and a.names()convenience method.- Variables:
models – The underlying list of
ModelInfoinstances.- Parameters:
- class pinecone.inference.models.index_embed.IndexEmbed(model, field_map, metric=None, read_parameters=<factory>, write_parameters=<factory>)[source]¶
Bases:
objectConfiguration for an integrated (model-backed) embedding index.
Describes the embedding model and field mapping used for an integrated index. Legacy class preserved for backwards compatibility.
- Parameters:
- __init__(model, field_map, metric=None, read_parameters=<factory>, write_parameters=<factory>)¶
Import Models¶
- class pinecone.models.imports.model.ImportModel(*, id, uri, status, created_at, finished_at=None, percent_complete=None, records_imported=None, error=None)[source]¶
Bases:
StructDictMixin,StructResponse model for a bulk import operation.
- Variables:
id (str) – Unique identifier for the import operation.
uri (str) – Source URI for the import data.
status (str) – Current status of the import (Pending, InProgress, Failed, Completed, Cancelled).
created_at (str) – Timestamp when the import was created.
finished_at (str | None) – Timestamp when the import finished.
percent_complete (float | None) – Percentage of the import that has completed.
records_imported (int | None) – Number of records imported so far.
error (str | None) – Error message if the import failed.
- Parameters:
- class pinecone.models.imports.list.ImportList(imports, *, pagination=None)[source]¶
Bases:
objectWrapper around a list of ImportModel with convenience methods.
- Parameters:
imports (list[ImportModel])
pagination (Pagination | None)
- __init__(imports, *, pagination=None)[source]¶
Initialize an ImportList.
- Parameters:
imports (list[ImportModel]) – List of
ImportModelinstances representing bulk import operations.pagination (Pagination | None) – Optional
Paginationtoken for fetching additional pages of results.
- Return type:
None
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of import dicts, each produced byImportModel.to_dict(). When the wrapper has a pagination token, the dict also includes a"pagination"key with the token for fetching the next page.- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> index = pc.Index("product-search") >>> imports = index.list_imports_paginated() >>> imports.to_dict() {'data': [{'id': 'import-abc123', ...}, {'id': 'import-def456', ...}]}
- class pinecone.models.imports.model.StartImportResponse(*, id)[source]¶
Bases:
StructDictMixin,StructResponse model for starting a bulk import operation.
- class pinecone.models.imports.error_mode.ImportErrorMode(value)[source]¶
-
Behaviour when an individual record fails during a bulk import.
- Variables:
CONTINUE – Skip the failed record and continue importing remaining records.
ABORT – Abort the entire import when any record fails.
- ABORT = 'abort'¶
- CONTINUE = 'continue'¶
Collection Models¶
- class pinecone.models.collections.model.CollectionModel(*, name, status, environment, size=None, dimension=None, vector_count=None)[source]¶
Bases:
StructDictMixin,StructResponse model for a Pinecone collection.
- Variables:
name (str) – The name of the collection.
status (str) – Current status of the collection (e.g.
"Ready","Initializing","Terminating").environment (str) – Deployment environment where the collection is hosted.
size (int | None) – Size of the collection in bytes, or
Noneif not yet available.dimension (int | None) – Dimensionality of vectors in the collection, or
Noneif not yet available.vector_count (int | None) – Number of vectors in the collection, or
Noneif not yet available.
- Parameters:
- class pinecone.models.collections.list.CollectionList(collections)[source]¶
Bases:
objectWrapper around a list of CollectionModel with convenience methods.
- Parameters:
collections (list[CollectionModel])
- __init__(collections)[source]¶
- Parameters:
collections (list[CollectionModel])
- Return type:
None
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of collection dicts, each produced byCollectionModel.to_dict().- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> collections = pc.list_collections() >>> collections.to_dict() {'data': [{'name': 'movie-embeddings-v1', ...}, {'name': 'product-snapshot', ...}]}
- class pinecone.db_control.models.collection_description.CollectionDescription(name, source)[source]¶
Bases:
NamedTupleBasic metadata describing a collection.
- Variables:
- Parameters:
Backup and Restore Models¶
- class pinecone.models.backups.model.BackupModel(*, backup_id, source_index_name, source_index_id, status, cloud, region, name=None, description=None, dimension=None, metric=None, record_count=None, namespace_count=None, size_bytes=None, tags=None, created_at=None)[source]¶
Bases:
StructResponse model for a Pinecone backup.
- Variables:
backup_id (str) – Unique identifier for the backup.
source_index_name (str) – Name of the index that was backed up.
source_index_id (str) – Unique identifier of the source index.
status (str) – Current status of the backup.
cloud (str) – Cloud provider where the backup is stored.
region (str) – Region where the backup is stored.
name (str | None) – User-provided name for the backup.
description (str | None) – User-provided description for the backup.
dimension (int | None) – Dimensionality of vectors in the backup.
metric (str | None) – Distance metric of the backed-up index.
record_count (int | None) – Number of records in the backup.
namespace_count (int | None) – Number of namespaces in the backup.
size_bytes (int | None) – Size of the backup in bytes.
created_at (str | None) – Timestamp when the backup was created.
- Parameters:
- to_dict()[source]¶
Return a dict representation of this backup model.
- Returns:
Dictionary with all fields, including optional ones that are
None(e.g.name,description,dimension,metric,record_count,namespace_count,size_bytes,tags,created_at). Values are not recursively converted.- Return type:
Examples
>>> from pinecone.models.backups.model import BackupModel >>> backup = BackupModel( ... backup_id="bkp-1", ... source_index_name="my-index", ... source_index_id="idx-abc", ... status="Ready", ... cloud="aws", ... region="us-east-1", ... name="weekly-backup", ... ) >>> d = backup.to_dict() >>> d["backup_id"] 'bkp-1' >>> d["name"] 'weekly-backup' >>> d["description"] is None True
- class pinecone.models.backups.list.BackupList(backups, *, pagination=None)[source]¶
Bases:
objectWrapper around a list of BackupModel with convenience methods.
- Parameters:
backups (list[BackupModel])
pagination (Pagination | None)
- __init__(backups, *, pagination=None)[source]¶
Initialize a BackupList.
- Parameters:
backups (list[BackupModel]) – List of
BackupModelinstances representing index backups.pagination (Pagination | None) – Optional
Paginationtoken for fetching additional pages of results.
- Return type:
None
- property data: list[BackupModel]¶
Return the list of backups.
- names()[source]¶
Return a list of backup names, falling back to backup_id.
If a backup has no
nameset, itsbackup_idis used instead.Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> backups = pc.list_backups(index_name="movie-recommendations") >>> backups.names() ['daily-2025-01-01', 'weekly-2024-12-29']
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of backup dicts, each produced byBackupModel.to_dict(). When the wrapper has a pagination token, the dict also includes a"pagination"key with the token for fetching the next page.- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> backups = pc.list_backups(index_name="movie-recommendations") >>> backups.to_dict() {'data': [{'backup_id': 'bkp-abc123', ...}, {'backup_id': 'bkp-def456', ...}]}
- class pinecone.models.backups.model.RestoreJobModel(*, restore_job_id, backup_id, target_index_name, target_index_id, status, created_at, completed_at=None, percent_complete=None)[source]¶
Bases:
StructResponse model for a Pinecone restore job.
- Variables:
restore_job_id (str) – Unique identifier for the restore job.
backup_id (str) – Identifier of the backup being restored.
target_index_name (str) – Name of the index being restored to.
target_index_id (str) – Unique identifier of the target index.
status (str) – Current status of the restore job.
created_at (str) – Timestamp when the restore job was created.
completed_at (str | None) – Timestamp when the restore job completed.
percent_complete (float | None) – Percentage of the restore job that has completed.
- Parameters:
- to_dict()[source]¶
Return a dict representation of this restore job model.
- Returns:
Dictionary with all fields, including optional ones that are
None(completed_atandpercent_complete). Values are not recursively converted.- Return type:
Examples
>>> from pinecone.models.backups.model import RestoreJobModel >>> job = RestoreJobModel( ... restore_job_id="rj-1", ... backup_id="bkp-1", ... target_index_name="my-index", ... target_index_id="idx-abc", ... status="Running", ... created_at="2024-01-01T00:00:00Z", ... ) >>> d = job.to_dict() >>> d["restore_job_id"] 'rj-1' >>> d["completed_at"] is None True
- class pinecone.models.backups.list.RestoreJobList(restore_jobs, *, pagination=None)[source]¶
Bases:
objectWrapper around a list of RestoreJobModel with convenience methods.
- Parameters:
restore_jobs (list[RestoreJobModel])
pagination (Pagination | None)
- __init__(restore_jobs, *, pagination=None)[source]¶
Initialize a RestoreJobList.
- Parameters:
restore_jobs (list[RestoreJobModel]) – List of
RestoreJobModelinstances representing restore operations.pagination (Pagination | None) – Optional
Paginationtoken for fetching additional pages of results.
- Return type:
None
- property data: list[RestoreJobModel]¶
Return the list of restore jobs.
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of restore job dicts, each produced byRestoreJobModel.to_dict(). When the wrapper has a pagination token, the dict also includes a"pagination"key with the token for fetching the next page.- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") jobs = pc.restore_jobs.list() jobs.to_dict() # {'data': [{'restore_job_id': 'rj-abc123', ...}, ...]}
Namespace Models¶
- class pinecone.models.namespaces.models.NamespaceDescription(*, name='', record_count=0, schema=None, indexed_fields=None)[source]¶
Bases:
StructDictMixin,StructDescription of a namespace including name, record count, and schema.
- Variables:
name (str) – The name of the namespace.
record_count (int) – The total number of records in the namespace.
schema (pinecone.models.namespaces.models.NamespaceSchema | None) – Schema configuration for metadata indexing, or None.
indexed_fields (pinecone.models.namespaces.models.IndexedFields | None) – List of indexed metadata fields, or None.
- Parameters:
- class pinecone.models.namespaces.models.ListNamespacesResponse(*, namespaces=<factory>, pagination=None, total_count=0)[source]¶
Bases:
StructDictMixin,StructResponse from a list namespaces operation.
- Variables:
namespaces (list[pinecone.models.namespaces.models.NamespaceDescription]) – List of namespace descriptions in this page.
pagination (pinecone.models.vectors.responses.Pagination | None) – Pagination token for the next page, or None if last page.
total_count (int) – Total number of namespaces matching the query.
- Parameters:
namespaces (list[NamespaceDescription])
pagination (Pagination | None)
total_count (int)
- namespaces: list[NamespaceDescription]¶
Pagination Models¶
- class pinecone.models.pagination.Page(*, items, pagination_token)[source]¶
Bases:
Generic[T]A single page of results from a paginated API.
- class pinecone.models.pagination.Paginator(*, fetch_page, initial_token=None, limit=None)[source]¶
Bases:
Generic[T]Lazy iterator over paginated API results (sync).
Fetches pages on demand. Supports item-level iteration, page-level access via
pages(), bulk collection viato_list(), and resumption via thepagination_tokenproperty.- Parameters:
fetch_page (Callable[[str | None], Page[T]]) – Callable that takes an optional pagination token and returns a
Page.initial_token (str | None) – Token to start pagination from.
Nonestarts from the beginning.limit (int | None) – Maximum number of items to yield across all pages.
Noneyields all items.
Examples
paginator = pc.assistants.list() for assistant in paginator: print(assistant.name)
Collect all results into a list:
all_assistants = pc.assistants.list().to_list()
- pages()[source]¶
Iterate over pages rather than individual items.
When
limitis set, yields full pages until the remaining budget is exhausted, then yields a truncated final page and stops.- Returns:
GeneratoryieldingPageobjects. Each page has anitemslist and an optionalpagination_token.- Return type:
Examples
for page in pc.assistants.list().pages(): for assistant in page.items: print(assistant.name)
- class pinecone.models.pagination.AsyncPaginator(*, fetch_page, initial_token=None, limit=None)[source]¶
Bases:
Generic[T]Async lazy iterator over paginated API results.
Fetches pages on demand. Supports item-level async iteration, page-level access via
pages(), bulk collection viato_list(), and resumption via thepagination_tokenproperty.- Parameters:
fetch_page (Callable[[str | None], Awaitable[Page[T]]]) – Async callable that takes an optional pagination token and returns a
Page.initial_token (str | None) – Token to start pagination from.
Nonestarts from the beginning.limit (int | None) – Maximum number of items to yield across all pages.
Noneyields all items.
Examples
paginator = async_pc.assistants.list() async for assistant in paginator: print(assistant.name)
Collect all results into a list:
paginator = async_pc.assistants.list() all_assistants = await paginator.to_list()
- async pages()[source]¶
Iterate over pages rather than individual items.
When
limitis set, yields full pages until the remaining budget is exhausted, then yields a truncated final page and stops.- Returns:
AsyncGeneratoryieldingPageobjects. Each page has anitemslist and an optionalpagination_token.- Return type:
AsyncGenerator[Page[T], None]
Examples
async for page in async_pc.assistants.list().pages(): for assistant in page.items: print(assistant.name)
Enums¶
- class pinecone.models.enums.CloudProvider(value)[source]¶
-
Supported cloud providers for Pinecone indexes.
- AWS = 'aws'¶
- AZURE = 'azure'¶
- GCP = 'gcp'¶
- class pinecone.models.enums.Metric(value)[source]¶
-
Supported similarity metrics for vector search.
- COSINE = 'cosine'¶
- DOTPRODUCT = 'dotproduct'¶
- EUCLIDEAN = 'euclidean'¶
- class pinecone.models.enums.VectorType(value)[source]¶
-
Supported vector types.
- DENSE = 'dense'¶
- SPARSE = 'sparse'¶
- class pinecone.models.enums.DeletionProtection(value)[source]¶
-
Deletion protection setting for indexes.
- DISABLED = 'disabled'¶
- ENABLED = 'enabled'¶
- class pinecone.models.enums.EmbedModel(value)[source]¶
-
Known embedding models for integrated indexes.
- Multilingual_E5_Large = 'multilingual-e5-large'¶
- Pinecone_Sparse_English_V0 = 'pinecone-sparse-english-v0'¶
- class pinecone.models.enums.RerankModel(value)[source]¶
-
Known reranking models.
- Bge_Reranker_V2_M3 = 'bge-reranker-v2-m3'¶
- Cohere_Rerank_3_5 = 'cohere-rerank-3.5'¶
- Pinecone_Rerank_V0 = 'pinecone-rerank-v0'¶
- class pinecone.models.enums.PodType(value)[source]¶
-
Supported pod type and size combinations.
- P1_X1 = 'p1.x1'¶
- P1_X2 = 'p1.x2'¶
- P1_X4 = 'p1.x4'¶
- P1_X8 = 'p1.x8'¶
- P2_X1 = 'p2.x1'¶
- P2_X2 = 'p2.x2'¶
- P2_X4 = 'p2.x4'¶
- P2_X8 = 'p2.x8'¶
- S1_X1 = 's1.x1'¶
- S1_X2 = 's1.x2'¶
- S1_X4 = 's1.x4'¶
- S1_X8 = 's1.x8'¶
- class pinecone.db_control.enums.clouds.AwsRegion(value)[source]¶
-
AWS regions supported for serverless indexes.
- AP_SOUTHEAST_1 = 'ap-southeast-1'¶
- EU_CENTRAL_1 = 'eu-central-1'¶
- EU_WEST_1 = 'eu-west-1'¶
- US_EAST_1 = 'us-east-1'¶
- US_WEST_2 = 'us-west-2'¶
Admin Models¶
- class pinecone.models.admin.api_key.APIKeyModel(*, id, name, project_id, roles, description=None)[source]¶
Bases:
StructDictMixin,StructResponse model for a Pinecone API key.
- Variables:
id (str) – Unique identifier for the API key.
name (str) – Name of the API key.
project_id (str) – Identifier of the project the key belongs to.
roles (list[APIKeyRole]) – List of roles assigned to the key (see
APIKeyRole).description (str | None) – Optional description for the API key.
Noneif no description was set.
- Parameters:
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> key = admin.api_keys.describe(api_key_id="key-abc123") >>> key.id 'key-abc123' >>> key.name 'prod-search-key' >>> key.roles [<APIKeyRole.DATA_PLANE_EDITOR: 'DataPlaneEditor'>] >>> key.description 'Used by the search service'
- property role: APIKeyRole¶
Singular alias for
roleswhen the key has exactly one role.- Returns:
The single role assigned to this key.
- Return type:
- Raises:
ValueError – If the key has no roles or more than one role.
Examples
>>> key = admin.api_keys.describe(api_key_id="key-abc123") >>> key.role <APIKeyRole.DATA_PLANE_EDITOR: 'DataPlaneEditor'>
Keys with multiple roles raise
ValueError; userolesinstead:multi_role_key = APIKeyModel( id="k2", name="k2", project_id="p1", roles=[APIKeyRole.PROJECT_EDITOR, APIKeyRole.DATA_PLANE_EDITOR] ) try: multi_role_key.role except ValueError as exc: print(exc) # API key has 2 roles; use .roles to access all
- roles: list[APIKeyRole]¶
- class pinecone.models.admin.api_key.APIKeyList(api_keys)[source]¶
Bases:
objectWrapper around a list of APIKeyModel with convenience methods.
- Parameters:
api_keys (list[APIKeyModel])
- __init__(api_keys)[source]¶
Initialize an APIKeyList.
- Parameters:
api_keys (list[APIKeyModel]) – List of
APIKeyModelinstances representing Pinecone API keys.- Return type:
None
- names()[source]¶
Return a list of API key names.
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> keys = admin.api_keys.list(project_id="proj-abc123") >>> keys.names() ['prod-search-key', 'ci-pipeline-key']
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of API key dicts, each produced byAPIKeyModel.to_dict().- Return type:
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> keys = admin.api_keys.list(project_id="proj-abc123") >>> keys.to_dict() {'data': [{'name': 'prod-search-key', ...}, {'name': 'ci-pipeline-key', ...}]}
- class pinecone.models.admin.api_key.APIKeyWithSecret(*, key, value)[source]¶
Bases:
StructDictMixin,StructResponse model for an API key with its secret value.
The secret value is only available at creation time.
- Variables:
key (pinecone.models.admin.api_key.APIKeyModel) – The API key metadata.
value (str) – The secret API key string.
- Parameters:
key (APIKeyModel)
value (str)
- key: APIKeyModel¶
- class pinecone.models.admin.api_key.APIKeyRole(value)[source]¶
-
Roles that can be assigned to a Pinecone API key.
Possible values:
PROJECT_EDITOR,PROJECT_VIEWER,CONTROL_PLANE_EDITOR,CONTROL_PLANE_VIEWER,DATA_PLANE_EDITOR,DATA_PLANE_VIEWER.Examples
>>> from pinecone import Admin >>> from pinecone.models.admin.api_key import APIKeyRole >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> result = admin.api_keys.create( ... project_id="proj-abc123", ... name="read-only-key", ... roles=[APIKeyRole.DATA_PLANE_VIEWER], ... ) >>> result.key.roles [<APIKeyRole.DATA_PLANE_VIEWER: 'DataPlaneViewer'>]
Update a key to use control-plane access:
>>> key = admin.api_keys.update( ... api_key_id="key-abc123", ... roles=[APIKeyRole.CONTROL_PLANE_EDITOR], ... ) >>> key.role <APIKeyRole.CONTROL_PLANE_EDITOR: 'ControlPlaneEditor'>
- CONTROL_PLANE_EDITOR = 'ControlPlaneEditor'¶
- CONTROL_PLANE_VIEWER = 'ControlPlaneViewer'¶
- DATA_PLANE_EDITOR = 'DataPlaneEditor'¶
- DATA_PLANE_VIEWER = 'DataPlaneViewer'¶
- PROJECT_EDITOR = 'ProjectEditor'¶
- PROJECT_VIEWER = 'ProjectViewer'¶
- class pinecone.models.admin.organization.OrganizationModel(*, id, name, plan, payment_status, created_at, support_tier)[source]¶
Bases:
StructDictMixin,StructResponse model for a Pinecone organization.
- Variables:
id (str) – Unique identifier for the organization.
name (str) – Name of the organization.
plan (str) – Plan tier (e.g. Free, Standard, Enterprise, Dedicated).
payment_status (str) – Current payment status.
created_at (str) – Timestamp when the organization was created.
support_tier (str) – Support tier for the organization.
- Parameters:
- class pinecone.models.admin.organization.OrganizationList(organizations)[source]¶
Bases:
objectWrapper around a list of OrganizationModel with convenience methods.
- Parameters:
organizations (list[OrganizationModel])
- __init__(organizations)[source]¶
Initialize an OrganizationList.
- Parameters:
organizations (list[OrganizationModel]) – List of
OrganizationModelinstances representing Pinecone organizations.- Return type:
None
- names()[source]¶
Return a list of organization names.
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> orgs = admin.organizations.list() >>> orgs.names() ['acme-corp', 'research-team']
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of organization dicts, each produced byOrganizationModel.to_dict().- Return type:
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> orgs = admin.organizations.list() >>> orgs.to_dict() {'data': [{'name': 'acme-corp', ...}, {'name': 'research-team', ...}]}
- class pinecone.models.admin.project.ProjectModel(*, id, name, max_pods, force_encryption_with_cmek, organization_id, created_at=None)[source]¶
Bases:
StructDictMixin,StructResponse model for a Pinecone project.
- Variables:
id (str) – Unique identifier for the project.
name (str) – Name of the project.
max_pods (int) – Maximum number of pods allowed in the project.
force_encryption_with_cmek (bool) – Whether CMEK encryption is enforced.
organization_id (str) – Identifier of the parent organization.
created_at (str | None) – Timestamp when the project was created.
- Parameters:
- class pinecone.models.admin.project.ProjectList(projects)[source]¶
Bases:
objectWrapper around a list of ProjectModel with convenience methods.
- Parameters:
projects (list[ProjectModel])
- __init__(projects)[source]¶
Initialize a ProjectList.
- Parameters:
projects (list[ProjectModel]) – List of
ProjectModelinstances representing Pinecone projects.- Return type:
None
- names()[source]¶
Return a list of project names.
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> projects = admin.projects.list() >>> projects.names() ['production-search', 'staging-recommendations']
- to_dict()[source]¶
Return the list as a serializable dict.
- Returns:
A dict with a
"data"key containing a list of project dicts, each produced byProjectModel.to_dict().- Return type:
Examples
>>> from pinecone import Admin >>> admin = Admin(client_id="your-client-id", client_secret="your-client-secret") >>> projects = admin.projects.list() >>> projects.to_dict() {'data': [{'name': 'production-search', ...}, {'name': 'staging-recommendations', ...}]}
Assistant Models¶
- class pinecone.models.assistant.model.AssistantModel(*, name, status, metadata=None, instructions=None, host=None, created_at=None, updated_at=None)[source]¶
Bases:
AssistantModelLegacyMethodsMixin,StructDictMixin,StructResponse model for a Pinecone assistant.
- Variables:
name (str) – The name of the assistant.
status (str) – Current status of the assistant (e.g.
"Initializing","Ready","Terminating","Failed","InitializationFailed").created_at (str | None) – ISO 8601 timestamp when the assistant was created, or
Noneif not returned by the API.updated_at (str | None) – ISO 8601 timestamp when the assistant was last updated, or
Noneif not returned by the API.metadata (dict[str, Any] | None) – Optional metadata dictionary associated with the assistant, or
Noneif not set.instructions (str | None) – Optional description or directive for the assistant to apply to all responses, or
Noneif not set.host (str | None) – The host where the assistant is deployed, or
Noneif not yet available.
- Parameters:
- class pinecone.models.assistant.file_model.AssistantFileModel(*, name, id, metadata=None, created_on=None, updated_on=None, status=None, size=None, multimodal=None, signed_url=None, content_hash=None, percent_done=None, error_message=None)[source]¶
Bases:
StructDictMixin,StructResponse model for a file attached to a Pinecone assistant.
- Variables:
name (str) – The name of the file.
id (str) – Unique identifier for the file.
metadata (dict[str, object] | None) – Optional metadata dictionary associated with the file, or
Noneif not set.created_on (str | None) – ISO 8601 timestamp when the file was created, or
None.updated_on (str | None) – ISO 8601 timestamp when the file was last updated, or
None.status (str | None) – Current status of the file (e.g.
"Processing","Available","Deleting","ProcessingFailed"), orNone.size (int | None) – Size of the file in bytes, or
None.multimodal (bool | None) – Whether the file was processed as multimodal, or
None.signed_url (str | None) – A temporary signed URL for downloading the file, or
Nonewhen not requested or unavailable.content_hash (str | None) – Hash of the file content (wire key
crc32c_hash), orNonewhen not available. Legacy callers can also access this value via thecrc32c_hashproperty alias.percent_done (float | None) – Processing progress as a percentage (0.0–100.0), or
Nonewhen not available or not applicable.error_message (str | None) – Error message describing why processing failed, or
Nonewhen processing succeeded or is still in progress.
- Parameters:
- property crc32c_hash: str | None¶
Backwards-compatibility alias for
content_hash.
- class pinecone.models.assistant.list.ListAssistantsResponse(*, assistants, next=None)[source]¶
Bases:
StructDictMixin,StructPaginated response for listing assistants.
- Variables:
assistants (list[pinecone.models.assistant.model.AssistantModel]) – The assistants returned in this page.
next (str | None) – Token for fetching the next page of results, or
Nonewhen no more pages exist.
- Parameters:
assistants (list[AssistantModel])
next (str | None)
- assistants: list[AssistantModel]¶
- class pinecone.models.assistant.list.ListFilesResponse(*, files, next=None)[source]¶
Bases:
StructDictMixin,StructPaginated response for listing assistant files.
- Variables:
files (list[pinecone.models.assistant.file_model.AssistantFileModel]) – The files returned in this page.
next (str | None) – Token for fetching the next page of results, or
Nonewhen no more pages exist.
- Parameters:
files (list[AssistantFileModel])
next (str | None)
- files: list[AssistantFileModel]¶
- class pinecone.models.assistant.message.Message(*, content, role='user')[source]¶
Bases:
StructDictMixin,StructA message to send to an assistant.
- Variables:
- Parameters:
- class pinecone.models.assistant.chat.ChatResponse(*, id, model, usage, message, finish_reason, citations)[source]¶
Bases:
StructDictMixin,StructNon-streaming response from the assistant chat endpoint.
- Variables:
id (str) – Unique identifier for the chat response.
model (str) – The model used to generate the response.
usage (pinecone.models.assistant.chat.ChatUsage) – Token usage statistics for the request.
message (pinecone.models.assistant.chat.ChatMessage) – The assistant’s response message.
finish_reason (str) – The reason the model stopped generating (e.g.
"stop","length").citations (list[pinecone.models.assistant.chat.ChatCitation]) – List of citations linking response text to source documents.
- Parameters:
- message: ChatMessage¶
- usage: ChatUsage¶
- class pinecone.models.assistant.chat.ChatCompletionResponse(*, id, model, usage, choices)[source]¶
Bases:
StructDictMixin,StructNon-streaming response from the OpenAI-compatible chat completion endpoint.
- Variables:
- Parameters:
- usage: ChatUsage¶
- class pinecone.models.assistant.context.ContextResponse(*, snippets, usage, id=None)[source]¶
Bases:
StructDictMixin,StructResponse from the assistant context endpoint.
- Variables:
snippets (list[pinecone.models.assistant.context.TextSnippet | pinecone.models.assistant.context.MultimodalSnippet]) – The list of context snippets.
usage (pinecone.models.assistant.chat.ChatUsage) – Token usage statistics for the request.
id (str | None) – Unique identifier for the context response, or
Noneif not included in the response.
- Parameters:
- usage: ChatUsage¶
- class pinecone.models.assistant.options.ContextOptions(*, top_k=None, snippet_size=None, multimodal=None, include_binary_content=None)[source]¶
Bases:
StructDictMixin,StructOptions controlling how context is retrieved for assistant operations.
All fields are optional and default to
None, letting the server apply its own defaults.- Variables:
top_k (int | None) – Maximum number of context snippets to retrieve.
snippet_size (int | None) – Target size (in tokens) for each context snippet.
multimodal (bool | None) – Whether to include multimodal (image) content in retrieved context.
include_binary_content (bool | None) – Whether to include binary file content in retrieved context.
- Parameters:
- class pinecone.models.assistant.evaluation.AlignmentResult(*, scores, facts, usage)[source]¶
Bases:
StructDictMixin,StructFull result of an alignment evaluation.
- Variables:
scores (pinecone.models.assistant.evaluation.AlignmentScores) – Aggregate correctness, completeness, and alignment scores.
facts (list[pinecone.models.assistant.evaluation.EntailmentResult]) – Per-fact entailment results with reasoning.
usage (pinecone.models.assistant.chat.ChatUsage) – Token usage statistics for the evaluation request.
- Parameters:
scores (AlignmentScores)
facts (list[EntailmentResult])
usage (ChatUsage)
- scores: AlignmentScores¶
- usage: ChatUsage¶
- class pinecone.models.assistant.streaming.ChatStream(stream)[source]¶
Bases:
objectWraps a Pinecone-native streaming response for convenient text access.
Iterating over this object yields the full
ChatStreamChunksequence, preserving the existing typed-chunk contract for callers that need it.text()andcollect()give direct access to text content without manual type dispatch.The stream is single-pass: iterating, calling
text(), or callingcollect()all consume the same underlying iterator.Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "What can you help me with?"}], stream=True, ) for text in stream.text(): print(text, end="", flush=True)
Use
collect()to drain the stream and return the full content as a single string:stream = pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Summarize your capabilities."}], stream=True, ) full_content = stream.collect()
- Parameters:
stream (Iterator[ChatStreamChunk])
- __init__(stream)[source]¶
- Parameters:
stream (Iterator[StreamMessageStart | StreamContentChunk | StreamCitationChunk | StreamMessageEnd])
- Return type:
None
- collect()[source]¶
Drain the stream and return all content fragments concatenated.
- Returns:
The complete response as a single string.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) full = stream.collect() print(full)
- text()[source]¶
Yield text fragments, skipping start/citation/end chunks.
- Returns:
Iterator of text fragment strings. Each fragment is a partial response as it arrives from the server.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) for chunk_text in stream.text(): print(chunk_text, end="", flush=True)
- pinecone.models.assistant.streaming.ChatStreamChunk¶
Union of all Pinecone-native chat streaming chunk types.
- class pinecone.models.assistant.streaming.ChatCompletionStream(stream)[source]¶
Bases:
objectWraps an OpenAI-compatible streaming response for convenient text access.
Iterating over this object yields the full
ChatCompletionStreamChunksequence.text()filters to non-empty content fragments and handles theNonesentinel values that appear in role-only and finish chunks.The stream is single-pass: iterating, calling
text(), or callingcollect()all consume the same underlying iterator.Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "What can you help me with?"}], stream=True, ) for text in stream.text(): print(text, end="", flush=True)
Use
collect()to drain the stream and return the full content as a single string:stream = pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Summarize your capabilities."}], stream=True, ) full_content = stream.collect()
- Parameters:
stream (Iterator[ChatCompletionStreamChunk])
- __init__(stream)[source]¶
- Parameters:
stream (Iterator[ChatCompletionStreamChunk])
- Return type:
None
- collect()[source]¶
Drain the stream and return all content fragments concatenated.
- Returns:
The complete response as a single string.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) full = stream.collect() print(full)
- text()[source]¶
Yield non-empty content strings, skipping role-only and finish chunks.
- Returns:
Iterator of non-empty text fragment strings. Role-only chunks and finish-reason chunks with
Noneor empty content are skipped.- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") stream = pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) for chunk_text in stream.text(): print(chunk_text, end="", flush=True)
- class pinecone.models.assistant.streaming.ChatCompletionStreamChunk(*, id, choices, model=None, object=None, created=None, system_fingerprint=None)[source]¶
Bases:
StructDictMixin,StructA streaming chunk from the OpenAI-compatible chat completion endpoint.
- Variables:
id (str) – Unique identifier for this chunk.
choices (list[pinecone.models.assistant.streaming.ChatCompletionStreamChoice]) – List of streaming choices.
model (str | None) – The model used to generate the response, or
Noneif not provided.object (str | None) – The object type (typically
"chat.completion.chunk"), orNone.created (int | None) – Unix timestamp when the chunk was created, or
None.system_fingerprint (str | None) – Opaque fingerprint identifying the backend, or
None.
- Parameters:
- class pinecone.models.assistant.streaming.StreamMessageStart(*, model, role)[source]¶
Bases:
StructDictMixin,StructFirst chunk in a chat stream, containing the model and role.
- Variables:
- Parameters:
- class pinecone.models.assistant.streaming.StreamMessageEnd(*, id, usage, model=None)[source]¶
Bases:
StructDictMixin,StructFinal chunk in a chat stream, containing token usage statistics.
- Variables:
- Parameters:
- usage: ChatUsage¶
- class pinecone.models.assistant.streaming.StreamContentChunk(*, id, delta, model=None)[source]¶
Bases:
StructDictMixin,StructA content chunk containing a text fragment in a delta object.
- Variables:
- Parameters:
- delta: StreamContentDelta¶
- class pinecone.models.assistant.streaming.StreamCitationChunk(*, id, citation, model=None)[source]¶
Bases:
StructDictMixin,StructA citation chunk linking response text to source references.
- Variables:
- Parameters:
- citation: ChatCitation¶
- class pinecone.models.assistant.streaming.AsyncChatStream(stream)[source]¶
Bases:
objectAsync version of
ChatStreamfor use withAsyncPinecone.The stream is single-pass: iterating, calling
text(), or callingcollect()all consume the same underlying async iterator.Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "What can you help me with?"}], stream=True, ) async for text in stream.text(): print(text, end="", flush=True) asyncio.run(main())
Use
collect()to drain the stream and return the full content as a single string:async def main() -> None: stream = await pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Summarize your capabilities."}], stream=True, ) full_content = await stream.collect() asyncio.run(main())
- Parameters:
stream (AsyncIterator[ChatStreamChunk])
- __init__(stream)[source]¶
- Parameters:
stream (AsyncIterator[StreamMessageStart | StreamContentChunk | StreamCitationChunk | StreamMessageEnd])
- Return type:
None
- async collect()[source]¶
Drain the stream and return all content fragments concatenated.
- Returns:
The complete response as a single string.
- Return type:
Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) full = await stream.collect() print(full) asyncio.run(main())
- async text()[source]¶
Yield text fragments, skipping start/citation/end chunks.
- Returns:
Async iterator of text fragment strings. Each fragment is a partial response as it arrives from the server.
- Return type:
Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) async for chunk_text in stream.text(): print(chunk_text, end="", flush=True) asyncio.run(main())
- class pinecone.models.assistant.streaming.AsyncChatCompletionStream(stream)[source]¶
Bases:
objectAsync version of
ChatCompletionStreamfor use withAsyncPinecone.The stream is single-pass: iterating, calling
text(), or callingcollect()all consume the same underlying async iterator.Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "What can you help me with?"}], stream=True, ) async for text in stream.text(): print(text, end="", flush=True) asyncio.run(main())
Use
collect()to drain the stream and return the full content as a single string:async def main() -> None: stream = await pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Summarize your capabilities."}], stream=True, ) full_content = await stream.collect() asyncio.run(main())
- Parameters:
stream (AsyncIterator[ChatCompletionStreamChunk])
- __init__(stream)[source]¶
- Parameters:
stream (AsyncIterator[ChatCompletionStreamChunk])
- Return type:
None
- async collect()[source]¶
Drain the stream and return all content fragments concatenated.
- Returns:
The complete response as a single string.
- Return type:
Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) full = await stream.collect() print(full) asyncio.run(main())
- async text()[source]¶
Yield non-empty content strings, skipping role-only and finish chunks.
- Returns:
Async iterator of non-empty text fragment strings. Role-only chunks and finish-reason chunks with
Noneor empty content are skipped.- Return type:
Examples
import asyncio from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") async def main() -> None: stream = await pc.assistants.chat_completions( assistant_name="acme-support-bot", messages=[{"content": "Explain vector databases in one sentence."}], stream=True, ) async for chunk_text in stream.text(): print(chunk_text, end="", flush=True) asyncio.run(main())
Filter Builder¶
- class pinecone.utils.filter_builder.Field(name)[source]¶
Bases:
objectRepresents a metadata field name for building filter expressions.
Usage:
Field("genre") == "drama" # {"genre": {"$eq": "drama"}} Field("score").gt(0.5) # {"score": {"$gt": 0.5}}
- Parameters:
name (str)