Skip to main content

Module models

Module models 

Source
Expand description

Asking an endpoint which models it serves.

drep init used to offer a hardcoded model name per preset and let the user type over it, with nothing checking the result. presets.rs said so out loud: the defaults are “the one thing here that goes stale”. A typo, or a model the plan does not include, surfaced as a 404 on the first push rather than at the prompt.

The endpoint already knows the answer, and the wizard is holding the key at exactly the moment it asks. So it asks the endpoint.

§Why not a registry

A vendored catalogue would go stale exactly as the hardcoded defaults do and would additionally have to be noticed and updated. A third-party index (models.dev) covers every provider at once, but describes what a vendor publishes rather than what this account’s plan serves, and it is a 4 MB network dependency on somebody else’s uptime. The endpoint is authoritative for the only question being asked.

§One shape, three vendors

Every endpoint drep ships a preset for answers GET {base_url}/models with {"data": [{"id": ...}]}, whichever protocol it otherwise speaks. They disagree only on what else is in each entry: z.ai sends OpenAI’s object/created/owned_by, MiniMax sends Anthropic’s type/created_at /display_name, and Kimi sends both plus context_length and supports_reasoning. Reading id and an optional display_name covers all three, and serde ignores the rest - which is also what stops a new field breaking the parse.

The protocol still decides the auth header, because that is not negotiable per request: bearer for OpenAI-compatible, x-api-key plus a version for Anthropic.

§Failure is never fatal

A listing is a convenience during setup. An endpoint that does not serve one (a local llama.cpp build, a gateway, anything older) must leave the user typing a name exactly as before, so every error here is something the caller reports and moves past. Nothing in this module can stop drep init.

Structs§

Http
The real thing: one HTTP GET.
Model
A model an endpoint offers.

Enums§

ListError
Why a listing could not be produced.

Traits§

ModelSource
Where the wizard gets a model list.