Documentation
¶
Overview ¶
Package modelcatalog projects the many vendor dialects of an OpenAI-compatible GET /models response onto one provider-neutral shape.
The OpenAI reference payload only carries ids, but real gateways add rich metadata in incompatible places: GitHub Copilot (and Copilot relays) nest it under capabilities.limits / capabilities.supports, OpenRouter uses context_length + architecture + supported_parameters, Mistral and LM Studio expose capability flags or lists, vLLM reports max_model_len, LiteLLM uses max_input_tokens, and so on. Parse understands all of these so a custom endpoint's catalog can carry real context windows, vision, tool and reasoning-effort support instead of bare ids.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID string
Name string // display name; empty when the endpoint advertises none
Vendor string
Kind Kind
// Context is the usable prompt budget in tokens (0 = unknown). When an
// endpoint distinguishes the prompt limit from the total window (Copilot's
// max_prompt_tokens vs max_context_window_tokens) the prompt limit wins:
// compaction math treats this value as the input ceiling, and requests
// above max_prompt_tokens are rejected even when the window is larger.
Context int
Attachment *bool // accepts image input
ToolCall *bool
Reasoning *bool
EffortTiers []string // advertised reasoning_effort values, in endpoint order
// Hidden mirrors Copilot's model_picker_enabled=false: listed for API
// completeness but not meant to be offered in a model picker.
Hidden bool
}
Entry is one model advertised by a /models endpoint. Tri-state capability flags are nil when the endpoint did not advertise them, so callers can fill only the unknowns from another source (e.g. the built-in registry) without overriding what the endpoint explicitly declared.
func Decode ¶
Decode parses a raw /models response body. Numbers are decoded as json.Number so large token limits survive exactly.
func Parse ¶
Parse extracts entries from an already-decoded /models payload. Entries keep the endpoint's order; duplicates (by id) keep the first occurrence.
func ParseEntry ¶
ParseEntry projects a single listing element. Plain strings are treated as ids. It returns false when no id can be determined.
func (Entry) IsChat ¶
IsChat reports whether the entry can serve chat completions. Unknown kinds count as chat because plain OpenAI-compatible payloads carry no type.
func (Entry) Selectable ¶
Selectable reports whether the entry belongs in a coding-agent model picker: a visible chat model that has not explicitly declared that it cannot call tools.
type Kind ¶
type Kind string
Kind is the normalized workload a catalog entry serves.
const ( KindUnknown Kind = "" KindChat Kind = "chat" KindEmbedding Kind = "embedding" KindImage Kind = "image" KindVideo Kind = "video" KindAudio Kind = "audio" KindRerank Kind = "rerank" KindModeration Kind = "moderation" )
Known kinds. KindUnknown means the endpoint did not say; callers treat it as chat because the OpenAI reference payload carries no type at all.
type RawEntry ¶
RawEntry is one undecoded element of a /models listing. FallbackID carries the map key when the listing is an id-keyed object ({"models":{"id":{...}}}).
func RawEntries ¶
RawEntries locates the model list inside the common response envelopes: a bare array, {"data":[...]}, {"items":[...]}, {"models":[...]} or an id-keyed {"models":{...}} map.