# Vector stores

**Last updated:** 2026-11-23T09:11:21-03:00 (UTC-3)

Store documents and search them by similarity for RAG, with the OpenAI vector stores API pointed at the gateway. Embeddings are computed by the gateway itself, with the provider you choose, and each store belongs to a team. Flag: `vector_stores`, which requires `embeddings` and PostgreSQL.

## Access model

- **Owner.** Each store belongs to a team. The owning team's keys create, ingest, search and delete.
- **Sharing.** From the console, the owner grants other teams list and search access. Shared teams never write and do not see the sharing list. With [organization admins](/docs/features/organization-admins/) on, a team or organization admin shares only with teams of the store's own organization; another organization's team answers `400 team_not_found`, like an unknown one. A global administrator may still share across organizations; such a team stays in the list when the owner edits it, but once removed only a global administrator can add it back.
- **No access.** For any other key the store does not exist: a nonexistent id and an id without access return the same 404.
- **Key without a team.** Reaches no store at all (`403 team_required`).
- **Key scopes:**
  - `vector_store:read` to list and search;
  - `vector_store:write` to create, ingest and delete.

  Both appear in key creation and in the team policy.

## Embeddings and cost

Ingestion and queries call the gateway's own `/v1/embeddings` **with the caller's key**. So the following apply, with no parallel path:
- the key's model allowlist;
- quotas, budgets and rate limits;
- cache, logs and the usage ledger, attributed to the team.

If `/v1/embeddings` refuses (for example `model_forbidden` or an exhausted quota), the response reaches the client as it came.

The embedding alias is fixed at creation. The dimension is recorded with the first document. If the alias starts pointing to a model with a different dimension, ingestion and search respond `409 embedding_dimension_mismatch` instead of mixing vector spaces.

## API (compatible with the OpenAI SDK)

| Route | Scope | Note |
|---|---|---|
| `POST /v1/vector_stores` | write | `{name, embedding_model}`; the id is generated (`vs_` + 128 bits) |
| `GET /v1/vector_stores`, `GET /v1/vector_stores/{id}` | read | The team's stores and the ones shared with it |
| `DELETE /v1/vector_stores/{id}` | write | Owner only |
| `POST /v1/vector_stores/{id}/documents` | write | `{title, text, attributes}`, up to 1 MiB of UTF-8; chunking in the gateway |
| `GET /v1/vector_stores/{id}/documents` | read | |
| `DELETE /v1/vector_stores/{id}/documents/{doc_id}` | write | |
| `POST /v1/vector_stores/{id}/search` | read | `query` of up to 2000 characters, `max_num_results` from 1 to 20, `ranking_options.score_threshold` |

`filters` and `rewrite_query` respond 422: they are rejected, not ignored.

With the official SDK:

```python
client = openai.OpenAI(api_key=KEY, base_url="https://gateway.example.com/v1")
vs = client.vector_stores.create(name="Runbooks", extra_body={"embedding_model": "embed"})
client.post(f"/vector_stores/{vs.id}/documents", body={"title": "Scheduling", "text": "..."}, cast_to=object)
client.vector_stores.search(vs.id, query="how are pods placed?", max_num_results=5)
```

## Limits

`vector_stores` in the YAML:

| Key | Default | Maximum |
|---|---|---|
| `max_stores_per_team` | 20 | 1000 |
| `max_documents` | 1000 | 100000 |
| `max_bytes` | 50 MiB | 1 GiB |
| `max_chunks` | 5000 | 50000 |
| `chunk_chars` | 1000 | 200–8000 |
| `chunk_overlap` | 150 | strictly below integer floor(`chunk_chars` / 2) |

The limits are checked before spending on embeddings and again under the store's lock. Search computes similarity in PostgreSQL, without an extension. The chunk ceiling is what keeps a search bounded.

## YAML and console

`vector_stores.stores` declares stores with id `vs-<name>`, team, embedding alias and `shared_with`. They receive documents normally, but the API and the console do not rename, reshare or delete them. Changing the model of a declared store that already has vectors prevents boot. A store removed from the YAML keeps existing and becomes managed from the console.

| Key | What it does |
| --- | --- |
| `vector_stores.stores[].id` | `vs-` followed by up to 60 lower-case letters, digits or dashes, so it never collides with a generated `vs_<hex>` |
| `vector_stores.stores[].name` | Display name of the store |
| `vector_stores.stores[].team` | ID of the team that owns the store |
| `vector_stores.stores[].embedding_model` | Embeddings alias that embeds the documents and the queries; it cannot change once the store has vectors |
| `vector_stores.stores[].shared_with` | Other teams that may read and search the store |
| `vector_stores.ocr_model` | OCR alias that turns uploaded PDFs and images into text before indexing; empty refuses those files |

The **Vector stores** screen shows owner, model, dimension, occupancy and sharing, and lets you create, share, list and delete documents and delete stores:
- the global administrator manages everything;
- `team_admin` manages the stores of the teams it administers;
- the other roles only read.

## Files (OpenAI files API)

With `vector_stores` and `batches` (which turns on `/v1/files`), a file uploaded with `purpose` `assistants` or `user_data` becomes a document in a store through `POST /v1/vector_stores/{id}/files`. This is the official SDK flow (`vector_stores.files.create_and_poll` and `upload_and_poll`):

```python
f = client.files.create(file=open("oncall.md", "rb"), purpose="assistants")
client.vector_stores.files.create_and_poll(vector_store_id=vs.id, file_id=f.id,
    chunking_strategy={"type": "static", "static": {"max_chunk_size_tokens": 400, "chunk_overlap_tokens": 100}})
```

- **Formats:** text (txt, md, csv, json, yaml, html, code), in UTF-8, up to 1 MiB. In HTML, tags, `script` and `style` are stripped. PDF and images (up to 20 MiB) go in through [OCR](/docs/features/ocr/) when `vector_stores.ocr_model` is configured; without it, they get 415, and nothing is indexed empty.
- **Chunking:** `auto` uses the store's default. `static` accepts 100 to 4096 tokens with an overlap of up to half, converted at a ratio of 4 characters per token. The split used is recorded and comes back in `retrieve`.
- **Access:** the file must belong to the key's team. A file from another team, with another `purpose` or expired gets the same 404 response. Only the owning team attaches and removes.
- **Idempotency:** attaching the same file again returns the existing object, without new embeddings.
- **Removal:** `DELETE .../files/{file_id}` deletes the document and the chunks; the file stays in `/v1/files`.
- **Search:** results from files carry the `file_id` and the file name.

- **Batches:** `POST .../file_batches` indexes up to 20 files within the request itself, one by one, as the caller. Each file becomes a document or fails with an error code (`file_not_found`, `unsupported_file`, `quota_exceeded`...), listed at `.../file_batches/{id}/files?filter=failed`. The SDK's `upload_and_poll` works without waiting; `cancel` returns the already-finished batch.
- **`file_ids` at creation:** `vector_stores.create(file_ids=[...])` indexes into the new store as a batch, and `file_counts` reports the failures.

The paginated content of `/files/{id}/content` is not available yet.

## Admin API routes

Every route below needs a console session or an admin Bearer token, the role's permission and, for writes, the `X-CSRF-Token` header; the full contract is in the [API reference](/docs/api/).

| Route | What it does |
| --- | --- |
| `GET /api/v1/admin/vector-stores` | Lists every store (`stores`) with owner (`team`), model (`embedding_model`), occupancy and sharing (`shared_with`), for the console (`vector_stores:read`), with the effective `vector_stores` settings (`max_stores_per_team`, `max_documents`, `max_bytes`, `max_chunks`, `chunk_chars`, `chunk_overlap`, `ocr_model`), read-only: they are boot settings |
| `POST /api/v1/admin/vector-stores` | Creates a store for a team (`team`; admin, or team admin of that team) |
| `DELETE /api/v1/admin/vector-stores/{id}` | Deletes a console store with its documents |
| `GET /api/v1/admin/vector-stores/{id}/documents` | Lists the documents of a store |
| `DELETE /api/v1/admin/vector-stores/{id}/documents/{doc_id}` | Deletes one document and its vectors |
| `PUT /api/v1/admin/vector-stores/{id}/sharing` | Replaces the teams the store is shared with (`shared_with`); in multi-tenant mode a team or organization admin names only teams of the store's organization |

## See also

- [OCR](/docs/features/ocr/): PDF and images in vector stores.
- [Capabilities and routes](/docs/features/capabilities/).

## Inspect capacity and chunking policy

Authorized global readers can inspect the existing six limits under **Settings & sources → Inspect session, vector and integration policies**, gated by `boot_settings_view`. `GET /api/v1/admin/config` exposes the same bounded `infrastructure.vector_settings`; `enabled` reflects the existing `vector_stores` flag. Reading these policies does not enable a store, add a vector engine, disclose document/team/OCR/model names, or report occupancy.

| YAML parameter | Default | Existing bound |
| --- | --- | --- |
| `vector_stores.max_stores_per_team` | `20` | Up to 1,000 |
| `vector_stores.max_documents` | `1000` | Up to 100,000 per store |
| `vector_stores.max_bytes` | `52428800` | Up to 1 GiB per store |
| `vector_stores.max_chunks` | `5000` | Up to 50,000 per store |
| `vector_stores.chunk_chars` | `1000` | 200–8,000 characters |
| `vector_stores.chunk_overlap` | `150` | Below half the effective chunk size |

Numeric zero keeps each existing fallback, including overlap 150; it does not mean zero overlap. Explicit zero/default values are labeled YAML, omitted/null values use the default source. Rows require a rollout and retain their origin through administrative snapshot refreshes. Unknown factories or invalid latent policies report unavailable values/source. Store CRUD and ingestion keep their existing ownership, authorization and limits; this inspection adds no runtime limits editor or storage adapter.

## Shared capacity constraints

The six existing capacity/chunking controls share [parameter definitions](/docs/reference/parameter-registry/) across their Go consumers and safe console reader. Raw zero retains each existing default, including `chunk_overlap: 0` selecting `150` rather than disabling overlap. Effective overlap must be strictly below the integer floor of half the effective chunk size: for `chunk_chars: 201`, overlap `99` is valid and `100` is invalid. The same rule is used in policy inspection. Feature activation, declared-store ownership, embedding/OCR references and permissions retain their existing validation; this adds no vector engine or runtime settings writer.
