troupe models --json prints what troupe models says as one JSON object for a program: the models with their prices as numbers, the roles, what the catalog fetched from where and when, and the named providers; never a key¶
Decision 783 · accepted · 2026-10-05 · issue #387
- Built beside the text.
Troupe.Config.Models.json/2, reached asConfig.models_json/2besideexplain/3, takes the config andaskedasdescribe/2does and is built from the calls the text is:Config.models/1,resolve_model/2,price/2, and the catalog's record (Store.sources/0,providers/1,source/2,served/3). The wording staysdescribe/2's; the JSON says the same facts as values. A test holds the two together: every model the JSON lists is a line of the text, each of its sources acatalog:line, and a role's model it says is not served is NOT SERVED there. - The shape.
models, one object for each ofConfig.models/1:id,provider(the named one,nullfor the session-wide),model,context,inputandoutputin dollars per million tokens (to four places, as the desktop app's list) ornull,price_source(catalog,configornull),source(where its facts came from, 778:catalog,config,yamloropencode),key, andserved:true,falsewith the fivenearestids the provider does list, ornullwhen that provider never answered.servedis said of every model, where the text marks only a role's: the text is loud about what would fail a turn, and a program decides for itself what to mark.roles:default,cheapandexpensive, each the idresolve_model/2resolves it to, so an unset role is the default's.catalog: the cache'spathandfetched_at, andsources, one for each provider a refresh asks, as thecatalog:lines are:provider,type,base_url, the listing'surl, how manymodelsit listed,fetched_at, andstatus,fetchedby this run,cached,failed(witherrorandfailed_at) ornot_asked;nullwhen there is no cache.providers: the named ones astroupe configlists them,name,type,base_url,auth,source,keyand themodelseach declares. - No key.
keyistrueorfalse, never the key, masked or not, as the extension's view shows it (765). It is whatConfig.models/1decided for each model; a named provider's is its models', so it is decided in one place. - The command.
troupe models --json [--workspace DIR] [--refresh]refreshes astroupe modelsdoes (778), prints the object and exits 0. A config that does not load exits 1 with the reason on standard error, astroupe modelsdoes, rather than as anerrorsobject on standard output asconfig --explain --jsondoes: a program that asks for the models has nothing to show of a config that does not load but the reason. It has its own line introupe --helpand the reference.
Governs: apps/troupe_core/lib/troupe/config/models.ex, clients/tui/lib/troupe/cli/runner.ex