> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wazoo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up bring-your-own-key embeddings

> Store your own OpenAI or OpenRouter key, pick an embedding model for a world, reindex, and search with hybrid ranking.

By default, search in a world is keyword search. With bring-your-own-key (BYOK)
embeddings, Worlds also builds vector embeddings of a world's text with your
embedding provider account, and search combines both rankings. Paraphrases and
questions that share no words with the stored text can then find the right
entity. See [Search](https://docs.wazoo.dev/worlds/search.md) for how the rankings merge.

You pay the provider directly for the embedding calls. Wazoo stores your key
encrypted, never returns it, and uses it only to embed the text of your own
worlds.

## Providers and models

A namespace holds one key per provider. The model you choose for a world decides
which provider's key is used.

| Provider | Model id | Notes |
| :- | :- | :- |
| OpenAI | `openai/text-embedding-3-small` | Smallest and cheapest |
| OpenAI | `openai/text-embedding-3-large` | Sent at 1536 dimensions |
| OpenRouter | `openrouter/openai/text-embedding-3-small` | Billed through OpenRouter |
| OpenRouter | `openrouter/openai/text-embedding-3-large` | Sent at 1536 dimensions |

All vectors are 1536 dimensions wide, so a model is only available if it can
produce that width. Larger models are sent a request for 1536 dimensions. Other
models are not accepted.

## Prerequisites

* A Wazoo platform token (`wzp_`) with the `users.write` scope to store and
  revoke keys. A token with `users.read` can list them. See
  [Tokens](https://docs.wazoo.dev/console/tokens.md) for more information.
* A world and a world token (`wzw_`) for it. Choosing a model for the world and
  reindexing it (rebuilding its search index with that model) require a token
  with the `data:write` scope. Searching requires `data:read`.
* An account and API key with an embedding provider. Set a monthly spend limit
  on the key if you want to cap what the provider can bill.
* The base URL of your Worlds deployment. The examples use
  `https://data.wazoo.dev`; if you self-host Worlds, use your own base URL.
  Replace `<world_id>` in each example with your world's id.

**1. Store your provider key**

Send the key to the Platform API with your platform token.

```bash title="Store an OpenAI key" theme={null}
curl -s -X PUT "https://api.wazoo.dev/v1/users/me/embedding-providers/openai" \
  -H "Authorization: Bearer $WAZOO_PLATFORM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "apiKey": "'"$OPENAI_API_KEY"'" }'
```

For OpenRouter, use `openrouter` in the path and your OpenRouter key.

The response shows metadata only:

```json title="Response" theme={null}
{
  "provider": "openai",
  "status": "active",
  "fingerprint": "3f9a1c2e",
  "last4": "Zq4w",
  "createTime": "2026-10-19T14:02:11.000Z"
}
```

The key must consist of 16 to 512 printable characters without whitespace.

**2. Choose a model for a world**

Set the model on the world with a world token that has `data:write`. Choosing a model requires
an active key for that model's provider.

```bash title="Choose a model" theme={null}
curl -s -X PATCH "https://data.wazoo.dev/worlds/<world_id>" \
  -H "Authorization: Bearer $WORLDS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "embeddingModel": "openai/text-embedding-3-small" }'
```

The world's `embeddingStatus` becomes `stale` because the world now has a
model but no vectors built with it yet. Search stays keyword-only until you
reindex.

**3. Reindex the world**

Reindexing rebuilds the world's search index. It embeds the world's text
with your key and spends your provider budget. Your data is not changed, and
reindexing does not run automatically.

```bash title="Reindex" theme={null}
curl -s -X POST "https://data.wazoo.dev/worlds/<world_id>/reindex" \
  -H "Authorization: Bearer $WORLDS_TOKEN"
```

The response `status` is one of:

| Status | Meaning |
| :- | :- |
| `completed` | All vectors are built. |
| `completed_with_vector_errors` | Some vectors failed. `vectorSync` lists what. Call reindex again to retry. |
| `in_progress` | A large world reindexes in windows. Call reindex again until the status is `completed`. |

Vector indexing is asynchronous. When reindex reports `completed`, your
vectors are written, but the vector index can take a minute or more to start
serving them. Keyword search reflects your data immediately, so results
still return in the meantime.

**4. Check the world's status**

```bash title="Read the world" theme={null}
curl -s "https://data.wazoo.dev/worlds/<world_id>" \
  -H "Authorization: Bearer $WORLDS_TOKEN"
```

Read `embeddingStatus` in the response:

| Value | Meaning |
| :- | :- |
| `ready` | Vectors are current. Search is hybrid. |
| `stale` | Vectors cannot be trusted for the current model or data. Reindex. |
| `partial` | Some vectors failed. Hybrid search covers what exists. Reindex. |
| `no_credential` | There is no active key for this model's provider. Store one. |
| `invalid` | The provider rejected your key. Store a new key. |
| `unconfigured` | The world has no allowlisted embedding model. Choose one. |

A world becomes `stale` when you change its model, when you revoke the key
its model uses, or when removing vectors after a delete fails. While a world
is `stale`, search ignores its vectors and runs keyword-only until you
reindex.

**5. Search**

```bash title="Search" theme={null}
curl -s -X POST "https://data.wazoo.dev/worlds/<world_id>/search" \
  -H "Authorization: Bearer $WORLDS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "query": "who does Gregory report to?", "limit": 5 }'
```

The response `mode` says which search ran: `hybrid` (keyword and vectors),
`semantic` (vectors only), `keyword` (full text only), or `fallback` (a
simple text match, used when the search engine is unavailable). A query
that does not share any words with the stored text, such as a paraphrase, returns
results only in `hybrid` or `semantic` mode. If `mode` is still `keyword`
right after a reindex, wait a minute and search again.

## List, rotate, and revoke keys

List the keys a namespace holds. Revoked keys stay in the list so their status
stays readable:

```bash title="List providers" theme={null}
curl -s "https://api.wazoo.dev/v1/users/me/embedding-providers" \
  -H "Authorization: Bearer $WAZOO_PLATFORM_TOKEN"
```

To rotate a key, send the same `PUT` with the new key.

To revoke a key, delete it:

```bash title="Revoke a key" theme={null}
curl -s -X DELETE "https://api.wazoo.dev/v1/users/me/embedding-providers/openai" \
  -H "Authorization: Bearer $WAZOO_PLATFORM_TOKEN"
```

Revoking erases the stored key. Every world that uses that provider's models
becomes `stale` and falls back to keyword search. Worlds on another provider's
models are not affected. After you store a new key, reindex each world before
hybrid search returns. Vectors built before a revoke are never reused.

## Cost and limits

* Reindexing and importing text call your provider and bill your account. A
  retry after a transient provider error is billed again.
* Each namespace has a daily limit on embedding writes. When it is exhausted,
  reindex returns `429` with the code `EMBEDDING_BUDGET_EXCEEDED` and nothing is
  embedded or billed.
* Searching embeds only the query text. Each namespace also has a daily limit on
  embedded searches. Past it, or when the provider is slow or unavailable,
  search falls back to keyword results.

## Troubleshooting

| Symptom | Cause and fix |
| :- | :- |
| `409` with `EMBEDDING_CREDENTIAL_REQUIRED` on step 2 | You have no active key for the model's provider. Store one in step 1. |
| `400` when storing a key | The key has whitespace or is outside 16 to 512 characters, or the provider in the path is not `openai` or `openrouter`. |
| `503` with `EMBEDDINGS_NOT_CONFIGURED` | Embeddings are not enabled on this deployment. Contact the Wazoo team. |
| `embeddingStatus` is `invalid` | Your provider rejected the key several times in a row. Check the key and its spend limit, then store it again. |
| Search `mode` stays `keyword` after reindex | Wait a minute or two, because the vector index updates asynchronously. If it persists, check `embeddingStatus`: anything other than `ready` or `partial` keeps search keyword-only. A `fallback` mode means the search engine itself was unavailable, so try again. |
| `completed_with_vector_errors` | Call reindex again. The `vectorSync.errors` list names the failures. |

## Next steps

* [Search](https://docs.wazoo.dev/worlds/search.md)
* [Tokens](https://docs.wazoo.dev/console/tokens.md)
* [Troubleshooting](https://docs.wazoo.dev/platform/troubleshooting.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.