Pinecone TypeScript SDK - v9.0.0
    Preparing search index...

    Class Pinecone

    A client for managing Pinecone resources and working with indexed data. Create a client with your project API key, or set PINECONE_API_KEY and call new Pinecone(). Use index for data operations and indexes to create and manage indexes.

    import { Pinecone } from '@pinecone-database/pinecone';

    const pc = new Pinecone();
    const index = pc.index({ name: 'product-catalog', namespace: 'products-en' });
    Index
    assistants: Assistants

    Create and manage assistants.

    const assistants = await pc.assistants.list();
    
    backups: Backups

    Create and restore index backups.

    const backups = await pc.backups.list();
    
    backupSchedules: BackupSchedules

    Manage recurring index backups.

    const schedules = await pc.backupSchedules.list('product-catalog');
    
    collections: Collections

    Create and manage collections of pod-based index data.

    const collections = await pc.collections.list();
    
    indexes: Indexes

    Create, configure, and manage indexes.

    const list = await pc.indexes.list();
    const indexModel = await pc.indexes.describe('product-catalog');
    inference: Inference

    Generate embeddings, rerank documents, and discover inference models.

    restoreJobs: RestoreJobs

    Inspect the progress of index restores.

    const jobs = await pc.restoreJobs.list();
    
    • Target an assistant for file uploads, context retrieval, and chat.

      Parameters

      • options: AssistantOptions

        Assistant name, with an optional host and additional request headers.

      Returns Assistant

      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.

      Parameters

      • name: string

        Assistant name, such as support-handbook.

      • Optionalhost: string

        Assistant host; omit to resolve it from the name.

      Returns Assistant

      An assistant client.

      const assistant = pc.assistant({ name: 'support-handbook' });
      

      Use the options overload of Pinecone.assistant instead.

    • Target an assistant for file uploads, context retrieval, and chat.

      Parameters

      • options: AssistantOptions

        Assistant name, with an optional host and additional request headers.

      Returns Assistant

      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.

      Parameters

      • name: string

        Assistant name, such as support-handbook.

      • Optionalhost: string

        Assistant host; omit to resolve it from the name.

      Returns Assistant

      An assistant client.

      const assistant = pc.assistant({ name: 'support-handbook' });
      

      Use the options overload of Pinecone.assistant instead.

    • Creates an index with searchable fields defined by a schema.

      Creation returns before the index is ready unless waitUntilReady is true.

      Parameters

      • options: CreateIndexOptions & { suppressConflicts?: false }

        The index name and schema. Set waitUntilReady to wait before writing data.

      Returns Promise<IndexModel>

      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.

      Parameters

      • options: CreateIndexOptions

        The index name and schema. Set waitUntilReady to wait before writing data.

      Returns Promise<void | IndexModel>

      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.

      Parameters

      • options: CreateIndexForModelOptions & { suppressConflicts?: false }

        The index name, cloud, region, and embedding configuration. Use fieldMap to select your text field.

      Returns Promise<IndexModel>

      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.

      Parameters

      • options: CreateIndexForModelOptions

        The index name, cloud, region, and embedding configuration. Use fieldMap to select your text field.

      Returns Promise<void | IndexModel>

      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.

    • Deletes an assistant by name.

      Parameters

      • assistantName: string

        The name of the assistant to delete, such as support-guide.

      Returns Promise<void>

      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.

      Parameters

      • backupId: string

        The ID of the backup to delete.

      Returns Promise<void>

      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.

      Parameters

      • collectionName: string

        The collection name, such as catalog-snapshot.

      Returns Promise<void>

      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.

      Parameters

      • indexName: string

        The index name, such as product-catalog.

      Returns Promise<void>

      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.

      Parameters

      • assistantName: string

        The name of the assistant, such as support-guide.

      Returns Promise<AssistantModel>

      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.

      Parameters

      • backupId: string

        The ID returned when the backup was created or listed.

      Returns Promise<BackupModel>

      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.

      Parameters

      • collectionName: string

        The collection name, such as catalog-snapshot.

      Returns Promise<CollectionModel>

      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.

      Parameters

      • indexName: string

        The index name, such as product-catalog.

      Returns Promise<IndexModel>

      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.

      Parameters

      Returns Promise<RestoreJobModel>

      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.

      Parameters

      • options: EvaluateOptions

        The question, generated answer, and reference answer in groundTruth.

      Returns Promise<AlignmentResponse>

      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.

    • Target an index for data operations.

      Supplying a host avoids the index-name lookup. A name alone is resolved when needed.

      Type Parameters

      Parameters

      • options: IndexOptions

        Index name or host, and optionally a namespace and additional request headers.

      Returns Index<T>

      An Index scoped to the selected index and namespace.

      const index = pc.index({ name: 'product-catalog', namespace: 'products-en' });
      
      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.

      Type Parameters

      Parameters

      • indexName: string

        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.

      Returns Index<T>

      An index client using the default namespace.

      const index = pc.index({ name: 'product-catalog' });
      

      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.

      Type Parameters

      Parameters

      • options: IndexOptions

        Index name or host, and optionally a namespace and additional request headers.

      Returns Index<T>

      An Index scoped to the selected index and namespace.

      const index = pc.index({ name: 'product-catalog', namespace: 'products-en' });
      
      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.

      Type Parameters

      Parameters

      • indexName: string

        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.

      Returns Index<T>

      An index client using the default namespace.

      const index = pc.index({ name: 'product-catalog' });
      

      Use the options overload of Pinecone.index instead.

    • Lists assistants in the project.

      Returns Promise<AssistantList>

      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.

      Parameters

      • options: ListBackupsOptions = {}

        Pagination settings and optional indexName. Omit to list project backups. includeDeleted applies only when indexName is supplied.

      Returns Promise<BackupList>

      Backups and a pagination token for the next page, when present.

      const page = await pc.backups.listByIndex('product-catalog');
      console.log(page.data);

      Use Backups.listByIndex for one index or Backups.list for the project.

    • Lists all collections in the project.

      Returns Promise<CollectionList>

      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.

      Returns Promise<IndexList>

      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.

      Parameters

      • Optionaloptions: ListRestoreJobsOptions

        Page size and continuation token. Omit to fetch the first page with the default size.

      Returns Promise<RestoreJobList>

      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.

      Parameters

      Returns Promise<UpdateAssistantResponse>

      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.