Skip to main content

wire/answer/
model_facts.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! What an endpoint said about one model it serves.
7
8use kernel::event::record::Listing;
9use kernel::{Ceiling, model::Window};
10use serde::{Deserialize, Serialize};
11
12/// One model an endpoint serves, with what the endpoint said about it.
13///
14/// **An endpoint's list is more than bare ids.** Everything the
15/// provider states beside each id — the window, the ceiling, what the
16/// model accepts, what it costs — is what a person chooses a model by.
17/// This is that statement, carried to the page that shows the list.
18///
19/// **Every field from `id` to `output_price` is what the upstream said,
20/// not what this city concluded.** Absence means the row said nothing; it
21/// never means zero, and it is never filled in from the preset table here.
22/// The ladder that picks a figure — the person's own entry, then the
23/// upstream's statement, then the preset table, then the policy default
24/// — runs where the call is made, and a summary that had already
25/// climbed it would be a second answer to which figure won.
26///
27/// The last three fields are the city's own, each from its one
28/// authority: `thinking` names the rung it came from, `canonical` is
29/// `gateway::provider::identity`'s (`crates/wire/spec/Answer/Endpoints.lean` §8-92),
30/// and `listing` is what the attach recorded about where the row came
31/// from (`crates/wire/spec/Frames.lean` D57).
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
34pub struct ModelFactsSummary {
35    pub id: String,
36    /// How many tokens this model reads in one call.
37    pub context_tokens: Option<Window>,
38    /// How many tokens it may write back.
39    pub max_output_tokens: Option<Ceiling>,
40    /// What it accepts, in the provider's own words (`text`, `image`,
41    /// `audio`). Empty means the row said nothing, never "text only".
42    pub input_modalities: Vec<String>,
43    /// The provider's own input price, verbatim, unit included when the
44    /// provider stated one. Text rather than a number: a price is a
45    /// float and a float does not belong in a payload this city writes
46    /// down, and the units providers quote in do not agree.
47    pub input_price: Option<String>,
48    /// The provider's own output price, verbatim. See `input_price`.
49    pub output_price: Option<String>,
50    /// The thinking levels this (Endpoint, model) offers, and the rung of
51    /// the gateway's thinking ladder that said so.
52    pub thinking: super::ThinkingOffer,
53    /// This model's identity across providers: two rows are one model
54    /// exactly when these are equal.
55    pub canonical: String,
56    /// Whether the endpoint listed this model, or the person named it
57    /// and the endpoint did not list it. A named row states nothing
58    /// else because nobody asked the provider, which is different from
59    /// a provider that said nothing.
60    pub listing: Listing,
61}