# Vector

> A vector index for embeddings, in one command.

```bash
npx extraorbital add vector --dimensions 1536
```

```txt
✓ 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`](/docs/quickstart#how-autopilot-decides) at the default 1536
dimensions. Name it explicitly when your embedding model needs a different size.

## What it writes

| Variable | Example |
| --- | --- |
| `UPSTASH_VECTOR_REST_URL` | `https://vector.extraorbital.dev/cosmic-otter-default` |
| `UPSTASH_VECTOR_REST_TOKEN` | `ABkFMHZlY3Rvci…` |

## Options

```bash
npx extraorbital add vector [--slug <name>] [--dimensions <n>] \
  [--similarity-function <fn>] [--embedding-model <model>] [--region <region>]
```

| Flag | Default | Description |
| --- | --- | --- |
| `--slug` | `default` | A second, fully separate index in the same project |
| `--dimensions` | `1536` | Vector dimensions, 1–4096. Match your embedding model |
| `--similarity-function` | `COSINE` | One of `COSINE`, `EUCLIDEAN`, `DOT_PRODUCT` |
| `--embedding-model` | — | Let the index embed raw text for you |
| `--region` | `us-east-1` | One 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:

```bash
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](/pricing).

## Use it

```ts title="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](/docs/resources/ai-gateway) — a key to generate the embeddings with
- [Pricing](/pricing) — plans, allowances and rates

---

More for agents: [Docs index](https://extraorbital.dev/sitemap.md) · [llms.txt](https://extraorbital.dev/llms.txt) · [agents.md](https://extraorbital.dev/agents.md)
