BudgetVec is now in public beta — deploy billion-scale vector search on Cloudflare for $0.015/GB. Get started →

API: Write

Upsert and delete vectors within a namespace.

Endpoint

POST /v2/namespaces/:namespace

Authentication

All requests require a Bearer token:

Authorization: Bearer bv_live_your_api_key

Request Body

{

"upsert_rows": [

{

"id": 1,

"vector": [0.1, 0.2, 0.3],

"title": "My document",

"category": "article"

}

],

"deletes": [100, 101, 102]

}

Fields

FieldTypeRequiredDescription
upsert_rowsarrayNoRows to upsert. Each row has id, vector, and any custom attributes
upsert_rows[].idnumberYesUnique row identifier
upsert_rows[].vectornumber[]YesVector embedding (must match namespace dimensions)
deletesnumber[]NoRow IDs to delete
distance_metricstringNoDistance metric ("cosine", "euclidean"). Defaults to "cosine"

Response

{

"rows_affected": 3,

"rows_upserted": 1,

"rows_deleted": 2

}

Batch Import (JSONL)

For large imports, use the JSONL endpoint:

POST /v2/namespaces/:namespace/import/jsonl

Content-Type: text/plain

Each line is a JSON object:

{"id": 1, "vector": [0.1, 0.2, ...], "title": "doc one"}

{"id": 2, "vector": [0.3, 0.4, ...], "title": "doc two"}

Lines starting with # are ignored. Maximum batch size: 1,000 rows.

Example (TypeScript SDK)

import { BudgetVecClient } from "@budgetvec/client";

const client = new BudgetVecClient({

baseUrl: "https://budgetvec.standupcode.workers.dev",

apiKey: "bv_live_your_key",

});

const ns = client.namespace("products");

// Upsert

await ns.upsert({

upsert_rows: [

{ id: 1, vector: embedding, name: "Widget", price: 9.99 },

],

});

// Delete

await ns.upsert({

deletes: [1, 2, 3],

});