# Model facts Albedo keeps facts about models that the catalogs lack in one table, `model-facts.json`. Each entry matches requests by provider extension, endpoint host, and model, and carries one or more sections: - `cache`: the prompt-cache lifetime and prices, read by [`cache_ttl`](../packages/albedo_sdk/src/albedo_sdk/cache_ttl.gleam). See [Prompt cache TTL table](cache-ttl.md). - `context`: a default context window, read by [`context_limits`](../packages/albedo_sdk/src/albedo_sdk/context_limits.gleam). See [context windows](#context-windows). - `media`: the copies a model is sent of a long clip, the fastest frame rate it samples, and what a clip costs, read by [`media_facts`](../packages/albedo_sdk/src/albedo_sdk/media_facts.gleam). See [copies a model takes in](media.md#copies-a-model-takes-in). [`model_facts`](../packages/albedo_sdk/src/albedo_sdk/model_facts.gleam) owns the layers, the merge, matching, and the remote copy. Each section's module owns its decoder and what its values mean. The shipped data is [`priv/model-facts.json`](../apps/albedo/priv/model-facts.json). ## Entries An entry has an `id`, an optional `match`, an optional `note`, provenance, and its sections. Provenance is `evidence` (`documented`, `measured`, `implemented`, `folklore` or `unknown`, the default), `source` and `checked`. The sections of one entry share it, so put facts with different sources in separate entries. `match` can restrict `extension`, `host`, and `model`, each one pattern or a list of them. A pattern matches case-insensitively, with `*` for any run of characters. An absent field matches anything. `model_facts.matches_glob` does the matching. A lookup takes the first entry in table order that matches and carries the section it wants. An entry with only a `context` section never shadows a `cache` entry below it. List specific entries before general ones. An entry whose section fails to decode is reported on standard error and left out of that section's lookups. ## Layers `model_facts` reads these files and merges them by `id`, later ones winning: 1. `default`: the shipped `priv/model-facts.json`. 2. `remote`: `$ALBEDO_HOME/model-facts-remote.json`, fetched from a URL. 3. `cache-ttl`: `$ALBEDO_HOME/cache-ttl.json`, the cache override from before this table. 4. `context-limits`: `$ALBEDO_HOME/context-limits.json`, the context override from before this table. 5. `local`: `$ALBEDO_HOME/model-facts.json`. A later entry replaces an entry with the same ID whole, in place, so an override repeats every section it keeps. New IDs go before every entry of earlier layers. Entries merge before their sections decode, so an invalid override still shadows the entry it replaces. Duplicate IDs invalidate a layer. An entry with no section that has a top-level `policy` is read as a `cache` section of the fields `cache-ttl.json` used, and one with a top-level `contextTokens` as a `context` section. Existing `cache-ttl.json` and `context-limits.json` files, and remote URLs that serve the old cache table, keep working without edits. Write new entries in sections. A daemon from before this table ignores `model-facts.json` and reads only the old files. [`layered_table`](../packages/albedo_sdk/src/albedo_sdk/layered_table.gleam) reads each layer. Files are limited to 1 MiB. Each section keeps its own parsed layers and decoded table, cached by file size and modification time. A malformed revision keeps the layer's last good entries and reports an error. Transient read errors are retried. A missing layer other than `default` contributes no entries and no error. ## Remote copy The `modelFacts` section of extension settings names the remote source. `url` defaults to `priv/model-facts.json` on the repository's main branch, and `null` disables fetching. `refreshHours` defaults to 24, and zero disables the background refresh. When `modelFacts` is absent or `null`, the `cacheTtl` section from before this table is read in its place, with the same fields. A URL it names that serves the old cache table still works. Reading the cache section (`cache_ttl.table`) or a model's media facts (`media_facts.fidelity`) starts a background refresh of a stale copy. Context lookups do not, since every catalog answer makes one. `model_facts.reload`, which `/reload` runs, fetches the copy now and reports a failure. A failed fetch keeps the previous copy. A fetched body is committed only when it is valid JSON that passes the layer check. A successful replacement invalidates every section's caches even if the file revision appears unchanged. [`sdk/cached_fetch`](../packages/albedo_sdk/src/albedo_sdk/cached_fetch.gleam) does the fetch. ## Context windows A `context` section has `tokens`, a window from 1 to 100,000,000: ```json { "id": "fixture-cap", "match": { "model": "fixture" }, "context": { "tokens": 100000 } } ``` [`extension.model_info`](../packages/albedo_sdk/src/albedo_sdk/extension.gleam) applies the first matching entry to each catalog answer as its default window, and appends `context-limits ()` to its source. When the catalog's window is larger, it becomes `max_context_tokens`, so `/raise-cap` and the model picker can still raise the cap to the provider's ceiling. The shipped table has no context entries. ## Related pages - [All topics](README.md) - [Prompt cache TTL table](cache-ttl.md) - [Audio and video input](media.md) - [Models](models.md) - [Change guidance](contributing.md)