Skip to content

feat(server): list context, output limit, and efforts on /v1/models - #161

Closed
erikfrish wants to merge 1 commit into
deLiseLINO:feat/models-visionfrom
erikfrish:feat/models-capabilities
Closed

erikfrish wants to merge 1 commit into
deLiseLINO:feat/models-visionfrom
erikfrish:feat/models-capabilities

Conversation

@erikfrish

@erikfrish erikfrish commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #160, which adds image input to /v1/models. Base is feat/models-vision; it moves to main once #160 lands.

Why

With #160 a client can tell from /v1/models whether a model takes images, but it still gets no context window, no output limit, and no effort levels, so it falls back to defaults: a 1M Opus shows up as 256k. Prism already resolves these facts for routing. With them on the list, every client can take the server's models as is instead of keeping a hand-written copy per machine.

Scope

  • handleModels adds to each claude-<provider>--<model> row the fields OpenRouter-style clients read: context_length and top_provider.context_length, top_provider.max_completion_tokens when the output limit is known, supported_reasoning_levels when effort levels are known, and metadata.display_name: "<provider>/<model>".
  • The values come from ResolveContextWindow, ResolveMaxOutput, and ResolveEffortsSource, the ones routing uses, so a manual model setting comes first.
  • id, top-level display_name, the image capability fields from feat(server): expose input image capabilities on /v1/models #160, and image rows stay the same. Route, alias, and combo rows get none of the new fields.
  • TestModelsListsImageModelsWithOutputModalities now checks that no row has the id gw/chat-a. It used to search the whole body for that string, which now legitimately appears in metadata.display_name.
  • verify/features/daemon-api.md documents the fields.

Blast Radius

The change only adds response fields. Claude Code reads id, type, and display_name, and ignores the rest.

Verification

  • go test -race ./internal/server passes, including TestModelsVisionCapabilities from feat(server): expose input image capabilities on /v1/models #160. TestModelsCarriesChatModelFacts sets a manual context window and efforts on a chat model and checks its row. It fails without this change.
  • I ran the daemon from this branch on a copy of a real config. All 34 provider chat rows carry context_length. claude-dia-proxy--claude-opus-5-5 returned the feat(server): expose input image capabilities on /v1/models #160 image fields plus context_length: 1000000 (manual setting), max_completion_tokens: 128000, efforts low to max, and metadata.display_name: "dia-proxy/claude-opus-5-5". The four image model rows did not change.

Model: claude-opus-5-5

- Add context_length, top_provider, supported_reasoning_levels, and metadata.display_name to every provider chat row, on top of the image capabilities from deLiseLINO#160.
@erikfrish
erikfrish force-pushed the feat/models-capabilities branch from ff5e533 to dcafb8c Compare November 30, 2026 08:28
@erikfrish erikfrish changed the title feat(server): list model facts on /v1/models feat(server): list context, output limit, and efforts on /v1/models Nov 30, 2026
@erikfrish
erikfrish changed the base branch from main to feat/models-vision November 30, 2026 08:33
@deLiseLINO
deLiseLINO deleted the branch deLiseLINO:feat/models-vision November 30, 2026 22:32
@deLiseLINO deLiseLINO closed this Nov 30, 2026
deLiseLINO pushed a commit that referenced this pull request Dec 1, 2026
…dels (#162)

Replaces #161, which GitHub closed when its base branch
`feat/models-vision` was deleted on the merge of #160.

## Why

After #160 a client can tell from `/v1/models` whether a model takes
images, but it still gets no context window, output limit, or effort
levels. It falls back to its own defaults, so a 1M Opus shows up as
256k.

The facts must be listed only when Prism knows them. omp, the main
client of this list, takes a listed `context_length` over its own
catalog, so a listed global default would hide a correct window. The
gateways compared (opencodex, OmniRoute, LiteLLM, CLIProxyAPI) all leave
an unknown limit out for the same reason.

## Scope

- Chat rows on `GET /v1/models` add these fields, each only when known:
- `context_length` and `top_provider.context_length`: from a manual
setting, the provider listing, or the catalog. The global default window
is never listed.
- `max_output_tokens` and `top_provider.max_completion_tokens`: the same
limit, under the flat name most gateways emit and the OpenRouter name.
omp reads both.
- `supported_reasoning_levels` and `default_reasoning_level`. Without a
default level, omp starts on the lowest level. The default is picked
like the omp and grok integrations do: medium, else high, else the first
level. That rule moves from `internal/daemon` to
`config.DefaultReasoningEffort`, so both use one function.
- `metadata.display_name`: `<provider>/<model>` on
`claude-<provider>--<model>` rows, the combo's display name on combos.
- Routes and aliases get the facts of their target, combos the facts
every enabled target shares: the smallest window and output limit, and
the efforts all of them accept. A fact any enabled target does not know
is left out for the whole combo, as opencodex does, so a fallback never
lands on a model with a smaller window than listed.
- Fixes combo image input from #160. A combo with one enabled target of
unknown image support no longer reports image input. It reports unknown,
unless the combo sets `imageInput` or the vision sidecar is on. A
text-only target still makes the combo text-only.
- `verify/features/daemon-api.md` describes the fields and the combo
rules.

## Blast Radius

The change only adds response fields. The exception is a combo whose
enabled targets include one with unknown image support: its image fields
from #160 are now left out. Claude Code reads `id`, `type`, and
`display_name` and ignores the rest. Image generation rows do not
change.

## Verification

- `go test -race -count=1 ./internal/server/ ./internal/config/
./internal/daemon/` passes. `go vet` on the same packages is clean.
- `TestModelsCarriesChatModelFacts` checks a provider row with a manual
window, a listed output limit, and efforts. It also checks that a model
with only the global default lists no limits, that a route takes its
target's facts, that a combo takes the smallest limits and shared
efforts, and that a combo with an unknown target lists nothing.
- `TestModelsVisionCapabilities` adds a combo of a vision model and a
model with unknown image support. It now reports unknown.

Model: claude-opus-5-5
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.

2 participants