@pinecone-database/pinecone
Version:
This is the official Node.js SDK for [Pinecone](https://www.pinecone.io), written in TypeScript.
343 lines • 21.3 kB
JavaScript
/* tslint:disable */
/* eslint-disable */
/**
* Pinecone Data Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2025-04
* Contact: support@pinecone.io
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VectorOperationsApi = void 0;
const runtime = __importStar(require("../runtime"));
const index_1 = require("../models/index");
/**
*
*/
class VectorOperationsApi extends runtime.BaseAPI {
/**
* Delete vectors by id from a single namespace. For guidance and examples, see [Delete data](https://docs.pinecone.io/guides/manage-data/delete-data).
* Delete vectors
*/
async deleteVectorsRaw(requestParameters, initOverrides) {
if (requestParameters.deleteRequest === null || requestParameters.deleteRequest === undefined) {
throw new runtime.RequiredError('deleteRequest', 'Required parameter requestParameters.deleteRequest was null or undefined when calling deleteVectors.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/vectors/delete`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.DeleteRequestToJSON)(requestParameters.deleteRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response);
}
/**
* Delete vectors by id from a single namespace. For guidance and examples, see [Delete data](https://docs.pinecone.io/guides/manage-data/delete-data).
* Delete vectors
*/
async deleteVectors(requestParameters, initOverrides) {
const response = await this.deleteVectorsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Return statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats
*/
async describeIndexStatsRaw(requestParameters, initOverrides) {
if (requestParameters.describeIndexStatsRequest === null || requestParameters.describeIndexStatsRequest === undefined) {
throw new runtime.RequiredError('describeIndexStatsRequest', 'Required parameter requestParameters.describeIndexStatsRequest was null or undefined when calling describeIndexStats.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/describe_index_stats`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.DescribeIndexStatsRequestToJSON)(requestParameters.describeIndexStatsRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.IndexDescriptionFromJSON)(jsonValue));
}
/**
* Return statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats
*/
async describeIndexStats(requestParameters, initOverrides) {
const response = await this.describeIndexStatsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Look up and return vectors by ID from a single namespace. The returned vectors include the vector data and/or metadata. For guidance and examples, see [Fetch data](https://docs.pinecone.io/guides/manage-data/fetch-data).
* Fetch vectors
*/
async fetchVectorsRaw(requestParameters, initOverrides) {
if (requestParameters.ids === null || requestParameters.ids === undefined) {
throw new runtime.RequiredError('ids', 'Required parameter requestParameters.ids was null or undefined when calling fetchVectors.');
}
const queryParameters = {};
if (requestParameters.ids) {
queryParameters['ids'] = requestParameters.ids;
}
if (requestParameters.namespace !== undefined) {
queryParameters['namespace'] = requestParameters.namespace;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/vectors/fetch`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.FetchResponseFromJSON)(jsonValue));
}
/**
* Look up and return vectors by ID from a single namespace. The returned vectors include the vector data and/or metadata. For guidance and examples, see [Fetch data](https://docs.pinecone.io/guides/manage-data/fetch-data).
* Fetch vectors
*/
async fetchVectors(requestParameters, initOverrides) {
const response = await this.fetchVectorsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* List the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. Returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/manage-data/list-record-ids). **Note:** `list` is supported only for serverless indexes.
* List vector IDs
*/
async listVectorsRaw(requestParameters, initOverrides) {
const queryParameters = {};
if (requestParameters.prefix !== undefined) {
queryParameters['prefix'] = requestParameters.prefix;
}
if (requestParameters.limit !== undefined) {
queryParameters['limit'] = requestParameters.limit;
}
if (requestParameters.paginationToken !== undefined) {
queryParameters['paginationToken'] = requestParameters.paginationToken;
}
if (requestParameters.namespace !== undefined) {
queryParameters['namespace'] = requestParameters.namespace;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/vectors/list`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.ListResponseFromJSON)(jsonValue));
}
/**
* List the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. Returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/manage-data/list-record-ids). **Note:** `list` is supported only for serverless indexes.
* List vector IDs
*/
async listVectors(requestParameters = {}, initOverrides) {
const response = await this.listVectorsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Search a namespace using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. For guidance, examples, and limits, see [Search](https://docs.pinecone.io/guides/search/search-overview).
* Search with a vector
*/
async queryVectorsRaw(requestParameters, initOverrides) {
if (requestParameters.queryRequest === null || requestParameters.queryRequest === undefined) {
throw new runtime.RequiredError('queryRequest', 'Required parameter requestParameters.queryRequest was null or undefined when calling queryVectors.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/query`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.QueryRequestToJSON)(requestParameters.queryRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.QueryResponseFromJSON)(jsonValue));
}
/**
* Search a namespace using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. For guidance, examples, and limits, see [Search](https://docs.pinecone.io/guides/search/search-overview).
* Search with a vector
*/
async queryVectors(requestParameters, initOverrides) {
const response = await this.queryVectorsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Search a namespace with a query text, query vector, or record ID and return the most similar records, along with their similarity scores. Optionally, rerank the initial results based on their relevance to the query. Searching with text is supported only for [indexes with integrated embedding](https://docs.pinecone.io/guides/indexes/create-an-index#integrated-embedding). Searching with a query vector or record ID is supported for all indexes. For guidance, examples, and limits, see [Search](https://docs.pinecone.io/guides/search/search-overview).
* Search with text
*/
async searchRecordsNamespaceRaw(requestParameters, initOverrides) {
if (requestParameters.namespace === null || requestParameters.namespace === undefined) {
throw new runtime.RequiredError('namespace', 'Required parameter requestParameters.namespace was null or undefined when calling searchRecordsNamespace.');
}
if (requestParameters.searchRecordsRequest === null || requestParameters.searchRecordsRequest === undefined) {
throw new runtime.RequiredError('searchRecordsRequest', 'Required parameter requestParameters.searchRecordsRequest was null or undefined when calling searchRecordsNamespace.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/records/namespaces/{namespace}/search`.replace(`{${"namespace"}}`, encodeURIComponent(String(requestParameters.namespace))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.SearchRecordsRequestToJSON)(requestParameters.searchRecordsRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.SearchRecordsResponseFromJSON)(jsonValue));
}
/**
* Search a namespace with a query text, query vector, or record ID and return the most similar records, along with their similarity scores. Optionally, rerank the initial results based on their relevance to the query. Searching with text is supported only for [indexes with integrated embedding](https://docs.pinecone.io/guides/indexes/create-an-index#integrated-embedding). Searching with a query vector or record ID is supported for all indexes. For guidance, examples, and limits, see [Search](https://docs.pinecone.io/guides/search/search-overview).
* Search with text
*/
async searchRecordsNamespace(requestParameters, initOverrides) {
const response = await this.searchRecordsNamespaceRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Update a vector in a namespace. If a value is included, it will overwrite the previous value. If a `set_metadata` is included, the values of the fields specified in it will be added or overwrite the previous value. For guidance and examples, see [Update data](https://docs.pinecone.io/guides/manage-data/update-data).
* Update a vector
*/
async updateVectorRaw(requestParameters, initOverrides) {
if (requestParameters.updateRequest === null || requestParameters.updateRequest === undefined) {
throw new runtime.RequiredError('updateRequest', 'Required parameter requestParameters.updateRequest was null or undefined when calling updateVector.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/vectors/update`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.UpdateRequestToJSON)(requestParameters.updateRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response);
}
/**
* Update a vector in a namespace. If a value is included, it will overwrite the previous value. If a `set_metadata` is included, the values of the fields specified in it will be added or overwrite the previous value. For guidance and examples, see [Update data](https://docs.pinecone.io/guides/manage-data/update-data).
* Update a vector
*/
async updateVector(requestParameters, initOverrides) {
const response = await this.updateVectorRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Upsert text into a namespace. Pinecone converts the text to vectors automatically using the hosted embedding model associated with the index. Upserting text is supported only for [indexes with integrated embedding](https://docs.pinecone.io/reference/api/2025-01/control-plane/create_for_model). For guidance, examples, and limits, see [Upsert data](https://docs.pinecone.io/guides/index-data/upsert-data).
* Upsert text
*/
async upsertRecordsNamespaceRaw(requestParameters, initOverrides) {
if (requestParameters.namespace === null || requestParameters.namespace === undefined) {
throw new runtime.RequiredError('namespace', 'Required parameter requestParameters.namespace was null or undefined when calling upsertRecordsNamespace.');
}
if (requestParameters.upsertRecord === null || requestParameters.upsertRecord === undefined) {
throw new runtime.RequiredError('upsertRecord', 'Required parameter requestParameters.upsertRecord was null or undefined when calling upsertRecordsNamespace.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/x-ndjson';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/records/namespaces/{namespace}/upsert`.replace(`{${"namespace"}}`, encodeURIComponent(String(requestParameters.namespace))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.upsertRecord.map(index_1.UpsertRecordToJSON),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Upsert text into a namespace. Pinecone converts the text to vectors automatically using the hosted embedding model associated with the index. Upserting text is supported only for [indexes with integrated embedding](https://docs.pinecone.io/reference/api/2025-01/control-plane/create_for_model). For guidance, examples, and limits, see [Upsert data](https://docs.pinecone.io/guides/index-data/upsert-data).
* Upsert text
*/
async upsertRecordsNamespace(requestParameters, initOverrides) {
await this.upsertRecordsNamespaceRaw(requestParameters, initOverrides);
}
/**
* Upsert vectors into a namespace. If a new value is upserted for an existing vector ID, it will overwrite the previous value. For guidance, examples, and limits, see [Upsert data](https://docs.pinecone.io/guides/index-data/upsert-data).
* Upsert vectors
*/
async upsertVectorsRaw(requestParameters, initOverrides) {
if (requestParameters.upsertRequest === null || requestParameters.upsertRequest === undefined) {
throw new runtime.RequiredError('upsertRequest', 'Required parameter requestParameters.upsertRequest was null or undefined when calling upsertVectors.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/vectors/upsert`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: (0, index_1.UpsertRequestToJSON)(requestParameters.upsertRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.UpsertResponseFromJSON)(jsonValue));
}
/**
* Upsert vectors into a namespace. If a new value is upserted for an existing vector ID, it will overwrite the previous value. For guidance, examples, and limits, see [Upsert data](https://docs.pinecone.io/guides/index-data/upsert-data).
* Upsert vectors
*/
async upsertVectors(requestParameters, initOverrides) {
const response = await this.upsertVectorsRaw(requestParameters, initOverrides);
return await response.value();
}
}
exports.VectorOperationsApi = VectorOperationsApi;
//# sourceMappingURL=VectorOperationsApi.js.map
;