Upstash
Configure @vitehub/vector against the Upstash Vector HTTP API.
Use the Upstash provider when you want a hosted vector API and do not want to manage your own vector database.
Before you start
Install @vitehub/vector and @upstash/vector:
Terminal
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/vector@main @upstash/vector
Set the Upstash REST URL and token in your runtime environment or pass them in top-level vector config.
Configure Upstash
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vitehub/vector/nuxt'],
vector: {
provider: 'upstash',
url: process.env.UPSTASH_VECTOR_REST_URL,
token: process.env.UPSTASH_VECTOR_REST_TOKEN,
namespace: 'docs',
},
})
Define a vector
server/vectors/docs.ts
export default defineVector({
dimensions: 1536,
filterable: ['tenantId'],
providers: {
upstash: {
namespace: 'search',
},
},
})
Use namespace or indexName when you want a prefix before the discovered vector name.
Query the vector
const docs = getVector('docs')
const matches = await docs.query({
vector: [0.1, 0.2, 0.3],
topK: 5,
filter: {
tenantId: 'acme',
},
})
Upstash-specific options
| Option | Use it for |
|---|---|
url | Point ViteHub at the Upstash Vector REST endpoint. |
token | Authenticate requests to the Upstash Vector API. |
namespace | Prefix the discovered vector name globally. |
providers.upstash.namespace | Prefix the discovered vector name for one vector definition only. |
What changes on Upstash
| Concern | Behavior |
|---|---|
| URL and token | ViteHub reads them from top-level config or environment variables. |
| Namespace naming | ViteHub prefixes the discovered vector name with namespace or indexName when you set one. |
| Runtime API | The public ViteHub vector API stays the same as the other providers. |
| Native handle | getVector(name).native gives you the raw Upstash index handle. |
Choose Upstash when you want a hosted vector service with the same ViteHub runtime API used by the other providers.