# Configure an index
control_2025-01 patch /indexes/{index_name}
This operation configures an existing index.
For serverless indexes, you can configure index deletion protection, tags, and integrated inference embedding settings for the index. For pod-based indexes, you can configure the pod size, number of replicas, tags, and index deletion protection.
It is not possible to change the pod type of a pod-based index. However, you can create a collection from a pod-based index and then [create a new pod-based index with a different pod type](http://docs.pinecone.io/guides/indexes/pods/create-a-pod-based-index#create-a-pod-index-from-a-collection) from the collection. For guidance and examples, see [Configure an index](http://docs.pinecone.io/guides/indexes/pods/manage-pod-based-indexes).
{/* ```python Python
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
pc.configure_index(
name="example-index",
pod_type="p1.x2",
replicas=4,
deletion_protection="enabled"
)
```
```javascript JavaScript
import { Pinecone } from '@pinecone-database/pinecone'
const pinecone = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pinecone.configureIndex('example-index', { podType: 'p1.x2', replicas: 4, deletionProtection: 'enabled' });
```
```java Java
import io.pinecone.clients.Pinecone;
public class ConfigureIndexExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.configureIndex("example-index", "p1.x2", 4, DeletionProtection.ENABLED);
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
idx, err := pc.ConfigureIndex(ctx, "example-index", pinecone.ConfigureIndexParams{PodType: "p1.x2", Replicas: 4, DeletionProtection: "enabled"})
if err != nil {
log.Fatalf("Failed to configure index \"%v\": %v", idx.Name, err)
} else {
fmt.Printf("Successfully configured index \"%v\"", idx.Name)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
var indexMetadata = await pinecone.ConfigureIndexAsync("example-index", new ConfigureIndexRequest
{
Spec = new ConfigureIndexRequestSpec
{
Pod = new ConfigureIndexRequestSpecPod {
Replicas = 4,
PodType = "p1.x2",
}
},
DeletionProtection = DeletionProtection.Disabled,
});
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -s -X PATCH "https://api.pinecone.io/indexes/example-index" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"spec": {
"pod": {
"pod_type": "p1.x2",
"replicas": 4
}
},
deletion_protection": "enabled"
}'
```
# Create a collection
control_2025-01 post /collections
This operation creates a Pinecone collection.
Serverless indexes do not support collections.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="API_KEY")
pc.create_collection("example-collection", "example-index")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.createCollection({
name: "example-collection",
source: "example-index",
});
```
```java Java
import io.pinecone.clients.Pinecone;
public class CreateCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createCollection("example-collection", "example-index");
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
collection, err := pc.CreateCollection(ctx, &pinecone.CreateCollectionRequest{
Name: "example-collection",
Source: "example-index",
})
if err != nil {
log.Fatalf("Failed to create collection: %v", err)
} else {
fmt.Printf("Successfully created collection: %v", collection.Name)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
var collectionModel = await pinecone.CreateCollectionAsync(new CreateCollectionRequest {
Name = "example-collection",
Source = "example-index",
});
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -s "https://api.pinecone.io/collections" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"name": "example-collection",
"source": "example-index"
}'
```
# Create an index for an embedding model
control_2025-01 post /indexes/create-for-model
This operation creates a serverless integrated inference index for a specific embedding model.
Refer to the [model guide](https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models) for available models and model details.
```python Python
# pip install --upgrade pinecone pinecone-plugin-records
from pinecone import Pinecone
import time
pc = Pinecone(api_key="YOUR_API_KEY")
index_name = "example-index"
index_model = pc.create_index_for_model(
name=index_name,
cloud="aws",
region="us-east-1",
embed={
"model":"multilingual-e5-large",
"field_map":{"text": "chunk_text"}
}
)
```
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl https://api.pinecone.io/indexes/create-for-model \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"name": "example-index",
"cloud": "aws",
"region": "us-east-1",
"embed": {
"model": "multilingual-e5-large",
"metric": "cosine",
"field_map": {
"text": "chunk_text"
},
"write_parameters": {
"input_type": "passage",
"truncate": "END"
},
"read_parameters": {
"input_type": "query",
"truncate": "END"
}
}
}'
```
```python Python
{'deletion_protection': 'disabled',
'dimension': 1024,
'embed': {'dimension': 1024,
'field_map': {'text': 'chunk_text'},
'metric': 'cosine',
'model': 'multilingual-e5-large',
'read_parameters': {'input_type': 'query', 'truncate': 'END'},
'write_parameters': {'input_type': 'passage', 'truncate': 'END'}},
'host': 'example-index-govk0nt.svc.aped-4627-b74a.pinecone.io',
'id': '9dabb7cb-ec0a-4e2e-b79e-c7c997e592ce',
'metric': 'cosine',
'name': 'example-index',
'spec': {'serverless': {'cloud': 'aws', 'region': 'us-east-1'}},
'status': {'ready': True, 'state': 'Ready'},
'tags': None}
```
```json curl
{
"id": "9dabb7cb-ec0a-4e2e-b79e-c7c997e592ce",
"name": "example-index",
"metric": "cosine",
"dimension": 1024,
"status": {
"ready": false,
"state": "Initializing"
},
"host": "example-index-govk0nt.svc.aped-4627-b74a.pinecone.io",
"spec": {
"serverless": {
"region": "us-east-1",
"cloud": "aws"
}
},
"deletion_protection": "disabled",
"tags": null,
"embed": {
"model": "multilingual-e5-large",
"field_map": {
"text": "chunk_text"
},
"dimension": 1024,
"metric": "cosine",
"write_parameters": {
"input_type": "passage",
"truncate": "END"
},
"read_parameters": {
"input_type": "query",
"truncate": "END"
}
}
}
```
# Create an index
control_2025-01 post /indexes
This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more.
For guidance and examples, see [Create an index](https://docs.pinecone.io/guides/indexes/create-an-index#create-a-serverless-index).
{/* ```python Python
# pip install pinecone[grpc]
# Serverless index
from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec
pc = Pinecone(api_key="YOUR_API_KEY")
pc.create_index(
name="example-index1",
dimension=1536,
metric="cosine",
spec=ServerlessSpec(
cloud="aws",
region="us-east-1",
),
deletion_protection="disabled"
)
# Pod-based index
from pinecone.grpc import PineconeGRPC as Pinecone, PodSpec
pc = Pinecone(api_key="YOUR_API_KEY")
pc.create_index(
name="example-index2",
dimension=1536,
metric="cosine",
spec=PodSpec(
environment="us-west1-gcp",
pod_type="p1.x1",
pods=1,
),
deletion_protection="disabled"
)
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
// Serverles index
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.createIndex({
name: 'severless-index',
dimension: 1536,
metric: 'cosine',
spec: {
serverless: {
cloud: 'aws',
region: 'us-east-1'
}
},
deletionProtection: 'disabled',
});
// Pod-based index
await pc.createIndex({
name: 'example-index2',
dimension: 1536,
metric: 'cosine',
spec: {
pod: {
environment: 'us-west1-gcp',
podType: 'p1.x1',
pods: 1
}
},
deletionProtection: 'disabled',
});
```
```java Java
import io.pinecone.clients.Pinecone;
// Serverless index
public class CreateServerlessIndexExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createServerlessIndex("example-index1", "cosine", 1536, "aws", "us-east-1", DeletionProtection.disabled);
}
}
// Pod-based index
public class CreatePodIndexExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createPodsIndex("example-index2", 1536, "us-west1-gcp",
"p1.x1", "cosine", DeletionProtection.disabled);
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// Serverless index
idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
Name: "example-index1",
Dimension: 1536,
Metric: pinecone.Cosine,
Cloud: pinecone.Aws,
Region: "us-east-1",
DeletionProtection: "disabled",
})
if err != nil {
log.Fatalf("Failed to create serverless index: %v", idx.Name)
} else {
fmt.Printf("Successfully created serverless index: %v", idx.Name)
}
// Pod-based index
idx, err := pc.CreatePodIndex(ctx, &pinecone.CreatePodIndexRequest{
Name: "example-index2",
Dimension: 1536,
Metric: pinecone.Cosine,
Environment: "us-east1-gcp",
PodType: "p1.x1",
DeletionProtection: "disabled",
})
if err != nil {
log.Fatalf("Failed to create pod-based index: %v", idx.Name)
} else {
fmt.Printf("Successfully created pod-based index: %v", idx.Name)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// Serverless index
var createIndexRequest = await pinecone.CreateIndexAsync(new CreateIndexRequest
{
Name = "example-index1",
Dimension = 1536,
Metric = CreateIndexRequestMetric.Cosine,
Spec = new ServerlessIndexSpec
{
Serverless = new ServerlessSpec
{
Cloud = ServerlessSpecCloud.Aws,
Region = "us-east-1",
}
},
DeletionProtection = DeletionProtection.Disabled
});
// Pod-based index
var createIndexRequest = await pinecone.CreateIndexAsync(new CreateIndexRequest
{
Name = "pod index",
Dimension = 1536,
Metric = CreateIndexRequestMetric.Cosine,
Spec = new PodIndexSpec
{
Pod = new PodSpec
{
Environment = "us-east1-gcp",
PodType = "p1.x1",
Pods = 1,
}
},
DeletionProtection = DeletionProtection.Disabled
});
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
# Serverless index
curl -s "https://api.pinecone.io/indexes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"name": "example-index1",
"dimension": 1536,
"metric": "cosine",
"spec": {
"serverless": {
"cloud": "aws",
"region": "us-east-1"
}
},
"tags"={
"example": "tag",
"environment": "production"
},
"deletion_protection"="disabled"
}'
# Pod-based index
curl -s "https://api.pinecone.io/indexes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-10" \
-d '{
"name": "example-index2",
"dimension": 1536,
"metric": "cosine",
"spec": {
"pod": {
"environment": "us-west1-gcp",
"pod_type": "p1.x1",
"pods": 1
}
},
"tags"={
"example": "tag",
"environment": "production"
},
"deletion_protection"="disabled"
}'
```
```shell
# Serverless index
{
"name": "example-index1",
"metric": "cosine",
"dimension": 1536,
"status": {
"ready": true,
"state": "Ready"
},
"host": "example-index1-4zo0ijk.svc.dev-us-west2-aws.pinecone.io",
"spec": {
"serverless": {
"region": "us-east-1",
"cloud": "aws"
},
"tags": {
"example": "tag",
"environment": "production"
}
}
}
# Pod-based index
{
"name": "example-index2",
"metric": "cosine",
"dimension": 1536,
"status": {
"ready": true,
"state": "Ready"
},
"host": "example-index2-4zo0ijk.svc.us-west1-gcp.pinecone.io",
"spec": {
"pod": {
"replicas": 1,
"shards": 1,
"pods": 1,
"pod_type": "p1.x1",
"environment": "us-west1-gcp"
},
"tags": {
"example": "tag",
"environment": "production"
}
}
}
```
# Delete a collection
control_2025-01 delete /collections/{collection_name}
This operation deletes an existing collection.
Serverless indexes do not support collections.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key='API_KEY')
pc.delete_collection("example-collection")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
await pc.deleteCollection("example-collection");
```
```java Java
import io.pinecone.clients.Pinecone;
public class DeleteCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.deleteCollection("example-collection");
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
collectionName := "example-collection"
err = pc.DeleteCollection(ctx, collectionName)
if err != nil {
log.Fatalf("Failed to delete collection: %v\n", err)
} else {
if len(collections) == 0 {
fmt.Printf("No collections found in project")
} else {
fmt.Printf("Successfully deleted collection \"%v\"\n", collectionName)
}
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
await pinecone.DeleteCollectionAsync("example-collection");
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -i -X DELETE "https://api.pinecone.io/collections/example-collection" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# Delete an index
control_2025-01 delete /indexes/{index_name}
This operation deletes an existing index.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone, PodSpec
pc = Pinecone(api_key="YOUR_API_KEY")
pc.delete_index("example-index")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.deleteIndex('example-index');
```
```java Java
import io.pinecone.clients.Pinecone;
public class DeleteIndexExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.deleteIndex("example-index");
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
indexName := "example-index"
err = pc.DeleteIndex(ctx, indexName)
if err != nil {
log.Fatalf("Failed to delete index: %v", err)
} else {
fmt.Println("Index \"%v\" deleted successfully", indexName)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
await pinecone.DeleteIndexAsync("example-index");
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -i -X DELETE "https://api.pinecone.io/indexes/example-index" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# Describe a collection
control_2025-01 get /collections/{collection_name}
This operation gets a description of a collection.
Serverless indexes do not support collections.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key='API_KEY')
pc.describe_collection("tiny-collection")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });
await pc.describeCollection('tiny-collection');
```
```java Java
import io.pinecone.clients.Pinecone;
import org.openapitools.client.model.CollectionModel;
public class DescribeCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
CollectionModel collectionModel = pc.describeCollection("tiny-collection");
System.out.println(collectionModel);
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
collectionName := "tiny-collection"
collection, err := pc.DescribeCollection(ctx, collectionName)
if err != nil {
log.Fatalf("Error describing collection %v: %v", collectionName, err)
} else {
fmt.Printf("Collection: %+v", collection)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
var collectionModel = await pinecone.DescribeCollectionAsync("tiny-collection");
Console.WriteLine(collectionModel);
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -i -X GET "https://api.pinecone.io/collections/tiny-collection" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# Describe an index
control_2025-01 get /indexes/{index_name}
Get a description of an index.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
pc.describe_index("movie-recommendations")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });
await pc.describeIndex('movie-recommendations');
```
```java Java
import io.pinecone.clients.Pinecone;
import org.openapitools.db_control.client.model.*;
public class DescribeIndexExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOURE_API_KEY").build();
IndexModel indexModel = pc.describeIndex("movie-recommendations");
System.out.println(indexModel);
}
}
```
```go Go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func prettifyStruct(obj interface{}) string {
bytes, _ := json.MarshalIndent(obj, "", " ")
return string(bytes)
}
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
idx, err := pc.DescribeIndex(ctx, "movie-recommendations")
if err != nil {
log.Fatalf("Failed to describe index \"%v\": %v", idx.Name, err)
} else {
fmt.Printf("index: %v\n", prettifyStruct(idx))
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
var indexModel = await pinecone.DescribeIndexAsync("example-index");
Console.WriteLine(indexModel);
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -i -X GET "https://api.pinecone.io/indexes/movie-recommendations" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# List collections
control_2025-01 get /collections
This operation returns a list of all collections in a project.
Serverless indexes do not support collections.
{/* ```python Python
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key='YOUR_API_KEY')
active_collections = pc.list_collections()
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
await pc.listCollections();
```
```java Java
import io.pinecone.clients.Pinecone;
import org.openapitools.client.model.CollectionModel;
public class ListCollectionsExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
List collectionList = pc.listCollections().getCollections();
System.out.println(collectionList);
}
}
```
```go Go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func prettifyStruct(obj interface{}) string {
bytes, _ := json.MarshalIndent(obj, "", " ")
return string(bytes)
}
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
collections, err := pc.ListCollections(ctx)
if err != nil {
log.Fatalf("Failed to list collections: %v", err)
} else {
if len(collections) == 0 {
fmt.Printf("No collections found in project")
} else {
for _, collection := range collections {
fmt.Printf("collection: %v\n", prettifyStruct(collection))
}
}
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
var collectionList = await pinecone.ListCollectionsAsync();
Console.WriteLine(collectionList);
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl -i -X GET "https://api.pinecone.io/collections" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# List indexes
control_2025-01 get /indexes
This operation returns a list of all indexes in a project.
{/* ```python Python
{'indexes': [{'deletion_protection': 'disabled',
'dimension': 1536,
'host': 'example-index1-4mkljsz.svc.aped-4627-b74a.pinecone.io',
'metric': 'cosine',
'name': 'example-index1',
'spec': {'serverless': {'cloud': 'aws', 'region': 'us-east-1'}},
'status': {'ready': True, 'state': 'Ready'}},
{'deletion_protection': 'disabled',
'dimension': 1536,
'host': 'example-index2-4mkljsz.svc.us-east-1-aws.pinecone.io',
'metric': 'cosine',
'name': 'example-index2',
'spec': {'pod': {'environment': 'us-east-1-aws',
'pod_type': 'p1.x1',
'pods': 1,
'replicas': 1,
'shards': 1}},
'status': {'ready': True, 'state': 'Ready'}}]}
```
```javascript JavaScript
{
"indexes":[
{
name: 'example-index1',
dimension: 1536,
metric: 'cosine',
host: 'example-index1-govk0nt.svc.aped-4627-b74a.pinecone.io',
deletionProtection: 'disabled',
tags: { environment: 'development', example: 'tag' },
spec: { pod: undefined, serverless: [Object] },
status: { ready: true, state: 'Ready' }
},
{
name: 'example-index2',
dimension: 1536,
metric: 'cosine',
host: 'example-index2-govk0nt.svc.aped-4627-b74a.pinecone.io',
deletionProtection: 'disabled',
tags: { environment: 'production', example: 'tag2' },
spec: { pod: undefined, serverless: [Object] },
status: { ready: true, state: 'Ready' }
}
]
}
```
```java Java
class IndexList {
indexes: [class IndexModel {
name: example-index1
dimension: 1536
metric: cosine
host: example-index1-4mkljsz.svc.aped-4627-b74a.pinecone.io
deletionProtection: disabled
spec: class IndexModelSpec {
pod: null
serverless: class ServerlessSpec {
cloud: aws
region: us-east-1
}
}
status: class IndexModelStatus {
ready: true
state: Ready
}
}, class IndexModel {
name: example-index2
dimension: 1536
metric: cosine
host: example-index2-4mkljsz.svc.us-east-1-aws.pinecone.io
spec: class IndexModelSpec {
pod: class PodSpec {
environment: us-east-1-aws
replicas: 1
shards: 1
podType: p1.x1
pods: 1
metadataConfig: null
sourceCollection: null
}
serverless: null
}
status: class IndexModelStatus {
ready: true
state: Ready
}]
}
```
```go Go
index: {
"name": "example-index2",
"dimension": 1536,
"host": "example-index2-govk0nt.svc.aped-4627-b74a.pinecone.io",
"metric": "cosine",
"deletion_protection": "disabled",
"spec": {
"serverless": {
"cloud": "aws",
"region": "us-east-1"
}
},
"status": {
"ready": true,
"state": "Ready"
},
"tags": {
"environment": "production",
"example": "tag2"
}
}
index: {
"name": "example-index1",
"dimension": 1536,
"host": "example-index1-govk0nt.svc.aped-4627-b74a.pinecone.io",
"metric": "cosine",
"deletion_protection": "disabled",
"spec": {
"serverless": {
"cloud": "aws",
"region": "us-east-1"
}
},
"status": {
"ready": true,
"state": "Ready"
},
"tags": {
"environment": "development",
"example": "tag"
}
}
```
```csharp C#
{
"indexes": [
{
"name": "example-index1",
"dimension": 1536,
"metric": "cosine",
"host": "example-index1-4mkljsz.svc.aped-4627-b74a.pinecone.io",
"deletion_protection": "disabled",
"spec": {
"pod": null,
"serverless": {
"cloud": "aws",
"region": "us-east-1"
}
},
"status": {
"ready": true,
"state": "Ready"
}
},
{
"name": "example-index2",
"dimension": 1536,
"metric": "cosine",
"host": "example-index2-4mkljsz.svc.us-east-1-aws.pinecone.io",
"deletion_protection": "disabled",
"spec": {
"pod": {
"environment": "us-east-1-aws",
"replicas": 1,
"shards": 1,
"pod_type": "p1.x1",
"pods": 1,
"metadata_config": null,
"source_collection": null
},
"serverless": null
},
"status": {
"ready": true,
"state": "Ready"
}
}
]
}
``` */}
```json curl
{
"indexes": [
{
"name": "example-index1",
"metric": "cosine",
"dimension": 1536,
"status": {
"ready": true,
"state": "Ready"
},
"host": "example-index1-4mkljsz.svc.aped-4627-b74a.pinecone.io",
"spec": {
"serverless": {
"region": "us-east-1",
"cloud": "aws"
}
}
},
{
"name": "example-index2",
"metric": "cosine",
"dimension": 1536,
"status": {
"ready": true,
"state": "Ready"
},
"host": "example-index2-4mkljsz.svc.us-east-1-aws.pinecone.io",
"spec": {
"pod": {
"replicas": 1,
"shards": 1,
"pods": 1,
"pod_type": "p1.x1",
"environment": "us-east-1-aws"
}
}
}
]
}
```
# Cancel an import
data_2025-01 delete /bulk/imports/{id}
Cancel an import operation if it is not yet finished. It has no effect if the operation is already finished.
For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
This feature is in [public preview](/release-notes/feature-availability) and available only on [Standard and Enterprise plans](https://www.pinecone.io/pricing/).
```bash curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X DELETE "https://{INDEX_HOST}/bulk/imports/101" \
-H 'Api-Key: $YOUR_API_KEY' \
-H "X-Pinecone-API-Version: 2025-01"
```
# Delete vectors
data_2025-01 post /vectors/delete
Delete vectors, by id, from a single namespace.
For guidance and examples, see [Delete data](https://docs.pinecone.io/guides/data/delete-data).
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
index.delete(ids=["id-1", "id-2"], namespace="example-namespace")
```
```javascript JavaScript
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
const ns = index.namespace('example-namespace')
// Delete one record by ID.
await ns.deleteOne('id-1');
// Delete more than one record by ID.
await ns.deleteMany(['id-2', 'id-3']);
```
```java Java
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import java.util.Arrays;
import java.util.List;
public class DeleteVectorsExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
List ids = Arrays.asList("id-1 ", "id-2");
index.deleteByIds(ids, "example-namespace");
}
}
```
```go Go
package main
import (
"context"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
id1 := "id-1"
id2 := "id-2"
err = idxConnection.DeleteVectorsByID(ctx, []string{id1, id2})
if err != nil {
log.Fatalf("Failed to delete vector with ID %v: %v", id, err)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var deleteResponse = await index.DeleteAsync(new DeleteRequest {
Ids = new List { "id-1", "id-2" },
Namespace = "example-namespace",
});
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/vectors/delete" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"ids": [
"id-1",
"id-2"
],
"namespace": "example-namespace"
}
'
```
# Describe an import
data_2024-10 get /bulk/imports/{id}
The `describe_import` operation returns details of a specific import operation.
For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
This feature is in [public preview](/release-notes/feature-availability) and available only on [Standard and Enterprise plans](https://www.pinecone.io/pricing/).
```bash curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X GET "https://{INDEX_HOST}/bulk/imports/101" \
-H 'Api-Key: $YOUR_API_KEY' \
-H 'X-Pinecone-API-Version: 2025-01'
```
# Get index stats
data_2025-01 post /describe_index_stats
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.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
index.describe_index_stats()
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
const stats = await index.describeIndexStats();
```
```java Java
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.proto.DescribeIndexStatsResponse;
public class DescribeIndexStatsExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
DescribeIndexStatsResponse indexStatsResponse = index.describeIndexStats();
System.out.println(indexStatsResponse);
}
}
```
```go Go
package main
import (
"context"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
stats, err := idxConnection.DescribeIndexStats(ctx)
if err != nil {
log.Fatalf("Failed to describe index \"%v\": %v", idx.Name, err)
} else {
fmt.Printf("%+v", *stats)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var indexStatsResponse = await index.DescribeIndexStatsAsync(new DescribeIndexStatsRequest());
Console.WriteLine(indexStatsResponse);
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X POST "https://$INDEX_HOST/describe_index_stats" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
{/* ```Python Python
{'dimension': 1024,
'index_fullness': 8e-05,
'namespaces': {'example-namespace1': {'vector_count': 4}, 'example-namespace2': {'vector_count': 4}},
'total_vector_count': 8}
```
```JavaScript JavaScript
Returns:
{
namespaces: { example-namespace1: { recordCount: 4 }, example-namespace2: { recordCount: 4 } },
dimension: 1024,
indexFullness: 0.00008,
totalRecordCount: 8
}
// Note: the value of totalRecordCount is the same as total_vector_count.
```
```java Java
namespaces {
key: "example-namespace1"
value {
vector_count: 4
}
}
namespaces {
key: "example-namespace2"
value {
vector_count: 4
}
}
dimension: 1024
total_vector_count: 8
```
```go Go
{
"dimension": 1024,
"index_fullness": 0,
"total_vector_count": 8,
"namespaces": {
"example-namespace1": {
"vector_count": 4
},
"example-namespace2": {
"vector_count": 4
}
}
}
```
```csharp C#
{
"namespaces": {
"example-namespace1": {
"vectorCount": 4
},
"example-namespace2": {
"vectorCount": 4
}
},
"dimension": 1024,
"indexFullness": 0,
"totalVectorCount": 8
}
``` */}
```shell curl
{
"namespaces": {
"example-namespace1": {
"vectorCount": 4
},
"example-namespace2": {
"vectorCount": 4
}
},
"dimension": 1024,
"indexFullness": 0.00008,
"totalVectorCount": 8
}
```
# Fetch vectors
data_2025-01 get /vectors/fetch
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/data/fetch-data).
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
index.fetch(ids=["id-1", "id-2"], namespace="example-namespace")
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
const fetchResult = await index.namespace('example-namespace').fetch(['id-1', 'id-2']);
```
```java Java
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.proto.FetchResponse;
import java.util.Arrays;
import java.util.List;
public class FetchExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
List ids = Arrays.asList("id-1", "id-2");
FetchResponse fetchResponse = index.fetch(ids, "example-namespace");
System.out.println(fetchResponse);
}
}
```
```go Go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func prettifyStruct(obj interface{}) string {
bytes, _ := json.MarshalIndent(obj, "", " ")
return string(bytes)
}
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
res, err := idxConnection.FetchVectors(ctx, []string{"id-1", "id-2"})
if err != nil {
log.Fatalf("Failed to fetch vectors: %+v", err)
} else {
fmt.Printf(prettifyStruct(res))
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var fetchResponse = await index.FetchAsync(new FetchRequest {
Ids = new List { "id-1", "id-2" },
Namespace = "example-namespace",
});
Console.WriteLine(fetchResponse);
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X GET "https://$INDEX_HOST/vectors/fetch?ids=id-1&ids=id-2&namespace=example-namespace" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
{/*
```shell
{
"vectors": {
"id-1": {
"id": "id-1",
"values": [0.568879, 0.632687092, 0.856837332, ...]
},
"id-2": {
"id": "id-2",
"values": [0.00891787093, 0.581895, 0.315718859, ...]
}
},
"namespace": "example-namespace"
"usage": {"readUnits": 1},
}
```
*/}
# List vector IDs
data_2025-01 get /vectors/list
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.
This 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/data/list-record-ids).
**Note:** `list` is supported only for serverless indexes.
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key='YOUR_API_KEY')
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
# To iterate over all result pages using a generator function
for ids in index.list(prefix="document1#", namespace="example-namespace"):
print(ids)
# For manual control over pagination
results = index.list_paginated(
prefix="document1#",
limit=3,
namespace="example-namespace",
pagination_token="eyJza2lwX3Bhc3QiOiIxMDEwMy0="
)
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST").namespace("example-namespace");
const results = await index.listPaginated({ prefix: 'document1#' });
console.log(results);
// Fetch the next page of results
await index.listPaginated({ prefix: 'document1#', paginationToken: results.pagination.next});
```
```java Java
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.proto.ListResponse;
public class ListExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
ListResponse listResponse = index.list("example-namespace", "document1#");
System.out.println(listResponse);
}
}
```
```go Go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func prettifyStruct(obj interface{}) string {
bytes, _ := json.MarshalIndent(obj, "", " ")
return string(bytes)
}
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
limit := uint32(3)
prefix := "document1#"
res, err := idxConnection.ListVectors(ctx, &pinecone.ListVectorsRequest{
Limit: &limit,
Prefix: &prefix,
})
if len(res.VectorIds) == 0 {
fmt.Println("No vectors found")
} else {
fmt.Printf(prettifyStruct(res))
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var listResponse = await index.ListAsync(new ListRequest {
Namespace = "example-namespace",
Prefix = "document1#",
});
Console.WriteLine(listResponse);
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X GET "https://$INDEX_HOST/vectors/list?namespace=example-namespace&prefix=document1#" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# List imports
data_2025-01 get /bulk/imports
List all recent and ongoing import operations.
By default, this returns up to 100 imports per page. If the `limit` parameter is set, `list` returns up to that number of imports 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 imports. When the response does not include a `pagination_token`, there are no more imports to return.
For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
This feature is in [public preview](/release-notes/feature-availability) and available only on [Standard and Enterprise plans](https://www.pinecone.io/pricing/).
{/* ```python Python
from pinecone import Pinecone, ImportErrorMode
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
# List using a generator that handles pagination
for i in index.list_imports():
print(f"id: {i.id} status: {i.status}")
# List using a generator that fetches all results at once
operations = list(index.list_imports())
print(operations)
```
```javascript JavaScript
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
const results = await index.listImports();
console.log(results);
// Fetch the next page of results
const results = await index.listImports({ paginationToken: 'Tm90aGluZyB0byBzZWUgaGVyZQo' });
```
```java Java
import io.pinecone.clients.Pinecone;
import io.pinecone.clients.AsyncIndex;
import org.openapitools.db_data.client.ApiException;
import org.openapitools.db_data.client.model.ListImportsResponse;
public class ListImports {
public static void main(String[] args) throws ApiException {
// Initialize a Pinecone client with your API key
Pinecone pinecone = new Pinecone.Builder("YOUR_API_KEY").build();
// Get async imports connection object
AsyncIndex asyncIndex = pinecone.getAsyncIndexConnection("example-index");
// List imports
ListImportsResponse response = asyncIndex.listImports(10, "Tm90aGluZyB0byBzZWUgaGVyZQo");
System.out.println(response);
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
limit := int32(10)
firstImportPage, err := idxConnection.ListImports(ctx, &limit, nil)
if err != nil {
log.Fatalf("Failed to list imports: %v", err)
}
fmt.Printf("First page of imports: %+v", firstImportPage.Imports)
paginationToken := firstImportPage.NextPaginationToken
nextImportPage, err := idxConnection.ListImports(ctx, &limit, paginationToken)
if err != nil {
log.Fatalf("Failed to list imports: %v", err)
}
fmt.Printf("Second page of imports: %+v", nextImportPage.Imports)
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var imports = await index.ListBulkImportsAsync(new ListBulkImportsRequest
{
Limit = 10,
PaginationToken = "Tm90aGluZyB0byBzZWUgaGVyZQo"
});
``` */}
```bash curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl -X GET "https://$INDEX_HOST/bulk/imports?paginationToken==Tm90aGluZyB0byBzZWUgaGVyZQo" \
-H "Api-Key: $YOUR_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01"
```
# Query vectors
data_2025-01 post /query
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 and examples, see [Query data](https://docs.pinecone.io/guides/data/query-data).
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
index.query(
namespace="example-namespace",
vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
filter={
"genre": {"$eq": "documentary"}
},
top_k=3,
include_values=True
)
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
const queryResponse = await index.namespace('example-namespace').query({
vector: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
filter: {
'genre': {'$eq': 'documentary'}
},
topK: 3,
includeValues: true
});
```
```java Java
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.unsigned_indices_model.QueryResponseWithUnsignedIndices;
import java.util.Arrays;
import java.util.List;
public class QueryExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
List query = Arrays.asList(0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f);
Struct filter = Struct.newBuilder()
.putFields("genre", Value.newBuilder()
.setStructValue(Struct.newBuilder()
.putFields("$eq", Value.newBuilder()
.setStringValue("documentary")
.build()))
.build())
.build();
QueryResponseWithUnsignedIndices queryResponse = index.query(3, query, null, null, null, "example-namespace", filter, false, true);
System.out.println(queryResponse);
}
}
```
```go Go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
)
func prettifyStruct(obj interface{}) string {
bytes, _ := json.MarshalIndent(obj, "", " ")
return string(bytes)
}
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
queryVector := []float32{0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3}
metadataMap := map[string]interface{}{
"genre": map[string]interface{}{
"$eq": "documentary",
},
}
metadataFilter, err := structpb.NewStruct(metadataMap)
if err != nil {
log.Fatalf("Failed to create metadata map: %v", err)
}
res, err := idxConnection.QueryByVectorValues(ctx, &pinecone.QueryByVectorValuesRequest{
Vector: queryVector,
TopK: 3,
MetadataFilter: metadataFilter,
IncludeValues: true,
})
if err != nil {
log.Fatalf("Error encountered when querying by vector: %v", err)
} else {
fmt.Printf(prettifyStruct(res))
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var queryResponse = await index.QueryAsync(new QueryRequest {
Vector = new[] { 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f },
Namespace = "example-namespace",
TopK = 3,
Filter = new Metadata
{
["genre"] =
new Metadata
{
["$eq"] = "documentary",
}
}
});
Console.WriteLine(queryResponse);
``` */}
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/query" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"namespace": "example-namespace",
"vector": [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
"filter": {"genre": {"$eq": "documentary"}},
"topK": 3,
"includeValues": true
}'
```
```shell
{
"matches":[
{
"id": "vec3",
"score": 0,
"values": [0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3]
},
{
"id": "vec2",
"score": 0.0800000429,
"values": [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
},
{
"id": "vec4",
"score": 0.0799999237,
"values": [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]
}
],
"namespace": "example-namespace",
"usage": {"read_units": 6}
}
```
# Search a namespace
data_2025-01 post /records/namespaces/{namespace}/search
This operation converts a query to a vector embedding and then searches a namespace using the embedding. It returns the most similar records in the namespace, along with their similarity scores.
```python Python
# pip install --upgrade pinecone pinecone-plugin-records
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("example-index")
ranked_results = index.search_records(
namespace="example-namespace",
query={
"inputs": {"text": "Disease prevention"},
"top_k": 4
},
rerank={
"model": "pinecone-rerank-v0",
"top_n": 2,
"rank_fields": ["chunk_text"]
},
"fields": ["category", "chunk_text"]
)
print(ranked_results)
```
```shell curl
INDEX_HOST="INDEX_HOST"
NAMESPACE="YOUR_NAMESPACE"
PINECONE_API_KEY="YOUR_API_KEY"
curl "https://$INDEX_HOST/records/namespaces/$NAMESPACE/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"query": {
"inputs": {"text": "Disease prevention"},
"top_k": 4,
},
"rerank": {
"model": "pinecone-rerank-v0",
"top_n": 2,
"rank_fields": ["chunk_text"]
},
"fields": ["category", "chunk_text"]
}'
```
```python Python
{'result': {'hits': [{'_id': 'rec6',
'_score': 0.004433765076100826,
'fields': {'category': 'nutrition',
'chunk_text': 'Rich in vitamin C and other '
'antioxidants, apples '
'contribute to immune health '
'and may reduce the risk of '
'chronic diseases.'}},
{'_id': 'rec8',
'_score': 0.0029121784027665854,
'fields': {'category': 'nutrition',
'chunk_text': 'The high fiber content in '
'apples can also help regulate '
'blood sugar levels, making '
'them a favorable snack for '
'people with diabetes.'}}]},
'usage': {'embed_total_tokens': 8, 'read_units': 6, 'rerank_units': 1}}
```
```json curl
{
"result": {
"hits": [
{
"_id": "rec6",
"_score": 0.004433765076100826,
"fields": {
"category": "nutrition",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases."
}
},
{
"_id": "rec8",
"_score": 0.0029121784027665854,
"fields": {
"category": "nutrition",
"chunk_text": "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes."
}
}
]
},
"usage": {
"embed_total_tokens": 8,
"read_units": 6,
"rerank_units": 1
}
}
```
# Start import
data_2025-01 post /bulk/imports
Start an asynchronous import of vectors from object storage into an index.
For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
This feature is in [public preview](/release-notes/feature-availability) and available only on [Standard and Enterprise plans](https://www.pinecone.io/pricing/).
```bash curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/bulk/imports" \
-H 'Api-Key: $YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'X-Pinecone-API-Version: 2025-01' \
-d '{
"integrationId": "a12b3d4c-47d2-492c-a97a-dd98c8dbefde",
"uri": "s3://BUCKET_NAME/PATH/TO/DIR",
"errorMode": {
"onError": "continue"
}
}'
```
# Update a vector
data_2025-01 post /vectors/update
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/data/update-data).
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
index.update(
id="id-3",
values=[4.0, 2.0],
set_metadata={"genre": "comedy"},
namespace="example-namespace"
)
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
await index.namespace('example-namespace').update({
id: 'id-3',
values: [4.0, 2.0],
metadata: {
genre: "comedy",
},
});
```
```java Java
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.proto.UpdateResponse;
import java.util.Arrays;
import java.util.List;
public class UpdateExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
List values = Arrays.asList(4.0f, 2.0f);
Struct metaData = Struct.newBuilder()
.putFields("genre",
Value.newBuilder().setStringValue("comedy").build())
.build();
UpdateResponse updateResponse = index.update("id-3", values, metaData, "example-namespace", null, null);
System.out.println(updateResponse);
}
}
```
```go Go
package main
import (
"context"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
id := "id-3"
metadataMap := map[string]interface{}{
"genre": "comedy",
}
metadataFilter, err := structpb.NewStruct(metadataMap)
if err != nil {
log.Fatalf("Failed to create metadata map: %v", err)
}
err = idxConnection.UpdateVector(ctx, &pinecone.UpdateVectorRequest{
Id: id,
Metadata: metadataFilter,
})
if err != nil {
log.Fatalf("Failed to update vector with ID %v: %v", id, err)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var updateResponse = await index.UpdateAsync(new UpdateRequest {
Id = "id-3",
Values = new[] { 4.0f, 2.0f },
SetMetadata = new Metadata { ["genre"] = "comedy" },
Namespace = "example-namespace",
});
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/vectors/update" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"id": "id-3",
"values": [4.0, 2.0],
"setMetadata": {"type": "comedy"},
"namespace": "example-namespace"
}'
```
# Upsert vectors
data_2025-01 post /vectors/upsert
Write vectors into a namespace. If a new value is upserted for an existing vector ID, it will overwrite the previous value.
For guidance and examples, see [Upsert data](https://docs.pinecone.io/guides/data/upsert-data).
{/* ```python Python
# pip install pinecone[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")
upsert_response = index.upsert(
vectors=[
{
"id": "vec1",
"values": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"sparse_values": {
"indices": [1, 5],
"values": [0.5, 0.5]
},
"metadata": {
"genre": "drama"
}
},
{
"id": "vec2",
"values": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
"sparse_values": {
"indices": [5, 6],
"values": [0.4, 0.5]
},
"metadata": {
"genre": "action"
}
}
],
namespace="example-namespace"
)
```
```javascript JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
const index = pc.index("INDEX_NAME", "INDEX_HOST")
await index.namespace('example-namespace').upsert([
{
id: 'vec1',
values: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
sparseValues: {
indices: [1, 5],
values: [0.5, 0.5]
},
metadata: {'genre': 'drama'},
},
{
id: 'vec2',
values: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
metadata: {'genre': 'action'},
sparseValues: {
indices: [5, 6],
values: [0.4, 0.5]
}
}
])
```
```java Java
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import java.util.Arrays;
import java.util.List;
public class UpsertExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
config.setHost("INDEX_HOST");
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "INDEX_NAME");
List values1 = Arrays.asList(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f);
List values2 = Arrays.asList(0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f);
Struct metaData1 = Struct.newBuilder()
.putFields("genre", Value.newBuilder().setStringValue("drama").build())
.build();
Struct metaData2 = Struct.newBuilder()
.putFields("genre", Value.newBuilder().setStringValue("action").build())
.build();
index.upsert("A", values1, null, null, metaData1, null);
index.upsert("B", values2, null, null, metaData2, null);
}
}
```
```go Go
package main
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST"})
if err != nil {
log.Fatalf("Failed to create IndexConnection for Host: %v", err)
}
sparseValues1 := pinecone.SparseValues{
Indices: []uint32{1, 5},
Values: []float32{0.5, 0.5},
}
sparseValues2 := pinecone.SparseValues{
Indices: []uint32{5, 6},
Values: []float32{0.4, 0.5},
}
metadataMap1 := map[string]interface{}{
"genre": "comedy",
"year": 2020,
}
metadata1, err := structpb.NewStruct(metadataMap1)
if err != nil {
log.Fatalf("Failed to create metadata map: %v", err)
}
metadataMap2 := map[string]interface{}{
"genre": "documentary",
"year": 2019,
}
metadata2, err := structpb.NewStruct(metadataMap2)
if err != nil {
log.Fatalf("Failed to create metadata map: %v", err)
}
vectors := []*pinecone.Vector{
{
Id: "vec1",
Values: []float32{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8},
SparseValues: &sparseValues1,
Metadata: metadata1,
},
{
Id: "vec2",
Values: []float32{0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9},
SparseValues: &sparseValues2,
Metadata: metadata2,
},
}
count, err := idxConnection.UpsertVectors(ctx, vectors)
if err != nil {
log.Fatalf("Failed to upsert vectors: %v", err)
} else {
fmt.Printf("Successfully upserted %d vector(s)!\n", count)
}
}
```
```csharp C#
using Pinecone;
var pinecone = new PineconeClient("YOUR_API_KEY");
// To get the unique host for an index,
// see https://docs.pinecone.io/guides/data/target-an-index
var index = pinecone.Index(host: "INDEX_HOST");
var upsertResponse = await index.UpsertAsync(new UpsertRequest {
Vectors = new[]
{
new Vector
{
Id = "vec1",
Values = new[] { 1.0f, 1.5f },
SparseValues = new SparseValues
{
Indices = [1, 5],
Values = new[] { 0.5f, 0.5f },
},
Metadata = new Metadata {
["genre"] = new("comedy"),
["year"] = new(2020),
}
},
new Vector
{
Id = "vec2",
Values = new[] { 2.0f, 1.0f },
SparseValues = new SparseValues
{
Indices = [5, 6],
Values = new[] { 0.4f, 0.5f },
},
Metadata = new Metadata {
["genre"] = new("documentary"),
["year"] = new(2019),
},
}
},
Namespace = "example-namespace",
});
``` */}
```shell curl
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/data/target-an-index
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/vectors/upsert" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"vectors": [
{
"id": "vec1",
"values": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"sparseValues": {
"indices": [2, 7],
"values": [0.4, 0.5]
},
"metadata": {
"genre": "drama"
}
},
{
"id": "vec2",
"values": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
"sparseValues": {
"indices": [1, 4],
"values": [0.1, 0.2]
},
"metadata": {
"genre": "action"
}
}
],
"namespace": "example-namespace"
}'
```
# Upsert records into a namespace
data_2025-01 post /records/namespaces/{namespace}/upsert
This operation converts input data to vector embeddings and then upserts the embeddings into a namespace.
```python Python
# pip install --upgrade pinecone pinecone-plugin-records
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("example-index")
index.upsert_records(
"example-namespace",
[
{
"_id": "rec1",
"chunk_text": "Apple's first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.",
"category": "product",
},
{
"_id": "rec2",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "nutrition",
},
{
"_id": "rec3",
"chunk_text": "Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.",
"category": "cultivation",
},
{
"_id": "rec4",
"chunk_text": "In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.",
"category": "product",
},
{
"_id": "rec5",
"chunk_text": "Apple went public in 1980, making history with one of the largest IPOs at that time.",
"category": "milestone",
},
{
"_id": "rec6",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "nutrition",
},
{
"_id": "rec7",
"chunk_text": "Known for its design-forward products, Apple's branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.",
"category": "influence",
},
{
"_id": "rec8",
"chunk_text": "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.",
"category": "nutrition",
},
],
)
```
```shell curl
INDEX_HOST="INDEX_HOST"
NAMESPACE="YOUR_NAMESPACE"
PINECONE_API_KEY="YOUR_API_KEY"
curl "https://$INDEX_HOST/records/namespaces/$NAMESPACE/upsert" \
-H "Content-Type: application/x-ndjson" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{"_id": "rec1", "chunk_text": "Apple'\''s first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.", "category": "product"}
{"_id": "rec2", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "nutrition"}
{"_id": "rec3", "chunk_text": "Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.", "category": "cultivation"}
{"_id": "rec4", "chunk_text": "In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.", "category": "product"}
{"_id": "rec5", "chunk_text": "Apple went public in 1980, making history with one of the largest IPOs at that time.", "category": "milestone"}
{"_id": "rec6", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "nutrition"}
{"_id": "rec7", "chunk_text": "Known for its design-forward products, Apple'\''s branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.", "category": "influence"}
{"_id": "rec8", "chunk_text": "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.", "category": "nutrition"}'
```
# Embed data
inference_2025-01 post /embed
Generate embeddings for input data.
For guidance and examples, see [Generate embeddings](https://docs.pinecone.io/guides/inference/generate-embeddings).
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl https://api.pinecone.io/embed \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-d '{
"model": "multilingual-e5-large",
"parameters": {
"input_type": "passage",
"truncate": "END"
},
"inputs": [
{"text": "Apple is a popular fruit known for its sweetness and crisp texture."},
{"text": "The tech company Apple is known for its innovative products like the iPhone."},
{"text": "Many people enjoy eating apples as a healthy snack."},
{"text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
{"text": "An apple a day keeps the doctor away, as the saying goes."},
{"text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."}
]
}'
```
```json curl
{
"data": [
{
"values": [
0.04925537109375,
-0.01313018798828125,
-0.0112762451171875,
...
]
},
...
],
"model": "multilingual-e5-large",
"usage": {
"total_tokens": 130
}
}
```
# Rerank documents
inference_2025-01 post /rerank
Rerank documents according to their relevance to a query.
For guidance and examples, see [Rerank documents](https://docs.pinecone.io/guides/inference/rerank).
```shell curl
PINECONE_API_KEY="YOUR_API_KEY"
curl https://api.pinecone.io/rerank \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Pinecone-API-Version: 2025-01" \
-H "Api-Key: $PINECONE_API_KEY" \
-d '{
"model": "bge-reranker-v2-m3",
"query": "The tech company Apple is known for its innovative products like the iPhone.",
"return_documents": true,
"top_n": 4,
"documents": [
{"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."},
{"id": "vec2", "text": "Many people enjoy eating apples as a healthy snack."},
{"id": "vec3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
{"id": "vec4", "text": "An apple a day keeps the doctor away, as the saying goes."}
],
"parameters": {
"truncate": "END"
}
}'
```
```JSON curl
{
"data":[
{
"index":2,
"document":{
"id":"vec3",
"text":"Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."
},
"score":0.47654688
},
{
"index":0,
"document":{
"id":"vec1",
"text":"Apple is a popular fruit known for its sweetness and crisp texture."
},
"score":0.047963805
},
{
"index":3,
"document":{
"id":"vec4",
"text":"An apple a day keeps the doctor away, as the saying goes."
},
"score":0.007587992
},
{
"index":1,
"document":{
"id":"vec2",
"text":"Many people enjoy eating apples as a healthy snack."
},
"score":0.0006491712
}
],
"usage":{
"rerank_units":1
}
}
```