# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
# To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.index(host="INDEX_HOST")
index.upsert_records(
namespace="example-namespace",
records=[
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
],
)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
// To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
const index = pc.index({
host: 'INDEX_HOST',
namespace: 'example-namespace',
});
await index.upsertRecords({
records: [
{
_id: 'rec1',
chunk_text:
'Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.',
category: 'digestive system',
},
{
_id: 'rec2',
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: 'rec3',
chunk_text:
'Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.',
category: 'immune system',
},
{
_id: 'rec4',
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: 'endocrine system',
},
],
});
package main
import (
"context"
"log"
"os"
"github.com/pinecone-io/go-pinecone/v7/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: os.Getenv("PINECONE_API_KEY"),
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the host for an index, see https://docs.pinecone.io/guides/manage-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: %v", err)
}
records := []*pinecone.IntegratedRecord{
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
}
err = idxConnection.UpsertRecords(ctx, records)
if err != nil {
log.Fatalf("Failed to upsert records: %v", err)
}
}
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
INDEX_HOST="INDEX_HOST"
NAMESPACE="YOUR_NAMESPACE"
PINECONE_API_KEY="YOUR_API_KEY"
# Upsert records into a namespace
# `chunk_text` fields are converted to dense vectors
# `category` fields are stored as metadata
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: 2026-07" \
-d '{"_id": "rec1", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "digestive system"}
{"_id": "rec2", "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": "rec3", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "immune system"}
{"_id": "rec4", "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": "endocrine system"}'
{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}Unauthorized{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}Upsert text (legacy Records API)
Upsert text into a namespace. Pinecone converts the text to vectors automatically using the hosted embedding model associated with the index.
This operation is part of the legacy Records API, which legacy integrated indexes require. For new work, create a document index with a string field that uses integrated embedding (embed or sparse_embed), and write text with the Documents API’s upsert_documents operation.
Upserting text is supported only for legacy integrated indexes; for any other index the request is rejected with 400. It is not available on BYOC indexes.
A request can contain at most 1000 records. Each record is identified by _id. The service also accepts id as an alias, which this schema does not model; a record must not carry both.
For guidance, examples, and limits, see Upsert data.
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
# To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.index(host="INDEX_HOST")
index.upsert_records(
namespace="example-namespace",
records=[
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
],
)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
// To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
const index = pc.index({
host: 'INDEX_HOST',
namespace: 'example-namespace',
});
await index.upsertRecords({
records: [
{
_id: 'rec1',
chunk_text:
'Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.',
category: 'digestive system',
},
{
_id: 'rec2',
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: 'rec3',
chunk_text:
'Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.',
category: 'immune system',
},
{
_id: 'rec4',
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: 'endocrine system',
},
],
});
package main
import (
"context"
"log"
"os"
"github.com/pinecone-io/go-pinecone/v7/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: os.Getenv("PINECONE_API_KEY"),
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the host for an index, see https://docs.pinecone.io/guides/manage-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: %v", err)
}
records := []*pinecone.IntegratedRecord{
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
}
err = idxConnection.UpsertRecords(ctx, records)
if err != nil {
log.Fatalf("Failed to upsert records: %v", err)
}
}
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
INDEX_HOST="INDEX_HOST"
NAMESPACE="YOUR_NAMESPACE"
PINECONE_API_KEY="YOUR_API_KEY"
# Upsert records into a namespace
# `chunk_text` fields are converted to dense vectors
# `category` fields are stored as metadata
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: 2026-07" \
-d '{"_id": "rec1", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "digestive system"}
{"_id": "rec2", "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": "rec3", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "immune system"}
{"_id": "rec4", "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": "endocrine system"}'
{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}Unauthorized{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "No 'ids' or 'filter' provided in the document fetch request. Provide at least one document ID in 'ids', or a metadata filter in 'filter'."
},
"status": 400
}# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
# To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.index(host="INDEX_HOST")
index.upsert_records(
namespace="example-namespace",
records=[
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
],
)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
// To get the host for an index, see https://docs.pinecone.io/guides/manage-data/target-an-index
const index = pc.index({
host: 'INDEX_HOST',
namespace: 'example-namespace',
});
await index.upsertRecords({
records: [
{
_id: 'rec1',
chunk_text:
'Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.',
category: 'digestive system',
},
{
_id: 'rec2',
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: 'rec3',
chunk_text:
'Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.',
category: 'immune system',
},
{
_id: 'rec4',
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: 'endocrine system',
},
],
});
package main
import (
"context"
"log"
"os"
"github.com/pinecone-io/go-pinecone/v7/pinecone"
)
func main() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: os.Getenv("PINECONE_API_KEY"),
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// To get the host for an index, see https://docs.pinecone.io/guides/manage-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: %v", err)
}
records := []*pinecone.IntegratedRecord{
{
"_id": "rec1",
"chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.",
"category": "digestive system",
},
{
"_id": "rec2",
"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": "rec3",
"chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.",
"category": "immune system",
},
{
"_id": "rec4",
"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": "endocrine system",
},
}
err = idxConnection.UpsertRecords(ctx, records)
if err != nil {
log.Fatalf("Failed to upsert records: %v", err)
}
}
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
INDEX_HOST="INDEX_HOST"
NAMESPACE="YOUR_NAMESPACE"
PINECONE_API_KEY="YOUR_API_KEY"
# Upsert records into a namespace
# `chunk_text` fields are converted to dense vectors
# `category` fields are stored as metadata
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: 2026-07" \
-d '{"_id": "rec1", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "digestive system"}
{"_id": "rec2", "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": "rec3", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "immune system"}
{"_id": "rec4", "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": "endocrine system"}'
Authorizations
Headers
Required date-based version header
Path Parameters
The namespace to upsert records into.
Body
Each record in the request body must include an _id field and a field that matches your index's field_map configuration (such as chunk_text or data). All other fields are stored as metadata.
The unique ID of the record to upsert. The service also accepts id as an alias, which this schema does not model.
1Response
A successful response.
Was this page helpful?