{"id":19797893,"url":"https://github.com/pinecone-io/pinecone-ts-client","last_synced_at":"2026-01-22T23:55:40.510Z","repository":{"id":65908857,"uuid":"581637435","full_name":"pinecone-io/pinecone-ts-client","owner":"pinecone-io","description":"The official TypeScript/Node client for the Pinecone vector database","archived":false,"fork":false,"pushed_at":"2025-05-07T23:21:03.000Z","size":2185,"stargazers_count":227,"open_issues_count":12,"forks_count":40,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-05-08T00:26:11.977Z","etag":null,"topics":["llm","pinecone","semantic-search","similarity-search","vector-database"],"latest_commit_sha":null,"homepage":"https://www.pinecone.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pinecone-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-23T19:47:24.000Z","updated_at":"2025-04-29T14:58:06.000Z","dependencies_parsed_at":"2023-12-14T19:54:59.799Z","dependency_job_id":"5ea73d94-cea3-437f-86b8-6914d9d73b21","html_url":"https://github.com/pinecone-io/pinecone-ts-client","commit_stats":{"total_commits":297,"total_committers":19,"mean_commits":"15.631578947368421","dds":0.7441077441077442,"last_synced_commit":"63bba87390b1d866ca18cfc824ad9256368b271a"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinecone-io%2Fpinecone-ts-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinecone-io%2Fpinecone-ts-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinecone-io%2Fpinecone-ts-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinecone-io%2Fpinecone-ts-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinecone-io","download_url":"https://codeload.github.com/pinecone-io/pinecone-ts-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253206154,"owners_count":21871164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llm","pinecone","semantic-search","similarity-search","vector-database"],"created_at":"2024-11-12T07:27:16.140Z","updated_at":"2026-01-22T23:55:40.503Z","avatar_url":"https://github.com/pinecone-io.png","language":"TypeScript","funding_links":[],"categories":["AI Databases \u0026 Memory"],"sub_categories":["Tier 3: Complex Projects (Platforms \u0026 Orchestration)"],"readme":"# Pinecone Node.js SDK \u0026middot; ![License](https://img.shields.io/github/license/pinecone-io/pinecone-ts-client?color=orange) ![npm](https://img.shields.io/npm/v/%40pinecone-database%2Fpinecone?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40pinecone-database%2Fpinecone) ![npm](https://img.shields.io/npm/dw/%40pinecone-database/pinecone?style=flat\u0026color=blue\u0026link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40pinecone-database%2Fpinecone) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/pinecone-io/pinecone-ts-client/pr.yml?label=CI\u0026link=https%3A%2F%2Fgithub.com%2Fpinecone-io%2Fpinecone-ts-client%2Factions%2Fworkflows%2Fmerge.yml)\n\nThis is the official Node.js SDK for [Pinecone](https://www.pinecone.io), written in TypeScript.\n\n## Documentation\n\n- [**Reference Documentation**](https://sdk.pinecone.io/typescript/classes/Pinecone.html)\n- If you are upgrading from `v0.x`, check out the [**v1 Migration Guide**](https://github.com/pinecone-io/pinecone-ts-client/blob/main/v1-migration.md).\n- If you are upgrading from `v1.x`, check out the [**v2 Migration Guide**](https://github.com/pinecone-io/pinecone-ts-client/blob/main/v2-migration.md).\n\n### Example code\n\nThe snippets shown in this README are intended to be concise. For more realistic examples, explore these examples:\n\n- [Semantic search](https://github.com/pinecone-io/semantic-search-example)\n- [Article recommender](https://github.com/pinecone-io/recommender-example-typescript)\n- [Image search](https://github.com/pinecone-io/image-search-example)\n\n## Upgrading the SDK\n\n#### Upgrading from `2.x` to `3.x`\n\nThere is a breaking change involving the `configureIndex` operation in this update. The structure of the object passed\nwhen configuring an index has changed to include `deletionProtection`. The `podType` and `replicas` fields can now be updated through the `spec.pod` object. See [Configure pod-based indexes](#configure-pod-based-indexes) for an example of the code.\n\n#### Upgrading from older versions\n\n- **Upgrading to `2.x`** : There were many changes made in this release to support Pinecone's new Serverless index offering. The changes are covered in detail in the [**v2 Migration Guide**](https://github.com/pinecone-io/pinecone-ts-client/blob/main/v2-migration.md). Serverless indexes are only available in `2.x` release versions or greater.\n- **Upgrading to `1.x`** : This release officially moved the SDK out of beta, and there are a number of breaking changes that need to be addressed when upgrading from a `0.x` version. See the [**v1 Migration Guide**](https://github.com/pinecone-io/pinecone-ts-client/blob/main/v1-migration.md) for details.\n\n## Prerequisites\n\nThe Pinecone TypeScript SDK is compatible with TypeScript \u003e=4.1 and Node \u003e=18.x.\n\n## Installation\n\n```\nnpm install @pinecone-database/pinecone\n```\n\n## Productionizing\n\nThe Pinecone Typescript SDK is intended for **server-side use only**. Using the SDK within a browser context can **expose\nyour API key(s)**. If you have deployed the SDK to production in a browser, **please rotate your API keys.**\n\n## Usage\n\n### Initializing the client\n\nAn API key is required to initialize the client. It can be passed using an environment variable or in code through a configuration object. Get an API key in the [console](https://app.pinecone.io).\n\n#### Using environment variables\n\nThe environment variable used to configure the API key for the client is the following:\n\n```bash\nPINECONE_API_KEY=\"your_api_key\"\n```\n\n`PINECONE_API_KEY` is the only required variable. When this environment variable is set, the client constructor does not require any additional arguments.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\n\nconst pc = new Pinecone();\n```\n\n#### Using a configuration object\n\nIf you prefer to pass configuration in code, the constructor accepts a config object containing the `apiKey` value.\nThis is the object in which you would pass properties like `maxRetries` (defaults to `3`) for retryable operations\n(`upsert`, `update`, and `configureIndex`).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\n\nconst pc = new Pinecone({\n  apiKey: 'your_api_key',\n  maxRetries: 5,\n});\n```\n\n### Using a proxy server\n\nIf your network setup requires you to interact with Pinecone via a proxy, you can pass a custom `ProxyAgent` from\nthe [`undici` library](https://undici.nodejs.org/#/). Below is an example of how to\nconstruct an `undici` `ProxyAgent` that routes network traffic through a [`mitm` proxy server](https://mitmproxy.org/) while hitting Pinecone's `/indexes` endpoint.\n\n**Note:** The following strategy relies on Node's native `fetch` implementation, [released in Node v16 and\nstabilized in Node v21](https://nodejs.org/docs/latest/api/globals.html#fetch). If you are running Node versions\n18-21, you may experience issues stemming from the instability of the feature. There are currently no known issues\nrelated to proxying in Node v18+.\n\n```typescript\nimport {\n  Pinecone,\n  type PineconeConfiguration,\n} from '@pinecone-database/pinecone';\nimport { Dispatcher, ProxyAgent } from 'undici';\nimport * as fs from 'fs';\n\nconst cert = fs.readFileSync('path-to-your-mitm-proxy-cert-pem-file');\n\nconst client = new ProxyAgent({\n  uri: '\u003cyour proxy server URI\u003e',\n  requestTls: {\n    port: '\u003cyour proxy server port\u003e',\n    ca: cert,\n    host: '\u003cyour proxy server host\u003e',\n  },\n});\n\nconst customFetch = (\n  input: string | URL | Request,\n  init: RequestInit | undefined\n) =\u003e {\n  return fetch(input, {\n    ...init,\n    dispatcher: client as Dispatcher,\n    keepalive: true,  # optional\n  });\n};\n\nconst config: PineconeConfiguration = {\n  apiKey:\n    '\u003cyour Pinecone API key, available in your dashboard at app.pinecone.io\u003e',\n  fetchApi: customFetch,\n};\n\nconst pc = new Pinecone(config);\n\nconst indexes = async () =\u003e {\n  return await pc.listIndexes();\n};\n\nindexes().then((response) =\u003e {\n  console.log('My indexes: ', response);\n});\n```\n\n## Indexes\n\n### Create Index\n\n#### Create a serverless index with minimal configuration\n\nAt a minimum, to create a serverless index you must specify a `name`, `dimension`, and `spec`. The `dimension`\nindicates the size of the vectors you intend to store in the index. For example, if your intention was to store and\nquery embeddings (vectors) generated with OpenAI's [textembedding-ada-002](https://platform.openai.com/docs/guides/embeddings/second-generation-models) model, you would need to create an index with dimension `1536` to match the output of that model. By default, serverless indexes will have a `vectorType` of `dense`.\n\nThe `spec` configures how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. For more information on serverless and regional availability, see [Understanding indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#serverless-indexes).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'sample-index',\n  dimension: 1536,\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'us-west-2',\n    },\n  },\n  tags: { team: 'data-science' },\n});\n```\n\n#### Create a sparse serverless index\n\nYou can also use `vectorType` to create `sparse` serverless indexes. These indexes enable direct indexing and retrieval of sparse vectors, supporting traditional methods like BM25 and learned sparse models such as [pinecone-sparse-english-v0](https://docs.pinecone.io/models/pinecone-sparse-english-v0). A `sparse` index must have a distance `metric` of `dotproduct` and does not require a specified dimension. If no\nmetric is provided with a `vectorType` of `sparse`, it will default to `dotproduct`:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'sample-index',\n  metric: 'dotproduct',\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'us-west-2',\n    },\n  },\n  tags: { team: 'data-science' },\n  vectorType: 'sparse',\n});\n```\n\n#### Create an integrated index\n\nIntegrated inference requires a serverless index configured for a specific embedding model. You can either create a new index for a model or configure an existing index for a model. To create an index that accepts source text and converts it to vectors automatically using an embedding model hosted by Pinecone, use the `createIndexForModel` method:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndexForModel({\n  name: 'integrated-index',\n  cloud: 'aws',\n  region: 'us-east-1',\n  embed: {\n    model: 'multilingual-e5-large',\n    fieldMap: { text: 'chunk_text' },\n  },\n  waitUntilReady: true,\n});\n```\n\n#### Create a pod-based index with optional configurations\n\nTo create a pod-based index, you define `pod` in the `spec` object which contains the `environment` where the index should be hosted, and the `podType` and `pods` size to use. Many optional configuration fields allow greater control over hardware resources and availability. To learn more about the purpose of these fields, see [Understanding indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes) and [Scale pod-based indexes](https://docs.pinecone.io/guides/indexes/scale-pod-based-indexes).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'sample-index-2',\n  dimension: 1536,\n  metric: 'dotproduct',\n  spec: {\n    pod: {\n      environment: 'us-east4-gcp',\n      pods: 2,\n      podType: 'p1.x2',\n      metadataConfig: {\n        indexed: ['product_type'],\n      },\n    },\n    tags: { team: 'data-science' },\n  },\n\n  // This option tells the client not to throw if the index already exists.\n  suppressConflicts: true,\n\n  // This option tells the client not to resolve the promise until the\n  // index is ready.\n  waitUntilReady: true,\n});\n```\n\n#### Checking the status of a newly created index\n\nThe `createIndex` method issues a create request to the API that returns quickly, but the resulting index is\nnot immediately ready for upserting, querying, or performing other data operations. You can use the\n`describeIndex` method to find out the status of an index and see whether it is ready for use.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.describeIndex('serverless-index');\n// {\n//    name: 'serverless-index',\n//    dimension: 1536,\n//    metric: 'cosine',\n//    host: 'serverless-index-4zo0ijk.svc.us-west2-aws.pinecone.io',\n//    deletionProtection: 'disabled',\n//    spec: {\n//       serverless: {\n//          cloud: 'aws',\n//          region: 'us-west-2'\n//       }\n//    },\n//    status: {\n//       ready: false,\n//       state: 'Initializing'\n//    }\n// }\n```\n\n#### Waiting until the index is ready\n\nIf you pass the `waitUntilReady` option, the client will handle polling for status updates on a newly created index. The promise returned by `createIndex` will not be resolved until the index status indicates it is ready to handle data operations. This can be especially useful for integration testing, where index creation in a setup step will be immediately followed by data operations.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'serverless-index',\n  dimension: 1536,\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'us-west-2',\n    },\n  },\n  waitUntilReady: true,\n});\n```\n\n#### Create a pod-based index from a Pinecone collection\n\n\u003e ℹ️ **Note**\n\u003e\n\u003e Serverless and starter indexes do not support collections.\n\nAs you use Pinecone for more things, you may wish to explore different index configurations with the same vector data. [Collections](https://docs.pinecone.io/guides/indexes/understanding-collections) provide an easy way to do this. See other client methods for working with collections [here](https://github.com/pinecone-io/pinecone-ts-client#collections).\n\nGiven that you have an existing collection:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.describeCollection('product-description-embeddings');\n// {\n//   name: 'product-description-embeddings',\n//   size: 543427063,\n//   status: 'Ready',\n//   dimension: 2,\n//   vectorCount: 10001498,\n//   environment: 'us-east4-gcp'\n// }\n```\n\n**Note:** For pod-based indexes, you can specify a `sourceCollection` from which to create an index. The\ncollection must be in the same environment as the index.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'product-description-p1x1',\n  dimension: 256,\n  metric: 'cosine',\n  spec: {\n    pod: {\n      environment: 'us-east4-gcp',\n      pods: 1,\n      podType: 'p1.x1',\n      sourceCollection: 'product-description-embeddings',\n    },\n  },\n});\n```\n\nWhen the new index is ready, it should contain all the data that was in the collection, ready to be queried.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.index({ name: 'product-description-p2x2' }).describeIndexStats();\n// {\n//   namespaces: { '': { recordCount: 78000 } },\n//   dimension: 256,\n//   indexFullness: 0.9,\n//   totalRecordCount: 78000\n// }\n```\n\n#### Create or configure an index with deletion protection\n\nYou can configure both serverless and pod indexes with `deletionProtection`. Any index with this property set to `'enabled'` will be unable to be deleted. By default, `deletionProtection` will be set to `'disabled'` if not provided as a part of the `createIndex` request. To enable `deletionProtection` you can pass the value while calling `createIndex`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'deletion-protected-index',\n  dimension: 1536,\n  metric: 'cosine',\n  deletionProtection: 'enabled',\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'us-west-2',\n    },\n  },\n});\n```\n\nTo disable deletion protection, you can use the `configureIndex` operation.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.configureIndex('deletion-protected-index', {\n  deletionProtection: 'disabled',\n});\n```\n\n#### Create or configure an index with index tags\n\nYou can create or configure serverless and pod indexes with [tags](https://docs.pinecone.io/guides/indexes/tag-an-index).\nIndexes can hold an arbitrary number of tags outlining metadata\nyou would like attached to the index object itself, such as team ownership, project, or any other relevant information.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// Create index with tag\nawait pc.createIndex({\n  name: 'tag-index',\n  dimension: 1536,\n  metric: 'cosine',\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'us-west-2',\n    },\n  },\n  tags: { team: 'data-science' }, // index tag\n});\n\n// Configure index with a new tag\nawait pc.configureIndex('tag-index', {\n  tags: { project: 'recommendation' }, // new index tag\n});\n\n// Delete an existing tag\nawait pc.configureIndex('tag-index', {\n  tags: { project: '' }, // Pass an empty string to an existing key to delete a tag; this will delete the `project` tag\n});\n```\n\n### Describe Index\n\nYou can fetch the description of any index by name using `describeIndex`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.describeIndex('serverless-index');\n// {\n//    name: 'serverless-index',\n//    dimension: 1536,\n//    metric: 'cosine',\n//    host: 'serverless-index-4zo0ijk.svc.us-west2-aws.pinecone.io',\n//    deletionProtection: 'disabled',\n//    spec: {\n//       serverless: {\n//          cloud: 'aws',\n//          region: 'us-west-2'\n//       },\n//    },\n//    status: {\n//       ready: true,\n//       state: 'Ready'\n//    }\n// }\n```\n\n### Configure pod-based indexes\n\n\u003e ℹ️ **Note**\n\u003e\n\u003e This section applies to [pod-based indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#pod-based-indexes) only. With serverless indexes, you don't configure any compute or storage resources. Instead, serverless indexes scale automatically based on usage.\n\nYou can adjust the number of replicas or scale to a larger pod size (specified with `podType`). See [Scale pod-based indexes](https://docs.pinecone.io/guides/indexes/scale-pod-based-indexes). You cannot downgrade pod size or change the base pod type.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nawait pc.configureIndex('pod-index', {\n  spec: {\n    pod: {\n      replicas: 2,\n      podType: 'p1.x4',\n    },\n  },\n});\nconst config = await pc.describeIndex('pod-index');\n// {\n//    name: 'pod-index',\n//    dimension: 1536,\n//    metric: 'cosine',\n//    host: 'pod-index-4zo0ijk.svc.us-east1-gcp.pinecone.io',\n//    deletionProtection: 'disabled',\n//    spec: {\n//       pod: {\n//         environment: 'us-east1-gcp',\n//         replicas: 2,\n//         shards: 2,\n//         podType: 'p1.x4',\n//         pods: 4,\n//         metadataConfig: [Object],\n//         sourceCollection: undefined\n//       }\n//    },\n//    status: {\n//       ready: true,\n//       state: 'ScalingUpPodSize'\n//    }\n// }\n```\n\n### Delete Index\n\nIndexes are deleted by name.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.deleteIndex('sample-index');\n```\n\n### List Indexes\n\nThe `listIndexes` command returns an object with an array of index models under `indexes`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.listIndexes();\n// {\n//   indexes: [\n//     {\n//       name: 'serverless-index',\n//       dimension: 1536,\n//       metric: 'cosine',\n//       host: 'serverless-index-4zo0ijk.svc.us-west2-aws.pinecone.io',\n//       deletionProtection: 'disabled',\n//       spec: {\n//         serverless: {\n//           cloud: 'aws',\n//           region: 'us-west-2',\n//         },\n//       },\n//       status: {\n//         ready: true,\n//         state: 'Ready',\n//       },\n//     },\n//     {\n//       name: 'pod-index',\n//       dimension: 1536,\n//       metric: 'cosine',\n//       host: 'pod-index-4zo0ijk.svc.us-west2-aws.pinecone.io',\n//       deletionProtection: 'disabled',\n//       spec: {\n//         pod: {\n//           environment: 'us-west2-aws',\n//           replicas: 1,\n//           shards: 1,\n//           podType: 'p1.x1',\n//           pods: 1,\n//         },\n//       },\n//       status: {\n//         ready: true,\n//         state: 'Ready',\n//       },\n//     },\n//   ],\n// }\n```\n\n## Collections\n\n\u003e ℹ️ **Note**\n\u003e\n\u003e Serverless and starter indexes do not support collections.\n\nA collection is a static copy of a pod-based index that may be used to create backups, to create copies of indexes, or to perform experiments with different index configurations. To learn more about Pinecone collections, see [Understanding collections](https://docs.pinecone.io/guides/indexes/understanding-collections).\n\n### Create Collection\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createCollection({\n  name: 'collection-name',\n  source: 'index-name',\n});\n```\n\nThis API call should return quickly, but the creation of a collection can take from minutes to hours depending on the size of the source index and the index's configuration. Use `describeCollection` to check the status of a collection.\n\n### Delete Collection\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.deleteCollection('collection-name');\n```\n\nYou can use `listCollections` to confirm the deletion.\n\n### Describe Collection\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst describeCollection = await pc.describeCollection('collection3');\n// {\n//   name: 'collection3',\n//   size: 3126700,\n//   status: 'Ready',\n//   dimension: 3,\n//   vectorCount: 1234,\n//   environment: 'us-east1-gcp',\n// }\n```\n\n### List Collections\n\nThe `listCollections` command returns an object with an array of collection models under `collections`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst list = await pc.listCollections();\n// {\n//   collections: [\n//     {\n//       name: 'collection1',\n//       size: 3089687,\n//       status: 'Ready',\n//       dimension: 3,\n//       vectorCount: 17378,\n//       environment: 'us-west1-gcp',\n//     },\n//     {\n//       name: 'collection2',\n//       size: 208309,\n//       status: 'Ready',\n//       dimension: 3,\n//       vectorCount: 1000,\n//       environment: 'us-east4-gcp',\n//     },\n//   ];\n// }\n```\n\n## Backups\n\nA backup is a static copy of a serverless index that only consumes storage. It is a non-queryable representation of a set of records. You can create a backup of a serverless index, and you can create a new serverless index from a backup. You can optionally apply new `tags` and `deletionProtection` configurations to the index. You can read more about [backups here](https://docs.pinecone.io/guides/manage-data/backups-overview).\n\n### Create a backup\n\nYou can create a new backup from an existing index using the index name:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst backup = await pc.createBackup({\n  indexName: 'my-index',\n  name: 'my-index-backup-1',\n  description: 'weekly backup',\n});\nconsole.log(backup);\n// {\n//   backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//   sourceIndexName: 'my-index',\n//   sourceIndexId: 'b480770b-600d-4c4e-bf19-799c933ae2bf',\n//   name: 'my-index-backup-1',\n//   description: 'weekly backup',\n//   status: 'Initializing',\n//   cloud: 'aws',\n//   region: 'us-east-1',\n//   dimension: 1024,\n//   metric: 'cosine',\n//   recordCount: 500,\n//   namespaceCount: 4,\n//   sizeBytes: 78294,\n//   tags: {},\n//   createdAt: '2025-05-07T03:11:11.722238160Z'\n// }\n```\n\n### Create a new index from a backup\n\nYou can restore a serverless index by creating a new index from a backup. Optionally, you can provide\nnew `tags` or `deletionProtection` values when restoring an index. Creating an index from a backup intiates\na new restore job, which can be used to view the progress of the index restoration through `describeRestoreJob`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst response = await pc.createIndexFromBackup({\n  backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n  name: 'my-index-restore-1',\n});\nconsole.log(response);\n// {\n//   restoreJobId: '4d4c8693-10fd-4204-a57b-1e3e626fca07',\n//   indexId: 'deb7688b-9f21-4c16-8eb7-f0027abd27fe'\n// }\n```\n\n### Describe and list backups\n\nYou can use a `backupId` and the `describeBackup` method to describe a specific backup:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst backup = await pc.describeBackup('11450b9f-96e5-47e5-9186-03f346b1f385');\nconsole.log(backup);\n// {\n//   backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//   sourceIndexName: 'my-index',\n//   sourceIndexId: 'b480770b-600d-4c4e-bf19-799c933ae2bf',\n//   name: 'my-index-backup-1',\n//   description: 'weekly backup',\n//   status: 'Initializing',\n//   cloud: 'aws',\n//   region: 'us-east-1',\n//   dimension: 1024,\n//   metric: 'cosine',\n//   recordCount: 500,\n//   namespaceCount: 4,\n//   sizeBytes: 78294,\n//   tags: {},\n//   createdAt: '2025-05-07T03:11:11.722238160Z'\n// }\n```\n\n`listBackups` lists all the backups for a specific index, or your entire project. If an `indexName` is provided, only\nthe backups for that index will be listed.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// list backups for the entire project\nconst projectBackups = await pc.listBackups({ limit: 2 });\n// list backups for a specific index\nconst myIndexBackups = await pc.listBackups({\n  indexName: 'my-index',\n  limit: 2,\n});\nconsole.log(myIndexBackups);\n// {\n//   data: [\n//     {\n//       backupId: '6a00902c-d118-4ad3-931c-49328c26d558',\n//       sourceIndexName: 'my-index',\n//       sourceIndexId: '0888b4d9-0b7b-447e-a403-ab057ceee4d4',\n//       name: 'my-index-backup-2',\n//       description: undefined,\n//       status: 'Ready',\n//       cloud: 'aws',\n//       region: 'us-east-1',\n//       dimension: 5,\n//       metric: 'cosine',\n//       recordCount: 200,\n//       namespaceCount: 2,\n//       sizeBytes: 67284,\n//       tags: {},\n//       createdAt: '2025-05-07T18:34:13.626650Z'\n//     },\n//     {\n//       backupId: '2b362ea3-b7cf-4950-866f-0dff37ab781e',\n//       sourceIndexName: 'my-index',\n//       sourceIndexId: '0888b4d9-0b7b-447e-a403-ab057ceee4d4',\n//       name: 'my-index-backup-1',\n//       description: undefined,\n//       status: 'Ready',\n//       cloud: 'aws',\n//       region: 'us-east-1',\n//       dimension: 1024,\n//       metric: 'cosine',\n//       recordCount: 500,\n//       namespaceCount: 4,\n//       sizeBytes: 78294,\n//       tags: {},\n//       createdAt: '2025-05-07T18:33:59.888270Z'\n//     },\n//   ],\n//   pagination: undefined\n// }\n```\n\n### Describe and list restore jobs\n\nYou can use a `restoreJobId` and the `describeRestoreJob` method to describe a specific backup:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst restoreJob = await pc.describeRestoreJob(\n  '4d4c8693-10fd-4204-a57b-1e3e626fca07'\n);\nconsole.log(restoreJob);\n//     {\n//       restoreJobId: '4d4c8693-10fd-4204-a57b-1e3e626fca07',\n//       backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//       targetIndexName: 'my-index-restore-1',\n//       targetIndexId: 'deb7688b-9f21-4c16-8eb7-f0027abd27fe',\n//       status: 'Completed',\n//       createdAt: 2025-05-07T03:38:37.107Z,\n//       completedAt: 2025-05-07T03:40:23.687Z,\n//       percentComplete: 100\n//     }\n```\n\n`listRestoreJobs` lists all the restore jobs for your project.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst projectRestoreJobs = await pc.listRestoreJobs({ limit: 3 });\nconsole.log(projectRestoreJobs);\n// {\n//   data: [\n//     {\n//       restoreJobId: '4d4c8693-10fd-4204-a57b-1e3e626fca07',\n//       backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//       targetIndexName: 'my-index-restore-1',\n//       targetIndexId: 'deb7688b-9f21-4c16-8eb7-f0027abd27fe',\n//       status: 'Completed',\n//       createdAt: 2025-05-07T03:38:37.107Z,\n//       completedAt: 2025-05-07T03:40:23.687Z,\n//       percentComplete: 100\n//     },\n//     {\n//       restoreJobId: 'c60a62e0-63b9-452a-88af-31d89c56c988',\n//       backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//       targetIndexName: 'my-index-restore-2',\n//       targetIndexId: 'f2c9a846-799f-4b19-81a4-f3096b3d6114',\n//       status: 'Completed',\n//       createdAt: 2025-05-07T21:42:38.971Z,\n//       completedAt: 2025-05-07T21:43:11.782Z,\n//       percentComplete: 100\n//     },\n//     {\n//       restoreJobId: '792837b7-8001-47bf-9c11-1859826b9c10',\n//       backupId: '11450b9f-96e5-47e5-9186-03f346b1f385',\n//       targetIndexName: 'my-index-restore-3',\n//       targetIndexId: '620dda62-c999-4dd1-b083-6beb087b31e7',\n//       status: 'Pending',\n//       createdAt: 2025-05-07T21:48:39.580Z,\n//       completedAt: 2025-05-07T21:49:12.084Z,\n//       percentComplete: 45\n//     }\n//   ],\n//   pagination: undefined\n// }\n```\n\n### Delete backups\n\nYou can delete a backup using the backupId and `deleteBackup`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nawait pc.deleteBackup('6a00902c-d118-4ad3-931c-49328c26d558');\n```\n\n## Index operations\n\nPinecone indexes support operations for working with vector data using methods such as upsert, query, fetch, and delete.\n\n### Targeting an index\n\nTo perform data operations on an index, you target it using the `index` method. You can target an index by providing its `name`, its `host`, or both.\n\n#### Targeting by name\n\nWhen you provide only a name, the SDK will automatically call `describeIndex` to resolve the index host URL:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'test-index' });\n\n// Now perform index operations\nawait index.fetch(['1']);\n```\n\n#### Targeting by host\n\nYou can also provide options like a host URL override to bypass the SDK's default behavior of resolving your index host via the provided index name. You can find your index host in the [Pinecone console](https://app.pinecone.io), or by using the `describeIndex` or `listIndexes` operations.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ host: 'my-index-host-1532-svc.io' });\n\n// Now perform index operations against: https://my-index-host-1532-svc.io\nawait index.fetch(['1']);\n```\n\n### Targeting an index, with metadata typing\n\nIf you are storing metadata alongside your vector values, you can pass a type parameter to `index()` in order to get proper TypeScript typechecking.\n\n```typescript\nimport { Pinecone, PineconeRecord } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\ntype MovieMetadata = {\n    title: string,\n    runtime: number,\n    genre: 'comedy' | 'horror' | 'drama' | 'action'\n}\n\n// Specify a custom metadata type while targeting the index\nconst index = pc.index\u003cMovieMetadata\u003e('test-index');\n\n// Now you get type errors if upserting malformed metadata\nawait index.upsert([{\n        id: '1234',\n        values: [\n            .... // embedding values\n    ],\n    metadata: {\n    genre: 'Gone with the Wind',\n        runtime: 238,\n        genre: 'drama',\n        // @ts-expect-error because category property not in MovieMetadata\n        category: 'classic'\n}\n}])\n\nconst results = await index.query({\n    vector: [\n        ... // query embedding\n    ],\n    filter: { genre: { '$eq': 'drama' }}\n})\nconst movie = results.matches[0];\n\nif (movie.metadata) {\n    // Since we passed the MovieMetadata type parameter above,\n    // we can interact with metadata fields without having to\n    // do any typecasting.\n    const { title, runtime, genre } = movie.metadata;\n    console.log(`The best match in drama was ${title}`)\n}\n```\n\n### Targeting a namespace\n\nBy default, all data operations take place inside the default namespace of `''`. If you are working with other non-default namespaces, you can specify the namespace in the options object.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'test-index', namespace: 'ns1' });\n\n// Now perform index operations in the targeted index and namespace\nawait index.fetch(['1']);\n```\n\nSee [Use namespaces](https://docs.pinecone.io/guides/indexes/use-namespaces) for more information.\n\n### Managing namespaces\n\nThere are several operations for managing namespaces within an index. You can list the namespaces within an index, describe a specific namespace, or delete a namespace entirely.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'test-index' });\n\n// list all namespaces\nconst namespacesResp = await index.listNamespaces();\n\n// describe a namespace\nconst namespace = await index.describeNamespace('ns1');\n\n// delete a namespace (including all record data)\nawait index.deleteNamespace('ns1');\n```\n\n### Upsert vectors\n\nPinecone expects records inserted into indexes to have the following form:\n\n```typescript\ntype PineconeRecord = {\n  id: string;\n  values: Array\u003cnumber\u003e;\n  sparseValues?: Array\u003cnumber\u003e;\n  metadata?: object;\n};\n```\n\nTo upsert some vectors, you can use the client like so:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// Target an index\nconst index = pc.index({ name: 'sample-index' });\n\n// Prepare your data. The length of each array\n// of vector values must match the dimension of\n// the index where you plan to store them.\nconst vectors = [\n  {\n    id: '1',\n    values: [0.236, 0.971, 0.559],\n    sparseValues: { indices: [0, 1], values: [0.236, 0.34] }, // Optional; for hybrid search\n  },\n  {\n    id: '2',\n    values: [0.685, 0.111, 0.857],\n    sparseValues: { indices: [0, 1], values: [0.345, 0.98] }, // Optional; for hybrid search\n  },\n];\n\n// Upsert the data into your index\nawait index.upsert(vectors);\n```\n\n### Import vectors from object storage\n\nYou can now [import vectors en masse](https://docs.pinecone.io/guides/data/understanding-imports) from object\nstorage. `Import` is a long-running, asynchronous operation that imports large numbers of records into a Pinecone\nserverless index.\n\nIn order to import vectors from object storage, they must be stored in Parquet files and adhere to the necessary\n[file format](https://docs.pinecone.io/guides/data/understanding-imports#parquet-file-format). Your object storage\nmust also adhere to the necessary [directory structure](https://docs.pinecone.io/guides/data/understanding-imports#directory-structure).\n\nThe following example imports vectors from an Amazon S3 bucket into a Pinecone serverless index:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\n\nconst pc = new Pinecone();\nconst indexName = 'sample-index';\n\nawait pc.createIndex({\n  name: indexName,\n  dimension: 10,\n  spec: {\n    serverless: {\n      cloud: 'aws',\n      region: 'eu-west-1',\n    },\n  },\n});\n\nconst index = pc.index({ name: indexName });\n\nconst storageURI = 's3://my-bucket/my-directory/';\n\nawait index.startImport(storageURI, 'continue'); // \"Continue\" will avoid aborting the operation if errors are encountered.\n\n// {\n//   \"id\": \"import-id\"\n// }\n```\n\nYou can [start, cancel, and check the status](https://docs.pinecone.io/guides/data/import-data) of all or one import operation(s).\n\n**Notes:**\n\n- `Import` only works with Serverless indexes\n- `Import` is in [public preview](https://docs.pinecone.io/release-notes/feature-availability)\n- The only object storage provider currently supported is [Amazon S3](https://docs.pinecone.io/guides/operations/integrations/integrate-with-amazon-s3)\n- Vectors will take _at least 10 minutes_ to appear in your index upon completion of the import operation, since\n  this operation is optimized for very large workloads\n- See [limits](https://docs.pinecone.io/guides/data/understanding-imports#limits) for further information\n\n### Seeing index statistics\n\nWhen experimenting with data operations, it's sometimes helpful to know how many records/vectors are stored in each\nnamespace. In that case, target the index and use the `describeIndexStats()` command.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'example-index' });\n\nawait index.describeIndexStats();\n// {\n//   namespaces: {\n//     '': { recordCount: 10 }\n//     foo: { recordCount: 2000 },\n//     bar: { recordCount: 2000 }\n//   },\n//   dimension: 1536,\n//   indexFullness: 0,\n//   totalRecordCount: 4010\n// }\n```\n\n### Querying\n\n#### Querying with vector values\n\nThe query method accepts a large number of options. The dimension of the query vector must match the dimension of your index.\n\n```typescript\ntype QueryOptions = {\n  topK: number; // number of results desired\n  vector?: Array\u003cnumber\u003e; // must match dimension of index\n  sparseVector?: {\n    indices: Array\u003cinteger\u003e; // indices must fall within index dimension\n    values: Array\u003cnumber\u003e; // indices and values arrays must have same length\n  };\n  id?: string;\n  includeMetadata: boolean;\n  includeValues: boolean;\n};\n```\n\nFor example, to query by vector values you would pass the `vector` param in the options configuration. For brevity sake this example query vector is tiny (dimension 2), but in a more realistic use case this query vector would be an embedding outputted by a model. Look at the [Example code](#example-code) to see more realistic examples of how to use `query`.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index' });\n\nawait index.query({ topK: 3, vector: [0.22, 0.66] });\n// {\n//   matches: [\n//     {\n//       id: '556',\n//       score: 1.00000012,\n//       values: [],\n//       sparseValues: undefined,\n//       metadata: undefined\n//     },\n//     {\n//       id: '137',\n//       score: 1.00000012,\n//       values: [],\n//       sparseValues: undefined,\n//       metadata: undefined\n//     },\n//     {\n//       id: '129',\n//       score: 1.00000012,\n//       values: [],\n//       sparseValues: undefined,\n//       metadata: undefined\n//     }\n//   ],\n//   namespace: '',\n//   usage: {\n//     readUnits: 5\n//   }\n// }\n```\n\nYou include options to `includeMetadata: true` or `includeValues: true` if you need this information. By default,\nthese are not returned to keep the response payload small.\n\nRemember that data operations take place within the context of a `namespace`, so if you are working with namespaces and do not see expected results you should check that you are targeting the correct namespace with your query.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// Target the index and namespace\nconst index = pc.index({ name: 'my-index', namespace: 'my-namespace' });\n\nconst results = await index.query({ topK: 3, vector: [0.22, 0.66] });\n```\n\n#### Querying by record id\n\nYou can query using the vector values of an existing record in the index by passing a record ID. Please note that\nthe record with the specified ID [may be in this operation's response](https://docs.pinecone.io/troubleshooting/limitations-of-querying-by-id).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index' });\n\nconst results = await index.query({ topK: 10, id: '1' });\n```\n\n#### Hybrid search with sparse vectors\n\nIf you are working with [sparse-dense vectors](https://docs.pinecone.io/guides/data/understanding-hybrid-search#sparse-dense-workflow), you can add sparse vector values to perform a hybrid search.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nawait pc.createIndex({\n  name: 'hybrid-search-index',\n  metric: 'dotproduct', // Note: dot product is the only distance metric supported for hybrid search\n  dimension: 2,\n  spec: {\n    pod: {\n      environment: 'us-west4-gcp',\n      podType: 'p2.x1',\n    },\n  },\n  waitUntilReady: true,\n});\n\nconst index = pc.index({ name: 'hybrid-search-index' });\n\nconst hybridRecords = [\n  {\n    id: '1',\n    values: [0.236, 0.971], // dense vectors\n    sparseValues: { indices: [0, 1], values: [0.236, 0.34] }, // sparse vectors\n  },\n  {\n    id: '2',\n    values: [0.685, 0.111],\n    sparseValues: { indices: [0, 1], values: [0.887, 0.243] },\n  },\n];\n\nawait index.upsert(hybridRecords);\n\nconst query = 'What is the most popular red dress?';\n// ... send query to dense vector embedding model and save those values in `denseQueryVector`\n// ... send query to sparse vector embedding model and save those values in `sparseQueryVector`\nconst denseQueryVector = [0.236, 0.971];\nconst sparseQueryVector = { indices: [0, 1], values: [0.0, 0.34] };\n\n// Execute a hybrid search\nawait index.query({\n  topK: 3,\n  vector: denseQueryVector,\n  sparseVector: sparseQueryVector,\n});\n```\n\n### Update a record\n\nYou may want to update vector `values`, `sparseValues`, or `metadata`. Specify the id and the attribute value you want to update.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'imdb-movies' });\n\nawait index.update({\n  id: '18593',\n  metadata: { genre: 'romance' },\n});\n```\n\n### List records\n\nThe `listPaginated` method can be used to list record IDs matching a particular ID prefix in a paginated format. With\n[clever assignment\nof record ids](https://docs.pinecone.io/guides/data/manage-rag-documents#use-id-prefixes), this can be used to help model hierarchical relationships between different records such as when there are embeddings for multiple chunks or fragments related to the same document.\n\nNotes:\n\n- When you do not specify a `prefix`, the default prefix is an empty string, which returns all vector IDs\n  in your index\n- There is a hard limit of `100` vector IDs if no `limit` is specified. Consequently, if there are fewer than `100`\n  vector IDs that match a given `prefix` in your index, and you do not specify a `limit`, your `paginationToken`\n  will be `undefined`\n\nThe following example shows how to fetch both pages of vector IDs for vectors whose IDs contain the prefix `doc1#`,\nassuming a `limit` of `3` and `doc1` document being [chunked](https://www.pinecone.io/learn/chunking-strategies/) into `4` vectors.\n\n```typescript\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index', namespace: 'my-namespace' });\n\n// Fetch the 1st 3 vector IDs matching prefix 'doc1#'\nconst results = await index.listPaginated({ limit: 3, prefix: 'doc1#' });\nconsole.log(results);\n// {\n//   vectors: [\n//     { id: 'doc1#01' }\n//     { id: 'doc1#02' }\n//     { id: 'doc1#03' }\n//     ...\n//   ],\n//   pagination: {\n//     next: 'eyJza2lwX3Bhc3QiOiJwcmVUZXN0LS04MCIsInByZWZpeCI6InByZVRlc3QifQ=='\n//   },\n//   namespace: 'my-namespace',\n//   usage: { readUnits: 1 }\n// }\n\n// Fetch the final vector ID matching prefix 'doc1#' using the paginationToken returned by the previous call\nconst nextResults = await index.listPaginated({\n  prefix: 'doc1#',\n  paginationToken: results.pagination?.next,\n});\nconsole.log(nextResults);\n// {\n//   vectors: [\n//     { id: 'doc1#04' }\n//   ],\n//   pagination: undefined,\n//   namespace: 'my-namespace',\n//   usage: { readUnits: 1 }\n// }\n```\n\n### Fetch records by ID(s)\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index' });\n\nconst fetchResult = await index.fetch(['id-1', 'id-2']);\n```\n\n### Delete records\n\nFor convenience there are several delete-related methods. You can verify the results of a delete operation by trying to `fetch()` a record or looking at the index summary with `describeIndexStats()`\n\n#### Delete one\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index' });\n\nawait index.deleteOne('id-to-delete');\n```\n\n#### Delete many by ID\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index' });\n\nawait index.deleteMany(['id-1', 'id-2', 'id-3']);\n```\n\n### Delete many by metadata filter\n\n**Note:** deletion by metadata filter only applies to pod-based indexes.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'albums-database' });\n\nawait index.deleteMany({ genre: 'rock' });\n```\n\n#### Delete all records in a namespace\n\n\u003e ℹ️ **NOTE**\n\u003e\n\u003e Indexes in the [gcp-starter environment](https://docs.pinecone.io/guides/indexes/convert-a-gcp-starter-index-to-serverless) do not support namespaces.\n\nTo nuke everything in the targeted namespace, use the `deleteAll` method.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst index = pc.index({ name: 'my-index', namespace: 'foo-namespace' });\n\nawait index.deleteAll();\n```\n\nIf you do not specify a namespace, the records in the default namespace `''` will be deleted.\n\n## Inference\n\nUse embedding and \u0026 reranking models hosted by Pinecone. Learn more about Inference in the [docs](https://docs.pinecone.io/guides/inference/understanding-inference).\n\n### Models\n\nTo see available models you can use the `getModel` and `listModels` methods on the `Inference` class:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\n\nconst client = new Pinecone({ apiKey: '\u003cYour API key from app.pinecone.io\u003e' });\n\nconst models = await pc.inference.listModels();\nconsole.log(models);\n// {\n//   models: [\n//     {\n//       model: 'llama-text-embed-v2',\n//       shortDescription: 'A high performance dense embedding model optimized for multilingual and cross-lingual text question-answering retrieval with support for long documents (up to 2048 tokens) and dynamic embedding size (Matryoshka Embeddings).',\n//       type: 'embed',\n//       vectorType: 'dense',\n//       defaultDimension: 1024,\n//       modality: 'text',\n//       maxSequenceLength: 2048,\n//       maxBatchSize: 96,\n//       providerName: 'NVIDIA',\n//       supportedDimensions: [Array],\n//       supportedMetrics: [Array],\n//       supportedParameters: [Array]\n//     },\n//     ...\n//     {\n//       model: 'pinecone-rerank-v0',\n//       shortDescription: 'A state of the art reranking model that out-performs competitors on widely accepted benchmarks. It can handle chunks up to 512 tokens (1-2 paragraphs)',\n//       type: 'rerank',\n//       vectorType: undefined,\n//       defaultDimension: undefined,\n//       modality: 'text',\n//       maxSequenceLength: 512,\n//       maxBatchSize: 100,\n//       providerName: 'Pinecone',\n//       supportedDimensions: undefined,\n//       supportedMetrics: undefined,\n//       supportedParameters: [Array]\n//     }\n//   ]\n// }\n\nconst model = await pc.inference.getModel('pinecone-sparse-english-v0');\nconsole.log(model);\n// {\n//   model: 'pinecone-sparse-english-v0',\n//   shortDescription: 'A sparse embedding model for converting text to sparse vectors for keyword or hybrid semantic/keyword search. Built on the innovations of the DeepImpact architecture.',\n//   type: 'embed',\n//   vectorType: 'sparse',\n//   defaultDimension: undefined,\n//   modality: 'text',\n//   maxSequenceLength: 512,\n//   maxBatchSize: 96,\n//   providerName: 'Pinecone',\n//   supportedDimensions: undefined,\n//   supportedMetrics: [ 'DotProduct' ],\n//   supportedParameters: [\n//     {\n//       parameter: 'input_type',\n//       type: 'one_of',\n//       valueType: 'string',\n//       required: true,\n//       allowedValues: [Array],\n//       min: undefined,\n//       max: undefined,\n//       _default: undefined\n//     },\n//     {\n//       parameter: 'truncate',\n//       type: 'one_of',\n//       valueType: 'string',\n//       required: false,\n//       allowedValues: [Array],\n//       min: undefined,\n//       max: undefined,\n//       _default: 'END'\n//     },\n//     {\n//       parameter: 'return_tokens',\n//       type: 'any',\n//       valueType: 'boolean',\n//       required: false,\n//       allowedValues: undefined,\n//       min: undefined,\n//       max: undefined,\n//       _default: false\n//     }\n//   ]\n// }\n```\n\n### Create embeddings\n\nGenerate embeddings for documents and queries.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\n\nconst client = new Pinecone({ apiKey: '\u003cYour API key from app.pinecone.io\u003e' });\n\nconst embeddingModel = 'multilingual-e5-large';\n\nconst documents = [\n  'Turkey is a classic meat to eat at American Thanksgiving.',\n  'Many people enjoy the beautiful mosques in Turkey.',\n];\nconst docParameters = {\n  inputType: 'passage',\n  truncate: 'END',\n};\nasync function generateDocEmbeddings() {\n  try {\n    return await client.inference.embed(\n      embeddingModel,\n      documents,\n      docParameters\n    );\n  } catch (error) {\n    console.error('Error generating embeddings:', error);\n  }\n}\ngenerateDocEmbeddings().then((embeddingsResponse) =\u003e {\n  if (embeddingsResponse) {\n    console.log(embeddingsResponse);\n  }\n});\n\n// \u003c\u003c Upsert documents into Pinecone \u003e\u003e\n\nconst userQuery = ['How should I prepare my turkey?'];\nconst queryParameters = {\n  inputType: 'query',\n  truncate: 'END',\n};\nasync function generateQueryEmbeddings() {\n  try {\n    return await client.inference.embed(\n      embeddingModel,\n      userQuery,\n      queryParameters\n    );\n  } catch (error) {\n    console.error('Error generating embeddings:', error);\n  }\n}\ngenerateQueryEmbeddings().then((embeddingsResponse) =\u003e {\n  if (embeddingsResponse) {\n    console.log(embeddingsResponse);\n  }\n});\n\n// \u003c\u003c Send query to Pinecone to retrieve similar documents \u003e\u003e\n```\n\n### Rerank documents\n\nRerank documents in descending relevance-order against a query.\n\n**Note:** The `score` represents the absolute measure of relevance of a given query and passage pair. Normalized\nbetween [0, 1], the `score` represents how closely relevant a specific item and query are, with scores closer to 1\nindicating higher relevance.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst rerankingModel = 'bge-reranker-v2-m3';\nconst myQuery = 'What are some good Turkey dishes for Thanksgiving?';\n\n// Option 1: Documents as an array of strings\nconst myDocsStrings = [\n  'I love turkey sandwiches with pastrami',\n  'A lemon brined Turkey with apple sausage stuffing is a classic Thanksgiving main',\n  'My favorite Thanksgiving dish is pumpkin pie',\n  'Turkey is a great source of protein',\n];\n\n// Option 1 response\nconst response = await pc.inference.rerank(\n  rerankingModel,\n  myQuery,\n  myDocsStrings\n);\nconsole.log(response);\n// {\n// model: 'bge-reranker-v2-m3',\n// data: [\n//   { index: 1, score: 0.5633179, document: [Object] },\n//   { index: 2, score: 0.02013874, document: [Object] },\n//   { index: 3, score: 0.00035419367, document: [Object] },\n//   { index: 0, score: 0.00021485926, document: [Object] }\n// ],\n// usage: { rerankUnits: 1 }\n// }\n\n// Option 2: Documents as an array of objects\nconst myDocsObjs = [\n  {\n    title: 'Turkey Sandwiches',\n    body: 'I love turkey sandwiches with pastrami',\n  },\n  {\n    title: 'Lemon Turkey',\n    body: 'A lemon brined Turkey with apple sausage stuffing is a classic Thanksgiving main',\n  },\n  {\n    title: 'Thanksgiving',\n    body: 'My favorite Thanksgiving dish is pumpkin pie',\n  },\n  {\n    title: 'Protein Sources',\n    body: 'Turkey is a great source of protein',\n  },\n];\n\n// Option 2: Options object declaring which custom key to rerank on\n// Note: If no custom key is passed via `rankFields`, each doc must contain a `text` key, and that will act as the default)\nconst rerankOptions = {\n  topN: 3,\n  returnDocuments: false,\n  rankFields: ['body'],\n  parameters: {\n    inputType: 'passage',\n    truncate: 'END',\n  },\n};\n\n// Option 2 response\nconst response = await pc.inference.rerank(\n  rerankingModel,\n  myQuery,\n  myDocsObjs,\n  rerankOptions\n);\nconsole.log(response);\n// {\n// model: 'bge-reranker-v2-m3',\n// data: [\n//   { index: 1, score: 0.5633179, document: undefined },\n//   { index: 2, score: 0.02013874, document: undefined },\n//   { index: 3, score: 0.00035419367, document: undefined },\n// ],\n// usage: { rerankUnits: 1 }\n//}\n```\n\n## Integrated Inference\n\nWhen using an index with integrated inference, embedding and reranking operations are tied to index operations and do not require extra steps. This allows working with an index that accepts source text and converts it to vectors automatically using an embedding model hosted by Pinecone.\n\nIntegrated inference requires a serverless index configured for a specific embedding model. You can either create a new index for a model or configure an existing index for a model. See [Create an integrated index](#create-an-integrated-index) for specifics on creating these indexes.\n\nOnce you have an index configured for a specific embedding model, use the `upsertRecords` operation on the `Index` class to convert your source data to embeddings and upsert them into a namespace.\n\n### Upsert integrated records\n\nNote the following requirements for each record:\n\n- Each record must contain a unique `id`, which will serve as the record identifier in the index namespace.\n- Each record must contain a field with the data for embedding. This field must match the field_map specified when creating the index.\n- Any additional fields in the record will be stored in the index and can be returned in search results or used to filter search results.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// Target an integrated index\nconst namespace = pc.index({\n  name: 'integrated-index',\n  namespace: 'namespace1',\n});\n\nconst records = [\n  {\n    id: 'rec1',\n    chunk_text:\n      \"Apple's first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.\",\n    category: 'product',\n  },\n  {\n    id: 'rec2',\n    chunk_text:\n      'Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.',\n    category: 'nutrition',\n  },\n  {\n    id: 'rec3',\n    chunk_text:\n      'Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.',\n    category: 'cultivation',\n  },\n  {\n    id: 'rec4',\n    chunk_text:\n      'In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.',\n    category: 'product',\n  },\n  {\n    id: 'rec5',\n    chunk_text:\n      'Apple went public in 1980, making history with one of the largest IPOs at that time.',\n    category: 'milestone',\n  },\n  {\n    id: 'rec6',\n    chunk_text:\n      'Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.',\n    category: 'nutrition',\n  },\n  {\n    id: 'rec7',\n    chunk_text:\n      \"Known for its design-forward products, Apple's branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.\",\n    category: 'influence',\n  },\n  {\n    id: 'rec8',\n    chunk_text:\n      'The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.',\n    category: 'nutrition',\n  },\n];\n\n// Upsert the data into your index\nawait namespace.upsertRecords(records);\n```\n\n### Search integrated records\n\nUse the `searchRecords` method to convert a query to a vector embedding and then search your namespace for the most semantically similar records, along with their similarity scores.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\n// Target an integrated index\nconst namespace = pc.index({\n  name: 'integrated-index',\n  namespace: 'namespace1',\n});\n\n// search for 4 records most semantically relevant to the query 'Disease prevention'\nconst response = await namespace.searchRecords({\n  query: { topK: 4, inputs: { text: 'Disease prevention' } },\n});\n```\n\nTo rerank initial search results based on relevance to the query, add the rerank parameter, including the [reranking model](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models) you want to use, the number of reranked results to return, and the fields to use for reranking, if different than the main query.\n\nFor example, repeat the search for the 4 documents most semantically related to the query, “Disease prevention”, but this time rerank the results and return only the 2 most relevant documents:\n\n```typescript\nconst response = await namespace.searchRecords({\n  query: {\n    topK: 4,\n    inputs: { text: 'Disease prevention' },\n  },\n  rerank: {\n    model: 'bge-reranker-v2-m3',\n    topN: 2,\n    rankFields: ['chunk_text'],\n  },\n  fields: ['category', 'chunk_text'],\n});\n```\n\n## Pinecone Assistant\n\nThe [Pinecone Assistant API](https://docs.pinecone.io/guides/assistant/understanding-assistant) enables you to create and manage AI assistants powered by Pinecone's vector database\ncapabilities. These Assistants can be customized with specific instructions and metadata, and can interact with\nfiles and engage in chat conversations.\n\n### Create an Assistant\n\n[Creates a new Assistant](https://docs.pinecone.io/guides/assistant/create-assistant) with specified configurations. You can define the Assistant's name, provide instructions\nthat guide its behavior, and attach metadata for organization and tracking purposes.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst assistant = await pc.createAssistant({\n  name: 'product-assistant',\n  instructions: 'You are a helpful product recommendation assistant.',\n  metadata: {\n    team: 'product',\n    version: '1.0',\n  },\n});\n```\n\n### Delete an Assistant\n\n[Deletes an Assistant](https://docs.pinecone.io/guides/assistant/manage-assistants#delete-an-assistant) by name.\n\n**Note:** Deleting an Assistant also deletes all associated files.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nawait pc.deleteAssistant('test1');\n```\n\n### Get information about an Assistant\n\n[Retrieves information](https://docs.pinecone.io/guides/assistant/manage-assistants#get-the-status-of-an-assistant) about an Assistant by name.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst test = await pc.describeAssistant('test1');\nconsole.log(test);\n// {\n//  name: 'test10',\n//  instructions: undefined,\n//  metadata: undefined,\n//  status: 'Ready',\n//  host: 'https://prod-1-data.ke.pinecone.io',\n//  createdAt: 2025-01-08T22:24:50.525Z,\n//  updatedAt: 2025-01-08T22:24:52.303Z\n// }\n```\n\n### Update an Assistant\n\n[Updates an Assistant](https://docs.pinecone.io/guides/assistant/manage-assistants#add-instructions-to-an-assistant) by name. You can update the Assistant's name, instructions, and/or metadata.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nawait pc.updateAssistant('test1', {\n  instructions: 'some new  instructions!',\n});\n```\n\n### List Assistants\n\nRetrieves a [list of all Assistants](https://docs.pinecone.io/guides/assistant/manage-assistants) in your account. This method returns details about each Assistant including their\nnames, instructions, metadata, status, and host.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\n\nconst assistants = await pc.listAssistants();\nconsole.log(assistants);\n// {\n//   assistants: [{\n//     name: 'product-assistant',\n//     instructions: 'You are a helpful product recommendation assistant.',\n//     metadata: { team: 'product', version: '1.0' },\n//     status: 'Ready',\n//     host: 'product-assistant-abc123.svc.pinecone.io'\n//   }]\n// }\n```\n\n### Chat with an Assistant\n\nYou can [chat with Assistants](https://docs.pinecone.io/guides/assistant/chat-with-assistant) using either the `chat` method or the `chatCompletion` methods.\n\n**Note:** Your Assistant must contain files in order for chat to work.\n\nThe following example shows how to chat with an Assistant using the `chat` methods:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst chatResp = await assistant.chat({\n  messages: [\n    {\n      role: 'user',\n      content: 'What is the capital of France?',\n    },\n  ],\n});\nconsole.log(chatResp);\n// {\n//  id: '000000000000000023e7fb015be9d0ad',\n//  finishReason: 'stop',\n//  message: {\n//    role: 'assistant',\n//    content: 'The capital of France is Paris.'\n//  },\n//  model: 'gpt-4o-2024-05-13',\n//  citations: [ { position: 209, references: [Array] } ],\n//  usage: { promptTokens: 493, completionTokens: 38, totalTokens: 531 }\n// }\n```\n\n`chatCompletion` is based on the [OpenAI Chat Completion](https://platform.openai.com/docs/api-reference/chat) format, and is useful if OpenAI-compatible responses. However, it has limited functionality compared to the standard `chat` method. Read more [here](https://docs.pinecone.io/reference/api/2025-01/assistant/chat_completion_assistant).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst chatResp = await assistant.chatCompletion({\n  messages: [\n    {\n      role: 'user',\n      content: 'What is the capital of France?',\n    },\n  ],\n});\nconsole.log(chatResp);\n// {\n//  id: '000000000000000023e7fb015be9d0ad',\n//  choices: [\n//    {\n//      finishReason: 'stop',\n//      index: 0,\n//      message: {\n//        role: 'assistant',\n//        content: 'The capital of France is Paris.'\n//      }\n//    }\n//  ],\n//  finishReason: 'stop',\n//  model: 'gpt-4o-2024-05-13',\n//  usage: { promptTokens: 493, completionTokens: 38, totalTokens: 531 }\n// }\n```\n\n### Stream Assistant responses\n\nAssistant chat responses can also be streamed using the `chatStream` and `chatCompletionStream` methods on the `Assistant` class. These methods return a `ChatStream` which implements `AsyncIterable`, returning an [async iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator) object allowing for manipulation of the stream. You can stream either the chat or chat completions operations.\n\nNote: The shape of the JSON returned in each streamed chunk will be different depending which method is being used.\n\nChat stream:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst chatStream = await assistant.chatStream({\n  messages: [\n    {\n      role: 'user',\n      content: 'What is the capital of France?',\n    },\n  ],\n});\n\nfor await (const chunk of chatStream) {\n  console.log(chunk);\n}\n// Each chunk in the stream will have a different shape depending on the type:\n//\n// {\n//   type: 'message_start',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   role: 'assistant'\n// }\n// {\n//   type: 'content_chunk',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   delta: { content: 'The' }\n// }\n// {\n//   type: 'content_chunk',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   delta: { content: ' capital' }\n// }\n// {\n//   type: 'content_chunk',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   delta: { content: ' of' }\n// }\n// {\n//   type: 'content_chunk',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   delta: { content: ' France' }\n// }\n// {\n//   type: 'content_chunk',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   delta: { content: ' is Paris.' }\n// }\n// {\n//   type: 'citation',\n//   id: 'response_id',\n//   model: 'gpt-4o-2024-05-13',\n//   citation: { position: 1538, references: [ [Object] ] }\n// }\n// {\n//   type: 'message_end',\n//   id: '000000000000000002378669324ef087',\n//   model: 'gpt-4o-2024-05-13',\n//   finishReason: 'stop',\n//   usage: { promptTokens: 9080, completionTokens: 312, totalTokens: 9392 }\n// }\n```\n\nChat completion stream:\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst chatCompletionStream = await assistant.chatCompletionStream({\n  messages: [\n    {\n      role: 'user',\n      content: 'What is the capital of France?',\n    },\n  ],\n});\n\nfor await (const chunk of chatCompletionStream) {\n  console.log(chunk);\n}\n// Each chunk will have the same OpenAI compatible completion shape:\n//\n// {\n//   id: 'response-id',\n//   choices: [\n//     {\n//       index: 0,\n//       delta: {\n//         role: 'assistant'\n//       },\n//       finishReason: null\n//     }\n//   ],\n//   model: 'gpt-4o-2024-05-13',\n//   usage: null\n// }\n// {\n//   id: 'response-id',\n//   choices: [\n//     {\n//       index: 0,\n//       delta: {\n//         content: 'The capital'\n//       },\n//       finishReason: null\n//     }\n//   ],\n//   model: 'gpt-4o-2024-05-13',\n//   usage: null\n// }\n// ... rest of stream\n// {\n//   id: 'response-id',\n//   choices: [],\n//   model: 'gpt-4o-2024-05-13',\n//   usage: {\n//     promptTokens: 9080,\n//     completionTokens: 338,\n//     totalTokens: 9418\n//   }\n// }\n```\n\n### Inspect context snippets associated with a chat\n\nReturns [context snippets associated with a given query and an Assistant's response](https://docs.pinecone.io/guides/assistant/understanding-context-snippets). This is useful for understanding\nhow the Assistant arrived at its answer(s).\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst context = await assistant.context({\n  messages: ['What is the capital of France?'],\n  topK: 1,\n});\nconsole.log(context);\n// {\n//  snippets: [\n//    {\n//      type: 'text',\n//      content: 'The capital of France is Paris.',\n//      score: 0.9978925,\n//      reference: [Object]\n//    },\n//  ],\n//  usage: { promptTokens: 527, completionTokens: 0, totalTokens: 527 }\n// }\n```\n\n### Add files to an Assistant\n\nYou can [add files to an Assistant](https://docs.pinecone.io/guides/assistant/manage-files#upload-a-local-file) to enable it to interact with files during chat conversations. The following\nexample shows how to upload a local `test-file.txt` file to an Assistant.\n\n**Note:** You must upload at least 1 file in order to chat with an Assistant.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nawait assistant.uploadFile({\n  path: 'test-file.txt',\n  metadata: { 'test-key': 'test-value' },\n});\n// {\n//  name: 'test-file.txt',\n//  id: '921ad74c-2421-413a-8c86-fca81ceabc5c',\n//  metadata: { 'test-key': 'test-value' },\n//  createdOn: 2025-01-06T19:14:21.969Z,\n//  updatedOn: 2025-01-06T19:14:21.969Z,\n//  status: 'Processing',\n//  percentDone: null,\n//  signedUrl: null,\n//  errorMessage: null\n// }\n```\n\n### List all files in an Assistant\n\n[Lists all files](https://docs.pinecone.io/guides/assistant/manage-files#list-files-in-an-assistant) that have been uploaded to an Assistant. Optionally, you can pass a filter to list only files that\nmeet certain criteria.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst files = await assistant.listFiles({\n  filter: { key: 'value' },\n});\nconsole.log(files);\n// {\n//  files: [\n//    {\n//      name: 'test-file.txt',\n//      id: '1a56ddd0-c6d8-4295-80c0-9bfd6f5cb87b',\n//      metadata: [Object],\n//      createdOn: 2025-01-06T19:14:21.969Z,\n//      updatedOn: 2025-01-06T19:14:36.925Z,\n//      status: 'Available',\n//      percentDone: 1,\n//      signedUrl: undefined,\n//      errorMessage: undefined\n//    }\n//  ]\n// }\n```\n\n### Get the status of a file in an Assistant\n\n[Retrieves information about a file](https://docs.pinecone.io/guides/assistant/manage-files#get-the-status-of-a-file) in an Assistant by ID.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst files = await assistant.listFiles();\nlet fileId: string;\nif (files.files) {\n  fileId = files.files[0].id;\n} else {\n  fileId = '';\n}\nconst resp = await assistant.describeFile({ fileId: fileId });\nconsole.log(resp);\n// {\n//  name: 'test-file.txt',\n//  id: '1a56ddd0-c6d8-4295-80c0-9bfd6f5cb87b',\n//  metadata: undefined,\n//  createdOn: 2025-01-06T19:14:21.969Z,\n//  updatedOn: 2025-01-06T19:14:36.925Z,\n//  status: 'Available',\n//  percentDone: 1,\n//  signedUrl: undefined,\n//   errorMessage: undefined\n// }\n```\n\n### Delete a file from an Assistant\n\n[Deletes a file(s)](https://docs.pinecone.io/guides/assistant/manage-files#delete-a-file) from an Assistant by ID.\n\n**Note:** Deleting files is a PERMANENT operation. Deleted files _cannot_ be recovered.\n\n```typescript\nimport { Pinecone } from '@pinecone-database/pinecone';\nconst pc = new Pinecone();\nconst assistantName = 'test1';\nconst assistant = pc.Assistant({ name: assistantName });\nconst files = await assistant.listFiles();\nlet fileId: string;\nif (files.files) {\n  fileId = files.files[0].id;\n  await assistant.deleteFile({ fileId: fileId });\n}\n```\n\n## Testing\n\nAll testing takes place automatically in CI and is configured using Github actions\nand workflows, located in the `.github` directory of this repo.\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinecone-io%2Fpinecone-ts-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinecone-io%2Fpinecone-ts-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinecone-io%2Fpinecone-ts-client/lists"}