Vector buckets, indexes, and vector data against Supabase Storage.
Provides vector bucket CRUD, per-bucket index operations, and
per-index vector data operations (put, get, list, query, delete).
Index ops take an instance returned by from; vector data ops take an
instance further scoped by index.
(require '[supabase.core.client :as client]
'[supabase.storage.vector :as vector])
(def c (client/make-client "https://abc.supabase.co" "anon-key"))
(vector/create-bucket (vector/from c) "embeddings")
(def b (vector/from c "embeddings"))
(vector/create-index b {:index-name "docs"
:data-type :float32
:dimension 384
:distance-metric :cosine})
(def i (vector/index b "docs"))
(vector/put-vectors i [{:key "doc-1" :data {:float32 [0.1 0.2]}}])
(vector/query-vectors i {:query-vector {:float32 [0.1 0.2]} :top-k 5})
Each function returns {:status :body :headers} on success or an anomaly
map on failure. All endpoints are POSTs under {storage-url}/vector with
camelCase JSON bodies. See
https://supabase.com/docs/reference/javascript/storage-vector-api
Vector buckets, indexes, and vector data against Supabase Storage.
Provides vector bucket CRUD, per-bucket index operations, and
per-index vector data operations (put, get, list, query, delete).
Index ops take an instance returned by `from`; vector data ops take an
instance further scoped by `index`.
## Example
(require '[supabase.core.client :as client]
'[supabase.storage.vector :as vector])
(def c (client/make-client "https://abc.supabase.co" "anon-key"))
(vector/create-bucket (vector/from c) "embeddings")
(def b (vector/from c "embeddings"))
(vector/create-index b {:index-name "docs"
:data-type :float32
:dimension 384
:distance-metric :cosine})
(def i (vector/index b "docs"))
(vector/put-vectors i [{:key "doc-1" :data {:float32 [0.1 0.2]}}])
(vector/query-vectors i {:query-vector {:float32 [0.1 0.2]} :top-k 5})
Each function returns `{:status :body :headers}` on success or an anomaly
map on failure. All endpoints are POSTs under `{storage-url}/vector` with
camelCase JSON bodies. See
https://supabase.com/docs/reference/javascript/storage-vector-api(create-bucket v name)Creates a vector bucket named name.
Creates a vector bucket named `name`.
(create-index v params)Creates a vector index within the instance's bucket.
:index-name — unique name within the bucket (required):data-type — :float32 (required, the only supported type):dimension — vector dimensionality, e.g. 384 (required):distance-metric — :cosine, :euclidean, or :dotproduct (required):metadata-configuration — optional map with
:non-filterable-metadata-keysCreates a vector index within the instance's bucket. ## Params * `:index-name` — unique name within the bucket (required) * `:data-type` — `:float32` (required, the only supported type) * `:dimension` — vector dimensionality, e.g. 384 (required) * `:distance-metric` — `:cosine`, `:euclidean`, or `:dotproduct` (required) * `:metadata-configuration` — optional map with `:non-filterable-metadata-keys`
(delete-bucket v name)Deletes the vector bucket name. The bucket must be empty first.
Deletes the vector bucket `name`. The bucket must be empty first.
(delete-index v index-name)Deletes the index index-name and all its data from the instance's
bucket.
Deletes the index `index-name` and all its data from the instance's bucket.
(delete-vectors v keys)Deletes vectors by their keys in batch (1-500 per request).
Deletes vectors by their `keys` in batch (1-500 per request).
(from client)(from client bucket-name)Returns a vector storage instance, optionally bound to bucket-name.
Bucket CRUD works on either form; index and vector data operations
require the bound form.
(def v (from client "embeddings"))
(def i (index v "docs"))
Returns a vector storage instance, optionally bound to `bucket-name`.
Bucket CRUD works on either form; index and vector data operations
require the bound form.
(def v (from client "embeddings"))
(def i (index v "docs"))(get-bucket v name)Retrieves metadata for the vector bucket name.
Retrieves metadata for the vector bucket `name`.
(get-index v index-name)Retrieves metadata for the index index-name in the instance's bucket.
Retrieves metadata for the index `index-name` in the instance's bucket.
(get-vectors v opts)Retrieves vectors by their keys in batch.
:keys — vector keys to fetch (required):return-data — include vector data in the response:return-metadata — include metadata in the responseRetrieves vectors by their `keys` in batch. ## Options * `:keys` — vector keys to fetch (required) * `:return-data` — include vector data in the response * `:return-metadata` — include metadata in the response
(index v index-name)Returns v scoped to index-name. Pass the result as the first
argument to vector data operations.
Returns `v` scoped to `index-name`. Pass the result as the first argument to vector data operations.
(list-buckets v)(list-buckets v opts)Lists vector buckets, optionally filtered and paginated.
:prefix — name prefix filter:max-results — page size (default 100):next-token — pagination token from a previous responseLists vector buckets, optionally filtered and paginated. ## Options * `:prefix` — name prefix filter * `:max-results` — page size (default 100) * `:next-token` — pagination token from a previous response
(list-indexes v)(list-indexes v opts)Lists vector indexes in the instance's bucket. Options match
list-buckets.
Lists vector indexes in the instance's bucket. Options match `list-buckets`.
(list-vectors v)(list-vectors v opts)Lists vectors in the instance's index with pagination.
:max-results — page size:next-token — pagination token from a previous response:return-data — include vector data in the response:return-metadata — include metadata in the response:segment-count — parallel scan segment count (1-16):segment-index — segment to return; with :segment-count given,
must be within [0, segment-count)Lists vectors in the instance's index with pagination. ## Options * `:max-results` — page size * `:next-token` — pagination token from a previous response * `:return-data` — include vector data in the response * `:return-metadata` — include metadata in the response * `:segment-count` — parallel scan segment count (1-16) * `:segment-index` — segment to return; with `:segment-count` given, must be within `[0, segment-count)`
(put-vectors v vectors)Inserts or updates vectors in batch (1-500 per request).
Each vector is API-shaped and passed through as-is:
{:key "doc-1" :data {:float32 [0.1 0.2 ...]} :metadata {...}}
Inserts or updates `vectors` in batch (1-500 per request).
Each vector is API-shaped and passed through as-is:
{:key "doc-1" :data {:float32 [0.1 0.2 ...]} :metadata {...}}(query-vectors v query)Queries for similar vectors using approximate nearest neighbor search.
:query-vector — {:float32 [...]} (required):top-k — number of nearest neighbors to return:filter — metadata filter map:return-distance — include distances in the response:return-metadata — include metadata in the responseQueries for similar vectors using approximate nearest neighbor search.
## Query
* `:query-vector` — `{:float32 [...]}` (required)
* `:top-k` — number of nearest neighbors to return
* `:filter` — metadata filter map
* `:return-distance` — include distances in the response
* `:return-metadata` — include metadata in the responsecljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |