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 MCP ask tool. |
Check active models and current monthly usage from the CLI with napalm models.
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.
Napalm supports three external model providers for embeddings and natural-language questions.
| 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. |
Provider keys follow branch inheritance and secret-storage rules across the CLI and console.
- 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
napalm models --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 vector index binds to one model, and switching models re-embeds every row.
Background embeddings
Napalm computes vectors in the background after writes commit.
Attach the model to any object type with a deferred ext::ai::index declaration.
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); }}Napalm manages batching, vector dimensions and background indexing automatically.
- 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 those fields 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.
Compiler-checked question queries
Drafted EdgeQL statements pass type and read-only checks before running as the caller.
Each feature sends only the text required for its task.
- 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.
Monthly spend cap
Reaching the monthly cap pauses model calls while keyword search and queries continue.
Inspect daily, weekly and monthly usage at GET /. When the monthly limit is reached, the provider refuses further model calls until the next month while your rows remain safe and searchable by words.
{ "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" }]}Common model and search errors appear below along with the recommended fix.
| 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.