{% from "_macros.html" import icon %} {# One connection: an editable form plus its current status. Swapped in place by "Test & refresh" and "Check balance", so this fragment has to render on its own as well as inside the list: everything it reads besides `connection` comes in `row` (api/admin.py `_row_context`). #} {% set health = connection.health_json or {} %} {% set status = health.status if connection.enabled else "off" %} {% set balance = health.balance or {} %}
{# The last health check (services/llm/health.py), every few minutes and on Test: answering, loading a model, unreachable, or answering with an error. Before the first check, what the last refresh said. #} {{ connection.name }} {{ connection.provider_name }} {{ t(connection.provider_info.label) if connection.provider_info.id == 'openai_compatible' and not health.server else health.server if connection.provider_info.id == 'openai_compatible' else connection.provider_info.label }} {% if health.latency_ms is defined and status in ('ok', 'loading') %} {{ t("%(ms)s ms", ms=health.latency_ms) }} {% endif %} {% if status == 'loading' and health.loading %} {{ t("loading %(model)s", model=health.loading) }} {% endif %} {% if row.model_count is defined %} {{ t("1 model") if row.model_count == 1 else t("%(n)s models", n=row.model_count) }} {% endif %} {% if not connection.enabled %} {{ t("disabled") }} {% endif %}
{% if message %} {#- What Test or Check balance just said: a toast (ui.js), like any result. -#}
{% if message_kind == "error" %}{{ icon("warning", "alert__icon") }}{% endif %} {{ message }}
{% elif connection.last_error %}
{{ icon("warning", "alert__icon") }} {{ connection.last_error }}
{% elif status in ('down', 'error') and health.error %}
{{ icon("warning", "alert__icon") }} {{ health.error }}
{% endif %}

{{ tm("How clients such as the LLeMbas CLI name this connection's models: provider/model, for example llama/bonsai. Lowercase letters, digits and hyphens, unique among connections.") }}

{% if connection.api_key_encrypted %} {{ tm("Currently %(masked)s. Leave the dots alone to keep it, or clear the field to remove the key entirely.", masked=row.masked) }} {% else %} {{ t("No key is stored for this endpoint.") }} {% endif %}

{# Only for the types whose spend is read with a separate admin key. #} {% if connection.provider_info.balance_needs_billing_key %}

{% if connection.billing_key_encrypted %} {{ tm("Currently %(masked)s. Leave the dots alone to keep it, or clear the field to remove the key entirely.", masked=row.masked_billing) }} {% endif %} {{ t("An admin key from the provider, used only to read what the account has spent. Never used for a reply; a reply never fails on it.") }}

{% else %} {% endif %}

{{ t("What this connection's model prices are typed in, and what a reply on one of them costs in.") }}

{% if row.has_balance %} {# What the provider itself says is left, or was spent -- its figure, beside (never mixed into) this instance's own cost estimate. #}
{{ t("Balance at the provider") if balance.kind != 'spent_30d' else t("Spent at the provider, last 30 days") }}
{% if balance.ok %} {% for item in balance["items"] %}{{ item.amount }} {{ item.currency }}{{ " · " if not loop.last }}{% else %}{{ t("Nothing reported.") }}{% endfor %} {% elif balance.error %} {{ t(balance.error) }} {% else %} {{ t("Not read yet.") }} {% endif %}

{% if balance.checked_at %}{{ t("As the provider reported it at %(when)s UTC.", when=balance.checked_at[:16].replace("T", " ")) }}{% endif %} {{ t("The provider's own figure. A reply's cost here is this instance's estimate from the model's prices, or the provider's when it reports one.") }}

{% endif %} {# Which data group this provider reads. Only worth a control once there is a second group to choose; until then every connection is in the default one and the field would be a select with one option. #} {% if row.data_group_choices and row.data_group_choices|length > 1 %}

{{ t("Its models read only this group's memories, and a chat started on one of them stays in it. Moving a connection does not move any data: it starts reading the other group.") }}

{% endif %}

{{ tm("Only used by image generation's Preserve VRAM, to free this endpoint's memory while ComfyUI works. llama-swap answers GET /unload. Leave it empty for anything on another machine — its memory is not the memory being freed, and it would be an unexplained request.") }}

{{ tm("One Name: value per line, sent with every request to this endpoint. OpenRouter reads HTTP-Referer and X-Title and attributes your usage with them. Leave it empty unless an endpoint has asked for something.") }}

{{ t("Tick this for llama-swap in front of one GPU, or anything else that unloads one model to serve another. A model here may then be its own helper, but never send a helper to another model on this connection: loading it would unload the model whose reply is waiting.") }}