Slim the models list payload and harden per-model endpoints#2410
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The full 123-model registry is fetched in the root layout and SSR-inlined into every page as a ~181KB
data-sveltekit-fetchedscript. Most of that weight is fields no list consumer reads:providersis ~59KB and is only used by the per-model settings page (one string field), andparametershas no client consumer at all.This PR:
providersandparametersfromGET /api/v2/models(list) and from the clientModeltypeGETModelResponseshapeclient.models({ id })accessor)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-modelendpointswith anapiKeyin theMODELSenv 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.tsswitches itsgenerateSettingstype from the clientModeltype toBackendModel, 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
providerswas the settings page, updated here/api/v2/models/omniand/api/v2/models/zai-org/GLM-5.2return providers and parameters with no server-only fieldsPart 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).