Each collection is its own vector index. The default is 768 dimensions — what Harakumo's default embedding model (bge-base, English) produces, so text you send fits as-is. Choose 384 (bge-small) or 1,024 (bge-large) to match those models, or 1,536 for vectors you make elsewhere; larger is refused.
Vector DB holds your app's documents, chunked and searched by meaning, with their text returned. To remember facts about one end user (their preferences, their conversations), use Memory, which always takes a userId.
In plain words
Search by meaning instead of exact words. You add your texts, and it finds the ones closest in meaning to what someone asks.
For example: Someone types "how do I get my money back" into a help center and finds the article called "Refunds".
Embed, upsert, query
- The text you send is kept with the vector (with
valuestoo) and comes back astexton every match and fromfetch. A vector written before text was kept has none: upsert it again to add it. It comes back withreturnMetadata: "all", the default, so with topK 50 or fewer. - A text is at most 2,000 characters (about what the embedding model reads). Longer is a 400
input_too_longnaming the field (vectors[3].text), never cut: split it into chunks of about 1,000-1,500 characters. - Metadata plus the text is at most 10,240 bytes per vector (400
metadata_too_large). Metadata keys that start with_hk_are Harakumo's own and are refused. - New vectors become searchable in about a minute.
GET /api/vectors/:idanswersall_writes_searchable: true once every write so far can be found.
const { collection } = await hk.vectors.create(project.id, {
name: 'docs', dimensions: 768, metric: 'cosine',
metadataIndexes: [{ propertyName: 'lang', indexType: 'string' }],
});
// Send text (at most 2,000 characters each; split longer documents into chunks
// with ids like doc42#0, doc42#1). Harakumo embeds it (metered on AI credits) and keeps it.
await hk.vectors.upsert(collection.id, [
{ id: 'doc-1#0', text: 'Peaches are in season in July.', metadata: { lang: 'en' } },
{ id: 'doc-2#0', text: 'Mangoes ripen best at room temperature.', metadata: { lang: 'en' } },
]);
const { matches } = await hk.vectors.query(collection.id, {
text: 'when can I buy peaches?', topK: 3, filter: { lang: 'en' },
});
// matches: [{ id: 'doc-1#0', score: 0.83, text: 'Peaches are in season in July.', metadata: { lang: 'en' } }, …]Namespaces: one per end user
- Give each vector a
namespace: your end user's id (userIdis the same field, the name Memory uses; send one, or both the same). A query that names it sees only that user's vectors. A namespace written to is 1-64 characters: letters, digits and . _ - : @ + =, so an id or an email fits as-is. An older namespace with other characters (a space, a slash) can still be searched and fetched from, but no longer written to: upsert those vectors again under a new one. - Leaving the namespace out of a query searches every namespace in the collection. Always pass it from your server when a search is about one user.
- Give every vector an id that is unique in the whole collection, not only in its namespace: fetch and delete take ids without a namespace, so two vectors sharing an id under two namespaces cannot be told apart. Prefix ids with the user's id (
u42:note-1), which also makes forgetting a user a delete by those ids. Up to 50,000 namespaces per collection.
Filters
- A filter is
{ field: value }or{ field: { $eq | $ne | $in | $nin | $lt | $lte | $gt | $gte: … } }; several fields in one filter mean AND. There is no$oror$exists: those are a 400filter_operator_unsupportedthat names the operator. - Filters work on metadata fields made filterable with
metadataIndexes, at create time or later withPATCH /api/vectors/:id { metadataIndexes: [{ propertyName, indexType }] }(string, number or boolean; at most 10 per collection, never removed). Only vectors written after a field is made filterable can be filtered on it, so re-upsert existing ones. A filter on any other field is a 400field_not_filterablethat says so.
Read, delete and change
POST /api/vectors/:id/fetch { ids, includeValues? }reads up to 100 vectors back by id: text, metadata and namespace (values when asked), andnotFound.POST /api/vectors/:id { action: "delete", ids: [...] }deletes up to 1,000 ids per request (each at most 64 bytes, repeats dropped);deletedcounts the ids sent, found or not, and they leave search in about a minute. The SDK'sdeleteIdssends any number, 1,000 at a time.PATCH /api/vectors/:id { visitorChat?, metadataIndexes? }changes a collection.DELETE /api/vectors/:iddeletes it and every vector in it.
Visitor chat
- An agent answering your app's visitors (visitor chat) may search a collection only once you open it:
visitorChat: trueon create, orPATCH /api/vectors/:id { visitorChat: true }. Collections start closed. Open one only if anything in it may be shown to anyone on your page. - A visitor's chat lists only the open collections, and is refused any other collection (describe, query or fetch) with 403
not_open_to_visitors. It searches by text across the whole collection, every namespace included, with at most 10 matches: open only a collection whose every vector may be shown to anyone. With no collection open, the agent's visitor runs have no document tools, and turning chat on says so (chat_note). Memory is never open to visitor chat.
Limits
- Upsert up to 1,000 vectors per request (100 when sending text).
- topK up to 100, or 50 when returning full metadata (and the text) or values.
- Upserts are applied in the background: new vectors become searchable in about a minute, and the upsert answer says so.
GET /api/vectors/:idreports the index's own count, which trails new writes by as much; the list shows the count as last read. - Collections per plan: 1 hobby, 1 indie, 10 pro, 25 team, 100 scale. Vectors per collection: 10,000 hobby, 20,000 indie, 1,000,000 pro, 1,000,000 team, 1,000,000 scale; a write that would pass it answers 402
plan_limitand writes nothing. Near the limit every vector sent counts as new until the index has processed it, even one that replaces an existing id, and a delete makes room once the index has processed it. - Keys: a key limited to the project works for everything here. A read-only key can query (by text too, charged to AI credits) and fetch, but not upsert, change or delete.
Errors
- Creating a collection when its index cannot be made answers 503 with Retry-After and keeps nothing. Deleting one when its index cannot be deleted answers 503 (or 502) and deletes nothing, so you can try again.
| Code | Status | When |
|---|---|---|
| input_too_long | 400 | A text is over 2,000 characters. param names it; split it into chunks. |
| metadata_too_large | 400 | Metadata plus text is over 10,240 bytes. |
| conflicting_param | 400 | namespace and userId were both sent and differ. |
| filter_operator_unsupported | 400 | The filter uses $or, $exists or another operator the index does not have. |
| field_not_filterable | 400 | The filter names a field that is not filterable on this collection. |
| invalid_request | 400 | Anything else malformed, with param when one field is at fault; also an 11th filterable field. |
| ai_gateway_off | 403 | Text was sent while the AI Gateway is switched off; send vectors you computed instead. |
| embedding_failed | 502 | The embedding model failed; nothing was charged or written. Try again. |
| not_open_to_visitors | 403 | A visitor's chat reached a collection not open to it. |
| plan_limit | 402 | The collection is at its plan's vectors per collection. |
| rate_limited | 429 | The index (or the embedding model) is busy, or the data allowance is used up; retry after Retry-After. |
| index_unavailable | 501 / 502 | The collection has no index behind it (501: delete it and create a new one), or its index is busy (502 with Retry-After: try again). |
| may_have_landed | 503 | The index did not confirm an upsert; sending the same vectors again is safe. |
| count_unavailable | 503 | A collection whose count was never read could not be counted for the plan's cap; retry. |
| maintenance | 503 | During a platform move text is not embedded; a query by vector still works. |
Reference
const { embeddings } = await hk.ai.embed(['fresh mango', 'ripe banana'], 'bge-base'); // 768 dims
await hk.vectors.upsert(collectionId, [{ id: 'u42:a', values: embeddings[0], text: 'fresh mango', metadata: { title: 'Mango' }, userId: 'u42' }]);
const { matches } = await hk.vectors.query(collectionId, { vector: embeddings[1], topK: 5, userId: 'u42' });
const { vectors, notFound } = await hk.vectors.fetch(collectionId, ['u42:a']);
await hk.vectors.update(collectionId, { visitorChat: true, metadataIndexes: [{ propertyName: 'title', indexType: 'string' }] });harakumo vectors <projectId> # list collections
harakumo vectors create <projectId> docs
harakumo vectors upsert <collectionId> docs.json # [{ "id": "doc#0", "text": "…", "userId"? }]
harakumo vectors query <collectionId> "refund policy" --top-k 3 --user u42
harakumo vectors rm <collectionId> doc#0 doc#1
harakumo vectors visitor-chat <collectionId> onPOST /api/projects/:id/vectors { "name": "docs", "dimensions"?: 768, "metric"?: "cosine", "metadataIndexes"?, "visitorChat"?: false }
POST /api/vectors/:id/upsert { "vectors": [{ "id": "doc-1#0", "values"?: [...], "text"?: "…", "metadata"?: {}, "namespace"? | "userId"? }] }
POST /api/vectors/:id/query { "vector"?: [...], "text"?: "…", "topK"?: 5, "filter"?, "namespace"? | "userId"? }
POST /api/vectors/:id/fetch { "ids": ["doc-1#0"], "includeValues"?: false }
GET /api/vectors/:id # the collection, its count and all_writes_searchable
PATCH /api/vectors/:id { "visitorChat"?: true, "metadataIndexes"?: [{ "propertyName", "indexType" }] }
POST /api/vectors/:id { "action": "delete", "ids": [...] }
DELETE /api/vectors/:id