LiveView for creating and editing AI endpoints.
An endpoint combines provider credentials, model selection, and generation parameters into a single configuration.
Summary
Functions
Formats a number with thousands separators.
Formats a per-token model price as a per-million-tokens display.
Returns parameters supported by the model, filtered to ones we have UI for. Groups them by :basic and :advanced.
Renders a single model option as a clickable card with name, ID, context-length / max-output badges, and prompt / completion pricing.
Gets the max tokens limit for the selected model.
Parameter definitions with type, constraints, and UI metadata. Only parameters we support in the UI are defined here.
Callback implementation for Phoenix.LiveView.render/1.
Functions
Formats a number with thousands separators.
Formats a per-token model price as a per-million-tokens display.
OpenRouter pricing comes back in two shapes — newer rows use a JSON
number, older rows use a stringified float. This helper accepts
either and returns a rounded "$X.XX" string. Returns nil for
empty/missing values so the template can render-or-skip cleanly.
Examples
iex> EndpointForm.format_price(0.0000015)
"$1.50"
iex> EndpointForm.format_price("0.0000015")
"$1.50"
iex> EndpointForm.format_price(nil)
nil
Returns parameters supported by the model, filtered to ones we have UI for. Groups them by :basic and :advanced.
Renders a single model option as a clickable card with name, ID, context-length / max-output badges, and prompt / completion pricing.
The same card is used in two places:
- Inside the model grid — the operator's browse surface. Click selects. The currently-selected card is excluded from the grid (it's hoisted to the top — see below) so each model appears in exactly one location.
- Hoisted above the grid as the "Current Model" — when
@selected_modelis set, the card moves out of the grid to the top of the section.show_clear: trueadds an "X" button that deselects (drops the card back into the grid). Clicking the card body itself is a no-op (selecting an already-selected model has no effect).
This keeps a single source of truth for the rich model display — badges + pricing — instead of duplicating the layout between a separate summary panel and the grid.
Attributes
model(:map) (required)selected(:boolean) (required)show_clear(:boolean) - Defaults tofalse.
Gets the max tokens limit for the selected model.
Attributes
key(:string) (required)definition(:map) (required)form(:map) (required)endpoint(:any) - Defaults tonil.selected_model(:map) - Defaults tonil.size(:string) - Defaults to"md".
Parameter definitions with type, constraints, and UI metadata. Only parameters we support in the UI are defined here.
Callback implementation for Phoenix.LiveView.render/1.