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::{Ceiling, model::Window};
9use serde::{Deserialize, Serialize};
10
11/// One model an endpoint serves, with what the endpoint said about it.
12///
13/// **An endpoint's list is more than bare ids.** Everything the
14/// provider states beside each id — the window, the ceiling, what the
15/// model accepts, what it costs — is what a person chooses a model by.
16/// This is that statement, carried to the page that shows the list.
17///
18/// **Every field from `id` to `output_price` is what the upstream said,
19/// not what this city concluded.** Absence means the row said nothing; it
20/// never means zero, and it is never filled in from the preset table here.
21/// The ladder that picks a figure — the person's own entry, then the
22/// upstream's statement, then the preset table, then the policy default
23/// — runs where the call is made, and a summary that had already
24/// climbed it would be a second answer to which figure won.
25///
26/// The last two fields are the city's answers, each from its one
27/// authority: `thinking` names the rung it came from, and `canonical` is
28/// `gateway::provider::identity`'s (`crates/wire/spec/Answer/Endpoints.lean` §8-92).
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
30#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
31pub struct ModelFactsSummary {
32 pub id: String,
33 /// How many tokens this model reads in one call.
34 pub context_tokens: Option<Window>,
35 /// How many tokens it may write back.
36 pub max_output_tokens: Option<Ceiling>,
37 /// What it accepts, in the provider's own words (`text`, `image`,
38 /// `audio`). Empty means the row said nothing, never "text only".
39 pub input_modalities: Vec<String>,
40 /// The provider's own input price, verbatim, unit included when the
41 /// provider stated one. Text rather than a number: a price is a
42 /// float and a float does not belong in a payload this city writes
43 /// down, and the units providers quote in do not agree.
44 pub input_price: Option<String>,
45 /// The provider's own output price, verbatim. See `input_price`.
46 pub output_price: Option<String>,
47 /// The thinking levels this (Endpoint, model) offers, and the rung of
48 /// the gateway's thinking ladder that said so.
49 pub thinking: super::ThinkingOffer,
50 /// This model's identity across providers: two rows are one model
51 /// exactly when these are equal.
52 pub canonical: String,
53}