# Migrate from turbopuffer

WarpSearch serves the turbopuffer HTTP API at `https://api.warpsearch.io/compat/turbopuffer`, so the official
turbopuffer SDKs for Python, TypeScript, Go, Java and Ruby run against it once you change the base URL and the
API key. A turbopuffer namespace becomes a WarpSearch collection. This page walks through a move: connect, check
what your code uses, copy the data, and trial it. The [turbopuffer compatibility](compat-turbopuffer.md) page has
the full reference.

## 1. Point the SDK at WarpSearch

Create an API key in the [management console](/console/), then change two settings and remove the region. Every
SDK refuses to start when a region is set and the base URL has no `{region}` placeholder.

```bash
export TURBOPUFFER_BASE_URL=https://api.warpsearch.io/compat/turbopuffer
export TURBOPUFFER_API_KEY=ws_...
unset TURBOPUFFER_REGION
```

Or in code:

```python
from turbopuffer import Turbopuffer

warp = Turbopuffer(
    base_url="https://api.warpsearch.io/compat/turbopuffer",
    api_key="ws_...",
)
```

The setting names for each SDK are in the [Connect](compat-turbopuffer.md#connect) table. Creating a namespace needs
a key with the `editor` or `admin` role; writes need `writer` and queries need `viewer`.

## 2. Check what works and what answers 501

| Area | On WarpSearch |
|---|---|
| Writes | `upsert_rows`, `upsert_columns`, `deletes`, `distance_metric`, `schema`, `create_namespace`, `return_affected_ids` |
| Queries | Vector `ANN` and exact `kNN`, BM25 full text, ordering by attributes, filters, `aggregate_by`, multi-query with RRF. See [Queries](compat-turbopuffer.md#queries) |
| Namespaces | Write, query, delete, list, metadata, schema, `hint_cache_warm` |
| `501`, not implemented yet | `patch_rows`, `patch_columns`, `patch_by_filter`, `delete_by_filter`, conditional writes (`upsert_condition`, `patch_condition`, `delete_condition`), `encryption`, `copy_from_namespace`, `branch_from_namespace`, `explain_query`, `_debug/recall`, `PATCH` on namespace metadata |
| `501` in queries | The `Attribute`, `Saturate`, `Decay` and `Dist` rank expressions, `SparseKNN`, `Embed` in `rank_by`, `compute_attributes` (including `Highlight`), `rerank_by` with a model, `IGlob` and `NotIGlob`, and some `Glob` and `limit.per` forms |
| Not supported | Sparse vectors, multi-vector `late_interaction`, `bytes`, `[N]i8` and `embed`. WarpSearch does not create embeddings; send your own vectors |

A write that contains any `501` feature is rejected and writes nothing, even if it also contains upserts. `501`
responses carry `x-should-retry: false`, so the SDK raises at once. Search your code for the features above before
you start; each one needs a change, such as a full upsert in place of a patch.

## 3. Copy a namespace

There is no server-side copy between turbopuffer and WarpSearch. Page through the turbopuffer namespace ordered by
`id`, and upsert each page into WarpSearch. Run this with your turbopuffer client configured as it is today, and a
second client pointed at WarpSearch:

```python
from turbopuffer import Turbopuffer

source = Turbopuffer(region="gcp-us-central1", api_key="tpuf_...")  # your turbopuffer account
warp = Turbopuffer(base_url="https://api.warpsearch.io/compat/turbopuffer", api_key="ws_...")

src = source.namespace("docs")
dst = warp.namespace("docs")

attributes = ["vector", "text", "category"]  # every attribute you want to keep
page_size = 1000                             # keep within turbopuffer's top_k limit
last_id = None

while True:
    query = {"rank_by": ("id", "asc"), "top_k": page_size, "include_attributes": attributes}
    if last_id is not None:
        query["filters"] = ("id", "Gt", last_id)
    page = src.query(**query)
    if not page.rows:
        break
    dst.write(
        upsert_rows=[row.to_dict() for row in page.rows],
        distance_metric="cosine_distance",  # the metric the namespace uses on turbopuffer
        schema={"text": {"type": "string", "full_text_search": True}},
    )
    last_id = page.rows[-1].id
```

- **Schema first.** Send the same `schema` you use on turbopuffer with the first write, including
  `full_text_search` on text attributes. Types are otherwise inferred from the first non-null value. Changing an
  attribute's options later (for example turning on `full_text_search`) answers `501`, so set them up front.
- **Vectors.** A column named `vector` is a vector automatically. Any other vector attribute needs an `[N]f32` type
  or `ann: true` in `schema`.
- **Attribute names.** Letters, digits, `_`, `.` and `@`, starting with a letter or `_`. Rename others before you
  write them, or the write fails with `400`.
- **Namespace names.** Names that are not valid collection names (uppercase, `-`, `.`) work through the turbopuffer
  API unchanged and are stored under a derived `tp_...` collection name.
- **Request size.** Plan limits on documents and bytes per request apply. On `413 request_too_large`, write
  smaller pages. See [Limits and errors](limits-and-errors.md).
- **Check the count.** `GET /v2/namespaces/{namespace}/metadata` reports `approx_row_count`, refreshed about once a
  minute. Compare it with the source namespace after the copy.

Writes are committed before the response returns, so the next query sees them.

## 4. Trial checklist

1. **Run your test suite** against WarpSearch with the new base URL. Log every `501` and `400`; that list is your
   migration work.
2. **Compare results.** Vector distances are the same as turbopuffer's. BM25 matching rows, `$dist`
   and ordering can differ (different tokenizer, stop words kept, English-only KStem stemming).
3. **Check ordering by attributes.** Documents without a value sort last in both directions; turbopuffer puts them
   first when ascending.
4. **Check multi-query.** Without `rerank_by`, each subquery runs separately, not on one snapshot.
5. **Plan for idle collections.** A collection that has been idle can answer `503 warming_up` with a `Retry-After`
   header while it loads. Retry on that code, call `hint_cache_warm` ahead of traffic, or use keep-warm. See
   [Idle collections and cold starts](collections.md#idle-collections-and-cold-starts).
6. **Read usage in the console.** The `billing` fields in responses are always zero; WarpSearch bills by
   [its own plans](pricing.md).
7. **Check the cost model.** Compare current plans using your measured query volume, storage,
   returned data and keep-warm usage. A single index-size threshold does not establish which
   service costs less. See [Pricing](pricing.md).
8. **Cut over.** Switch the environment variables in production, and keep the turbopuffer namespace until you are
   satisfied.
