Create a client authenticated with a project API key.
Optionaloptions: PineconeConfiguration
Client configuration. Omit to read PINECONE_API_KEY and the optional
PINECONE_CONTROLLER_HOST from the environment. An explicit configuration must include apiKey.
Errors.PineconeConfigurationError if the API key is missing.
Errors.PineconeEnvironmentVarsNotSupportedError if options are omitted and the runtime cannot read environment variables; pass an explicit configuration instead.
Create and manage assistants.
Create and restore index backups.
Manage recurring index backups.
Create and manage collections of pod-based index data.
Create, configure, and manage indexes.
Generate embeddings, rerank documents, and discover inference models.
Inspect the progress of index restores.
Target an assistant for file uploads, context retrieval, and chat.
Assistant name, with an optional host and additional request headers.
An Assistant scoped to the selected assistant.
const assistant = pc.assistant({ name: 'support-handbook' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'How do I return a damaged order?' }],
});
console.log(response.message?.content);
Pinecone.assistants to create an assistant or update its instructions.
Target an assistant using positional arguments.
Assistant name, such as support-handbook.
Optionalhost: string
Assistant host; omit to resolve it from the name.
An assistant client.
Use the options overload of Pinecone.assistant instead.
Target an assistant for file uploads, context retrieval, and chat.
Assistant name, with an optional host and additional request headers.
An Assistant scoped to the selected assistant.
const assistant = pc.assistant({ name: 'support-handbook' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'How do I return a damaged order?' }],
});
console.log(response.message?.content);
Pinecone.assistants to create an assistant or update its instructions.
Target an assistant using positional arguments.
Assistant name, such as support-handbook.
Optionalhost: string
Assistant host; omit to resolve it from the name.
An assistant client.
Use the options overload of Pinecone.assistant instead.
Update an index configuration.
Index name and the settings to change; omitted settings are unchanged.
The updated index details.
Use Indexes.configure with the index name as its first argument.
Creates an assistant.
Check its status with Assistants.describe before using it.
Assistant name, such as support-guide, and optional instructions, metadata, and region.
Assistant details, including its status and host.
Errors.PineconeArgumentError if options are missing or the region is unsupported.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = await pc.assistants.create({ name: 'support-guide' });
console.log(assistant.status);
Use Assistants.create instead.
Create a backup of an index.
Source indexName and optional backup name and description.
The backup details and creation status.
Use Backups.create with the index name as its first argument.
Starts creating a collection from a pod-based index.
The collection name and the source pod-based index name.
The collection metadata and status; check Collections.describe for readiness.
Errors.PineconeArgumentError when the collection name or source is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const collection = await pc.collections.create({
name: 'catalog-snapshot',
source: 'catalog-pod-index',
});
console.log(collection.status);
Use Collections.create instead.
Creates an index with searchable fields defined by a schema.
Creation returns before the index is ready unless waitUntilReady is true.
The index name and schema. Set waitUntilReady to wait before writing data.
The index configuration and status.
Errors.PineconeArgumentError when the index name or schema is missing.
Errors.PineconeConflictError when an index with this name already exists.
Errors.PineconeTimeoutError when the readiness timeout expires.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = await pc.indexes.create({
name: 'product-catalog',
schema: { fields: { description: { type: 'string', fullTextSearch: {} } } },
waitUntilReady: true,
});
console.log(index.name);
Indexes.createForModel to embed document text with an integrated model.
Use Indexes.create instead.
Creates an index with searchable fields defined by a schema.
Creation returns before the index is ready unless waitUntilReady is true.
The index name and schema. Set waitUntilReady to wait before writing data.
The index configuration and status, or undefined if suppressConflicts ignores an existing index.
Errors.PineconeArgumentError when the index name or schema is missing.
Errors.PineconeConflictError when an index with this name already exists.
Errors.PineconeTimeoutError when the readiness timeout expires.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = await pc.indexes.create({
name: 'product-catalog',
schema: { fields: { description: { type: 'string', fullTextSearch: {} } } },
waitUntilReady: true,
});
console.log(index.name);
Indexes.createForModel to embed document text with an integrated model.
Use Indexes.create instead.
Creates an index that embeds document text with an integrated model.
Creation returns before the index is ready unless waitUntilReady is true.
The index name, cloud, region, and embedding configuration. Use fieldMap to select your text field.
The index configuration and status.
Errors.PineconeArgumentError when required index or embedding settings are missing or the metric is invalid.
Errors.PineconeConflictError when an index with this name already exists.
Errors.PineconeTimeoutError when the readiness timeout expires.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = await pc.indexes.createForModel({
name: 'product-catalog',
cloud: 'aws',
region: 'us-east-1',
embed: {
model: 'multilingual-e5-large',
fieldMap: { text: 'description' },
},
waitUntilReady: true,
});
console.log(index.name);
Indexes.create to define vector or full-text search fields yourself.
Use Indexes.createForModel instead.
Creates an index that embeds document text with an integrated model.
Creation returns before the index is ready unless waitUntilReady is true.
The index name, cloud, region, and embedding configuration. Use fieldMap to select your text field.
The index configuration and status, or undefined if suppressConflicts ignores an existing index.
Errors.PineconeArgumentError when required index or embedding settings are missing or the metric is invalid.
Errors.PineconeConflictError when an index with this name already exists.
Errors.PineconeTimeoutError when the readiness timeout expires.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = await pc.indexes.createForModel({
name: 'product-catalog',
cloud: 'aws',
region: 'us-east-1',
embed: {
model: 'multilingual-e5-large',
fieldMap: { text: 'description' },
},
waitUntilReady: true,
});
console.log(index.name);
Indexes.create to define vector or full-text search fields yourself.
Use Indexes.createForModel instead.
Start restoring a backup into a new index.
Source backupId, destination index name, and optional index settings.
The restore job ID and destination index details.
Use Backups.createIndex with the backup ID as its first argument.
Deletes an assistant by name.
The name of the assistant to delete, such as support-guide.
Resolves when the deletion request completes.
Errors.PineconeArgumentError if assistantName is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
await pc.assistants.delete('support-guide');
Use Assistants.delete instead.
Deletes a backup.
Deletion is asynchronous; the backup may remain visible briefly after this call returns.
The ID of the backup to delete.
Resolves when the deletion request is accepted.
Errors.PineconeArgumentError when the backup ID is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
await pc.backups.delete('11450b9f-96e5-47e5-9186-03f346b1f385');
Use Backups.delete instead.
Deletes a collection.
The collection name, such as catalog-snapshot.
Resolves when the deletion request succeeds.
Errors.PineconeArgumentError when the collection name is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
await pc.collections.delete('catalog-snapshot');
Use Collections.delete instead.
Deletes an index and its data.
Disable deletion protection first. The index may still be terminating when this call returns.
The index name, such as product-catalog.
Resolves when the deletion request is accepted.
Errors.PineconeArgumentError when the index name is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
await pc.indexes.delete('product-catalog');
Use Indexes.delete instead.
Gets assistant configuration and readiness status.
The name of the assistant, such as support-guide.
Assistant details, including its status and host.
Errors.PineconeArgumentError if assistantName is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = await pc.assistants.describe('support-guide');
console.log(assistant.status);
Assistants.list to discover assistants.
Use Assistants.describe instead.
Retrieves the configuration and status of a backup.
The ID returned when the backup was created or listed.
The backup ID, source index, and current status.
Errors.PineconeArgumentError when the backup ID is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const backup = await pc.backups.describe('11450b9f-96e5-47e5-9186-03f346b1f385');
console.log(backup.status);
Use Backups.describe instead.
Retrieves the metadata and status of a collection.
The collection name, such as catalog-snapshot.
The collection status, size, dimension, and record count.
Errors.PineconeArgumentError when the collection name is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const collection = await pc.collections.describe('catalog-snapshot');
console.log(collection.status);
Use Collections.describe instead.
Retrieves the configuration, schema, and readiness of an index.
The index name, such as product-catalog.
The index configuration, host, schema, and current status.
Errors.PineconeArgumentError when the index name is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = await pc.indexes.describe('product-catalog');
console.log(index.status.ready);
Use Indexes.describe instead.
Retrieves the current progress of a restore job.
The restoreJobId returned by Backups.createIndex.
The restore status, target index, and completion percentage.
Errors.PineconeArgumentError when the restore job ID is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const job = await pc.restoreJobs.describe('4d4c8693-10fd-4204-a57b-1e3e626fca07');
console.log(job.status, job.percentComplete);
Backups.createIndex to start a restore.
Use RestoreJobs.describe instead.
Evaluates a generated answer against a ground truth answer.
The question, generated answer, and reference answer in groundTruth.
Correctness, completeness, and alignment metrics, with reasoning and usage.
Errors.PineconeArgumentError if options are missing or an answer or question is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const result = await pc.assistants.evaluate({
question: 'Where can I start a return?',
answer: 'Start a return from your order history.',
groundTruth: 'Customers can start returns from their order history.',
});
console.log(result.metrics);
Use Assistants.evaluate instead.
Return the configuration used by this client.
The configuration object, including the API key. Treat it as sensitive.
Target an index for data operations.
Supplying a host avoids the index-name lookup. A name alone is resolved when needed.
Metadata fields associated with vector records.
Index name or host, and optionally a namespace and additional request headers.
An Index scoped to the selected index and namespace.
type ProductMetadata = { title: string; category: string };
const model = await pc.indexes.describe('product-catalog');
const index = pc.index<ProductMetadata>({ host: model.host });
const result = await index.fetch({ ids: ['trail-shoe-42'] });
console.log(result.records['trail-shoe-42']?.metadata?.title);
Pinecone.indexes to create or configure an index.
Target an index using positional arguments.
Metadata fields associated with vector records.
Index name, such as product-catalog.
OptionalindexHostUrl: string
Index host; omit to resolve it from the name.
OptionaladditionalHeaders: HTTPHeaders
Additional headers to include in index requests.
An index client using the default namespace.
Use the options overload of Pinecone.index instead.
Target an index for data operations.
Supplying a host avoids the index-name lookup. A name alone is resolved when needed.
Metadata fields associated with vector records.
Index name or host, and optionally a namespace and additional request headers.
An Index scoped to the selected index and namespace.
type ProductMetadata = { title: string; category: string };
const model = await pc.indexes.describe('product-catalog');
const index = pc.index<ProductMetadata>({ host: model.host });
const result = await index.fetch({ ids: ['trail-shoe-42'] });
console.log(result.records['trail-shoe-42']?.metadata?.title);
Pinecone.indexes to create or configure an index.
Target an index using positional arguments.
Metadata fields associated with vector records.
Index name, such as product-catalog.
OptionalindexHostUrl: string
Index host; omit to resolve it from the name.
OptionaladditionalHeaders: HTTPHeaders
Additional headers to include in index requests.
An index client using the default namespace.
Use the options overload of Pinecone.index instead.
Lists assistants in the project.
Assistant details in assistants.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const result = await pc.assistants.list();
console.log(result.assistants);
Assistants.describe for details of one assistant.
Use Assistants.list instead.
List one page of backups for an index or the project.
Pagination settings and optional indexName. Omit to list project backups.
includeDeleted applies only when indexName is supplied.
Backups and a pagination token for the next page, when present.
Use Backups.listByIndex for one index or Backups.list for the project.
Lists all collections in the project.
The collections and their current status.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const result = await pc.collections.list();
console.log(result.collections);
Use Collections.list instead.
Lists all indexes in the project.
The indexes and their configuration, schema, and readiness status.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const result = await pc.indexes.list();
console.log(result.indexes);
Use Indexes.list instead.
Lists one page of restore jobs in the project.
Optionaloptions: ListRestoreJobsOptions
Page size and continuation token. Omit to fetch the first page with the default size.
Jobs in data; pass pagination.next as paginationToken to fetch the next page.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const page = await pc.restoreJobs.list({ limit: 10 });
console.log(page.data, page.pagination?.next);
Use RestoreJobs.list instead.
Updates assistant instructions or metadata.
Omitted fields are left unchanged; an empty instructions string is not applied.
The assistant name and the instructions or metadata to update.
The updated assistant name, instructions, and metadata.
Errors.PineconeArgumentError if options or the assistant name are missing.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const result = await pc.assistants.update({
name: 'support-guide',
instructions: 'Answer using the uploaded support policies and cite your sources.',
});
console.log(result.instructions);
Use Assistants.update instead.
A client for managing Pinecone resources and working with indexed data. Create a client with your project API key, or set
PINECONE_API_KEYand callnew Pinecone(). Use index for data operations and indexes to create and manage indexes.Example
See