Model controls
Search a model catalog, configure reasoning and approval mode, and compare prices
ModelSelector provides a form trigger. ChatModelSelector provides a compact chat trigger with model and optional reasoning submenus. Both use the same searchable, sorted catalog, selection state, brand icons, and focus/hover details.
Catalog and configuration
Pass models: ModelSummary[]. The shared City catalog supplies the description, modalities, context window, tags, reasoning, and pricing fields. Map a CityModelDescriptor to the UI projection with { ...descriptor, model_id: descriptor.id }. pricing accepts one shared ModelPricing object or an array. The components do not fetch a catalog or save settings.
ModelSelector takes current_model_id, on_select_model, optional loading, empty_text, trigger_label, control_size (compact, default, or large), align, side, and class_name. It supports every model in the supplied catalog. The field trigger uses theme field colors at heights of 24, 32, and 40px; the chat trigger is a transparent 24px pill.
ChatModelSelector takes configuration: { model_id, reasoning_effort? }, models, models_loading, set_model, and optional set_reasoning_effort. It only lists models with text, stream, or openai capability. Reasoning is shown only when the selected model declares efforts and the host supplies a save callback. The host decides whether changing models resets a reasoning preference. Selection callbacks own persistence and error handling.
ChatApprovalModeSelector takes configuration: { approval_mode } and set_approval_mode. It uses the shared Session modes ask and always-allow. Omit configuration to disable the trigger.
Compose individual parts
| Export | Purpose |
|---|---|
ModelOptions | Search input, keyboard entry, selected model, and preview details; takes models, current_model_id, loading, and on_select. Set variant="field" for compact form rows; the default menu uses chat menu rows |
ModelDetails | Standalone description, context, capabilities, reasoning, tags, and token price; takes model |
ReasoningOptions | Ordered reasoning choices; takes efforts, selected_effort, and on_select |
SelectorSubmenu | Positioned submenu entry with label, value, and children |
LLMModelIcon | Brand recognition from model_id, optional model_name, and tags |
ModelPricingChart | Responsive SVG comparison from data: ModelPricingPoint[]; optional numeric locale |
build_model_pricing(models) returns input and output USD prices per million tokens. It skips entries missing either price, unsupported currency/unit combinations, and invalid scales. For conditional prices it uses the highest input and output rate. The chart uses a logarithmic scale when the positive price range is at least 20
Use format_token_count, format_usd_price, format_credit_amount, format_compact_number, format_model_reasoning, format_default_model_reasoning, and get_default_model_reasoning to keep adjacent model information consistent. is_text_model shares the chat capability predicate.
Text and styles
Text-bearing components accept translate(key, values?). Keys use the chat:, common:, and settings: namespaces; the built-in fallback is English. Supply the host's translation function to update labels with the application's current language. ModelPricingChart.locale controls numeric formatting independently.
Load Tailwind, @downcity/ui/source.css, and @downcity/ui/styles.css as described in Installation. Model components use the SDK theme and do not depend on Desktop stores, IPC, or routing.