Skip to content

feat(models): pull OpenRouter catalog from its live models API - #847

Merged
Pizzaface merged 2 commits into
mainfrom
feat/openrouter-live-models
Aug 22, 2026
Merged

feat(models): pull OpenRouter catalog from its live models API#847
Pizzaface merged 2 commits into
mainfrom
feat/openrouter-live-models

Conversation

@Pizzaface

Copy link
Copy Markdown
Owner

Problem

OpenRouter models came from a static list: @earendil-works/pi-ai ships a build-time snapshot (providers/data/openrouter.json, 346 models), and pi overlays it with pi.dev's catalog (withRemoteCatalog). Both lag OpenRouter itself — new models never show up until an upstream release.

Change

Register a native openrouter provider that spreads pi-ai's own provider (auth — env key + OAuth — and streaming untouched) and replaces only getModels() with OpenRouter's live https://openrouter.ai/api/v1/models.

  • Cached in ~/.pizzapi/openrouter-models-cache.json, 24h TTL, 0600
  • Sessions warm it stale-while-revalidate (extensions/openrouter-provider.ts): cached list is used immediately, a refreshed fetch re-registers the provider so the runtime snapshot updates mid-session
  • Fetch only runs when OpenRouter credentials exist (env or stored)
  • Daemon listConfiguredModels() reads the cache too, so the web model picker shows live models
  • Filtered to models advertising tools (same rule pi-ai's generated catalog uses); pricing converted per-token → per-million
  • Any failure (offline, API down, empty/corrupt cache) falls back to the static catalog

Verification

static: 346 live: 352 fetched: 352
live-only sample: [ "meta/muse-spark-1.2-contributor", "deepseek/deepseek-v4-flash-vision-exp", "stealth/ox-alpha", "~z-ai/glm-latest", "z-ai/glm-5.3" ]
resolves live-only model: meta/muse-spark-1.2-contributor true
  • packages/cli/src/openrouter-models.test.ts — 10 new tests (mapping, cost conversion, tools filter, TTL, stale refetch, failure paths, corrupt cache, both registration shapes)
  • bun run typecheck clean
  • bun test packages/cli/src: 2823 pass / 254 fail — identical 254 failures on origin/main baseline (pre-existing full-suite cross-file pollution), so no regressions

Skipped

  • Daemon periodic refresh loop (like runner-ollama-models-cache.ts) — sessions warm the cache; add if idle runners serve >24h-stale lists
  • Registration in provider-auth.ts / commit-message-generator.ts — auth behaviour is identical since the provider spreads pi-ai's; add if either needs live-only model ids
  • Docs — no new flag, env var, or config key

pi-ai ships a build-time OpenRouter snapshot (346 models) overlaid with
pi.dev's catalog; both lag OpenRouter itself (352 tool-capable models
live, incl. z-ai/glm-5.3). Register a native provider that spreads
pi-ai's openrouter provider (auth + streaming untouched) and serves the
live /api/v1/models list, cached in ~/.pizzapi/openrouter-models-cache.json
for 24h. Sessions warm the cache stale-while-revalidate; the daemon's
model listing reads it so the web picker shows live models.
react-icons' Simple Icons pack has no OpenRouter glyph, so openrouter fell
through to the generic robot. Inline the simple-icons path (CC0 1.0).
@Pizzaface
Pizzaface merged commit f5c27f7 into main Aug 22, 2026
13 checks passed
@Pizzaface
Pizzaface deleted the feat/openrouter-live-models branch August 22, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant