Pinecone¶
Pinecone is the synchronous control-plane client — use it to manage indexes,
collections, backups, and related resources. Sub-clients for each resource type are
accessed as properties (e.g. pc.indexes, pc.collections) and are
lazily initialized on first access.
- class pinecone.Pinecone(api_key=None, *, host=None, additional_headers=None, source_tag=None, proxy_url=None, proxy_headers=None, ssl_ca_certs=None, ssl_verify=True, timeout=30.0, connection_pool_maxsize=0, retry_config=None, **kwargs)[source]¶
Bases:
objectSynchronous Pinecone client for control-plane operations.
- Parameters:
api_key (str | None) – Pinecone API key. Falls back to
PINECONE_API_KEYenv var.host (str | None) – Control-plane API host. Falls back to
PINECONE_CONTROLLER_HOSTenv var, then defaults tohttps://api.pinecone.io.additional_headers (dict[str, str] | None) – Extra headers included in every request.
source_tag (str | None) – Tag appended to the User-Agent string for request attribution.
proxy_url (str | None) – HTTP proxy URL for outgoing requests.
proxy_headers (dict[str, str] | None) – Custom headers for proxy authentication.
ssl_ca_certs (str | None) – Path to a CA certificate bundle for SSL verification.
ssl_verify (bool) – Whether to verify SSL certificates. Defaults to
True.timeout (float) – Request timeout in seconds. Defaults to
30.0.connection_pool_maxsize (int) – Maximum number of connections to keep in the pool.
0(default) uses httpx defaults.retry_config (RetryConfig | None) – Custom retry configuration. When
None(default), uses built-in defaults (5 attempts, exponential backoff, retries on 500/502/503/504 for GET/HEAD).pool_threads (int | None) – Opt-in for the legacy
async_req=Trueexecution model on data-plane methods. When set, indexes created viaindex()acceptasync_req=Trueonupsert,query,describe_index_stats, andlist_paginated. For new code, preferAsyncPineconeorconcurrent.futures.ThreadPoolExecutor. This kwarg exists for backcompat with pre-rewrite callers.kwargs (Any)
- Raises:
PineconeValueError – If no API key can be resolved from arguments or environment variables.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") # or set PINECONE_API_KEY env var # Control plane: manage indexes indexes = pc.indexes.list() # Data plane: operate on vectors index = pc.index("my-index")
- Index(name='', host='', **kwargs)[source]¶
Backwards-compatibility shim for
Pinecone.index().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.index(name=..., host=...)instead ofpc.Index(...). Accepts a legacypool_threads=kwarg and forwards it to size theasync_req=Truethread pool; other unknown kwargs raiseTypeError.
- IndexAsyncio(host, **kwargs)[source]¶
Backwards-compatibility shim that returns an
AsyncIndex.Preserved to ease migration from the legacy Pinecone Python SDK. New code should construct an
AsyncPineconeand call.index(host=...)on it (or instantiateAsyncIndexdirectly) instead ofPinecone.IndexAsyncio(...).
- __init__(api_key=None, *, host=None, additional_headers=None, source_tag=None, proxy_url=None, proxy_headers=None, ssl_ca_certs=None, ssl_verify=True, timeout=30.0, connection_pool_maxsize=0, retry_config=None, **kwargs)[source]¶
- property assistant: _AssistantNamespaceProxy¶
Convenience alias for
Pinecone.assistants.Returns a proxy that supports both namespace-style access (
pc.assistant.create_assistant(...)) and the convenience call form (pc.assistant("my-name")— shortcut forpc.assistants.describe(name="my-name")).The canonical entry point is
Pinecone.assistants; this alias is provided for ergonomic singular-form access and is not deprecated.
- property assistants: Assistants¶
Access the Assistants namespace for assistant operations.
Lazily imported and instantiated on first access.
- Returns:
Assistantsnamespace instance.
Examples
>>> names = [a.name for a in pc.assistants.list()]
- property backups: Backups¶
Access the Backups namespace for backup operations.
Lazily imported and instantiated on first access.
- Returns:
Backupsnamespace instance.
Examples
>>> ids = [b.backup_id for b in pc.backups.list()]
- property collections: Collections¶
Access the Collections namespace for collection operations.
Lazily imported and instantiated on first access.
- Returns:
Collectionsnamespace instance.
Examples
>>> names = [col.name for col in pc.collections.list()]
- property config: PineconeConfig¶
The resolved configuration for this client.
- configure_index(name, replicas=None, pod_type=None, deletion_protection=None, tags=None, embed=None, read_capacity=None)[source]¶
Backwards-compatibility shim for
Pinecone.indexes.configure().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.configure()instead ofpc.configure_index().
- create_backup(*, index_name, backup_name=None, description='')[source]¶
Backwards-compatibility shim for
Pinecone.backups.create().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.backups.create()instead ofpc.create_backup().- Parameters:
- Return type:
- create_collection(name, source)[source]¶
Backwards-compatibility shim for
Pinecone.collections.create().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.collections.create()instead ofpc.create_collection().- Parameters:
- Return type:
- create_index(name, spec, dimension=None, metric='cosine', timeout=None, deletion_protection='disabled', vector_type='dense', tags=None)[source]¶
Backwards-compatibility shim for
Pinecone.indexes.create().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.create()instead ofpc.create_index().- Parameters:
name (str)
spec (ServerlessSpec | PodSpec | ByocSpec | IntegratedSpec | dict[str, Any])
dimension (int | None)
timeout (int | None)
deletion_protection (DeletionProtection | str | None)
vector_type (VectorType | str)
- Return type:
- create_index_for_model(name, cloud, region, embed, tags=None, deletion_protection='disabled', read_capacity=None, schema=None, timeout=None)[source]¶
Backwards-compatibility shim for creating an integrated (model-backed) index.
Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.create()with anIntegratedSpec(IntegratedSpec(cloud=..., region=..., embed=EmbedConfig(...))) instead ofpc.create_index_for_model().- Parameters:
name (str)
cloud (CloudProvider | str)
region (AwsRegion | GcpRegion | AzureRegion | str)
embed (IndexEmbed | EmbedConfig | dict[str, Any])
deletion_protection (DeletionProtection | str | None)
timeout (int | None)
- Return type:
- create_index_from_backup(*, name, backup_id, deletion_protection=None, tags=None, timeout=None)[source]¶
Create a new index by restoring from a backup.
Sends a POST to
/backups/{backup_id}/create-indexand then polls until the index is ready (unless timeout is-1).- Parameters:
name (str) – Name for the new index.
backup_id (str) – Identifier of the backup to restore from.
deletion_protection (DeletionProtection | str | None) –
"enabled"or"disabled". Defaults to"disabled"server-side when omitted.tags (dict[str, str] | None) – Optional key-value tags for the new index.
timeout (int | None) – Seconds to wait for readiness.
None(default) blocks up to 300 s.-1returns immediately without polling.
- Returns:
An
IndexModeldescribing the restored index.- Raises:
PineconeValueError – If name or backup_id is empty.
PineconeTimeoutError – If the index is not ready within the timeout.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> index = pc.create_index_from_backup( ... name="product-search-restored", ... backup_id="bk-daily-20240115", ... )
>>> index = pc.create_index_from_backup( ... name="product-search-restored", ... backup_id="bk-daily-20240115", ... deletion_protection="enabled", ... tags={"env": "production", "team": "search"}, ... )
- delete_backup(*, backup_id)[source]¶
Backwards-compatibility shim for
Pinecone.backups.delete().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.backups.delete()instead ofpc.delete_backup().- Parameters:
backup_id (str)
- Return type:
None
- delete_collection(name)[source]¶
Backwards-compatibility shim for
Pinecone.collections.delete().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.collections.delete()instead ofpc.delete_collection().- Parameters:
name (str)
- Return type:
None
- delete_index(name, timeout=None)[source]¶
Backwards-compatibility shim for
Pinecone.indexes.delete().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.delete()instead ofpc.delete_index().
- describe_backup(*, backup_id)[source]¶
Backwards-compatibility shim for
Pinecone.backups.describe().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.backups.describe()instead ofpc.describe_backup().- Parameters:
backup_id (str)
- Return type:
- describe_collection(name)[source]¶
Backwards-compatibility shim for
Pinecone.collections.describe().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.collections.describe()instead ofpc.describe_collection().- Parameters:
name (str)
- Return type:
- describe_index(name)[source]¶
Backwards-compatibility shim for
Pinecone.indexes.describe().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.describe()instead ofpc.describe_index().- Parameters:
name (str)
- Return type:
- describe_restore_job(*, job_id)[source]¶
Backwards-compatibility shim for
Pinecone.restore_jobs.describe().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.restore_jobs.describe()instead ofpc.describe_restore_job().- Parameters:
job_id (str)
- Return type:
- has_index(name)[source]¶
Backwards-compatibility shim for
Pinecone.indexes.exists().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.exists()instead ofpc.has_index().
- index(name='', *, host='', grpc=False, pool_threads=None)[source]¶
Create a data plane client targeting a specific index.
Can target by host URL directly (skips the describe call) or by index name (triggers a describe-index lookup to resolve the host).
See also
Use
pc.indexesfor control-plane operations (create, list, describe, delete, configure). To create an index from a backup, usePinecone.create_index_from_backup().- Parameters:
- Returns:
- Raises:
PineconeValueError – If neither name nor host is provided.
- Return type:
Examples
pc = Pinecone(api_key="...") idx = pc.index(host="my-index-abc123.svc.pinecone.io") # or idx = pc.index(name="my-index") # gRPC transport idx = pc.index(name="my-index", grpc=True)
- property indexes: Indexes¶
Access the Indexes namespace for control-plane index operations.
Lazily imported and instantiated on first access.
- Returns:
Indexesnamespace instance.
Examples
>>> names = [idx.name for idx in pc.indexes.list()]
- property inference: Inference¶
Access the Inference namespace for embed and rerank operations.
Lazily imported and instantiated on first access.
- Returns:
Inferencenamespace instance.
Examples
>>> embeddings = pc.inference.embed( ... model="multilingual-e5-large", inputs=["Hello, world!"] ... )
- list_backups(*, index_name=None, limit=10, pagination_token=None)[source]¶
Backwards-compatibility shim for
Pinecone.backups.list().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.backups.list()instead ofpc.list_backups().- Parameters:
- Return type:
- list_collections()[source]¶
Backwards-compatibility shim for
Pinecone.collections.list().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.collections.list()instead ofpc.list_collections().- Return type:
- list_indexes()[source]¶
Backwards-compatibility shim for
Pinecone.indexes.list().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.indexes.list()instead ofpc.list_indexes().- Return type:
- list_restore_jobs(*, limit=10, pagination_token=None)[source]¶
Backwards-compatibility shim for
Pinecone.restore_jobs.list().Preserved to ease migration from the legacy Pinecone Python SDK. New code should use
pc.restore_jobs.list()instead ofpc.list_restore_jobs().- Parameters:
- Return type:
- property preview: Preview¶
Access the Preview namespace for pre-release API features.
Lazily imported and instantiated on first access. Preview surface is not covered by SemVer — signatures and behavior may change in any minor SDK release.
- Returns:
Previewnamespace instance.
Examples
pc = Pinecone(api_key="your-api-key") pc.preview.indexes.create(...) # when a preview area exists
- property restore_jobs: RestoreJobs¶
Access the RestoreJobs namespace for restore job operations.
Lazily imported and instantiated on first access.
- Returns:
RestoreJobsnamespace instance.
Examples
>>> ids = [job.restore_job_id for job in pc.restore_jobs.list()]
Indexes¶
- class pinecone.client.indexes.Indexes(http, host_cache=None)[source]¶
Bases:
objectControl-plane operations for Pinecone indexes.
Provides
list,describe,exists,create,delete, andconfiguremethods.See also
Use
Pinecone.index(name)to get a data-plane client for vector operations on a specific index.- Parameters:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") names = [idx.name for idx in pc.indexes.list()]
- configure(name, *, replicas=None, pod_type=None, deletion_protection=None, tags=None, embed=None, read_capacity=None)[source]¶
Configure an existing index.
Updates mutable properties of an index such as replicas, pod type, deletion protection, tags, and read capacity.
- Parameters:
name (str) – The name of the index to configure.
replicas (int | None) – Number of replicas for pod-based indexes.
pod_type (str | None) – Pod type for pod-based indexes (e.g.
"p1.x2").deletion_protection (DeletionProtection | str | None) –
"enabled"or"disabled".tags (dict[str, str] | None) – Key-value tags to merge with existing tags. Set a value to
""to remove a tag.read_capacity (dict[str, Any] | None) – Read capacity configuration for BYOC indexes. Pass
{"mode": "OnDemand"}or{"mode": "Dedicated", "dedicated": {"node_type": "t1", "scaling": "Manual", "manual": {"replicas": 2, "shards": 1}}}.
- Raises:
PineconeValueError – If name is empty or read_capacity is invalid.
NotFoundError – If the index does not exist.
ApiError – If the API returns another error response.
- Return type:
None
Examples
>>> pc.indexes.configure("my-index", replicas=4) >>> pc.indexes.configure("my-index", tags={"env": "prod"})
- create(*, name, spec, dimension=None, metric='cosine', vector_type='dense', deletion_protection='disabled', tags=None, schema=None, timeout=None)[source]¶
Create a new Pinecone index.
Supports serverless, pod-based, BYOC (bring your own cloud), and integrated (model-backed) index creation. Integrated indexes use Pinecone’s built-in embedding models so dimension and metric are inferred from the model.
- Parameters:
name (str) – Name for the new index.
spec (ServerlessSpec | PodSpec | ByocSpec | IntegratedSpec | dict[str, Any]) – Deployment spec — a ServerlessSpec, PodSpec, ByocSpec, IntegratedSpec, or raw dict.
dimension (int | None) – Vector dimension (required for dense non-integrated indexes).
metric (Metric | str) – Similarity metric (cosine, euclidean, dotproduct).
vector_type (VectorType | str) – Vector type (dense or sparse).
deletion_protection (DeletionProtection | str) – Whether deletion protection is enabled.
schema (dict[str, Any] | None) – Optional metadata schema defining field types for indexing. Accepts both flat format (
{"field": {"type": "str"}}) and nested format ({"fields": {"field": {"type": "str"}}}).timeout (int | None) – Seconds to wait for the index to become ready. Use
None(default) to poll indefinitely every 5 seconds with no upper time bound. Use a positive int to poll with a deadline. Use-1to return immediately without polling. RaisesPineconeTimeoutErrorif the index is not ready before the deadline.IndexInitFailedErrorif initialization fails.
- Returns:
IndexModeldescribing the created index.- Raises:
PineconeValueError – If inputs fail client-side validation.
NotFoundError – If the index disappears during readiness polling.
IndexInitFailedError – If the index fails to initialise.
PineconeTimeoutError – If the index is not ready before the deadline.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> from pinecone import Pinecone, ServerlessSpec >>> pc = Pinecone(api_key="your-api-key") >>> index = pc.indexes.create( ... name="movie-recommendations", ... dimension=1536, ... spec=ServerlessSpec(cloud="aws", region="us-east-1"), ... )
>>> from pinecone import Pinecone, IntegratedSpec, EmbedConfig >>> pc = Pinecone(api_key="your-api-key") >>> index = pc.indexes.create( ... name="semantic-search", ... spec=IntegratedSpec( ... cloud="aws", ... region="us-east-1", ... embed=EmbedConfig( ... model="multilingual-e5-large", ... field_map={"text": "my_text_field"}, ... ), ... ), ... )
- delete(name, *, timeout=None)[source]¶
Delete an index by name.
After sending the delete request, removes the cached host URL for the index. By default, polls every 5 seconds until the index disappears with no upper time bound.
- Parameters:
- Raises:
PineconeValueError – If name is empty.
NotFoundError – If the index does not exist.
PineconeTimeoutError – If the index still exists after timeout seconds.
ApiError – If the API returns another error response.
- Return type:
None
Examples
pc.indexes.delete("my-index") # Wait up to 60 seconds for deletion to complete pc.indexes.delete("my-index", timeout=60)
- describe(name)[source]¶
Get detailed information about a named index.
After a successful call the host URL is cached internally for later data-plane client construction.
- Parameters:
name (str) – The name of the index to describe.
- Returns:
IndexModelwith name, dimension, metric, host, spec, status, deletion_protection, vector_type, and tags.- Raises:
PineconeValueError – If name is empty.
NotFoundError – If the index does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> desc = pc.indexes.describe("my-index") >>> desc.host 'https://my-index.svc.pinecone.io'
- exists(name)[source]¶
Check whether a named index exists.
Uses describe internally; returns
Trueon success andFalsewhen a 404 is returned.- Parameters:
name (str) – The name of the index to check.
- Returns:
True if the index exists, False otherwise. Returns False immediately without a network call if name is empty or whitespace-only.
- Raises:
ApiError – If the API returns an error other than 404.
- Return type:
Examples
>>> pc.indexes.exists("my-index") True
- list()[source]¶
List all indexes in the project.
Returns all indexes in a single response without filtering, sorting, or pagination.
- Returns:
IndexListsupporting iteration, len(), index access, and a names() convenience method.- Raises:
ApiError – If the API returns an error response (e.g. authentication failure or server error).
- Return type:
Examples
>>> indexes = pc.indexes.list() >>> indexes.names() ['my-index']
Collections¶
- class pinecone.client.collections.Collections(http)[source]¶
Bases:
objectControl-plane operations for Pinecone collections.
Provides methods to create, list, describe, and delete collections.
- Parameters:
http (HTTPClient) – HTTP client for making API requests.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") names = [col.name for col in pc.collections.list()]
- create(*, name, source)[source]¶
Create a collection from an existing index.
Returns immediately after the API call without polling for readiness.
- Parameters:
- Returns:
A CollectionModel describing the created collection.
- Raises:
ValidationError – If name or source is empty.
ApiError – If the API returns an error response (e.g. authentication failure or server error).
- Return type:
Examples
>>> col = pc.collections.create(name="my-collection", source="my-index") >>> col.status 'Initializing'
- delete(name)[source]¶
Delete a collection by name.
- Parameters:
name (str) – The name of the collection to delete.
- Raises:
ValidationError – If name is empty.
NotFoundError – If the collection does not exist.
ApiError – If the API returns another error response.
- Return type:
None
Examples
>>> pc.collections.delete("my-collection")
- describe(name)[source]¶
Get detailed information about a named collection.
- Parameters:
name (str) – The name of the collection to describe.
- Returns:
A CollectionModel with name, status, size, dimension, vector_count, and environment.
- Raises:
ValidationError – If name is empty.
NotFoundError – If the collection does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> desc = pc.collections.describe("my-collection") >>> desc.size 1024
- list()[source]¶
List all collections in the project.
Returns all collections in a single response without filtering, sorting, or pagination.
- Returns:
A CollectionList supporting iteration, len(), index access, and a names() convenience method.
- Raises:
ApiError – If the API returns an error response (e.g. authentication failure or server error).
- Return type:
Examples
>>> collections = pc.collections.list() >>> collections.names() ['my-collection']
Backups¶
- class pinecone.client.backups.Backups(http)[source]¶
Bases:
objectControl-plane operations for Pinecone backups.
Provides methods to create, list, describe, and delete backups.
- Parameters:
http (HTTPClient) – HTTP client for making API requests.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") ids = [b.backup_id for b in pc.backups.list()]
- create(*, index_name, name=None, description='')[source]¶
Create a backup of an existing index.
- Parameters:
- Returns:
A
BackupModeldescribing the created backup.- Raises:
ValidationError – If index_name is empty.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> backup = pc.backups.create(index_name="product-search") >>> backup.backup_id 'bk-abc123'
>>> backup = pc.backups.create( ... index_name="product-search", ... name="daily-20240115", ... description="Scheduled daily backup before reindexing", ... )
- delete(*, backup_id)[source]¶
Delete a backup.
- Parameters:
backup_id (str) – The identifier of the backup to delete.
- Raises:
ValidationError – If backup_id is empty.
NotFoundError – If the backup does not exist.
ApiError – If the API returns another error response.
- Return type:
None
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> pc.backups.delete(backup_id="bk-daily-20240115")
- describe(*, backup_id)[source]¶
Get detailed information about a backup.
- Parameters:
backup_id (str) – The identifier of the backup to describe.
- Returns:
A
BackupModelwith full backup details.- Raises:
ValidationError – If backup_id is empty.
NotFoundError – If the backup does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> backup = pc.backups.describe(backup_id="bk-daily-20240115") >>> backup.status 'Ready'
- get(*, backup_id)[source]¶
Get detailed information about a backup (alias for
describe()).- Parameters:
backup_id (str) – The identifier of the backup.
- Returns:
A
BackupModelwith full backup details.- Raises:
ValidationError – If backup_id is empty.
NotFoundError – If the backup does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> backup = pc.backups.get(backup_id="bk-daily-20240115") >>> backup.status 'Ready'
- list(*, index_name=None, limit=10, pagination_token=None)[source]¶
List backups.
When index_name is provided, lists backups for that index only. Otherwise lists all backups in the project.
- Parameters:
- Returns:
A
BackupListsupporting iteration, len(), and index access.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> for backup in pc.backups.list(): ... print(backup.backup_id, backup.name)
>>> for backup in pc.backups.list(index_name="product-search"): ... print(backup.name)
RestoreJobs¶
- class pinecone.client.restore_jobs.RestoreJobs(http)[source]¶
Bases:
objectControl-plane operations for Pinecone restore jobs.
Provides methods to list and describe restore jobs.
- Parameters:
http (HTTPClient) – HTTP client for making API requests.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") ids = [job.restore_job_id for job in pc.restore_jobs.list()]
- describe(*, job_id)[source]¶
Get detailed information about a restore job.
- Parameters:
job_id (str) – The identifier of the restore job to describe.
- Returns:
A
RestoreJobModelwith full restore job details.- Raises:
ValidationError – If job_id is empty.
NotFoundError – If the restore job does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> job = pc.restore_jobs.describe(job_id="rj-restore-20240115") >>> job.status 'Completed'
- list(*, limit=10, pagination_token=None)[source]¶
List all restore jobs in the project.
Supports cursor-based pagination. Defaults to 10 results per page.
- Parameters:
- Returns:
A
RestoreJobListsupporting iteration, len(), and index access.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> for job in pc.restore_jobs.list(): ... print(job.restore_job_id, job.status)
>>> jobs = pc.restore_jobs.list(limit=5) >>> len(jobs) 5
Inference¶
- class pinecone.client.inference.Inference(config)[source]¶
Bases:
objectControl-plane operations for Pinecone inference (embed & rerank).
Provides methods to generate embeddings and rerank documents using Pinecone’s hosted models.
- Parameters:
config (PineconeConfig) – SDK configuration used to construct an HTTP client targeting the inference API version.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") embeddings = pc.inference.embed( model="multilingual-e5-large", inputs=["Hello, world!"] )
- class EmbedModel(value)¶
-
Known embedding models for integrated indexes.
- Multilingual_E5_Large = 'multilingual-e5-large'¶
- Pinecone_Sparse_English_V0 = 'pinecone-sparse-english-v0'¶
- class RerankModel(value)¶
-
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'¶
- embed(model, inputs, parameters=None)[source]¶
Generate embeddings for the provided inputs.
- Parameters:
model (EmbedModel | str) – Embedding model name.
inputs (str | list[str] | list[dict[str, Any]]) – Text inputs. A single string is automatically wrapped.
parameters (dict[str, Any] | None) –
Model-specific parameters (e.g.,
{"input_type": "passage", "truncate": "END"}). To discover valid parameters for a model, callget_model():pc.inference.get_model(model="multilingual-e5-large").supported_parameters
- Returns:
An
EmbeddingsListwith.data,.model, and.usage.- Raises:
PineconeValueError – If model is empty or inputs is empty.
PineconeTypeError – If inputs has an invalid type.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request exceeds the configured timeout.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> embeddings = pc.inference.embed( ... model="multilingual-e5-large", ... inputs=["Hello, world!"], ... parameters={"input_type": "passage"}, ... ) >>> len(embeddings.data) 1
Note
To store embeddings in a Pinecone index, extract the raw vector values and pass them to
upsert():values = embeddings.data[0].values index.upsert(vectors=[("doc-1", values)])
Alternatively, use an index with integrated inference (
IntegratedSpec) and callupsert_records()to let Pinecone handle embedding server-side — no manual embed step required.
- get_model(*, model=None, **kwargs)[source]¶
Get detailed information about a specific model.
- Parameters:
- Returns:
A
ModelInfowith full model details.- Raises:
PineconeValueError – If model is empty.
NotFoundError – If the model does not exist.
ApiError – If the API returns another error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request exceeds the configured timeout.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> model_info = pc.inference.get_model(model="multilingual-e5-large") >>> model_info.type 'embed'
- list_models(*, type=None, vector_type=None)[source]¶
List available inference models.
- Parameters:
- Returns:
A
ModelInfoListsupporting iteration, len(), and.names().- Raises:
PineconeValueError – If type or vector_type is not a valid value.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request exceeds the configured timeout.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> models = pc.inference.list_models() >>> models.names() ['multilingual-e5-large', 'pinecone-sparse-english-v0']
>>> embed_models = pc.inference.list_models(type="embed")
- property model: ModelResource¶
Lazily-initialized resource for listing and getting model info.
- Returns:
A
ModelResourcethat exposes.list()and.get()methods.
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> models = pc.inference.model.list() >>> info = pc.inference.model.get("multilingual-e5-large")
- rerank(model, query, documents, rank_fields=['text'], return_documents=True, top_n=None, parameters=None)[source]¶
Rerank documents by relevance to a query.
- Parameters:
model (RerankModel | str) – Reranking model name.
query (str) – Query text to rank against.
documents (list[str] | list[dict[str, Any]]) – Documents to rank. Strings are auto-wrapped as
{"text": ...}.rank_fields (list[str]) – Document fields to rank on. Defaults to
["text"].return_documents (bool) – Include document text in response. Defaults to
True.top_n (int | None) – Number of top documents to return.
Nonereturns all.parameters (dict[str, Any] | None) –
Model-specific parameters. To discover valid parameters for a model, call
get_model():pc.inference.get_model(model="bge-reranker-v2-m3").supported_parameters
- Returns:
A
RerankResultwith.dataand.usage.- Raises:
PineconeValueError – If model, query, or documents is empty.
PineconeTypeError – If documents has an invalid type.
ApiError – If the API returns an error response.
PineconeConnectionError – If a network-level connection fails (DNS, refused, transport error).
PineconeTimeoutError – If the request exceeds the configured timeout.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> result = pc.inference.rerank( ... model="bge-reranker-v2-m3", ... query="Tell me about tech companies", ... documents=["Apple is a fruit.", "Acme Inc. revolutionized tech."], ... top_n=1, ... ) >>> result.data[0].score 0.95
Assistants¶
- class pinecone.client.assistants.Assistants(config)[source]¶
Bases:
AssistantsLegacyNamespaceMixinControl-plane operations for Pinecone assistants.
- Parameters:
config (PineconeConfig) – SDK configuration used to construct an HTTP client targeting the assistant API version.
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") assistants = pc.assistants
- chat(*, assistant_name, messages, model='gpt-4o', stream=False, temperature=None, filter=None, json_response=False, include_highlights=False, context_options=None)[source]¶
Chat with an assistant and receive citations in Pinecone-native format.
- Parameters:
assistant_name (str) – Name of the assistant to chat with.
messages (list[Message | dict[str, str]]) – Conversation messages. Dicts are converted to
Messageobjects; role defaults to"user"when not present.model (str) – Large language model to use. Defaults to
"gpt-4o".stream (bool) – If
True, return aChatStream. Defaults toFalse.temperature (float | None) – Controls randomness. Lower values produce more deterministic responses. Omitted from request when
None.filter (dict[str, Any] | None) – Metadata filter restricting which documents are used as context. Omitted from request when
None.json_response (bool) – If
True, instruct the assistant to return a JSON response. Cannot be used with streaming.include_highlights (bool) – If
True, include highlight snippets from referenced documents in citations.context_options (ContextOptions | dict[str, Any] | None) – Options controlling context retrieval. Omitted from request when
None.
- Returns:
ChatResponsefor non-streaming requests, or aChatStreamfor streaming requests.- Raises:
PineconeValueError – If both
stream=Trueandjson_response=Trueare specified.ApiError – If the API returns an error response.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") response = pc.assistants.chat( assistant_name="my-assistant", messages=[{"content": "What is Pinecone?"}], )
stream = pc.assistants.chat( assistant_name="my-assistant", messages=[{"content": "What is Pinecone?"}], stream=True, ) for text in stream.text(): print(text, end="", flush=True)
- chat_completions(*, assistant_name, messages, model='gpt-4o', stream=False, temperature=None, filter=None)[source]¶
Chat with an assistant using an OpenAI-compatible interface.
Returns responses in OpenAI chat completion format. Useful when you need inline citations or OpenAI-compatible responses. Has limited functionality compared to the standard
chat()interface — does not supportinclude_highlights,context_options, orjson_responseparameters.The model parameter accepts any string value and is not validated client-side. Known models include
"gpt-4o","gpt-4.1","o4-mini","claude-3-5-sonnet","claude-3-7-sonnet", and"gemini-2.5-pro".- Parameters:
assistant_name (str) – Name of the assistant to chat with.
messages (list[Message | dict[str, str]]) – Conversation messages. Dicts are converted to
Messageobjects; role defaults to"user"when not present.model (str) – Large language model to use. Defaults to
"gpt-4o". Not validated client-side — any string is accepted.stream (bool) – If
True, return aChatCompletionStream. Defaults toFalse.temperature (float | None) – Controls randomness. Lower values produce more deterministic responses. Omitted from request when
None.filter (dict[str, Any] | None) – Metadata filter restricting which documents are used as context. Omitted from request when
None.
- Returns:
ChatCompletionResponsefor non-streaming requests, or aChatCompletionStreamfor streaming requests.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") response = pc.assistants.chat_completions( assistant_name="research-assistant", messages=[{"content": "Explain quantum entanglement briefly."}], ) response.choices[0].message.content
stream = pc.assistants.chat_completions( assistant_name="research-assistant", messages=[{"content": "Explain quantum entanglement briefly."}], stream=True, ) for chunk in stream: print(chunk)
- close()[source]¶
Close the underlying HTTP client and any cached data-plane clients.
- Return type:
None
- context(*, assistant_name, query=None, messages=None, filter=None, top_k=None, snippet_size=None, multimodal=None, include_binary_content=None)[source]¶
Retrieve relevant context snippets from a Pinecone assistant.
Retrieves context snippets matching a text query or conversation history. Exactly one of query or messages must be provided and non-empty.
- Parameters:
assistant_name (str) – Name of the assistant to retrieve context from.
query (str | None) – Text query to use for context retrieval. Mutually exclusive with messages. Empty string is treated as not provided.
messages (list[Message | dict[str, str]] | None) – Conversation messages to use for context retrieval. Mutually exclusive with query. Empty list is treated as not provided. Dicts are converted to
Messageobjects.filter (dict[str, Any] | None) – Metadata filter restricting which documents contribute context. Omitted from request when
None.top_k (int | None) – Maximum number of context snippets to return. Omitted from request when
None.snippet_size (int | None) – Maximum snippet size in tokens. Omitted from request when
None.multimodal (bool | None) – Whether to include image-related context snippets. Omitted from request when
None.include_binary_content (bool | None) – Whether image snippets include base64 image data. Only meaningful when multimodal is
True. Omitted from request whenNone.
- Returns:
ContextResponsecontaining the matching context snippets.- Raises:
PineconeValueError – If both or neither of query and messages are provided (or if they are empty).
ApiError – If the API returns an error response.
- Return type:
Examples
response = pc.assistants.context( assistant_name="my-assistant", query="What is Pinecone?", ) for snippet in response.snippets: print(snippet.content)
- create(*, name=None, instructions=None, metadata=None, region='us', timeout=None, **kwargs)[source]¶
Create a new Pinecone assistant.
Creates an assistant and optionally polls until it reaches
"Ready"status. The assistant starts in"Initializing"status.- Parameters:
name (str) – Name for the new assistant. Must be 1-63 characters, start and end with an alphanumeric character, and consist only of lowercase alphanumeric characters or hyphens.
instructions (str | None) – Optional directive for the assistant to apply to all responses. Maximum 16 KB.
metadata (dict[str, Any] | None) – Optional metadata dictionary. Defaults to an empty dict if not provided.
region (str) – Region to deploy the assistant in. Must be
"us"or"eu"(case-sensitive). Defaults to"us".timeout (float | None) – Seconds to wait for the assistant to become ready. Use
None(default) to poll indefinitely. Use-1to return immediately without polling. Use0or a positive value to poll with a deadline. RaisesPineconeTimeoutErrorif the assistant is not ready before the deadline.kwargs (Any)
- Returns:
AssistantModeldescribing the created assistant.- Raises:
PineconeValueError – If region is not
"us"or"eu".PineconeTimeoutError – If the assistant does not become ready before the deadline.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> assistant = pc.assistants.create(name="my-assistant")
>>> assistant = pc.assistants.create( ... name="research-assistant", ... instructions="You are a helpful research assistant.", ... metadata={"team": "engineering", "version": "1"}, ... region="eu", ... )
- delete(*, name=None, timeout=None, **kwargs)[source]¶
Delete a Pinecone assistant by name.
Sends a DELETE request, then polls every 5 seconds until the assistant is confirmed gone (404 from describe). Other errors during polling propagate immediately.
- Parameters:
name (str) – The name of the assistant to delete.
timeout (float | None) – Seconds to wait for the assistant to disappear. Use
None(default) to poll indefinitely. Use-1to return immediately without polling. Use a positive value to poll with a deadline. RaisesPineconeTimeoutErrorif the assistant is not gone before the deadline.kwargs (Any)
- Returns:
None
- Raises:
PineconeTimeoutError – If the assistant still exists after timeout seconds.
ApiError – If the API returns an error response.
- Return type:
None
Examples
pc.assistants.delete(name="my-assistant") # Return immediately without waiting for deletion pc.assistants.delete(name="my-assistant", timeout=-1)
- delete_file(*, assistant_name, file_id, timeout=None)[source]¶
Delete a file from a Pinecone assistant.
Sends a DELETE request, then polls every 5 seconds until the file is confirmed gone (404 from describe_file). Other errors during polling propagate immediately.
- Parameters:
assistant_name (str) – Name of the assistant that owns the file.
file_id (str) – Unique identifier of the file to delete.
timeout (float | None) – Seconds to wait for the file to be deleted. Use
None(default) to poll indefinitely. Use-1to return immediately without polling. Use a positive value to poll with a deadline. RaisesPineconeTimeoutErrorif the file is not gone before the deadline.
- Returns:
None- Raises:
PineconeError – If server-side file deletion fails.
PineconeTimeoutError – If the file still exists after timeout seconds.
ApiError – If the API returns an error response.
- Return type:
None
Examples
>>> pc.assistants.delete_file( ... assistant_name="my-assistant", ... file_id="file-abc123", ... )
- describe(*, name=None, **kwargs)[source]¶
Get detailed information about a named assistant.
- Parameters:
- Returns:
AssistantModelwith name, status, created_at, updated_at, metadata, instructions, and host.- Raises:
ApiError – If the API returns an error response (e.g. 404 when the assistant does not exist).
- Return type:
Examples
>>> assistant = pc.assistants.describe(name="my-assistant") >>> assistant.status 'Ready'
- describe_file(*, assistant_name, file_id, include_url=False)[source]¶
Get the status and metadata of a file uploaded to an assistant.
- Parameters:
- Returns:
AssistantFileModelwith file metadata and status.- Raises:
NotFoundError – If the file does not exist.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> file = pc.assistants.describe_file( ... assistant_name="my-assistant", ... file_id="file-abc123", ... ) >>> file.status 'Available'
- evaluate_alignment(*, question, answer, ground_truth_answer)[source]¶
Evaluate answer alignment against a ground truth answer.
Measures the correctness and completeness of a generated answer with respect to a ground truth answer. Alignment is the harmonic mean of correctness (precision) and completeness (recall).
- Parameters:
- Returns:
AlignmentResultwith aggregate scores, per-fact entailment results, and token usage statistics.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
>>> result = pc.assistants.evaluate_alignment( ... question="What is the capital of Spain?", ... answer="Barcelona.", ... ground_truth_answer="Madrid.", ... )
- list(*, limit=None, pagination_token=None)[source]¶
List assistants in the project with transparent lazy pagination.
- Parameters:
- Returns:
PaginatoroverAssistantModelobjects. Supportsforloops,.to_list(),.pages(), andlimit.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
for a in pc.assistants.list(): print(a.name, a.status) all_assistants = pc.assistants.list().to_list()
- list_files(*, assistant_name, filter=None, limit=None, pagination_token=None)[source]¶
List files for an assistant with lazy pagination.
- Parameters:
assistant_name (str) – Name of the assistant whose files to list.
filter (dict[str, Any] | None) – Optional metadata filter expression. Serialized to a JSON string before being sent to the API.
limit (int | None) – Maximum number of files to yield across all pages.
None(default) yields all files.pagination_token (str | None) – Token to resume pagination from a previous call.
- Returns:
PaginatoroverAssistantFileModelobjects. Supportsforloops,.to_list(),.pages(), andlimit.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
for f in pc.assistants.list_files(assistant_name="my-assistant"): print(f.name, f.status) files = pc.assistants.list_files(assistant_name="my-assistant").to_list()
- list_files_page(*, assistant_name, pagination_token=None, filter=None)[source]¶
List one page of files for an assistant with explicit pagination control.
Only the parameters that are explicitly provided are sent in the request. Omitted parameters are not included as query params.
- Parameters:
- Returns:
ListFilesResponsewith afileslist and an optionalnextcontinuation token.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
page = pc.assistants.list_files_page(assistant_name="my-assistant") names = [f.name for f in page.files] token = page.next # use as pagination_token for the next call
- list_page(*, page_size=None, pagination_token=None, **kwargs)[source]¶
List one page of assistants with explicit pagination control.
Only the parameters that are explicitly provided are sent in the request. Omitted parameters are not included as query params.
- Parameters:
- Returns:
ListAssistantsResponsewith anassistantslist and an optionalnextcontinuation token.- Raises:
ApiError – If the API returns an error response.
- Return type:
Examples
page = pc.assistants.list_page(page_size=10) names = [a.name for a in page.assistants] token = page.next # use as pagination_token for the next call
- update(*, name=None, instructions=None, metadata=None, **kwargs)[source]¶
Update an existing Pinecone assistant.
Updates the specified assistant’s instructions and/or metadata. Metadata is fully replaced (not merged) when provided.
- Parameters:
- Returns:
AssistantModeldescribing the updated assistant.- Raises:
ApiError – If the API returns an error response (e.g. 404 when the assistant does not exist).
- Return type:
Examples
>>> assistant = pc.assistants.update( ... name="my-assistant", ... instructions="You are a helpful research assistant.", ... )
>>> assistant = pc.assistants.update( ... name="my-assistant", ... metadata={"team": "ml", "version": "2"}, ... )
- upload_file(*, assistant_name, file_path=None, file_stream=None, file_name=None, metadata=None, multimodal=None, file_id=None, timeout=None)[source]¶
Upload a file to a Pinecone assistant.
Uploads a file from a local path or an in-memory byte stream, then polls until server-side processing completes.
- Parameters:
assistant_name (str) – Name of the target assistant.
file_path (str | None) – Path to a local file to upload. Mutually exclusive with file_stream.
file_stream (IO[bytes] | None) – An open byte stream to upload. Mutually exclusive with file_path. Use file_name to set the filename.
file_name (str | None) – Filename to associate with file_stream. Ignored when file_path is provided.
metadata (dict[str, Any] | None) – Optional metadata dictionary. Sent as a JSON string.
multimodal (bool | None) – Whether to enable multimodal processing for PDFs.
file_id (str | None) – Optional caller-specified file identifier for upsert behavior.
timeout (float | None) – Seconds to wait for processing to complete.
None(default) polls indefinitely. Use-1to return immediately after upload with one describe call. RaisesPineconeTimeoutErrorif processing is not done before the deadline.
- Returns:
AssistantFileModelfetched fresh from the API after processing completes.- Raises:
PineconeValueError – If both or neither of file_path and file_stream are provided, or if file_path does not exist.
PineconeTimeoutError – If processing does not complete before timeout.
PineconeError – If server-side processing fails.
- Return type:
Examples
>>> file = pc.assistants.upload_file( ... assistant_name="research-assistant", ... file_path="/data/report.pdf", ... ) >>> file.status 'Available'