Skip to content

feat: expose model prices on GET /v1/models - #6

Merged
tito merged 1 commit into
mainfrom
feat/models-include-pricing
Sep 2, 2026
Merged

tito merged 1 commit into
mainfrom
feat/models-include-pricing

Conversation

@tito

@tito tito commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What

GET /v1/models?include_pricing=1 adds two fields to every entry:

{
  "id": "qwen-72b",
  "object": "model",
  "owned_by": "vllm-1",
  "pricing": {"input_tokens": 0.4, "output_tokens": 1.2},
  "pricing_inherited": false
}

Why

A client that prices its own requests (OpenCode, for one) otherwise carries its own cost table, or asks an admin endpoint it has no key for. The prices are per million units and resolved in the same order the data plane resolves them (own name, the model it points at, upstream name), so what the client multiplies by is what the proxy bills.

Notes

  • Off by default: the plain list keeps its OpenAI shape.
  • The parameter requires an API key or session (401 without one), following include_hidden. Prices stay invisible to anonymous callers.
  • A unit with no price is absent from the map. Unpriced is not zero.
  • Price lookup moved out of modelView into modelPricing, shared with the admin view so the two cannot drift.

Tests

internal/server/modelpricing_test.go: default-off shape, priced and unpriced entries, the 401, and inheritance through an alias. go test ./..., just lint, mkdocs build --strict pass.

Docs: docs/reference/api.md, docs/reference/openapi.yaml, and a "Let clients read the prices" section in docs/guides/pricing.md.

Clients that show spend (OpenCode and the like) had no way to read what
the proxy bills a model at without an admin key. `include_pricing=1` adds
`pricing` (per million units) and `pricing_inherited` to every entry,
resolved the way the data plane resolves them, so a client's arithmetic
matches the proxy's accounting.

Off by default, so the public list keeps its OpenAI shape. The parameter
needs an API key or session, like `include_hidden`: prices are operator
data, and anonymous callers see none.

Price lookup moves out of modelView into modelPricing, shared by the
admin view and the list so the two cannot drift.
@tito
tito merged commit 99a5e3b into main Sep 2, 2026
5 checks passed
@tito
tito deleted the feat/models-include-pricing branch September 2, 2026 21:46
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