opencode-plugin-litellm 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -73,7 +73,7 @@ also shows how to configure a provider directly in `opencode.json`.
73
73
  | 🔍 **Auto-detection** | Probes `localhost:4000`, `:8000`, `:8080` and adopts the first responsive proxy. |
74
74
  | 📡 **Dynamic discovery** | Queries `/v1/models` so your OpenCode model picker always reflects your live `model_list`. |
75
75
  | ⚡ **Stale-while-revalidate** | A warm disk cache supplies models without a network request. New sessions trigger a background refresh, and cache entries expire after 7 days. |
76
- | 🏷️ **Smart formatting** | Turns `anthropic/claude-3-5-sonnet` into `Claude 3.5 Sonnet` in the picker — handles versions, sizes, quantizations, and brand-cased names like `gpt-4o`. Set `formatModelNames: false` to keep the raw LiteLLM ids instead. |
76
+ | 🏷️ **Smart formatting** | Uses LiteLLM's `model_info.display_name` when set; otherwise turns `anthropic/claude-3-5-sonnet` into `Claude 3.5 Sonnet` in the picker — handles versions, sizes, quantizations, and brand-cased names like `gpt-4o`. Set `formatModelNames: false` to keep the raw LiteLLM ids instead. |
77
77
  | 🧠 **Modality-aware** | Enriches `/v1/models` entries with `/v1/model/info` (`mode`, token limits, capability flags) and hides embedding / image / audio models from the picker. Declares `temperature` support only for models whose `supported_openai_params` lists it, so OpenCode applies (and the user can set) a sampling temperature on exactly those models. |
78
78
  | 💵 **Real pricing** | Maps `input_cost_per_token` / `output_cost_per_token` (and cache read/write costs) from `/v1/model/info` into OpenCode's `cost` field, so the picker and `/cost` show what the proxy actually bills instead of `$0.00`. Models LiteLLM has no price for are left unpriced, not falsely marked free. |
79
79
  | 🧩 **Reasoning-effort variants** | When LiteLLM reports per-model effort support (`supports_low_reasoning_effort`, …), the plugin surfaces each level as a picker variant automatically. |
@@ -472,7 +472,7 @@ Model classification (tool-call badge, attachments, reasoning, input modalities)
472
472
 
473
473
  ### Keeping raw model ids in the picker (`formatModelNames`)
474
474
 
475
- By default the plugin prettifies each discovered id into a display name — `anthropic/claude-3-5-sonnet` shows up as `Claude 3.5 Sonnet`. If you'd rather see your LiteLLM `model_list` aliases verbatim (for example because your team refers to models by those exact names, or the formatter mangles an internal naming scheme), turn formatting off:
475
+ By default the plugin uses the name LiteLLM reports in `model_info.display_name` when it is set, and otherwise prettifies the id — `anthropic/claude-3-5-sonnet` shows up as `Claude 3.5 Sonnet`. If you'd rather see your LiteLLM `model_list` aliases verbatim (for example because your team refers to models by those exact names, or the formatter mangles an internal naming scheme), turn formatting off:
476
476
 
477
477
  ```jsonc
478
478
  {
@@ -487,9 +487,11 @@ By default the plugin prettifies each discovered id into a display name — `ant
487
487
  }
488
488
  ```
489
489
 
490
- - The display name becomes the exact model id as returned by `/v1/models` (provider prefix, version suffixes and all). Nothing else changes — ids, capability flags, pricing and filtering behave exactly as before.
490
+ - With formatting off, the display name becomes the exact model id as returned by `/v1/models` (provider prefix, version suffixes and all). Nothing else changes — ids, capability flags, pricing and filtering behave exactly as before.
491
+ - With formatting on, a valid `model_info.display_name` replaces the formatted id. Empty, whitespace-only and non-string values are ignored.
492
+ - An explicit `models.<id>.name` always wins; `formatModelNames: false` keeps the raw id even when `display_name` is set.
491
493
  - Only a boolean `false` disables formatting; omitting the option or setting anything else keeps the default.
492
- - Like the other options above, `formatModelNames` is part of the cache identity, so toggling it triggers a fresh discovery on the next start instead of serving previously cached names.
494
+ - Like the other options above, `formatModelNames` is part of the cache identity, so toggling it triggers a fresh discovery on the next start instead of serving previously cached names. A changed `display_name` is picked up by the existing background refresh (on OpenCode 1 it appears after the following start).
493
495
  - To rename just a handful of models while keeping smart formatting for the rest, use the per-model `name` override described in [Overriding or curating individual models](#overriding-or-curating-individual-models-optional).
494
496
 
495
497
  ### Naming models per provider (`modelNameTemplate`)
@@ -523,13 +525,12 @@ Several providers can point at the same LiteLLM proxy with different keys. Every
523
525
 
524
526
  | Placeholder | Value |
525
527
  | --- | --- |
526
- | `{name}` | The display name the plugin would produce anyway — formatted, or the raw id when `formatModelNames: false` |
528
+ | `{name}` | The display name the plugin resolved — LiteLLM's `display_name` when valid, otherwise the formatted id, or the raw id when `formatModelNames: false` |
527
529
  | `{id}` | The model id exactly as `/v1/models` returned it |
528
530
  | `{provider_id}` | The OpenCode provider id, for example `litellm-team-a` |
529
531
  | `{provider_name}` | The provider's configured `name`, or its id when no name is set |
530
532
 
531
533
  - The default is `{name}`, so omitting the setting changes nothing.
532
- - The template runs after name formatting, so it composes with `formatModelNames: false`.
533
534
  - An explicit `models.<id>.name` still wins and is never templated.
534
535
  - Unknown placeholders are left as written, and substitution is single-pass: a placeholder that appears inside a resolved value stays literal.
535
536
  - Non-string and empty values are ignored.
@@ -604,7 +605,7 @@ sequenceDiagram
604
605
  2. If `providers.litellm` exists, its `settings.baseURL` is used. Otherwise common ports are probed — that probe is the only health check (3 s fail-fast per port).
605
606
  3. With a configured `baseURL` the proxy is not contacted during startup unless the cache is cold; the discovery fetch itself fails fast if the proxy is unreachable.
606
607
  4. **Fast path:** if a fresh on-disk cache exists (≤ 7 days old), its models are registered synchronously — startup does not wait on network discovery.
607
- 5. **Cold path:** `/v1/models` and `/v1/model/info` are fetched in parallel. Models are enriched with info metadata (`mode`, token limits, capability flags, per-token pricing — `/v1/models` omits these for database-defined models) and converted into OpenCode model entries with formatted `name`, inferred `modalities`, and `cost` (USD/1M tokens, converted from LiteLLM's USD/token). Non-chat models (embedding / image / audio) are excluded from the picker.
608
+ 5. **Cold path:** `/v1/models` and `/v1/model/info` are fetched in parallel. Models are enriched with info metadata (`mode`, token limits, capability flags, per-token pricing — `/v1/models` omits these for database-defined models) and converted into OpenCode model entries with a resolved `name`, inferred `modalities`, and `cost` (USD/1M tokens, converted from LiteLLM's USD/token). Non-chat models (embedding / image / audio) are excluded from the picker.
608
609
  6. Discovered models are added alongside user-defined models — never overwriting them — and persisted to the cache.
609
610
  7. On `session.created`, the cache is revalidated in the background (throttled to once per 5 minutes). V2 calls `provider.reload()` when the inventory changes; V1 surfaces refreshed entries on the next OpenCode start. The cold path is capped by a 20 s timeout.
610
611
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-plugin-litellm",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "description": "OpenCode CLI (v1 and v2) and Desktop plugin for LiteLLM proxy support with auto-detection and dynamic model discovery",
6
6
  "type": "module",
7
7
  "main": "./src/index.ts",
@@ -10,7 +10,8 @@ import {
10
10
  import {
11
11
  applyModelNameTemplate,
12
12
  DEFAULT_MODEL_NAME_TEMPLATE,
13
- formatModelName,
13
+ normalizeModelDisplayName,
14
+ resolveModelDisplayName,
14
15
  categorizeModel,
15
16
  type ModelNaming,
16
17
  } from '../utils/format-model-name'
@@ -297,10 +298,15 @@ const USD_PER_TOKEN_TO_PER_MILLION = 1_000_000
297
298
 
298
299
  /**
299
300
  * The display name a model gets before any provider template is applied —
300
- * the plugin's default formatting, or the raw `/v1/models` id.
301
+ * LiteLLM's `model_info.display_name` when valid, the plugin's default
302
+ * formatting, or the raw `/v1/models` id when formatting is disabled.
301
303
  */
302
- function baseDisplayName(model: { id: string }, formatModelNames: boolean): string {
303
- return formatModelNames ? formatModelName(model) : model.id
304
+ function baseDisplayName(
305
+ model: { id: string },
306
+ formatModelNames: boolean,
307
+ displayName?: unknown,
308
+ ): string {
309
+ return resolveModelDisplayName(model, { formatModelNames, displayName })
304
310
  }
305
311
 
306
312
  /**
@@ -310,9 +316,10 @@ function baseDisplayName(model: { id: string }, formatModelNames: boolean): stri
310
316
  * image, audio) — they can't be used as primary chat models and would
311
317
  * clutter the picker.
312
318
  *
313
- * Exported for tests: the `naming` options decide the display name — the
314
- * prettified id or the raw `/v1/models` id, optionally wrapped in the
315
- * provider's `modelNameTemplate`.
319
+ * Exported for tests: the display name comes from `info.display_name` when
320
+ * valid, otherwise the prettified id or the raw `/v1/models` id when
321
+ * formatting is disabled, optionally wrapped in the provider's
322
+ * `modelNameTemplate`.
316
323
  */
317
324
  export function toConfigModel(
318
325
  model: LiteLLMModel,
@@ -326,7 +333,11 @@ export function toConfigModel(
326
333
  const providerId = naming.providerId ?? ''
327
334
  const entry: Record<string, unknown> = {
328
335
  name: applyModelNameTemplate(naming.modelNameTemplate, {
329
- name: baseDisplayName(model, naming.formatModelNames !== false),
336
+ name: baseDisplayName(
337
+ model,
338
+ naming.formatModelNames !== false,
339
+ info?.display_name,
340
+ ),
330
341
  id: model.id,
331
342
  providerId,
332
343
  // Without a configured display name the picker falls back to the id,
@@ -410,12 +421,16 @@ export function toConfigModel(
410
421
  * lists the subset that must be invoked through the OpenAI Responses API;
411
422
  * callers route those accordingly without inspecting each entry. `hints`
412
423
  * carries per-model upstream facts OpenCode 2 maps to `compatibility` and
413
- * `variants`.
424
+ * `variants`. `displayNames` records each model's valid
425
+ * `model_info.display_name` (when formatting is enabled), so a cached model
426
+ * can be re-rendered for the Responses sibling without losing it; an explicit
427
+ * `models.<id>.name` still wins at merge time.
414
428
  */
415
429
  export interface DiscoveredModels {
416
430
  models: Record<string, unknown>
417
431
  responsesIds: string[]
418
432
  hints: Record<string, ModelHints>
433
+ displayNames: Record<string, string>
419
434
  }
420
435
 
421
436
  /**
@@ -492,6 +507,7 @@ export async function discoverModels(
492
507
  const built: Record<string, unknown> = {}
493
508
  const responsesIds: string[] = []
494
509
  const hints: Record<string, ModelHints> = {}
510
+ const displayNames: Record<string, string> = {}
495
511
  let skipped = 0
496
512
  let wildcards = 0
497
513
  let filtered = 0
@@ -520,6 +536,13 @@ export async function discoverModels(
520
536
  continue
521
537
  }
522
538
  built[model.id] = entry
539
+ // Record the display name for every built model: an explicit
540
+ // models.<id>.name still wins at merge time, and with formatting
541
+ // disabled the raw id wins, so nothing is recorded.
542
+ if (naming.formatModelNames !== false) {
543
+ const displayName = normalizeModelDisplayName(info?.display_name)
544
+ if (displayName) displayNames[model.id] = displayName
545
+ }
523
546
  if (requiresResponsesAPI(enriched)) responsesIds.push(model.id)
524
547
  const params = info?.supported_openai_params
525
548
  hints[model.id] = {
@@ -558,7 +581,7 @@ export async function discoverModels(
558
581
  ')',
559
582
  )
560
583
 
561
- return { models: built, responsesIds, hints }
584
+ return { models: built, responsesIds, hints, displayNames }
562
585
  }
563
586
 
564
587
  /**
@@ -674,7 +697,9 @@ function readHeaderMap(value: unknown): Record<string, string> {
674
697
  * sibling, so a template that uses `{provider_id}`/`{provider_name}` must
675
698
  * resolve to the provider the user actually selects. The entry in the cache
676
699
  * stays as discovered — OpenCode 2 reads the same cache with a single
677
- * provider — so this returns a copy instead of mutating it.
700
+ * provider — so this returns a copy instead of mutating it. `displayName` is
701
+ * the LiteLLM value recorded during discovery (when any), so re-rendering
702
+ * does not lose it.
678
703
  */
679
704
  function renameForProvider(
680
705
  entry: Record<string, unknown>,
@@ -682,12 +707,17 @@ function renameForProvider(
682
707
  naming: ModelNaming,
683
708
  providerId: string,
684
709
  providerName: string,
710
+ displayName?: string,
685
711
  ): Record<string, unknown> {
686
712
  if (naming.modelNameTemplate === undefined) return entry
687
713
  return {
688
714
  ...entry,
689
715
  name: applyModelNameTemplate(naming.modelNameTemplate, {
690
- name: baseDisplayName({ id: modelId }, naming.formatModelNames !== false),
716
+ name: baseDisplayName(
717
+ { id: modelId },
718
+ naming.formatModelNames !== false,
719
+ displayName,
720
+ ),
691
721
  id: modelId,
692
722
  providerId,
693
723
  providerName,
@@ -708,6 +738,7 @@ function injectDiscoveredModels(
708
738
  baseModels: Record<string, unknown>,
709
739
  entries: Record<string, unknown>,
710
740
  responsesIds: readonly string[],
741
+ displayNames: Record<string, string>,
711
742
  baseURL: string,
712
743
  apiKey: string | undefined,
713
744
  customHeaders: Record<string, string> | undefined,
@@ -778,6 +809,7 @@ function injectDiscoveredModels(
778
809
  naming,
779
810
  responsesProviderId,
780
811
  siblingName,
812
+ displayNames[id],
781
813
  )
782
814
  }
783
815
  added.push(...mergeModels(siblingModels, responsesEntries))
@@ -822,7 +854,13 @@ async function backgroundRefresh(cacheKey: string): Promise<void> {
822
854
  DISCOVERY_TIMEOUT_MS,
823
855
  )
824
856
  if (discovered && Object.keys(discovered.models).length > 0) {
825
- writeModelCache(cacheKey, discovered.models, discovered.responsesIds, discovered.hints)
857
+ writeModelCache(
858
+ cacheKey,
859
+ discovered.models,
860
+ discovered.responsesIds,
861
+ discovered.hints,
862
+ discovered.displayNames,
863
+ )
826
864
  log(
827
865
  'info',
828
866
  `[opencode-litellm] Background-refreshed model cache for ${ctx.baseURL} (${Object.keys(discovered.models).length} models)`,
@@ -1117,6 +1155,7 @@ export const LiteLLMPlugin: Plugin = async (input: PluginInput) => {
1117
1155
  models,
1118
1156
  cached.models,
1119
1157
  cached.responsesIds,
1158
+ cached.displayNames,
1120
1159
  baseURL,
1121
1160
  runtimeKey,
1122
1161
  customHeaders,
@@ -1154,6 +1193,7 @@ export const LiteLLMPlugin: Plugin = async (input: PluginInput) => {
1154
1193
  models,
1155
1194
  discovered.models,
1156
1195
  discovered.responsesIds,
1196
+ discovered.displayNames,
1157
1197
  baseURL,
1158
1198
  runtimeKey,
1159
1199
  customHeaders,
@@ -1161,7 +1201,13 @@ export const LiteLLMPlugin: Plugin = async (input: PluginInput) => {
1161
1201
  naming,
1162
1202
  )
1163
1203
  injectedModelIds.set(cacheKey, new Set(added))
1164
- writeModelCache(cacheKey, discovered.models, discovered.responsesIds, discovered.hints)
1204
+ writeModelCache(
1205
+ cacheKey,
1206
+ discovered.models,
1207
+ discovered.responsesIds,
1208
+ discovered.hints,
1209
+ discovered.displayNames,
1210
+ )
1165
1211
  }
1166
1212
  }
1167
1213
  },
package/src/plugin/v2.ts CHANGED
@@ -626,7 +626,7 @@ async function makeProviderSource(
626
626
  entries = discovered.models
627
627
  responsesIds = discovered.responsesIds
628
628
  hints = discovered.hints
629
- writeModelCache(cacheKey, entries, responsesIds, hints)
629
+ writeModelCache(cacheKey, entries, responsesIds, hints, discovered.displayNames)
630
630
  } else {
631
631
  entries = null
632
632
  responsesIds = []
@@ -746,7 +746,13 @@ async function refreshProviderSource(
746
746
  compatibility: source.compatibility,
747
747
  })
748
748
  if (JSON.stringify(models) === JSON.stringify(source.models)) {
749
- writeModelCache(source.cacheKey, discovered.models, discovered.responsesIds, discovered.hints)
749
+ writeModelCache(
750
+ source.cacheKey,
751
+ discovered.models,
752
+ discovered.responsesIds,
753
+ discovered.hints,
754
+ discovered.displayNames,
755
+ )
750
756
  source.refreshRequired = false
751
757
  return
752
758
  }
@@ -760,7 +766,13 @@ async function refreshProviderSource(
760
766
  throw error
761
767
  }
762
768
 
763
- writeModelCache(source.cacheKey, discovered.models, discovered.responsesIds, discovered.hints)
769
+ writeModelCache(
770
+ source.cacheKey,
771
+ discovered.models,
772
+ discovered.responsesIds,
773
+ discovered.hints,
774
+ discovered.displayNames,
775
+ )
764
776
  source.refreshRequired = false
765
777
  logInfo(
766
778
  `[opencode-litellm] Refreshed ${models.length} models for provider "${source.id}"; the provider registry was reloaded.`,
@@ -59,6 +59,12 @@ export interface LiteLLMModelInfo {
59
59
  db_model?: boolean
60
60
  /** Alias LiteLLM assigns to the model; mirrors the `/v1/models` id. */
61
61
  key?: string
62
+ /**
63
+ * Human-readable name configured on the deployment
64
+ * (`model_info.display_name`). Display-only: never used as the model id or
65
+ * in API requests. Absent or malformed values fall back to id formatting.
66
+ */
67
+ display_name?: string | null
62
68
  mode?: string
63
69
  max_tokens?: number
64
70
  max_input_tokens?: number
@@ -197,13 +197,51 @@ export function formatModelName(model: Pick<LiteLLMModel, 'id'>): string {
197
197
  return tokens.join(' ') || id
198
198
  }
199
199
 
200
+ /**
201
+ * Normalise a LiteLLM `model_info.display_name` into a display name.
202
+ *
203
+ * Only a non-empty string counts. The value is trimmed so surrounding
204
+ * whitespace never reaches the picker; everything else (undefined, null,
205
+ * empty, whitespace-only, numbers, objects) is treated as "no display name"
206
+ * and lets the caller fall back to id formatting.
207
+ */
208
+ export function normalizeModelDisplayName(value: unknown): string | undefined {
209
+ if (typeof value !== 'string') return undefined
210
+ const trimmed = value.trim()
211
+ return trimmed === '' ? undefined : trimmed
212
+ }
213
+
214
+ /**
215
+ * Resolve the display name for a discovered model before any provider
216
+ * template is applied.
217
+ *
218
+ * Precedence:
219
+ * 1. `formatModelNames: false` keeps the raw `/v1/models` id, as before.
220
+ * 2. A valid LiteLLM `model_info.display_name`.
221
+ * 3. The prettified id (`formatModelName`).
222
+ *
223
+ * `display_name` is display-only: callers keep using `model.id` for the
224
+ * model id, requests, routing and filtering.
225
+ */
226
+ export function resolveModelDisplayName(
227
+ model: Pick<LiteLLMModel, 'id'>,
228
+ options: { formatModelNames?: boolean; displayName?: unknown } = {},
229
+ ): string {
230
+ if (options.formatModelNames === false) return model.id
231
+ return normalizeModelDisplayName(options.displayName) ?? formatModelName(model)
232
+ }
233
+
200
234
  /**
201
235
  * The naming choices that decide how a discovered model is displayed. They
202
236
  * are baked into cached model entries, so the same object also feeds the
203
237
  * cache identity (see `buildCacheKey` in `model-cache.ts`).
204
238
  */
205
239
  export interface ModelNaming {
206
- /** Prettify a model id into a display name; `false` keeps the raw id. */
240
+ /**
241
+ * Prettify a model id into a display name. A valid LiteLLM
242
+ * `model_info.display_name` takes precedence; `false` keeps the raw id and
243
+ * ignores the display name too.
244
+ */
207
245
  formatModelNames?: boolean
208
246
  /**
209
247
  * Template applied to every discovered model's display name. Unset (or
@@ -102,10 +102,11 @@ export async function discoverLiteLLMModels(
102
102
  }
103
103
 
104
104
  /**
105
- * Fetch per-model metadata (`mode`, token limits, capability flags)
106
- * from `/v1/model/info`, keyed by model name. `/v1/models` omits these
107
- * fields for database-defined models, so classification (e.g. filtering
108
- * out embedding models) relies on this endpoint.
105
+ * Fetch per-model metadata (`mode`, token limits, capability flags and the
106
+ * optional `display_name`) from `/v1/model/info`, keyed by model name.
107
+ * `/v1/models` omits these fields for database-defined models, so
108
+ * classification (e.g. filtering out embedding models) relies on this
109
+ * endpoint.
109
110
  */
110
111
  export async function discoverLiteLLMModelInfo(
111
112
  baseURL: string = DEFAULT_LITELLM_URL,
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto'
2
2
  import { readFileSync, mkdirSync, writeFileSync, renameSync, rmSync } from 'node:fs'
3
3
  import { homedir, tmpdir } from 'node:os'
4
4
  import { join } from 'node:path'
5
- import type { ModelNaming } from './format-model-name'
5
+ import { normalizeModelDisplayName, type ModelNaming } from './format-model-name'
6
6
 
7
7
  /**
8
8
  * Facts about a discovered model's upstream that OpenCode 2 turns into
@@ -30,7 +30,7 @@ export interface ModelHints {
30
30
  * from older plugin versions are ignored rather than deserialized into
31
31
  * an incompatible structure.
32
32
  */
33
- const CACHE_VERSION = 6
33
+ const CACHE_VERSION = 7
34
34
 
35
35
  /**
36
36
  * Maximum age of a cache entry before it's treated as a miss. Without a
@@ -56,6 +56,13 @@ interface ModelCacheFile {
56
56
  * no place in a provider-config entry (see `ModelHints`).
57
57
  */
58
58
  hints?: Record<string, ModelHints>
59
+ /**
60
+ * LiteLLM `model_info.display_name` values that were used for a model's
61
+ * display name. The templated name is already baked into `models`, but
62
+ * OpenCode 1's Responses sibling re-renders names with its own provider
63
+ * placeholders and needs the pre-template display name to do so.
64
+ */
65
+ displayNames?: Record<string, string>
59
66
  }
60
67
 
61
68
  /**
@@ -183,6 +190,17 @@ function normalizeResponsesIds(value: unknown): string[] {
183
190
  return value.filter((id): id is string => typeof id === 'string')
184
191
  }
185
192
 
193
+ /** Keep only non-empty string entries of a cached `displayNames` map. */
194
+ function normalizeDisplayNames(value: unknown): Record<string, string> {
195
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
196
+ const out: Record<string, string> = {}
197
+ for (const [id, name] of Object.entries(value as Record<string, unknown>)) {
198
+ const normalized = normalizeModelDisplayName(name)
199
+ if (normalized !== undefined) out[id] = normalized
200
+ }
201
+ return out
202
+ }
203
+
186
204
  /** Keep only well-formed entries of a cached `hints` map. */
187
205
  function normalizeHints(value: unknown): Record<string, ModelHints> {
188
206
  if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
@@ -220,10 +238,10 @@ export function readModelCache(
220
238
  }
221
239
 
222
240
  /**
223
- * Read the models, Responses-API model ids and model hints for a cache key
224
- * in one parse. Returns `null` under the same conditions as
225
- * {@link readModelCache} (missing/expired cache), so the three can't
226
- * disagree within a single lookup.
241
+ * Read the models, Responses-API model ids, model hints and LiteLLM display
242
+ * names for a cache key in one parse. Returns `null` under the same
243
+ * conditions as {@link readModelCache} (missing/expired cache), so the four
244
+ * can't disagree within a single lookup.
227
245
  */
228
246
  export function readModelCacheEntry(
229
247
  cacheKey: string,
@@ -231,6 +249,7 @@ export function readModelCacheEntry(
231
249
  models: Record<string, unknown>
232
250
  responsesIds: string[]
233
251
  hints: Record<string, ModelHints>
252
+ displayNames: Record<string, string>
234
253
  } | null {
235
254
  const parsed = readCacheFile(cacheKey)
236
255
  if (!parsed) return null
@@ -244,6 +263,7 @@ export function readModelCacheEntry(
244
263
  models: parsed.models,
245
264
  responsesIds: normalizeResponsesIds(parsed.responsesIds),
246
265
  hints: normalizeHints(parsed.hints),
266
+ displayNames: normalizeDisplayNames(parsed.displayNames),
247
267
  }
248
268
  }
249
269
 
@@ -278,6 +298,7 @@ export function writeModelCache(
278
298
  models: Record<string, unknown>,
279
299
  responsesIds: readonly string[] = [],
280
300
  hints: Record<string, ModelHints> = {},
301
+ displayNames: Record<string, string> = {},
281
302
  ): void {
282
303
  try {
283
304
  mkdirSync(cacheDir(), { recursive: true })
@@ -287,6 +308,7 @@ export function writeModelCache(
287
308
  models,
288
309
  responsesIds: [...responsesIds],
289
310
  hints,
311
+ displayNames,
290
312
  }
291
313
  // Write to a temp file and rename so concurrent OpenCode processes
292
314
  // never observe a partially-written JSON file (rename is atomic on