Skip to content

Slim the models list payload and harden per-model endpoints#2410

Merged
gary149 merged 1 commit into
mainfrom
perf/models-payload-diet
Jul 2, 2026
Merged

Slim the models list payload and harden per-model endpoints#2410
gary149 merged 1 commit into
mainfrom
perf/models-payload-diet

Conversation

@gary149

@gary149 gary149 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What

The full 123-model registry is fetched in the root layout and SSR-inlined into every page as a ~181KB data-sveltekit-fetched script. Most of that weight is fields no list consumer reads: providers is ~59KB and is only used by the per-model settings page (one string field), and parameters has no client consumer at all.

This PR:

  • removes providers and parameters from GET /api/v2/models (list) and from the client Model type
  • serves them from the per-model detail endpoints instead, via a new GETModelResponse shape
  • makes the settings model page fetch providers lazily with a loading state (new client.models({ id }) accessor)
  • replaces the raw model serialization in the per-model endpoints with an explicit field map

That last point is also a hardening fix: GET /api/v2/models/[namespace]([/model]) previously returned the entire server-side model object. For self-hosted deployments that configure per-model endpoints with an apiKey in the MODELS env var, that serialized secrets into an unauthenticated response. Nothing in the app called those routes, which is why it went unnoticed. They now share the same explicit serializer as the list.

src/lib/server/endpoints/endpoints.ts switches its generateSettings type from the client Model type to BackendModel, which it should have used all along.

Measured

Models list payload drops from 164KB to 95KB raw (with compression on top where available). The SSR HTML document shrinks accordingly on every page load.

Verification

  • svelte-check catches all consumers; the only client reader of providers was the settings page, updated here
  • Both id shapes exercised against a running build: /api/v2/models/omni and /api/v2/models/zai-org/GLM-5.2 return providers and parameters with no server-only fields
  • Provider dropdown on the settings page verified working with the lazy fetch

Part of a performance series measured from a live profile of hf.co/chat. Each PR is file-disjoint and merges independently, in any order: #2409 (compression), #2410 (models payload), #2411 (markdown pipeline), #2412 (conversation switching), #2413 (stream update batching), #2414 (send handler DB), #2415 (sidebar hydration).

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