Vector

A vector index for embeddings, in one command.

AI/LLM: this page is available in plain markdown at /docs/resources/vector.md

npx extraorbital add vector --dimensions 1536
✓ Provisioned vector/default (1536 dimensions, COSINE)
✓ Wrote 2 variables to .env

  UPSTASH_VECTOR_REST_URL, UPSTASH_VECTOR_REST_TOKEN

A project that mentions either UPSTASH_VECTOR_REST_* variable gets this from extraorbital provision at the default 1536 dimensions. Name it explicitly when your embedding model needs a different size.

What it writes

VariableExample
UPSTASH_VECTOR_REST_URLhttps://vector.extraorbital.dev/cosmic-otter-default
UPSTASH_VECTOR_REST_TOKENABkFMHZlY3Rvci…

Options

npx extraorbital add vector [--slug <name>] [--dimensions <n>] \
  [--similarity-function <fn>] [--embedding-model <model>] [--region <region>]
FlagDefaultDescription
--slugdefaultA second, fully separate index in the same project
--dimensions1536Vector dimensions, 1–4096. Match your embedding model
--similarity-functionCOSINEOne of COSINE, EUCLIDEAN, DOT_PRODUCT
--embedding-modelLet the index embed raw text for you
--regionus-east-1One of us-east-1, eu-central-1, ap-southeast-1

Dimensions and the similarity function are fixed at creation. To change them, provision a new slug and re-index:

npx extraorbital add vector --slug small --dimensions 384

Prototype allowance

10K queries plus 10K updates per day and 1 GB of data free on the Prototype plan, counted across your whole account and shared by up to five indexes. Past it, $0.40/100K requests and $0.25/GB-mo — our own cost, with nothing added — on a paid plan.

Use it

search.ts
import { Index } from "@upstash/vector";

const index = Index.fromEnv(); // reads UPSTASH_VECTOR_REST_URL and _TOKEN

await index.upsert({
  id: "doc-42",
  vector: embedding, // number[1536]
  metadata: { title: "Q3 report" },
});

const hits = await index.query({ vector: queryEmbedding, topK: 5, includeMetadata: true });

Next

  • AI Gateway — a key to generate the embeddings with
  • Pricing — plans, allowances and rates