Learn · Models & search
Models & embeddings
Project models embed indexed text and translate plain-English questions into EdgeQL. Use Napalm’s managed models under a monthly spend limit or add your own provider key.
- API
POST /ask- In the schema
ext::ai::index- Guides
- In-app AI copilots
Napalm’s models#
A project calls models through a configured provider to embed indexed text and to write EdgeQL queries for natural-language questions.
Enabling a project’s API provisions a managed napalm provider with a dedicated key and a monthly spend cap. No external provider account is required.
| Task | Model | Surface |
|---|---|---|
| Embeddings | openai/, 1,536 dimensions. | Surfaceext::ai::index and searches over the index. |
| Questions | Claude Haiku 5.5. If two Haiku statements fail to compile, Claude Sonnet 5.5 takes over. | SurfacePOST /ask, napalm ask and the ask tool agents call. |
Run napalm models notes --give to enable Napalm’s models on an older project or on a project whose managed key could not be created when the API was turned on.
Your own provider#
A project can also call a provider where you hold your own account. Add your key to the project, and the provider bills your account directly without markup or spend caps from Napalm.
| Provider | Name in your schema | Purpose |
|---|---|---|
| OpenAI | builtin::openai | PurposeEmbeddings using the OpenAI models in ext::ai. |
| Mistral | builtin::mistral | PurposeEmbeddings using mistral-embed. |
| Anthropic | builtin::anthropic | PurposeNatural-language questions on projects that do not use Napalm’s models. |
- Key storage
- Napalm stores the secret in the project’s settings and never displays the value again. Pass the secret through
NAPALM_PROVIDER_SECRETor stdin rather than a command-line argument. - A new key
- Run
--addagain to replace the existing key. - Branches
- A new branch copies
main’s providers and keys. Pass--branchto change one branch alone. - In the console
- The Models section of a project’s page adds and removes providers the same way.
Embedding models#
Each ext::ai::index binds to a single embedding model and vector dimension. Declare a model type backed by the napalm provider once, then reference that type on each index.
Bound embedding model
Each ext::ai::index binds to one embedding model. Switching models runs a schema migration that re-embeds every indexed record.
Asynchronous vector index
Vectors in an index share one dimensionality and coordinate space, computed asynchronously in the background after writes commit.
module default { abstract type NapalmTextEmbedding3Small extending ext::ai::EmbeddingModel { annotation ext::ai::model_name := 'openai/text-embedding-3-small'; annotation ext::ai::model_provider := 'napalm'; annotation ext::ai::embedding_model_max_input_tokens := '8191'; annotation ext::ai::embedding_model_max_batch_tokens := '8191'; annotation ext::ai::embedding_model_max_output_dimensions := '1536'; annotation ext::ai::embedding_model_supports_shortening := 'true'; } type Note { required title: str; deferred index ext::ai::index(embedding_model := 'openai/text-embedding-3-small') on (.title); }}- In the background
- Writes commit without waiting for embeddings. Keyword search finds new rows at once, and semantic search includes each row once its embedding finishes.
- Embedded text
- The
on (…)expression defines the text to embed. Concatenate multiple fields inside that expression to embed them together. - Size
- Models that support truncation can be indexed at fewer dimensions. Shorter vectors use less storage and search faster at a modest recall trade-off. The AI extension reference lists all index options.
- Sent once
- Duplicate text within a single batch is embedded once across matching rows.
Changing an index’s model#
Changing an index’s model or dimensions triggers a migration that re-embeds every indexed row and bills for the new calls. Vectors from different models live in incompatible spaces, so one index cannot mix vectors across models.
Rehearse the change first on a branch cloned from your data. Push the model change to the branch, compare search quality against main, and push to main once results look right.
Data sent to models#
Only indexed text, search query strings and POST /ask prompts cross to the model provider. Every question compiles against your schema and executes as the asking caller, so a model sees only rows that caller may read.
Type-checked POST /ask compilation
POST /ask sends your schema and prompt to draft an EdgeQL statement, verifies types and read-only safety in the compiler, and executes under the caller’s select policies.
- To embed
- The indexed text on each inserted or updated row, plus each search query string.
- To answer a question
- Your schema, the question and any compile error from an earlier attempt. Query results return to the model for a written summary unless the request sets
answertofalse.
Through Napalm’s models, questions go only to providers that do not store or train on sent data. When you bring your own key, your agreement with that provider governs data retention.
Spend, limits and failures#
Each project’s managed key enforces a monthly spend cap. napalm models, the Models section of the project page in the console and the Control API all report current spend.
Hard monthly spend ceiling
GET / and napalm models track usage against the monthly cap. Reaching the ceiling returns 424 model_unavailable while fts::search and EdgeQL reads continue uninterrupted.
{ "isAvailable": true, "isManaged": true, "spend": { "limit": 20, "limitRemaining": 15.82, "limitReset": "monthly", "usageDaily": 0.31, "usageWeekly": 1.9, "usageMonthly": 4.18, "usage": 11.6 }, "providers": [{ "name": "napalm", "kind": "napalm", "displayName": "Napalm" }]}When the monthly limit is reached, the provider refuses further calls until the next month while your rows remain safe and searchable by words.
| Symptom | Cause | Fix |
|---|---|---|
| New rows are not found by meaning | Embeddings are still waiting on the provider, while keyword search (fts::search) already finds the new rows. | FixNothing. The rows are embedded once the provider answers again. |
424 model_unavailable | The provider refused or failed the call, usually because the monthly limit is spent. | FixCheck the project’s spend or wait for the monthly reset. |
409 ask_not_configured | The project has no provider that answers questions. | FixGive the project Napalm’s models with napalm models --give. |
409 model_not_configured | A search by meaning ran on a project without a provider for the index’s model. | FixGive the project Napalm’s models with napalm models --give. |
422 ask_unanswered | No generated statement compiled. The error response includes the last statement and the compile error. | FixRephrase the question or name the target type. |
Pricing lists the cost of model calls.