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.
The main entry point for the SDK. Use the
indexes,collections, andbackupsnamespace properties to create and manage those resources, and callindex()to get a client for reading and writing vectors on a specific index.- 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 (Mapping[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 (Mapping[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.
FileNotFoundError – If
ssl_ca_certsnames a path that does not exist, raised when the client is constructed, so a mistyped path cannot leave you silently verifying against the default trust store instead. A bundle that exists but cannot be parsed as a certificate raisesssl.SSLErrorinstead.
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")
- __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¶
Access assistants through the singular-form alias for
Pinecone.assistants.Pinecone.assistantsis the canonical namespace; this alias exists for ergonomic singular-form access and is not deprecated. It forwards attribute access to that namespace and also supports calling it directly with a name as a shortcut fordescribe().- Returns:
A proxy that behaves like the
Assistantsnamespace for attribute access (pc.assistant.create(...)) and, when called with a name, returns that assistant’s details.
Examples
>>> bot = pc.assistant("acme-support-bot") >>> pc.assistant.create( ... name="support-bot", ... instructions="Help users with billing questions.", ... )
- property assistants: Assistants¶
Access the Assistants namespace for managing Pinecone Assistants.
A Pinecone Assistant is a hosted, retrieval-augmented chat service: upload files to it and it answers questions grounded in their content. Use this namespace to create, list, and configure assistants. Lazily imported and instantiated on first access.
- Returns:
Assistantsnamespace instance. Callcreate()to create an assistant, orlist()to see existing ones.
Examples
>>> names = [assistant.name for assistant in pc.assistants.list()]
- property backup_schedules: BackupSchedules¶
Access the BackupSchedules namespace for managing recurring backups.
A backup schedule attaches a recurring cadence (daily, weekly, or monthly) to an index, so Pinecone creates a backup automatically without you having to trigger one each time. Lazily imported and instantiated on first access.
- Returns:
BackupSchedulesnamespace instance. Callcreate()to attach a schedule to an index, orlist()to see existing ones.
Examples
>>> schedules = pc.backup_schedules.list(index_name="my-index")
- property backups: Backups¶
Access the Backups namespace for control-plane backup operations.
Lazily imported and instantiated on first access.
- Returns:
Backupsnamespace instance.
Examples
>>> ids = [backup.backup_id for backup in pc.backups.list()]
- close()[source]¶
Close all open HTTP connections.
Closes the main control-plane client and any namespace clients (inference, assistants) that were initialized during this session.
Prefer the context manager form (
with Pinecone(...) as pc:) which callsclose()automatically on exit.Examples
Close the client explicitly after use:
>>> from pinecone import Pinecone >>> client = Pinecone(api_key="your-api-key") >>> client.close()
Use Pinecone as a context manager (
closeis called automatically):>>> with Pinecone(api_key="your-api-key") as pinecone_client: ... _ = pinecone_client.indexes.list()
- Return type:
None
- property collections: Collections¶
Access the Collections namespace for control-plane 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¶
Return the resolved configuration for this client.
- Returns:
PineconeConfigcontaining the resolved API key, host, timeout, and connection settings.
Examples
>>> cfg = pc.config >>> cfg.timeout 30.0
- create_index_from_backup(*, name, backup_id, deletion_protection=None, tags=None, read_capacity=None, timeout=None)[source]¶
Create a new index by restoring from a backup.
Polls until the restored index is ready, unless timeout is
-1.This is the only supported way to restore a backup:
Pinecone.create_index()rejectssource_backup_id=with a message pointing here.Changed in version 10.0: Added read_capacity, so a restore can land straight onto dedicated read nodes instead of defaulting to on-demand capacity.
- Parameters:
name (str) – Name for the new index.
backup_id (str) – Identifier of the backup to restore from. Obtain this from
Pinecone.backups.create()orPinecone.backups.list().deletion_protection (DeletionProtection | str | None) –
"enabled"or"disabled". Defaults to"disabled"server-side when omitted.tags (Mapping[str, str] | None) – Optional key-value tags for the new index. When omitted, the server copies the backup’s own tags.
read_capacity (dict[str, Any] | None) – Optional read capacity for the restored index —
{"mode": "OnDemand"}or{"mode": "Dedicated", "dedicated": {"node_type": ..., "scaling": "Manual", "manual": {"shards": ..., "replicas": ...}}}. Omitted entirely whenNone, leaving the server’s on-demand default in place. Serverless backups only; the server rejects a dedicated configuration too small for the backup.timeout (int | None) – Seconds to wait for readiness.
None(default) blocks up to 300 s.-1returns aCreateIndexFromBackupResponseimmediately (containsrestore_job_idandindex_id) without polling.
- Returns:
A
CreateIndexFromBackupResponsewhen timeout is-1(containsrestore_job_idandindex_id), or anIndexModeldescribing the restored index once it is ready.- Raises:
PineconeValueError – If name or backup_id is empty, or read_capacity is an empty dict.
PineconeTimeoutError – If the index is not ready within the timeout.
IndexInitFailedError – If the index enters
InitializationFailedstate.IndexTerminatedError – If the index enters
TerminatingorDisabledstate.NotFoundError – If backup_id does not match an existing backup.
ConflictError – If an index named name already exists.
ApiError – If the API returns another error response, for example if the backup is not yet complete.
- 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", ... )
>>> result = pc.create_index_from_backup( ... name="product-search-restored", ... backup_id="bk-daily-20240115", ... timeout=-1, ... ) >>> print(result.restore_job_id)
Restore directly onto dedicated read nodes:
>>> index = pc.create_index_from_backup( ... name="restored-drn-index", ... backup_id="bk-daily-20240115", ... read_capacity={ ... "mode": "Dedicated", ... "dedicated": { ... "node_type": "t1", ... "scaling": "Manual", ... "manual": {"shards": 2, "replicas": 2}, ... }, ... }, ... )
- 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:
name (str) – Name of the index. Triggers a describe call to resolve host.
host (str) – Direct host URL of the index. Skips the describe call.
grpc (bool) – If
True, return aGrpcIndexthat routes data-plane operations over gRPC instead of HTTP. Defaults toFalse.pool_threads (int | None) – Maximum number of threads in the connection pool used by the underlying HTTP client. Pass
Noneto use the client-level default set atPineconeconstruction time. Has no effect whengrpc=True. Defaults toNone.
- Returns:
A sync
Index(HTTP) orGrpcIndex(gRPC) data-plane client.- Raises:
PineconeValueError – If neither
namenorhostis provided.NotFoundError – If
nameis given but no index with that name exists.
- Return type:
Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") idx = pc.index(host="product-search-abc123.svc.pinecone.io") # or resolve the host by name idx = pc.index(name="product-search") # gRPC transport for high-throughput upserts idx = pc.index(name="product-search", 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 embedding and reranking text.
Use this to generate vector embeddings from text or images, or to rerank a list of documents by relevance to a query, without running a model yourself. Lazily imported and instantiated on first access.
- Returns:
Inferencenamespace instance. Callembed()to generate embeddings, orrerank()to reorder documents by relevance.
Examples
>>> embeddings = pc.inference.embed( ... model="multilingual-e5-large", ... inputs=["Solar panels reduce energy costs and lower carbon emissions."], ... )
- property restore_jobs: RestoreJobs¶
Access the RestoreJobs namespace for tracking backup restores.
A restore job represents an in-progress or completed request to create an index from a backup; use this namespace to check on that request rather than polling the index itself. Lazily imported and instantiated on first access.
- Returns:
RestoreJobsnamespace instance. Calllist()to see restore jobs, ordescribe()for the status of one.
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 (2026-07 API).
Provides
list,describe,exists,create,create_for_model,delete, andconfiguremethods, plus the index-scoped backup methodscreate_backup,list_backups, anddescribe_backup.Changed in version 10.0: Graduated to the 2026-07 schema-based API.
create()takesschema=/deployment=instead ofspec=/dimension=/metric=/vector_type=;configure()nests pod scaling underdeployment=and removedembed=;list()returns aPaginator; the index-scoped backup methods graduated from the preview namespace.See also
Backups(pc.backups) covers the project-wide backup listing plusdelete, which are not scoped to one index.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, *, deployment=None, schema=None, read_capacity=None, deletion_protection=None, tags=None, replicas=None, pod_type=None, serverless_read_capacity=None, **legacy_kwargs)[source]¶
Configure an existing index (2026-07 API).
Only the fields you provide are updated; omitted parameters are left unchanged on the server.
Changed in version 10.0: Before/after:
# 9.x pc.indexes.configure("my-index", replicas=4, pod_type="p1.x2") # 10.x pc.indexes.configure("my-index", deployment={"replicas": 4, "pod_type": "p1.x2"})
embed=is gone entirely (the 2025-10 convert-to-integrated flow no longer exists);replicas=/pod_type=/serverless_read_capacity=remain available below as deprecated keyword-only sugar fordeployment=/read_capacity=; and the method returns the updatedIndexModelinstead ofNone.Deprecated since version 10.0:
replicas=,pod_type=, andserverless_read_capacity=are translated intodeployment=/read_capacity=rather than sent as-is, and cannot be combined with the 2026-07 argument they translate to — passing both raisesPineconeValueError. New code should usedeployment=/read_capacity=directly.Note
Only
semantic_textfield parameters (read_parameters/write_parameters) can be updated throughschema=; other field types can’t be added, removed, or retyped after creation. Sincecreate()cannot declare asemantic_textfield directly, this only applies to indexes created withcreate_for_model().- Parameters:
name (str) – Name of the index to configure.
deployment (dict[str, Any] | None) – Pod-scaling updates for pod-based indexes —
{"replicas": int, "pod_type": str}(either or both). Must not include"deployment_type": deployment type, cloud/region, and environment cannot be changed after creation.schema (dict[str, Any] | IndexSchema | None) – Schema updates. Only
semantic_textfield parameters (read_parameters/write_parameters) are updatable server-side; see note above.read_capacity (dict[str, Any] | None) – Updated read capacity dict —
{"mode": "OnDemand"}or{"mode": "Dedicated", "dedicated": {...}}. Applies to managed and BYOC indexes.deletion_protection (str | None) –
"enabled"or"disabled".tags (Mapping[str, str] | None) – Tag updates, merged with existing tags on the server. Set a value to
""to delete that key; keys you do not mention are left unchanged. The 20-tag cap is applied to the merged total rather than to this request, so adding tags to an index that already carries several can be rejected even though the request on its own is well within the cap. When the merge leaves no tags the index stores no tag map at all rather than an empty one.{}is rejected client-side.replicas (int | None) – Deprecated. Legacy pod-scaling replica count, translated into
deployment={"replicas": ...}. Mutually exclusive with deployment.pod_type (PodType | str | None) – Deprecated. Legacy pod type, translated into
deployment={"pod_type": ...}alongside replicas. Mutually exclusive with deployment.serverless_read_capacity (dict[str, Any] | None) – Deprecated. Legacy read-capacity keyword for managed indexes, translated straight into read_capacity. Mutually exclusive with read_capacity.
legacy_kwargs (Any)
- Returns:
IndexModelreflecting the updated index state. Some changes (read capacity, pod scaling) apply asynchronously — checkstatus.- Raises:
PineconeValueError – If name is empty, all kwargs are
None, any dict kwarg is empty, deployment includesdeployment_type, tags/deletion_protection are invalid, or deployment/read_capacity is combined with the deprecated keyword argument it translates to.PineconeTypeError – If
embed=orspec=is passed; neither has a 2026-07 translation and the message shows the equivalent 2026-07 call where one exists.NotFoundError – If the index does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> pc.indexes.configure("my-index", deployment={"replicas": 4}) >>> pc.indexes.configure("my-index", tags={"env": "prod"})
- create(*, schema=None, name=None, deployment=None, read_capacity=None, deletion_protection=None, tags=None, cmek_id=None, timeout=None, spec=None, dimension=None, metric=None, vector_type=None, **legacy_kwargs)[source]¶
Create a new index (2026-07 schema-based API).
An index’s field layout is declared as a
schemaof named, typed fields. Every field in the schema must be one that gets searched —dense_vector,sparse_vector, orstringwithfull_text_searchenabled. Metadata-only fields aren’t declared here; they’re indexed automatically the first time they appear on an upserted record. The schema can’t change after the index is created.Changed in version 10.0: Replaces the 2025-10 signature.
spec=,dimension=,metric=, andvector_type=are deprecated, keyword-only sugar for the currentschema=/deployment=arguments (see below).pods=,metadata_config=,source_collection=,source_backup_id=, andspec=IntegratedSpec(...)have no equivalent here; usecreate_for_model()for integrated embedding.- Parameters:
schema (dict[str, Any] | IndexSchema | None) –
The index’s field schema. Required unless the deprecated
dimension=(with optionalmetric=/vector_type=) is used instead — the two are mutually exclusive. A dict with a"fields"key mapping field names to typed configurations:{ "fields": { "embedding": {"type": "dense_vector", "dimension": 1536, "metric": "cosine"}, "body": {"type": "string", "full_text_search": {"language": "en"}}, } }
Also accepts the dict produced by
SchemaBuilderor anIndexSchema. A hybrid index must declare itssparse_vectorfield explicitly. At 2026-07 a dense field withmetric="dotproduct"no longer accepts sparse values on its own: the create succeeds, and only the sparse upserts are refused later. The field cannot be added byconfigure(), so an index created without one has to be recreated. Seedocs/migration/v10-migration.md.full_text_search.languageaccepts a fixed set of language codes (or their English names, defaulten), butstop_words=Trueis not supported for every language — the server’s 400 names the unsupported language, by its English name rather than the code you sent.name (str | None) – Name for the index — 1-45 characters, lowercase alphanumerics and hyphens (e.g.
"movie-recommendations"). The server assigns a name when omitted.deployment (dict[str, Any] | None) – Deployment configuration, discriminated on
"deployment_type". For a managed index:{"deployment_type": "managed", "cloud": "aws", "region": "us-east-1"}. For a pod-based index,"deployment_type": "pod"plusenvironment,pod_type,replicas, andshards. Defaults to a managed index on AWSus-east-1when omitted. Mutually exclusive with the deprecatedspec=.read_capacity (dict[str, Any] | None) – Read capacity for a managed or BYOC index —
{"mode": "OnDemand"}or{"mode": "Dedicated", "dedicated": {"node_type": ..., "scaling": ..., "manual": {"replicas": ..., "shards": ...}}}.deletion_protection (str | None) –
"enabled"to blockdelete()on this index until it’s set back to"disabled"(the default).tags (Mapping[str, str] | None) – Key-value tags to attach, e.g.
{"env": "prod"}, up to 20 pairs. PassNone(the default) to attach none.cmek_id (str | None) – ID of a customer-managed encryption key to encrypt the index with.
timeout (int | None) – How long to wait, in seconds, for the index to become ready before returning.
None(default) waits indefinitely;-1returns immediately without waiting.spec (Any) –
Deprecated. A
ServerlessSpec,PodSpec,ByocSpec, or the equivalent dict, translated intodeployment=(andread_capacity=when the spec carries one). Mutually exclusive withdeployment=. Usecreate_for_model()forIntegratedSpec.Deprecated since version 10.0: Pass
deployment=directly instead.dimension (int | None) –
Deprecated. Dense vector width for the legacy path, translated into a single-field
schema=. Required when creating a dense index this way.Deprecated since version 10.0: Declare a named field in
schema=instead.metric (Metric | str | None) –
Deprecated. Similarity metric for the legacy dense path —
"cosine"(default),"euclidean", or"dotproduct".Deprecated since version 10.0: Set
metricinside theschema=field declaration instead.vector_type (VectorType | str | None) –
Deprecated.
"dense"(default) or"sparse", for the legacy path.Deprecated since version 10.0: Declare a named
dense_vector/sparse_vectorfield inschema=instead.legacy_kwargs (Any)
- Returns:
IndexModeldescribing the created index — ready, unlesstimeout=-1was passed.- Raises:
PineconeValueError – If neither
schema=nordimension=is given, or mutually exclusive arguments (schema=with a legacy vector kwarg, ordeployment=withspec=) are combined.PineconeTypeError – If an unsupported legacy keyword (e.g.
pods=) orspec=IntegratedSpec(...)is passed.IndexInitFailedError – If the index fails to initialize.
PineconeTimeoutError – If the index isn’t ready before timeout elapses.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> pc.indexes.create( ... name="movie-recommendations", ... schema={"fields": {"embedding": { ... "type": "dense_vector", "dimension": 1536, "metric": "cosine"}}}, ... )
- create_backup(index_name, *, name=None, description=None)[source]¶
Create a backup of an index.
Index-scoped shortcut for
Pinecone.backups.create()— pass the same arguments either way.Added in version 10.0: Graduated from
pc.preview.indexes.create_backup, now returning the single top-levelBackupModel.- Parameters:
- Returns:
BackupModeldescribing the new backup.statusis typically"Initializing"right after creation; polldescribe_backup()until it reads"Ready"before restoring from it.- Raises:
PineconeValueError – If index_name is empty.
NotFoundError – If the index does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> backup = pc.indexes.create_backup("my-index", name="nightly") >>> backup.status 'Initializing'
- create_for_model(*, name, cloud, region, embed, deletion_protection=None, tags=None, schema=None, read_capacity=None, timeout=None)[source]¶
Create a serverless index with an integrated embedding model.
Pinecone embeds text written to the mapped field automatically at upsert time and embeds queries at read time using the same model. In the returned index, the embedding configuration surfaces as a
semantic_textfield inschema, named after thefield_maptext entry.- Parameters:
name (str) – Required name for the index (1-45 characters,
^[a-z0-9]([a-z0-9-]*[a-z0-9])?$).cloud (str) – Public cloud provider —
"aws","gcp", or"azure".region (str) – Cloud region (e.g.
"us-east-1").embed (Mapping[str, Any] | Any) – Embedding configuration. A dict (or
EmbedConfig/IndexEmbed) with requiredmodelandfield_map(e.g.{"text": "chunk_text"}) and optionalmetric,dimension,read_parameters,write_parameters. The model cannot be changed after creation.deletion_protection (str | None) –
"enabled"or"disabled".tags (Mapping[str, str] | None) – Optional key-value tags (same limits as
create()).schema (dict[str, Any] | None) – Optional metadata schema dict for filterable metadata fields, e.g.
{"fields": {"genre": {"filterable": True}}}. A bare field map is wrapped in{"fields": ...}.read_capacity (dict[str, Any] | None) – Optional read capacity dict (see
create()).timeout (int | None) – Readiness polling — same semantics as
create().
- Returns:
IndexModeldescribing the created index.- Raises:
PineconeValueError – If name, cloud, region, or embed fail client-side validation.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> pc.indexes.create_for_model( ... name="semantic-search", ... cloud="aws", ... region="us-east-1", ... embed={"model": "multilingual-e5-large", ... "field_map": {"text": "chunk_text"}}, ... )
- 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.
ForbiddenError – If deletion protection is enabled on the index.
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.
Caches the index’s host internally, so a later
Pinecone.index(name)call for the same name skips its own describe round trip.- Parameters:
name (str) – The name of the index to describe.
- Returns:
IndexModelwith name, host, schema, deployment, read_capacity, status, deletion_protection, 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'
- describe_backup(backup_id)[source]¶
Describe a backup by its ID.
Alias of
Pinecone.backups.describe(). Backups are identified independently of any index, so despite living onindexesthis takes a backup ID rather than an index name.Added in version 10.0: Graduated from
pc.preview.indexes.describe_backup.- Parameters:
backup_id (str) – The unique identifier of the backup to describe.
- Returns:
BackupModelwith the current state of the backup.- Raises:
PineconeValueError – If backup_id is empty.
NotFoundError – If the backup does not exist.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> backup = pc.indexes.describe_backup("bkp-123") >>> backup.status 'Ready'
- exists(name)[source]¶
Check whether a named index exists.
Calls
describe()internally and returnsFalseinstead of raising when the index isn’t found.Changed in version 10.0: An empty name now raises
PineconeValueErrorinstead of returningFalse.- Parameters:
name (str) – The name of the index to check.
- Returns:
True if the index exists, False otherwise.
- Raises:
PineconeValueError – If name is empty.
ApiError – If the API returns an error response other than a not-found error.
- Return type:
Examples
>>> pc.indexes.exists("my-index") True
- list(*, limit=None, pagination_token=None)[source]¶
List all indexes in the project.
The server currently returns every index in one page, so the returned
Paginatoryields once and stops. It still exposes the paginator interface for consistency with other list methods, and so a future page size increase or signature change isn’t needed if the server starts paginating.Changed in version 10.0: Returns a
Paginatorinstead of anIndexList. Iteration keeps working; replacepc.indexes.list().names()with[idx.name for idx in pc.indexes.list()].- Parameters:
- Returns:
PaginatoroverIndexModelinstances.- Raises:
PineconeValueError – If limit is zero or negative.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> for index in pc.indexes.list(): ... print(index.name)
- list_backups(index_name, *, limit=None, pagination_token=None, include_deleted=None)[source]¶
List the backups of one index.
Added in version 10.0: Graduated from
pc.preview.indexes.list_backups, and gained include_deleted. For the project-wide listing usePinecone.backups.list()with noindex_name.Important
NotFoundErrorhere does not necessarily mean index_name was never used. With include_deleted omitted orFalse, index_name must resolve to an active index: if every index that used the name has since been deleted, this raisesNotFoundErrorrather than returning an empty list. Retry withinclude_deleted=Trueto get those backups back; aNotFoundErrorthere means the name was never used in this project.- Parameters:
index_name (str) – Name of the index whose backups to list.
limit (int | None) – Maximum number of backups to yield across all pages. Must be a positive integer.
Noneyields all backups. It also sets the requested page size, but only on a request that carries no pagination token: every later page is sized by the token, which already encodes it.pagination_token (str | None) – Token to resume pagination from a previous call. limit still caps the total yield, but it is not sent alongside a token — see above.
include_deleted (bool | None) – When
True, include backups of every index that has ever used index_name, deleted ones included; those backups carry a non-Nonesource_index_deleted_at. WhenNone(the default) the parameter is omitted entirely and the server’s default (false) applies.
- Returns:
PaginatoroverBackupModelinstances. Iteration stops when the response carries no pagination envelope.- Raises:
PineconeValueError – If index_name is empty or limit is zero or negative.
NotFoundError – If index_name does not resolve to an active index — see above.
ApiError – If the API returns another error response.
- Return type:
Examples
>>> for backup in pc.indexes.list_backups("my-index"): ... print(backup.backup_id, backup.status)
>>> orphans = pc.indexes.list_backups( ... "my-index", include_deleted=True ... ) >>> [b.backup_id for b in orphans if b.source_index_deleted_at] ['bkp_oldidx']
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 pod-based index.
A collection is a static copy of an index’s vector data. Create one to preserve an index’s contents, then later pass its name as
source_collectionwhen creating a new index to restore the data. Only a pod-based index can be used as a source, and it must already be ready. The call returns as soon as creation starts — it does not wait for the collection to become ready.- Parameters:
- Returns:
A CollectionModel describing the created collection.
- Raises:
PineconeValueError – If name or source is empty, or name doesn’t meet the naming rules above.
NotFoundError – If source does not name an index in this project.
- Return type:
Examples
>>> col = pc.collections.create(name="my-collection", source="my-index") >>> col.status 'Initializing'
- delete(name)[source]¶
Delete a collection permanently.
- Parameters:
name (str) – Name of the collection to delete.
- Raises:
PineconeValueError – If name is empty.
NotFoundError – If the collection does not exist.
- Return type:
None
Examples
>>> pc.collections.delete("my-collection")
- describe(name)[source]¶
Get details about a collection.
- Parameters:
name (str) – Name of the collection to describe.
- Returns:
A CollectionModel with the collection’s name, status, size, dimension, vector_count, and environment.
- Raises:
PineconeValueError – If name is empty.
NotFoundError – If the collection does not exist.
- Return type:
Examples
>>> desc = pc.collections.describe("my-collection") >>> desc.size 1024
- list()[source]¶
List every collection in the project.
There’s no filtering, sorting, or pagination — all collections come back at once.
- Returns:
A CollectionList supporting iteration, len(), index access, and a names() convenience method.
- 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=None)[source]¶
Create a backup of an existing index.
A backup is a stored, point-in-time snapshot of an index’s data and schema. Restore one into a new index with
Pinecone.create_index_from_backup(). Only serverless and BYOC indexes can be backed up.- Parameters:
- Returns:
A
BackupModeldescribing the new backup. The call returns once the backup is initiated; check itsstatusviadescribe()to see when it’s ready.- Raises:
PineconeValueError – If index_name is empty.
ForbiddenError – If the organization’s plan does not include backups.
NotFoundError – If index_name does not resolve to an index in this project.
ApiError – If the API returns another error response, for example because index_name names a pod-based index.
- 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:
PineconeValueError – 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:
PineconeValueError – 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:
PineconeValueError – 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=None, pagination_token=None, include_deleted=None)[source]¶
List backups.
When index_name is given, lists backups of that index only. Otherwise lists every backup in the project.
Changed in version 10.0: Added include_deleted.
BackupModelnow carriessource_index_deleted_atinstead ofdimension/metric.Note
If every index that ever used index_name has since been deleted, listing without include_deleted raises
NotFoundErrorrather than returning an empty list. Passinclude_deleted=Trueto see backups of deleted indexes too.Because paging walks a live result set rather than a fixed snapshot, backups created or deleted between requests can shift later pages. De-duplicate by
backup_idrather than relying on page order, and stop oncepaginationisNone.- Parameters:
index_name (str | None) – Index name to scope the listing to, or
Nonefor every backup in the project.limit (int | None) – Maximum number of results per page. When
None, the parameter is omitted and the server applies its own default. Omitted too when pagination_token is given: the token already carries the page size it was minted with, and a different one sent alongside it would skip or repeat rows.pagination_token (str | None) – Offset token naming the next page, taken from
BackupList.pagination.next. Takes precedence over limit — see above.include_deleted (bool | None) – When
True, include backups of every index that has ever used index_name, deleted ones included. WhenNone(the default) the parameter is omitted entirely and the server’s default (false) applies. Only valid together with index_name.
- Returns:
A
BackupListsupporting iteration, len(), and index access.BackupList.paginationisNoneon the final page.- Raises:
PineconeValueError – If include_deleted is given without index_name.
NotFoundError – If index_name does not resolve to an active index and include_deleted is not
True.ApiError – If the API returns another 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)
Recover backups of an index that has since been deleted:
>>> orphaned = pc.backups.list( ... index_name="product-search", include_deleted=True ... ) >>> [b.backup_id for b in orphaned if b.source_index_deleted_at] ['bk-abc123']
BackupSchedules¶
- class pinecone.client.backup_schedules.BackupSchedules(http)[source]¶
Bases:
objectControl-plane operations for automatic, time-based backup schedules.
- Parameters:
http (HTTPClient) – HTTP client for making API requests.
Note
Backups are a plan entitlement. A project without it gets a
ForbiddenErrorrather than aNotFoundErrorfor a schedule that does not exist, and the SDK appends that clarification to the error while keeping the server’s own message as the prefix. On-demand backups are gated on the same entitlement, so they are not a fallback.Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") schedule = pc.backup_schedules.create( index_name="product-search", name="daily-compliance-backup", frequency="daily", retention_days=90, ) for run in pc.backup_schedules.iter_history(schedule_id=schedule.schedule_id): print(run.backup_id, run.status)
- create(*, index_name, name, frequency, retention_days)[source]¶
Create a time-based backup schedule for an index.
A backup schedule runs automatically at a fixed cadence, producing a backup of the index on each run. There is no cron support here — choose one of the three fixed cadences below.
Important
Keep the schedule name short. Each run names its backup
"{name}-{run timestamp}", and a long schedule name can push that derived name past the length limit backup names allow.- Parameters:
index_name (str) – Name of the index to attach the schedule to.
name (str) – Name for the schedule. Backups it produces are named
"{name}-{run timestamp}"— see the length note above.frequency (str) – Cadence for the schedule:
"daily","weekly", or"monthly".retention_days (int) – Number of days to retain each backup this schedule produces. Must be at least 1.
- Returns:
A
BackupScheduleModeldescribing the new schedule. It is created enabled, sonext_scheduled_runis already populated.- Raises:
PineconeValueError – If index_name or name is empty, if frequency is not a supported cadence, or if retention_days is less than 1.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the index does not exist.
ConflictError – If the index already has an enabled schedule — only one per index is allowed, so disable or delete the existing one first.
ApiError – If the API returns another error response, such as when scheduling is requested for a pod-based index, which does not support it.
- Return type:
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> schedule = pc.backup_schedules.create( ... index_name="product-search", ... name="daily-compliance-backup", ... frequency="daily", ... retention_days=90, ... ) >>> schedule.frequency 'daily'
- delete(*, schedule_id)[source]¶
Permanently delete a backup schedule.
Backups the schedule already produced are not deleted; they age out on their own retention window. Deleting the schedule only stops future runs.
Important
This is not safe to retry blindly. A successful delete raises nothing, and a second attempt on the same
schedule_idraisesNotFoundError– so a retry after a dropped response is indistinguishable from deleting something that was never there. Treat aNotFoundErrorfollowing a delete attempt as success.- Parameters:
schedule_id (str) – The identifier of the schedule to delete.
- Returns:
None. The 204 carries no body, and none is parsed.- Raises:
PineconeValueError – If schedule_id is empty.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the schedule does not exist – see the retry caveat above.
ApiError – If the API returns another error response.
- Return type:
None
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key") >>> pc.backup_schedules.delete( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867" ... )
- describe(*, schedule_id)[source]¶
Get detailed information about a backup schedule.
- Parameters:
schedule_id (str) – The identifier of the schedule to describe. This is the
schedule_idfromcreate()orlist(), not the index name.- Returns:
A
BackupScheduleModelwith the schedule’s current configuration.- Raises:
PineconeValueError – If schedule_id is empty.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the schedule 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") >>> schedule = pc.backup_schedules.describe( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867" ... ) >>> schedule.enabled True
- get(*, schedule_id)[source]¶
Get detailed information about a schedule (alias for
describe()).- Parameters:
schedule_id (str) – The identifier of the schedule.
- Returns:
A
BackupScheduleModelwith the schedule’s current configuration.- Raises:
PineconeValueError – If schedule_id is empty.
NotFoundError – If the schedule 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") >>> schedule = pc.backup_schedules.get( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867" ... ) >>> schedule.frequency 'daily'
- history(*, schedule_id, limit=None, pagination_token=None)[source]¶
List one page of the backups produced by a schedule.
Rows describe backup snapshots, not the schedule, and a row appears as soon as a run is planned – so the listing mixes runs that have already completed with ones that have not started.
Note
This returns a single page. A daily schedule with a 90-day retention window has many more rows than one page holds, so prefer
iter_history()unless you are managing pagination yourself.- Parameters:
schedule_id (str) – The identifier of the schedule whose history to list.
limit (int | None) – Maximum results per page. Defaults to the server’s page size when
None. Ignored when a pagination token is given, since the token already carries the page size it was created with.pagination_token (str | None) – Token naming the next page, taken from the previous page’s
pagination.next. Takes precedence over limit — see above.
- Returns:
A
BackupScheduleHistoryListsupporting iteration,len(), and index access.BackupScheduleHistoryList.paginationisNoneon the final page.- Raises:
PineconeValueError – If schedule_id is empty or limit is zero or negative.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the schedule 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") >>> runs = pc.backup_schedules.history( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867" ... ) >>> [r.backup_id for r in runs.scheduled()] ['b2c3d4e5-f6a7-8901-bcde-f12345678901']
- iter_history(*, schedule_id, limit=None, pagination_token=None)[source]¶
Iterate every backup a schedule has produced, fetching pages on demand.
The auto-paginating twin of
history(). Iteration stops when a response carries no pagination envelope or anullone.- Parameters:
- Returns:
A
PaginatoroverBackupScheduleHistoryIteminstances.- Raises:
PineconeValueError – If schedule_id is empty or limit is zero or negative. Raised as soon as you call this method, before the first page is fetched.
ForbiddenError – If the project’s plan does not include scheduled backups. Raised while iterating, when a page is fetched.
NotFoundError – If the schedule 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") >>> for run in pc.backup_schedules.iter_history( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867" ... ): ... print(run.backup_id, run.status, run.scheduled_execution_at)
- iter_schedules(*, index_name, limit=None, pagination_token=None)[source]¶
Iterate every backup schedule on an index, fetching pages on demand.
The auto-paginating twin of
list(). Iteration stops when a response carries no pagination envelope or anullone.- Parameters:
- Returns:
A
PaginatoroverBackupScheduleModelinstances.- Raises:
PineconeValueError – If index_name is empty or limit is zero or negative. Raised as soon as you call this method, before the first page is fetched.
ForbiddenError – If the project’s plan does not include scheduled backups. Raised while iterating, when a page is fetched.
NotFoundError – If the index 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") >>> for s in pc.backup_schedules.iter_schedules( ... index_name="my-index" ... ): ... print(s.schedule_id, s.frequency, s.enabled)
- list(*, index_name, limit=None, pagination_token=None)[source]¶
List one page of an index’s backup schedules.
Schedules are always listed per index; there is no project-wide schedule listing. Disabled schedules are included, so a listing can hold several rows even though at most one may be enabled.
Note
This returns a single page. Use
iter_schedules()to walk every page instead of managing the token yourself.- Parameters:
index_name (str) – Name of the index whose schedules to list.
limit (int | None) – Maximum results per page. Defaults to the server’s page size when
None. Ignored when a pagination token is given, since the token already carries the page size it was created with.pagination_token (str | None) – Token naming the next page, taken from the previous page’s
pagination.next. Takes precedence over limit — see above.
- Returns:
A
BackupScheduleListsupporting iteration,len(), and index access.BackupScheduleList.paginationisNoneon the final page.- Raises:
PineconeValueError – If index_name is empty or limit is zero or negative.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the index 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") >>> schedules = pc.backup_schedules.list(index_name="my-index") >>> schedules.names() ['daily-compliance-backup'] >>> [s.schedule_id for s in schedules.enabled_schedules()] ['e88f7273-42aa-47e9-af73-593827136867']
- update(*, schedule_id, frequency=None, retention_days=None, enabled=None)[source]¶
Update a backup schedule’s cadence, retention, or enabled state.
Only the arguments you pass are sent, so omitted fields are left unchanged rather than reset. The schedule’s
nameand its index cannot be changed – the API exposes no field for either.Warning
Passing
enabled=Trueon a disabled schedule immediately enqueues a backup run and recomputesnext_scheduled_runfrom the moment of the update rather than resuming the old slot, so a disable/re-enable cycle shifts the cadence rather than pausing it. Only one schedule per index can be enabled, so re-enabling raisesConflictErrorif another one already is. On an already-enabled schedule,enabled=Trueenqueues nothing.- Parameters:
schedule_id (str) – The identifier of the schedule to update.
frequency (str | None) – New cadence, one of
"daily","weekly","monthly".Noneleaves it unchanged.retention_days (int | None) – New retention window in days, at least 1.
Noneleaves it unchanged. Changing it also re-times the pending deletion of backups this schedule has already produced.enabled (bool | None) –
Falseto disable (clearingnext_scheduled_run),Trueto re-enable – see the warning above.Noneleaves it unchanged.
- Returns:
A
BackupScheduleModelwith the updated configuration. Afterenabled=Falseitsnext_scheduled_runisNone.- Raises:
PineconeValueError – If schedule_id is empty, if frequency is set to an unsupported cadence, or if retention_days is set to less than 1.
ForbiddenError – If the project’s plan does not include scheduled backups.
NotFoundError – If the schedule does not exist.
ConflictError – If
enabled=Trueand another schedule on the same index is already enabled.ApiError – If the API returns another error response.
- Return type:
Note
Calling this with none of frequency, retention_days, or enabled set is a no-op: it returns the schedule unchanged.
Examples
>>> from pinecone import Pinecone >>> pc = Pinecone(api_key="your-api-key")
Pause a schedule without losing its configuration:
>>> paused = pc.backup_schedules.update( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867", enabled=False ... ) >>> paused.next_scheduled_run is None True
Move to a weekly cadence with a shorter retention window:
>>> pc.backup_schedules.update( ... schedule_id="e88f7273-42aa-47e9-af73-593827136867", ... frequency="weekly", ... retention_days=30, ... )
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.statusis one of"Pending","Completed","Failed", or"Cancelled". There is no in-progress state: a restore that is actively running reports"Pending", so do not poll for a"Running"-style value.percent_completeis100oncestatusis"Completed"andNoneat every other point — it reports completion, not progress, and cannot be used to draw a progress bar.completed_atis populated on the same condition.- Raises:
PineconeValueError – If job_id is empty.
NotFoundError – If the API answers
404— which is not the same as “the restore job does not exist”; see the warning below.ApiError – If the API returns another error response.
- Return type:
Warning
A ``404`` from this endpoint cannot be trusted to mean “no such restore job”. Every failure to read the restore-job store, an outage included, is answered with a
404, soNotFoundErrorhere means “could not produce this job”, not “this job does not exist”. Any retry policy or control flow keyed on a404fromdescribeis therefore unsafe: giving up, deleting local state, or reporting the job as gone can each be the wrong call on what was really a transient store failure. Treat it as possibly transient unless you have independent evidence the id is bad.A restore job whose target index has been deleted also answers
404, and the message it carries is not the one a genuinely missing job produces — so do not match on the message text either. Such a job is dropped fromlist()entirely rather than reported. Tracked in pinecone-io/python-sdk-internal#250.Examples
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") job = pc.restore_jobs.describe(job_id="rj-restore-20240115") print(job.status)
- list(*, limit=None, pagination_token=None)[source]¶
List one page of the project’s restore jobs.
Pagination is offset-based, not cursor-based: the token names a position in the result set rather than a stable cursor. This returns a single page and does not auto-fetch:
RestoreJobListcarries apaginationtoken but never follows it, so iterating the return value sees at most one page. Drive the token yourself to walk the rest — see Examples.- Parameters:
limit (int | None) – Maximum number of results per page. When
None, the parameter is omitted and the server applies its own default. Omitted too when pagination_token is given: the token already carries the page size it was minted with, and a different one sent alongside it would skip or repeat rows.pagination_token (str | None) – Offset token naming the next page, taken from
RestoreJobList.pagination.next. A malformed or truncated token is rejected with400(ApiError) rather than restarting the listing.
- Returns:
A
RestoreJobListsupporting iteration, len(), and index access. Itspaginationattribute isNoneon the final page.- Raises:
ApiError – If the API returns an error response.
- Return type:
Warning
This listing can silently drop restore jobs, stop paginating early, and repeat rows across pages. The token stream can end while restore jobs remain, and successive pages can overlap, so pages are neither exhaustive nor disjoint. A restore job whose target index has been deleted is dropped from the listing entirely.
What that means for you: treat the result as a best-effort sample rather than an exhaustive inventory, never conclude a restore job does not exist from its absence here, and de-duplicate by
restore_job_idwhile walking pages. The SDK offers no workaround on purpose — the token stream itself ends early, so no client-side code can recover pages the server never points at. Tracked in pinecone-io/python-sdk-internal#250.Examples
Walk every page the server will hand out:
from pinecone import Pinecone pc = Pinecone(api_key="your-api-key") page = pc.restore_jobs.list(limit=100) jobs = list(page) while page.pagination and page.pagination.next: page = pc.restore_jobs.list(pagination_token=page.pagination.next) jobs.extend(page) for job in jobs: print(job.restore_job_id, job.status, job.percent_complete)
When one page is all you want:
page = pc.restore_jobs.list(limit=5) print(len(page))
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.
A convenience enum rather than an exhaustive list:
modelis also accepted as a plain string, so a model added after this SDK release can still be used. Calllist_models()for the models currently available.- Llama_Text_Embed_V2 = 'llama-text-embed-v2'¶
- Multilingual_E5_Large = 'multilingual-e5-large'¶
- Pinecone_Sparse_English_V0 = 'pinecone-sparse-english-v0'¶
- Pinecone_Sparse_Multilingual_V0 = 'pinecone-sparse-multilingual-v0'¶
- class RerankModel(value)¶
-
Known reranking models.
Like
EmbedModel, a convenience enum rather than an exhaustive list.Note
Pinecone_Rerank_V0is deprecated and most projects can no longer use it: a request naming it is rejected with a permission error whose message points to a current model. Prefer another member of this enum.- 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 | Sequence[str] | Sequence[Mapping[str, Any]]) – Text inputs. A single string is automatically wrapped. Any Sequence type (list, tuple, etc.) of strings or Mappings is accepted.
parameters (Mapping[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.
NotFoundError – If model is not available to this project — either no such model exists, or the project is not authorized to use it. The error does not distinguish the two cases.
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") >>> 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:
model (str) – The model name to look up, e.g.
"multilingual-e5-large". Calllist_models()to see the names currently available.kwargs (str)
- Returns:
A
ModelInfowith full model details.- Raises:
PineconeValueError – If model is empty.
NotFoundError – If no model with that name exists.
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 (Sequence[str] | Sequence[Mapping[str, Any]]) – Documents to rank. Strings are auto-wrapped as
{"text": ...}. Any Sequence type (list, tuple, etc.) is accepted.rank_fields (Sequence[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 (Mapping[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, or top_n is less than 1.
PineconeTypeError – If documents has an invalid type.
NotFoundError – If model does not name a model the API serves. A typo in the model name surfaces here, so check this before assuming the request body was at fault.
ForbiddenError – If the project is not authorized to use model, including when model has been deprecated.
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") >>> 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
Note
The model that serves a request is not always the model named in it — Pinecone may substitute a different one.
result.modelreports the model that actually served the request, so read it there rather than assuming it echoes model.
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, timeout=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. Roles are case-sensitive"user"or"assistant"and content must be non-blank — seeMessage. Neither is checked client-side.model (str) – Name of the large language model to use. Defaults to
"gpt-4o". The models the2026-07API documents for this endpoint are"gpt-4o","gpt-4.1","gpt-5","o4-mini","claude-sonnet-4-5", and"gemini-2.5-pro". The removed aliases"claude-3-5-sonnet"and"claude-3-7-sonnet"are still accepted but deprecated — the backend silently remaps them to"claude-sonnet-4-5", so migrate to that name. Not validated client-side; the API rejects an unrecognized name.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.timeout (float | None) – Per-call HTTP timeout in seconds, overriding the client-level default. On a streaming request this bounds the gap between chunks rather than the whole response (see below).
- 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, for example if the assistant has no processed files yet.
- Return type:
Note
On a streaming request, the timeout applies to the gap between chunks rather than the whole response, and the default is raised so a model that thinks for a while isn’t mistaken for a dead connection. Pass timeout to change it. A stream that exceeds its timeout raises
PineconeTimeoutErrorpartway through iteration, after earlier chunks have already been yielded.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, timeout=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.- 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. Roles are case-sensitive"user"or"assistant"and content must be non-blank — seeMessage. Neither is checked client-side.model (str) – Name of the large language model to use. Defaults to
"gpt-4o". The models the2026-07API documents for this endpoint are"gpt-4o","gpt-4.1","o4-mini","claude-sonnet-4-5", and"gemini-2.5-pro"— the same listchat()accepts, minus"gpt-5", which the spec documents only on the Pinecone-native chat endpoint. The removed aliases"claude-3-5-sonnet"and"claude-3-7-sonnet"are still accepted but deprecated — the backend silently remaps them to"claude-sonnet-4-5", so migrate to that name. Not validated client-side; the API rejects an unrecognized name.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.timeout (float | None) – Per-call HTTP timeout in seconds, overriding the client-level default. On a streaming request this bounds the gap between chunks rather than the whole response (see below).
- Returns:
ChatCompletionResponsefor non-streaming requests, or aChatCompletionStreamfor streaming requests.- Raises:
ApiError – If the API returns an error response, for example if the assistant has no processed files yet.
- Return type:
Note
On a streaming request, the timeout applies to the gap between chunks rather than the whole response, and the default is raised so a model that pauses for longer while reasoning isn’t mistaken for a dead connection. Pass timeout to widen it further. A stream that exceeds its timeout raises
PineconeTimeoutErrorpartway through iteration, after earlier chunks have already been yielded.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]¶
Release the HTTP connections held by this namespace.
Call this when you’re done using
pc.assistantsto free pooled connections, including any opened for individual assistants.- 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 a conversation history, without generating a chat response. Provide exactly one of query or messages.
- 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. An empty string is treated as not provided.
messages (Sequence[Message | Mapping[str, str]] | None) – Conversation messages to use for context retrieval. Mutually exclusive with query. An empty list is treated as not provided. Dicts are converted to
Messageobjects. Roles are case-sensitive"user"or"assistant"and content must be non-blank — seeMessage.filter (dict[str, Any] | None) – Metadata filter restricting which documents contribute context. Omitted from the request when
None.top_k (int | None) – Maximum number of context snippets to return. Omitted from the request when
None, in which case the API applies its own default.snippet_size (int | None) – Maximum snippet size in tokens. Omitted from the request when
None, in which case the API applies its own default.multimodal (bool | None) – Whether to include image-related context snippets. Omitted from the request when
None.include_binary_content (bool | None) – Whether image snippets include base64 image data. Only meaningful when multimodal is
True. Omitted from the request whenNone.
- Returns:
ContextResponsecontaining the matching context snippets.- Raises:
PineconeValueError – If both or neither of query and messages are provided, or if top_k or snippet_size is negative.
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', environment=None, timeout=None, **kwargs)[source]¶
Create a new Pinecone assistant.
A Pinecone assistant is a managed conversational AI service that answers questions grounded in documents you upload to it. This method creates the assistant and, by default, waits until it reaches
"Ready"status before returning.- Parameters:
name (str) – Name for the new assistant, e.g.
"docs-assistant". Must be unique within the project.instructions (str | None) – Guidance the assistant applies to every response, e.g.
"Always cite the source document.". Maximum 16 KB.metadata (dict[str, Any] | None) – Optional metadata to attach to the assistant, e.g.
{"team": "docs"}.region (str) – Region to deploy the assistant in,
"us"or"eu". Defaults to"us". EU availability depends on your plan.environment (str | None) – Advanced override for select internal Pinecone deployments. Most users should leave this unset.
timeout (float | None) – Seconds to wait for the assistant to become ready. Use
None(default) to poll indefinitely,-1to return immediately without polling, or a non-negative value to poll with a 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, such as reaching your project’s assistant limit.
- 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.
By default, waits until the assistant is confirmed gone before returning.
If the assistant enters a terminal failure state while being deleted, waiting stops with
PineconeErrorinstead of polling indefinitely for a state that will never arrive.- 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:
PineconeError – If the assistant enters a terminal failure state (
"Failed","InitializationFailed") while being deleted.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.
Deletion can finish immediately or run as a pending operation, depending on the file’s state. When it is pending, this method polls until it finishes, unless you pass
timeout=-1.- 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 deletion to finish. Use
None(default) to poll indefinitely. Use-1to return as soon as the request is accepted — the file may still exist when this returns. Use a positive value to poll with a deadline. RaisesPineconeTimeoutErrorif the deletion is not done before the deadline.
- Returns:
None- Raises:
NotFoundError – If file_id does not name a file on this assistant. Deleting an id that is already gone raises rather than returning silently.
PineconeError – If the deletion operation reports failure.
PineconeTimeoutError – If the deletion has not finished 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:
NotFoundError – If the assistant does not exist.
ApiError – If the API returns another error response.
- 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:
Note
Unlike
list_files(), this applies no age filter: a"ProcessingFailed"file whosecreated_onis more than 7 days old is still returned here after it has dropped out of that listing.Examples
>>> file = pc.assistants.describe_file( ... assistant_name="my-assistant", ... file_id="file-abc123", ... ) >>> file.status 'Available'
- describe_operation(*, assistant_name, operation_id)[source]¶
Get the current status of a long-running assistant operation.
upload_file()anddelete_file()poll their own operation for you by default. Reach for this method when you called one of them withtimeout=-1and want to check on it later — for example, to find the file a fire-and-forget upload created, viaOperationModel.file_id.- Parameters:
assistant_name (str) – Name of the assistant that owns the operation.
operation_id (str) – Identifier of the operation to describe, as returned by
upload_file(),delete_file(), orlist_operations().
- Returns:
OperationModelwithstatus,operation_type,file_id,percent_complete,created_at,completed_on,ingestion_unitsanderror.statusis"Processing","Completed"or"Failed". Readerroronly whenstatusis"Failed": a retried operation keeps the previous attempt’s text, so a non-Noneerroris not by itself evidence of failure.- Raises:
NotFoundError – If the assistant or the operation does not exist. A finished operation stays describable until it ages out of the API’s retention window, and 404s from then on.
ApiError – If the API returns an error response.
- Return type:
Examples
>>> operation = pc.assistants.describe_operation( ... assistant_name="my-assistant", ... operation_id="op-1234-abcd-5678", ... ) >>> operation.status 'Processing' >>> operation.percent_complete 42
- 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. This endpoint requires a paid plan.
- 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 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:
NotFoundError – If the assistant does not exist.
ApiError – If the API returns an error response.
- Return type:
Note
A
"ProcessingFailed"file drops out of this listing once itscreated_onis more than 7 days old. It is not gone — it stays retrievable by id throughdescribe_file().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, page_size=None, pagination_token=None, filter=None, **kwargs)[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:
assistant_name (str) – Name of the assistant whose files to list.
page_size (int | None) – Maximum number of files in this page, sent as the
limitquery parameter. Only sent when explicitly provided; omitted, the API chooses the page size. A value outside the range the API accepts comes back as anApiErrornaming the bound it broke.pagination_token (str | None) – Token from a previous response to fetch the next page.
filter (dict[str, Any] | None) – Optional metadata filter expression. Serialized to a JSON string before being sent to the API.
kwargs (Any)
- Returns:
ListFilesResponsewith afileslist and an optionalnextcontinuation token.- Raises:
NotFoundError – If the assistant does not exist.
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_operations(*, assistant_name, operation_type=None, status=None, limit=None, pagination_token=None)[source]¶
List an assistant’s operations with lazy pagination.
Covers operations that are still in progress as well as ones that finished — both successes and failures — until they age out of the API’s retention window.
- Parameters:
assistant_name (str) – Name of the assistant whose operations to list.
operation_type (str | None) – Restrict the listing to one kind of operation. One of
"upload_file","upsert_file","update_file_metadata"or"delete_file".status (str | None) – Restrict the listing to one status. One of
"Processing","Completed"or"Failed"(case-sensitive).limit (int | None) – Maximum number of operations to yield across all pages.
None(default) yields all of them.pagination_token (str | None) – Token to resume pagination from a previous call.
- Returns:
PaginatoroverOperationModelobjects. Supportsforloops,.to_list(),.pages(), andlimit.- Raises:
PineconeValueError – If operation_type or status is not one of the values above.
NotFoundError – If the assistant does not exist.
ApiError – If the API returns an error response.
- Return type:
Examples
for op in pc.assistants.list_operations(assistant_name="my-assistant"): print(op.operation_id, op.status, op.percent_complete) pending = pc.assistants.list_operations( assistant_name="my-assistant", operation_type="upload_file", status="Processing", ).to_list()
- list_operations_page(*, assistant_name, operation_type=None, status=None, page_size=None, pagination_token=None)[source]¶
List one page of an assistant’s operations 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:
assistant_name (str) – Name of the assistant whose operations to list.
operation_type (str | None) – Restrict the listing to one kind of operation. One of
"upload_file","upsert_file","update_file_metadata"or"delete_file".status (str | None) – Restrict the listing to one status. One of
"Processing","Completed"or"Failed"(case-sensitive).page_size (int | None) – Maximum number of operations in this page, sent as the
limitquery parameter. Only sent when explicitly provided; omitted, the API chooses the page size. A value outside the range the API accepts comes back as anApiErrornaming the bound it broke.pagination_token (str | None) – Token from a previous response to fetch the next page.
- Returns:
ListOperationsResponsewith anoperationslist and an optionalnextcontinuation token.- Raises:
PineconeValueError – If operation_type or status is not one of the values above.
NotFoundError – If the assistant does not exist.
ApiError – If the API returns an error response.
- Return type:
Examples
page = pc.assistants.list_operations_page( assistant_name="my-assistant", status="Failed", page_size=10, ) for op in page.operations: print(op.operation_id, op.error) token = page.next
- 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:
page_size (int | None) – Maximum number of assistants per page. Only sent when explicitly provided; omitted, the API chooses the page size. A value outside the range the API accepts comes back as an
ApiErrornaming the bound it broke.pagination_token (str | None) – Token from a previous response to fetch the next page.
kwargs (Any)
- 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. At least one of instructions and metadata must be given.
Nonemeans “leave this field alone” — it is omitted from the patch body rather than sent as an explicit null, and the server has no way to clear a field from a null. To clear, send the empty value:instructions=""ormetadata={}.- Parameters:
name (str) – The name of the assistant to update.
instructions (str | None) – New instructions for the assistant. Pass an empty string to clear existing instructions.
metadata (dict[str, Any] | None) – New metadata dictionary. Fully replaces any existing metadata rather than merging. Pass an empty dict to clear existing metadata.
kwargs (Any)
- Returns:
AssistantModeldescribing the updated assistant.- Raises:
PineconeValueError – If neither instructions nor metadata is provided.
NotFoundError – If the assistant does not exist.
ApiError – If the API returns another error response.
- 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 waits until processing finishes before returning.
- 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. Requires file_name.
file_name (str | None) – Filename to associate with file_stream. Required when file_stream is used, and must include a supported extension (
.txt,.pdf,.json,.md, or.docx), since the extension determines how the file is processed. Ignored when file_path is given, since its basename already supplies the extension.metadata (dict[str, Any] | None) – Optional metadata to attach to the file, e.g.
{"department": "research"}. At most 16 KB once encoded.multimodal (bool | None) – Whether to enable multimodal processing for PDFs.
file_id (str | None) – Optional identifier for the uploaded file. When given, any existing file with that id is replaced. Otherwise the server assigns one.
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:
AssistantFileModeldescribing the uploaded file, once processing completes.- Raises:
PineconeValueError – If both or neither of file_path and file_stream are provided, if file_path does not exist, or if file_stream is used without a file_name carrying a file extension.
PineconeTimeoutError – If processing does not complete before timeout.
PineconeError – If processing fails.
- Return type:
Examples
>>> file = pc.assistants.upload_file( ... assistant_name="research-assistant", ... file_path="/data/report.pdf", ... ) >>> file.status 'Available'
>>> file = pc.assistants.upload_file( ... assistant_name="research-assistant", ... file_stream=io.BytesIO(pdf_bytes), ... file_name="report.pdf", ... )