v0.1.54 7134fb7

models.go RawHistoryFolder

1package provider
2
3import (
4	"fmt"
5	"sync"
6)
7
8// Model describes a single LLM we know about.
9type Model struct {
10	Provider      string // "anthropic" | "openai"
11	ID            string // API id
12	DisplayName   string
13	ContextWindow int
14	MaxOutput     int
15	Reasoning     bool // supports reasoning/thinking
16
17	// Prices are USD per 1M tokens.
18	PriceInput      float64
19	PriceOutput     float64
20	PriceCacheRead  float64
21	PriceCacheWrite float64
22
23	// Speculative marks models whose ids are known from the upstream
24	// vendor's CLI but not yet live on their public API. They'll 404
25	// today but start working the moment the provider flips the switch.
26	Speculative bool
27
28	// BaseURL overrides the provider's default API endpoint for this
29	// model. Optional; when empty the provider's default (or the
30	// --base-url flag) is used. Useful for local models served by
31	// ollama, vLLM, LM Studio, etc.
32	BaseURL string
33
34	// Source is where this model entry came from: "catalog" (baked in),
35	// "live" (discovered via /v1/models), or "cache" (loaded from the
36	// on-disk cache). Informational.
37	Source string
38}
39
40// Catalog is the hardcoded, read-only list of supported models.
41// Prices are USD per 1M tokens. The list is curated to what zot's
42// clients (Anthropic Messages + OpenAI Chat Completions) can actually
43// talk to; models that are only reachable through the OpenAI Responses
44// API (o1-pro, o3-pro, gpt-5-pro) are omitted.
45var Catalog = []Model{
46	// ---- Anthropic / Claude 4.x ----
47	{
48		Provider: "anthropic", ID: "claude-sonnet-4-5", DisplayName: "Claude Sonnet 4.5",
49		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
50		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
51	},
52	{
53		Provider: "anthropic", ID: "claude-opus-4-1", DisplayName: "Claude Opus 4.1",
54		ContextWindow: 200000, MaxOutput: 32000, Reasoning: true,
55		PriceInput: 15.00, PriceOutput: 75.00, PriceCacheRead: 1.50, PriceCacheWrite: 18.75,
56	},
57	{
58		Provider: "anthropic", ID: "claude-opus-4-0", DisplayName: "Claude Opus 4",
59		ContextWindow: 200000, MaxOutput: 32000, Reasoning: true,
60		PriceInput: 15.00, PriceOutput: 75.00, PriceCacheRead: 1.50, PriceCacheWrite: 18.75,
61	},
62	{
63		Provider: "anthropic", ID: "claude-sonnet-4-0", DisplayName: "Claude Sonnet 4",
64		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
65		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
66	},
67	{
68		Provider: "anthropic", ID: "claude-haiku-4-5", DisplayName: "Claude Haiku 4.5",
69		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
70		PriceInput: 1.00, PriceOutput: 5.00, PriceCacheRead: 0.10, PriceCacheWrite: 1.25,
71	},
72
73	// ---- Anthropic / Claude 3.x (legacy) ----
74	{
75		Provider: "anthropic", ID: "claude-3-7-sonnet-20250219", DisplayName: "Claude Sonnet 3.7",
76		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
77		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
78	},
79	{
80		Provider: "anthropic", ID: "claude-3-5-sonnet-20241022", DisplayName: "Claude Sonnet 3.5 v2",
81		ContextWindow: 200000, MaxOutput: 8192, Reasoning: false,
82		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
83	},
84	{
85		Provider: "anthropic", ID: "claude-3-5-haiku-latest", DisplayName: "Claude Haiku 3.5",
86		ContextWindow: 200000, MaxOutput: 8192, Reasoning: false,
87		PriceInput: 0.80, PriceOutput: 4.00, PriceCacheRead: 0.08, PriceCacheWrite: 1.00,
88	},
89	{
90		Provider: "anthropic", ID: "claude-3-opus-20240229", DisplayName: "Claude Opus 3",
91		ContextWindow: 200000, MaxOutput: 4096, Reasoning: false,
92		PriceInput: 15.00, PriceOutput: 75.00, PriceCacheRead: 1.50, PriceCacheWrite: 18.75,
93	},
94
95	// ---- Kimi / Kimi Code ----
96	{
97		Provider: "kimi", ID: "kimi-for-coding", DisplayName: "Kimi-k2.6",
98		ContextWindow: 262144, MaxOutput: 32000, Reasoning: true,
99		BaseURL: "https://api.kimi.com/coding/v1",
100	},
101
102	// ---- OpenAI / GPT-5 family ----
103	{
104		Provider: "openai", ID: "gpt-5", DisplayName: "GPT-5",
105		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
106		PriceInput: 1.25, PriceOutput: 10.00, PriceCacheRead: 0.125,
107	},
108	{
109		Provider: "openai", ID: "gpt-5-mini", DisplayName: "GPT-5 mini",
110		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
111		PriceInput: 0.25, PriceOutput: 2.00, PriceCacheRead: 0.025,
112	},
113	{
114		Provider: "openai", ID: "gpt-5-nano", DisplayName: "GPT-5 nano",
115		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
116		PriceInput: 0.05, PriceOutput: 0.40, PriceCacheRead: 0.005,
117	},
118
119	// ---- OpenAI / GPT-4.1 family ----
120	{
121		Provider: "openai", ID: "gpt-4.1", DisplayName: "GPT-4.1",
122		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
123		PriceInput: 2.00, PriceOutput: 8.00, PriceCacheRead: 0.50,
124	},
125	{
126		Provider: "openai", ID: "gpt-4.1-mini", DisplayName: "GPT-4.1 mini",
127		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
128		PriceInput: 0.40, PriceOutput: 1.60, PriceCacheRead: 0.10,
129	},
130	{
131		Provider: "openai", ID: "gpt-4.1-nano", DisplayName: "GPT-4.1 nano",
132		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
133		PriceInput: 0.10, PriceOutput: 0.40, PriceCacheRead: 0.03,
134	},
135
136	// ---- OpenAI / GPT-4o family ----
137	{
138		Provider: "openai", ID: "gpt-4o", DisplayName: "GPT-4o",
139		ContextWindow: 128000, MaxOutput: 16384, Reasoning: false,
140		PriceInput: 2.50, PriceOutput: 10.00, PriceCacheRead: 1.25,
141	},
142	{
143		Provider: "openai", ID: "gpt-4o-mini", DisplayName: "GPT-4o mini",
144		ContextWindow: 128000, MaxOutput: 16384, Reasoning: false,
145		PriceInput: 0.15, PriceOutput: 0.60, PriceCacheRead: 0.08,
146	},
147
148	// ---- OpenAI / reasoning models ----
149	{
150		Provider: "openai", ID: "o4-mini", DisplayName: "o4-mini",
151		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
152		PriceInput: 1.10, PriceOutput: 4.40, PriceCacheRead: 0.275,
153	},
154	{
155		Provider: "openai", ID: "o3", DisplayName: "o3",
156		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
157		PriceInput: 2.00, PriceOutput: 8.00, PriceCacheRead: 0.50,
158	},
159	{
160		Provider: "openai", ID: "o3-mini", DisplayName: "o3-mini",
161		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
162		PriceInput: 1.10, PriceOutput: 4.40, PriceCacheRead: 0.55,
163	},
164	{
165		Provider: "openai", ID: "o1", DisplayName: "o1",
166		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
167		PriceInput: 15.00, PriceOutput: 60.00, PriceCacheRead: 7.50,
168	},
169
170	// ---- Speculative: Anthropic ----
171	{
172		Provider: "anthropic", ID: "claude-opus-4-5", DisplayName: "Claude Opus 4.5",
173		// 200k ctx / 64k maxOutput per Anthropic's published sizing
174		// for the opus-4-5 family; the 1M context is a 4.6+ thing.
175		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
176		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
177		Speculative: true,
178	},
179	{
180		Provider: "anthropic", ID: "claude-opus-4-6", DisplayName: "Claude Opus 4.6",
181		ContextWindow: 1000000, MaxOutput: 128000, Reasoning: true,
182		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
183		Speculative: true,
184	},
185	{
186		Provider: "anthropic", ID: "claude-opus-4-7", DisplayName: "Claude Opus 4.7",
187		ContextWindow: 1000000, MaxOutput: 128000, Reasoning: true,
188		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
189		Speculative: true,
190	},
191	{
192		Provider: "anthropic", ID: "claude-sonnet-4-6", DisplayName: "Claude Sonnet 4.6",
193		ContextWindow: 1000000, MaxOutput: 64000, Reasoning: true,
194		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
195		Speculative: true,
196	},
197
198	// ---- Speculative: OpenAI ----
199	// Context windows on the OpenAI gpt-5.x family differ by route:
200	// the direct API advertises 400k, the ChatGPT Codex OAuth backend
201	// caps at 272k. zot serves both auth modes from one catalog row
202	// per id, so we pin to the smaller number to keep the context-usage
203	// meter honest under subscription auth. Users on the direct API
204	// simply see a conservative headroom estimate.
205	{
206		Provider: "openai", ID: "gpt-5.1", DisplayName: "GPT-5.1",
207		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
208		PriceInput: 1.25, PriceOutput: 10.00, PriceCacheRead: 0.125,
209		Speculative: true,
210	},
211	{
212		Provider: "openai", ID: "gpt-5.2", DisplayName: "GPT-5.2",
213		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
214		PriceInput: 1.75, PriceOutput: 14.00, PriceCacheRead: 0.175,
215		Speculative: true,
216	},
217	{
218		Provider: "openai", ID: "gpt-5.3", DisplayName: "GPT-5.3",
219		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
220		PriceInput: 1.75, PriceOutput: 14.00, PriceCacheRead: 0.175,
221		Speculative: true,
222	},
223	{
224		Provider: "openai", ID: "gpt-5.4", DisplayName: "GPT-5.4",
225		// ContextWindow: 272k across every route we support (OpenAI
226		// direct API and the ChatGPT Codex OAuth backend).
227		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
228		PriceInput: 2.50, PriceOutput: 15.00, PriceCacheRead: 0.25,
229		Speculative: true,
230	},
231	{
232		Provider: "openai", ID: "gpt-5.4-mini", DisplayName: "GPT-5.4 mini",
233		// ContextWindow: 400k on the OpenAI direct API, 272k on the
234		// ChatGPT Codex OAuth backend. We pin to the smaller Codex
235		// cap so the context-usage meter is honest under subscription
236		// auth; direct-API users simply see a conservative headroom
237		// estimate rather than an inflated one.
238		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
239		PriceInput: 0.75, PriceOutput: 4.50, PriceCacheRead: 0.075,
240		Speculative: true,
241	},
242	{
243		Provider: "openai", ID: "gpt-5.5", DisplayName: "GPT-5.5",
244		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
245		PriceInput: 2.50, PriceOutput: 15.00, PriceCacheRead: 0.25,
246		Speculative: true,
247	},
248	{
249		Provider: "openai", ID: "gpt-5.5-mini", DisplayName: "GPT-5.5 mini",
250		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
251		PriceInput: 0.75, PriceOutput: 4.50, PriceCacheRead: 0.075,
252		Speculative: true,
253	},
254}
255
256// DefaultModel is used when the user does not specify one.
257var DefaultModel = Catalog[0] // claude-sonnet-4-5
258
259// ----- active (merged) catalog -----
260//
261// Callers should use Active() / FindModel / ModelsForProvider for
262// lookups. They return the baked-in Catalog merged with any live
263// models loaded via SetLiveModels.
264
265var (
266	activeMu sync.RWMutex
267	active   []Model = Catalog // default: just the static catalog
268)
269
270// SetLiveModels replaces the "live" overlay used by the active catalog.
271// Typically called after a successful /v1/models discovery or on load
272// from the on-disk cache.
273func SetLiveModels(live []Model) {
274	activeMu.Lock()
275	defer activeMu.Unlock()
276	if len(live) == 0 {
277		active = Catalog
278		return
279	}
280	active = MergeCatalog(live)
281}
282
283// Active returns the current merged catalog.
284func Active() []Model {
285	activeMu.RLock()
286	defer activeMu.RUnlock()
287	out := make([]Model, len(active))
288	copy(out, active)
289	return out
290}
291
292// FindModel returns a Model by id, optionally constrained by provider.
293// If provider is empty, the first matching id is returned. Looks up
294// against the merged active catalog.
295func FindModel(provider, id string) (Model, error) {
296	for _, m := range Active() {
297		if m.ID == id && (provider == "" || m.Provider == provider) {
298			return m, nil
299		}
300	}
301	return Model{}, fmt.Errorf("unknown model %q (provider=%q)", id, provider)
302}
303
304// ModelsForProvider returns all models for the given provider, from the
305// merged active catalog.
306func ModelsForProvider(provider string) []Model {
307	var out []Model
308	for _, m := range Active() {
309		if m.Provider == provider {
310			out = append(out, m)
311		}
312	}
313	return out
314}
315
316// ComputeCost returns the USD cost for the given usage on model m.
317func ComputeCost(m Model, u Usage) float64 {
318	const per = 1_000_000.0
319	return float64(u.InputTokens)*m.PriceInput/per +
320		float64(u.OutputTokens)*m.PriceOutput/per +
321		float64(u.CacheReadTokens)*m.PriceCacheRead/per +
322		float64(u.CacheWriteTokens)*m.PriceCacheWrite/per
323}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close