v0.1.12 25b2bd4

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	// ---- OpenAI / GPT-5 family ----
96	{
97		Provider: "openai", ID: "gpt-5", DisplayName: "GPT-5",
98		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
99		PriceInput: 1.25, PriceOutput: 10.00, PriceCacheRead: 0.125,
100	},
101	{
102		Provider: "openai", ID: "gpt-5-mini", DisplayName: "GPT-5 mini",
103		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
104		PriceInput: 0.25, PriceOutput: 2.00, PriceCacheRead: 0.025,
105	},
106	{
107		Provider: "openai", ID: "gpt-5-nano", DisplayName: "GPT-5 nano",
108		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
109		PriceInput: 0.05, PriceOutput: 0.40, PriceCacheRead: 0.005,
110	},
111
112	// ---- OpenAI / GPT-4.1 family ----
113	{
114		Provider: "openai", ID: "gpt-4.1", DisplayName: "GPT-4.1",
115		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
116		PriceInput: 2.00, PriceOutput: 8.00, PriceCacheRead: 0.50,
117	},
118	{
119		Provider: "openai", ID: "gpt-4.1-mini", DisplayName: "GPT-4.1 mini",
120		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
121		PriceInput: 0.40, PriceOutput: 1.60, PriceCacheRead: 0.10,
122	},
123	{
124		Provider: "openai", ID: "gpt-4.1-nano", DisplayName: "GPT-4.1 nano",
125		ContextWindow: 1047576, MaxOutput: 32768, Reasoning: false,
126		PriceInput: 0.10, PriceOutput: 0.40, PriceCacheRead: 0.03,
127	},
128
129	// ---- OpenAI / GPT-4o family ----
130	{
131		Provider: "openai", ID: "gpt-4o", DisplayName: "GPT-4o",
132		ContextWindow: 128000, MaxOutput: 16384, Reasoning: false,
133		PriceInput: 2.50, PriceOutput: 10.00, PriceCacheRead: 1.25,
134	},
135	{
136		Provider: "openai", ID: "gpt-4o-mini", DisplayName: "GPT-4o mini",
137		ContextWindow: 128000, MaxOutput: 16384, Reasoning: false,
138		PriceInput: 0.15, PriceOutput: 0.60, PriceCacheRead: 0.08,
139	},
140
141	// ---- OpenAI / reasoning models ----
142	{
143		Provider: "openai", ID: "o4-mini", DisplayName: "o4-mini",
144		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
145		PriceInput: 1.10, PriceOutput: 4.40, PriceCacheRead: 0.275,
146	},
147	{
148		Provider: "openai", ID: "o3", DisplayName: "o3",
149		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
150		PriceInput: 2.00, PriceOutput: 8.00, PriceCacheRead: 0.50,
151	},
152	{
153		Provider: "openai", ID: "o3-mini", DisplayName: "o3-mini",
154		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
155		PriceInput: 1.10, PriceOutput: 4.40, PriceCacheRead: 0.55,
156	},
157	{
158		Provider: "openai", ID: "o1", DisplayName: "o1",
159		ContextWindow: 200000, MaxOutput: 100000, Reasoning: true,
160		PriceInput: 15.00, PriceOutput: 60.00, PriceCacheRead: 7.50,
161	},
162
163	// ---- Speculative: Anthropic ----
164	{
165		Provider: "anthropic", ID: "claude-opus-4-5", DisplayName: "Claude Opus 4.5",
166		// 200k ctx / 64k maxOutput per Anthropic's published sizing
167		// for the opus-4-5 family; the 1M context is a 4.6+ thing.
168		ContextWindow: 200000, MaxOutput: 64000, Reasoning: true,
169		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
170		Speculative: true,
171	},
172	{
173		Provider: "anthropic", ID: "claude-opus-4-6", DisplayName: "Claude Opus 4.6",
174		ContextWindow: 1000000, MaxOutput: 128000, Reasoning: true,
175		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
176		Speculative: true,
177	},
178	{
179		Provider: "anthropic", ID: "claude-opus-4-7", DisplayName: "Claude Opus 4.7",
180		ContextWindow: 1000000, MaxOutput: 128000, Reasoning: true,
181		PriceInput: 5.00, PriceOutput: 25.00, PriceCacheRead: 0.50, PriceCacheWrite: 6.25,
182		Speculative: true,
183	},
184	{
185		Provider: "anthropic", ID: "claude-sonnet-4-6", DisplayName: "Claude Sonnet 4.6",
186		ContextWindow: 1000000, MaxOutput: 64000, Reasoning: true,
187		PriceInput: 3.00, PriceOutput: 15.00, PriceCacheRead: 0.30, PriceCacheWrite: 3.75,
188		Speculative: true,
189	},
190
191	// ---- Speculative: OpenAI ----
192	// Context windows on the OpenAI gpt-5.x family differ by route:
193	// the direct API advertises 400k, the ChatGPT Codex OAuth backend
194	// caps at 272k. zot serves both auth modes from one catalog row
195	// per id, so we pin to the smaller number to keep the context-usage
196	// meter honest under subscription auth. Users on the direct API
197	// simply see a conservative headroom estimate.
198	{
199		Provider: "openai", ID: "gpt-5.1", DisplayName: "GPT-5.1",
200		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
201		PriceInput: 1.25, PriceOutput: 10.00, PriceCacheRead: 0.125,
202		Speculative: true,
203	},
204	{
205		Provider: "openai", ID: "gpt-5.2", DisplayName: "GPT-5.2",
206		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
207		PriceInput: 1.75, PriceOutput: 14.00, PriceCacheRead: 0.175,
208		Speculative: true,
209	},
210	{
211		Provider: "openai", ID: "gpt-5.3", DisplayName: "GPT-5.3",
212		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
213		PriceInput: 1.75, PriceOutput: 14.00, PriceCacheRead: 0.175,
214		Speculative: true,
215	},
216	{
217		Provider: "openai", ID: "gpt-5.4", DisplayName: "GPT-5.4",
218		// ContextWindow: 272k across every route we support (OpenAI
219		// direct API and the ChatGPT Codex OAuth backend).
220		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
221		PriceInput: 2.50, PriceOutput: 15.00, PriceCacheRead: 0.25,
222		Speculative: true,
223	},
224	{
225		Provider: "openai", ID: "gpt-5.4-mini", DisplayName: "GPT-5.4 mini",
226		// ContextWindow: 400k on the OpenAI direct API, 272k on the
227		// ChatGPT Codex OAuth backend. We pin to the smaller Codex
228		// cap so the context-usage meter is honest under subscription
229		// auth; direct-API users simply see a conservative headroom
230		// estimate rather than an inflated one.
231		ContextWindow: 272000, MaxOutput: 128000, Reasoning: true,
232		PriceInput: 0.75, PriceOutput: 4.50, PriceCacheRead: 0.075,
233		Speculative: true,
234	},
235	{
236		Provider: "openai", ID: "gpt-5.5", DisplayName: "GPT-5.5",
237		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
238		PriceInput: 2.50, PriceOutput: 15.00, PriceCacheRead: 0.25,
239		Speculative: true,
240	},
241	{
242		Provider: "openai", ID: "gpt-5.5-mini", DisplayName: "GPT-5.5 mini",
243		ContextWindow: 400000, MaxOutput: 128000, Reasoning: true,
244		PriceInput: 0.75, PriceOutput: 4.50, PriceCacheRead: 0.075,
245		Speculative: true,
246	},
247}
248
249// DefaultModel is used when the user does not specify one.
250var DefaultModel = Catalog[0] // claude-sonnet-4-5
251
252// ----- active (merged) catalog -----
253//
254// Callers should use Active() / FindModel / ModelsForProvider for
255// lookups. They return the baked-in Catalog merged with any live
256// models loaded via SetLiveModels.
257
258var (
259	activeMu sync.RWMutex
260	active   []Model = Catalog // default: just the static catalog
261)
262
263// SetLiveModels replaces the "live" overlay used by the active catalog.
264// Typically called after a successful /v1/models discovery or on load
265// from the on-disk cache.
266func SetLiveModels(live []Model) {
267	activeMu.Lock()
268	defer activeMu.Unlock()
269	if len(live) == 0 {
270		active = Catalog
271		return
272	}
273	active = MergeCatalog(live)
274}
275
276// Active returns the current merged catalog.
277func Active() []Model {
278	activeMu.RLock()
279	defer activeMu.RUnlock()
280	out := make([]Model, len(active))
281	copy(out, active)
282	return out
283}
284
285// FindModel returns a Model by id, optionally constrained by provider.
286// If provider is empty, the first matching id is returned. Looks up
287// against the merged active catalog.
288func FindModel(provider, id string) (Model, error) {
289	for _, m := range Active() {
290		if m.ID == id && (provider == "" || m.Provider == provider) {
291			return m, nil
292		}
293	}
294	return Model{}, fmt.Errorf("unknown model %q (provider=%q)", id, provider)
295}
296
297// ModelsForProvider returns all models for the given provider, from the
298// merged active catalog.
299func ModelsForProvider(provider string) []Model {
300	var out []Model
301	for _, m := range Active() {
302		if m.Provider == provider {
303			out = append(out, m)
304		}
305	}
306	return out
307}
308
309// ComputeCost returns the USD cost for the given usage on model m.
310func ComputeCost(m Model, u Usage) float64 {
311	const per = 1_000_000.0
312	return float64(u.InputTokens)*m.PriceInput/per +
313		float64(u.OutputTokens)*m.PriceOutput/per +
314		float64(u.CacheReadTokens)*m.PriceCacheRead/per +
315		float64(u.CacheWriteTokens)*m.PriceCacheWrite/per
316}

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