# Dataset to Vector DB - Pinecone, Qdrant & pgvector RAG (`gazidev/vector-db-uploader`) Actor

Load Apify datasets, JSON, CSV or Markdown into your own Pinecone, Qdrant or Postgres pgvector (Supabase, Neon). Chunking, metadata, idempotent IDs, delta sync. Free local embeddings or your OpenAI key. Pay per chunk.

- **URL**: https://apify.com/gazidev/vector-db-uploader.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 chunk embedded and upserteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Dataset to Vector DB: load Apify data into Pinecone, Qdrant and pgvector for RAG

**Dataset to Vector DB** turns crawled pages and scraped records into embeddings inside **your own vector database**. Point it at an Apify dataset (for example from Website Content Crawler or [Website to Markdown](https://apify.com/gazidev/website-to-markdown)), a JSON, CSV or Markdown file, or pasted JSON. The Actor then:

1. **chunks** the text (Markdown-aware: headings, paragraphs, sentences, with overlap)
2. **embeds** each chunk, free with a built-in local model or with your own OpenAI-compatible key
3. **upserts** the chunks into **Pinecone**, **Qdrant** or **Postgres pgvector** (Supabase, Neon, RDS, self-hosted) with the metadata you choose
4. **syncs**: deterministic IDs and content hashes, so a re-run only embeds new or changed chunks. It removes orphaned chunks and can delete pages that disappeared from the source.

You do not write glue code, run a LangChain script or keep a server running. It also works as a webhook step after every crawl.

### Who it is for

- **RAG / chatbot builders**: crawl docs or a help centre, then keep the vector index fresh on a schedule.
- **AI agencies**: one reusable pipeline per client: crawler → this Actor → the client's Pinecone, Qdrant or Supabase.
- **Data teams**: embed product catalogues, reviews, tickets or job posts for semantic search and deduplication.
- **Anyone testing embeddings**: use the dry-run target `None` to get chunks and vectors back as a dataset (JSON/CSV) without any database.

### Features

| | |
|---|---|
| Sources | Apify datasets (resource picker, works with `{{resource.defaultDatasetId}}` in integrations), JSON / JSON Lines / CSV / TSV URLs, raw Markdown/text URLs, pasted JSON |
| Targets | Qdrant (Cloud or self-hosted), Pinecone (serverless, namespaces), Postgres + pgvector (Supabase, Neon, RDS, Cloud SQL...), or `None` (dry run to the dataset) |
| Embeddings | **Local, no API key**: `bge-small-en-v1.5` (preloaded), `bge-base-en-v1.5`, `all-MiniLM-L6-v2`, multilingual `paraphrase-multilingual-MiniLM-L12-v2`, `snowflake-arctic-embed-s`, `nomic-embed-text-v1.5`. **API**: any OpenAI-compatible `/embeddings` endpoint (OpenAI, Mistral, Together, LiteLLM, Ollama...) with optional `dimensions` |
| Chunking | Size and overlap in characters, Markdown-aware (code fences kept intact, heading path stored per chunk), minimum chunk length |
| Metadata | Pick fields with dot paths and rename them (`metadata.title:title`). The chunk text is stored as `text`, plus `doc_id`, `chunk_index`, `chunk_count`, `headings`, `content_hash`, `source_tag` |
| Sync | `delta` (default) skips unchanged chunks for free. Orphan chunks are deleted when a page gets shorter. With a source tag, documents missing from the source can be deleted |
| Auto-create | Qdrant collection (cosine), Pinecone serverless index, or Postgres table with an HNSW cosine index, sized to the model's dimension. A dimension mismatch is detected before any write |
| Safety | Credentials are secret (encrypted) inputs. The Actor only reads the dataset you pick (Apify limited permissions). It stops at your max cost per run, and an affordability check happens before embedding |

### Quick start (1 click)

The prefilled input embeds the Crawlee README with the local model and target `None`. You get about 16 chunk rows with vectors in the dataset, and no database is needed. Then switch the target to your database:

```json
{
  "datasetIds": ["<your Website Content Crawler dataset ID>"],
  "textFields": ["markdown", "text"],
  "metadataFields": ["url", "metadata.title:title", "metadata.languageCode:language"],
  "chunkSize": 1000,
  "chunkOverlap": 150,
  "embeddingProvider": "local",
  "localModel": "BAAI/bge-small-en-v1.5",
  "target": "qdrant",
  "qdrantUrl": "https://YOUR-CLUSTER.cloud.qdrant.io:6333",
  "qdrantApiKey": "********",
  "collection": "docs",
  "mode": "delta",
  "sourceTag": "docs-site",
  "deleteMissingDocuments": true
}
```

**Pinecone**: set `target: "pinecone"`, `pineconeApiKey`, `collection` (index name) and optionally `pineconeNamespace`. A missing index is created as serverless (default `aws` / `us-east-1`).
**Supabase / Postgres**: set `target: "pgvector"`, `postgresUrl` (`postgresql://user:pass@host:5432/postgres?sslmode=require`; the pooler string works) and `collection` (table name, optionally `schema.table`).

#### Automate after every crawl

In your crawler task, go to **Integrations → Connect Actor**, choose this Actor and set `"datasetIds": ["{{resource.defaultDatasetId}}"]`. With `mode: "delta"` and a `sourceTag`, each scheduled crawl only pays for chunks that actually changed.

### Output

**Database targets**: one row per document, plus a run summary in the key-value store (`OUTPUT`):

```json
{"docId": "https://docs.example.com/install", "title": "Install", "status": "upserted", "chunks": 6, "upserted": 2, "skippedUnchanged": 4, "deletedOrphans": 1, "error": null, "source": "dataset:abc123"}
```

```json
{"ok": true, "target": "qdrant", "collection": "docs", "model": "BAAI/bge-small-en-v1.5", "dimension": 384, "documents": 240, "chunks": 1310, "upserted": 96, "skippedUnchanged": 1214, "deletedOrphanChunks": 3, "deletedMissingDocVectors": 12, "chargedChunks": 96, "stoppedAtMaxCharge": false}
```

**Dry run (`target: "none"`)**: one row per chunk:

```json
{"id": "a585ecb02426232d7909d1a0-3", "docId": "https://raw.githubusercontent.com/apify/crawlee/master/README.md", "chunkIndex": 3, "chunkCount": 16, "text": "## Installation ...", "headings": ["Crawlee", "Installation"], "metadata": {"url": "...", "title": "..."}, "contentHash": "…", "model": "BAAI/bge-small-en-v1.5", "dimension": 384, "vector": [-0.0493, -0.0132, ...]}
```

#### What is stored in your database

| Target | Layout |
|---|---|
| Qdrant | Point ID = UUIDv5 of the chunk ID, cosine vector, payload = your metadata + `text`, `doc_id`, `chunk_id`, `chunk_index`, `chunk_count`, `headings`, `content_hash`, `source_tag` (keyword indexes on `doc_id`, `source_tag`) |
| Pinecone | ID = `[sourceTag#]<doc-hash>-<n>`, metadata as above (nested values JSON-encoded, text trimmed to stay under 40 KB) |
| pgvector | Table `id text pk, doc_id, chunk_index, chunk_count, content, metadata jsonb, content_hash, source_tag, embedding vector(d), updated_at` + HNSW `vector_cosine_ops` index |

Query with the **same embedding model** you indexed with. For example, in pgvector: `SELECT content, metadata FROM docs ORDER BY embedding <=> $1 LIMIT 5`.

### Pricing

Pay per event: **$0.30 per 1,000 chunks written** (`chunk-upserted`). Local embedding compute is included, so you need no OpenAI bill. You are not charged for:

- unchanged chunks skipped by delta mode
- deletions
- empty or duplicate rows
- errors

If you use your own OpenAI-compatible key, the provider bills you for embedding tokens directly (`text-embedding-3-small` is about $0.02 per 1M tokens, roughly $0.005 per 1,000 chunks).

| Actor | Price | Notes |
|---|---|---|
| **This Actor** | $0.0003 / chunk, unchanged chunks free | Pinecone + Qdrant + pgvector, local embeddings or your key, delta sync |
| apify/pinecone-integration | free | Pinecone only, needs an OpenAI key |
| apify/qdrant-integration | free | Qdrant only, needs an OpenAI key |
| oldjard/dataset-to-pinecone-qdrant | $0.00025 / record | Pinecone and Qdrant |

(Store data, October 2026.)

### Use with AI agents (Apify MCP)

Add the Actor to Claude, ChatGPT, Cursor or any MCP client through the [Apify MCP server](https://mcp.apify.com). An agent can pass a dataset ID or JSON documents and get them indexed in the user's vector store in one call, for example: *"Index the dataset from my last docs crawl into my Qdrant collection 'support', only changed pages."*

### FAQ

**Do I need an OpenAI key?** No. The default local model runs inside the Actor. Use an API model if you already query with OpenAI embeddings, or if you need higher quality on long or multilingual text.

**Which local model should I pick?** For English, use `bge-small-en-v1.5` (fast, 384 dims). For other languages, use `paraphrase-multilingual-MiniLM-L12-v2`. Use the same model at query time (fastembed, sentence-transformers or Hugging Face).

**Is re-running safe?** Yes. IDs are deterministic (document ID + chunk number), so a re-run updates vectors in place instead of creating duplicates. In delta mode, unchanged chunks are not re-embedded and not charged.

**What happens if I change the model or the chunk size?** Content hashes include the model, text and metadata, so changed chunks are rewritten. A different dimension needs a new collection, index or table (the Actor stops with a clear message before writing).

**Are my credentials safe?** API keys and the connection string are secret inputs: they are encrypted, hidden in the UI and logs, and only sent to the host you enter.

**Can it read datasets from other runs?** Yes. Pick them in the dataset field or pass `{{resource.defaultDatasetId}}`. The Actor gets read access only to the datasets you select.

**How fast is it?** Local embedding is CPU-bound. At the default 2 GB memory, expect a few hundred chunks per minute. More memory gives more CPU and a proportionally faster run. API embeddings are faster.

Related: [Dataset Filter & Transform](https://apify.com/gazidev/dataset-filter-transform) (clean or dedupe before indexing), [Bulk AI Dataset Enricher](https://apify.com/gazidev/bulk-ai-dataset-enricher) (add AI summaries or tags first).

# Actor input Schema

## `datasetIds` (type: `array`):

Datasets to load, e.g. the output of Website Content Crawler or any scraper. In an integration / webhook use {{resource.defaultDatasetId}}. Datasets, file URLs and pasted items are combined.

## `fileUrls` (type: `array`):

Public URLs of JSON arrays, JSON Lines, CSV/TSV files (one document per row) or a raw Markdown / text file (one document). GitHub 'blob' links are converted to raw links.

## `items` (type: `array`):

Optional: a JSON array of objects, e.g. \[{"url": "https://example.com/a", "text": "..."}]. Handy for AI agents and quick tests.

## `textFields` (type: `array`):

Field(s) holding the text to embed (dot paths allowed, e.g. content.body). The first non-empty field is used, unless 'Combine text fields' is on. Default: markdown, text, content, body, pageContent, description (works with Website Content Crawler output).

## `combineTextFields` (type: `boolean`):

Join all listed text fields (e.g. title + description + body) instead of using the first non-empty one.

## `idField` (type: `string`):

Field that identifies a document (stable across runs), used to build deterministic vector IDs so re-runs update instead of duplicating. Default: url, then id. Without an ID the text hash is used.

## `metadataFields` (type: `array`):

Fields stored as metadata/payload next to each vector, for filtering and citations. Use 'path:name' to rename, e.g. 'metadata.title:title'. Missing fields are skipped. The chunk text is always stored as 'text'.

## `chunkSize` (type: `integer`):

Maximum characters per chunk (~4 characters per token). 800-1500 is typical for RAG.

## `chunkOverlap` (type: `integer`):

Characters repeated from the end of the previous chunk (max half the chunk size).

## `markdownAware` (type: `boolean`):

Split at Markdown headings first (code blocks kept intact) and store the heading path of each chunk as 'headings'. Then paragraphs, lines, sentences, words.

## `minChunkChars` (type: `integer`):

Drop chunks shorter than this many characters (e.g. lone headings or menu leftovers).

## `embeddingProvider` (type: `string`):

'Local' runs a small open-source model inside the Actor (no API key, no token cost). 'OpenAI-compatible' uses your own key with OpenAI or any compatible /embeddings endpoint.

## `localModel` (type: `string`):

Used when Embeddings = Local. bge-small-en-v1.5 (384 dims) is preloaded and fastest. Use the multilingual MiniLM model for non-English text. Use the same model for indexing and for your queries.

## `embeddingApiKey` (type: `string`):

Your OpenAI (or compatible provider) API key. Stored encrypted. Only used when Embeddings = OpenAI-compatible.

## `embeddingModel` (type: `string`):

Model name for the API, e.g. text-embedding-3-small, text-embedding-3-large, mistral-embed, nomic-embed-text.

## `embeddingBaseUrl` (type: `string`):

OpenAI-compatible base URL (the Actor calls {base}/embeddings). Default https://api.openai.com/v1. Examples: https://api.mistral.ai/v1, https://api.together.xyz/v1.

## `embeddingDimensions` (type: `integer`):

Ask the API for shorter vectors (supported by text-embedding-3 models). Leave empty for the model default.

## `target` (type: `string`):

Where to write the vectors. 'None' = dry run: chunks and embeddings are saved to the dataset only (no database needed).

## `collection` (type: `string`):

Qdrant collection, Pinecone index (lowercase letters, digits, '-'; underscores become '-') or Postgres table (optionally schema.table).

## `createIfMissing` (type: `boolean`):

Create the collection / serverless index / table (with HNSW cosine index) when it does not exist, sized to the model's dimension.

## `qdrantUrl` (type: `string`):

Your Qdrant cluster URL incl. port, e.g. https://xyz.eu-central-1-0.aws.cloud.qdrant.io:6333

## `qdrantApiKey` (type: `string`):

Qdrant Cloud API key (stored encrypted). Leave empty for an unsecured self-hosted instance.

## `pineconeApiKey` (type: `string`):

Your Pinecone API key (stored encrypted).

## `pineconeNamespace` (type: `string`):

Optional namespace inside the index.

## `pineconeCloud` (type: `string`):

Cloud for a newly created serverless index.

## `pineconeRegion` (type: `string`):

Region for a newly created serverless index (free Starter plan: aws us-east-1).

## `postgresUrl` (type: `string`):

postgresql://user:password@host:5432/db?sslmode=require (stored encrypted). Supabase: use the session or transaction pooler string. The 'vector' extension must be enabled or creatable.

## `mode` (type: `string`):

'Delta' compares a content hash per chunk with what is already stored and only embeds + writes new or changed chunks (unchanged chunks are free). 'Upsert all' re-embeds and overwrites everything.

## `sourceTag` (type: `string`):

Optional label stored with every vector (e.g. 'docs-site') and used as an ID prefix, so several sources can share one collection. Required for deleting missing documents.

## `deleteMissingDocuments` (type: `boolean`):

After a complete run, delete vectors with this Source tag whose document ID was not in this run's input (e.g. pages removed from a website). Skipped when the run stopped early or a source failed.

## `maxItems` (type: `integer`):

Stop after this many documents (0 = all). Useful for a first test.

## `maxChunks` (type: `integer`):

Stop after writing this many chunks (0 = no limit). The run also stops at your max cost per run.

## `includeVectorsInOutput` (type: `boolean`):

Target 'None' only: include the embedding vector in each dataset row (turn off to just preview chunks).

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/apify/crawlee/master/README.md"
  ],
  "textFields": [
    "text"
  ],
  "combineTextFields": false,
  "metadataFields": [
    "url",
    "title",
    "metadata.title:title",
    "metadata.description:description",
    "metadata.languageCode:language",
    "crawl.loadedTime:crawledAt"
  ],
  "chunkSize": 1000,
  "chunkOverlap": 150,
  "markdownAware": true,
  "minChunkChars": 20,
  "embeddingProvider": "local",
  "localModel": "BAAI/bge-small-en-v1.5",
  "embeddingModel": "text-embedding-3-small",
  "target": "none",
  "collection": "apify_docs",
  "createIfMissing": true,
  "pineconeCloud": "aws",
  "pineconeRegion": "us-east-1",
  "mode": "delta",
  "deleteMissingDocuments": false,
  "maxItems": 0,
  "maxChunks": 0,
  "includeVectorsInOutput": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fileUrls": [
        "https://raw.githubusercontent.com/apify/crawlee/master/README.md"
    ],
    "textFields": [
        "text"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/vector-db-uploader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "fileUrls": ["https://raw.githubusercontent.com/apify/crawlee/master/README.md"],
    "textFields": ["text"],
}

# Run the Actor and wait for it to finish
run = client.actor("gazidev/vector-db-uploader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fileUrls": [
    "https://raw.githubusercontent.com/apify/crawlee/master/README.md"
  ],
  "textFields": [
    "text"
  ]
}' |
apify call gazidev/vector-db-uploader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gazidev/vector-db-uploader"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/xfw2nFqYdYYjF93jZ/builds/SjQaVMinjdrdCf7fb/openapi.json
