# Upserting Data with Embedding Models

Upstash Vector provides embedding models that can automatically generate vector embeddings for you.

You can read more about [Embedding Models](/vector/features/embeddingmodels) on our docs.

## Upsert Data

We’ll use the `upsertData()` method to instruct the SDK to upsert data that generates vectors from one of our embedding models, as demonstrated below:

<CodeGroup>
```php simple
use Upstash\Vector\Index;
use Upstash\Vector\DataUpsert;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->upsertData(new DataUpsert(
  id: '1',
  data: 'The capital of Japan is Tokyo',
));
```

```php using namespaces
use Upstash\Vector\Index;
use Upstash\Vector\DataUpsert;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->namespace('my-namespace')->upsertData(new DataUpsert(
  id: '1',
  data: 'The capital of Japan is Tokyo',
));
```
</CodeGroup>

You can also enhance your index by adding metadata, enabling more efficient filtering in the future.

You can read more about [Metadata](/vector/features/metadata#metadata), [Data](/vector/features/metadata#data) and [Metadata Filtering](/vector/features/filtering) on our docs.

## Upsert Data Many

Building on the previous section, Upstash Vector also supports generating multiple vectors at once.

To do this, we’ll use the `upsertDataMany()` method, which enables you to efficiently insert or update multiple vectors in an index, as shown below:

<CodeGroup>
```php simple
use Upstash\Vector\Index;
use Upstash\Vector\DataUpsert;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->upsertDataMany([
  new DataUpsert(id: '1', data: 'The capital of Japan is Tokyo'),
  new DataUpsert(id: '2', data: 'The capital of France is Paris'),
  new DataUpsert(id: '3', data: 'The capital of Germany is Berlin'),
]);
```

```php using namespaces
use Upstash\Vector\Index;
use Upstash\Vector\DataUpsert;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->namespace('my-namespace')->upsertDataMany([
  new DataUpsert(id: '1', data: 'The capital of Japan is Tokyo'),
  new DataUpsert(id: '2', data: 'The capital of France is Paris'),
  new DataUpsert(id: '3', data: 'The capital of Germany is Berlin'),
]);
```
</CodeGroup>

Upserting multiple records simultaneously improves performance by allowing you to batch your upserts efficiently.

<Note>For optimal results, we recommend limiting each batch to no more than 1,000 records at a time.</Note>

## Sparse Indexes & Hybrid Indexes

Sparse and hybrid indexes do not require a different API. They will generate their vectors and sparse vectors 
based on the models you selected when creating your vector index.

You can read more about [Sparse Indexes](/vector/features/sparseindexes) and [Hybrid Indexes](/vector/features/hybridindexes) on our docs.
