Pull requests / #3500
#3500 [Engine] add GET /v1/models/{id} so Visual Studio can use Strata
open · @MajMcCloud · 0 comentarios · En GitHub
Server & APIAMD / HIPNVIDIA / CUDASecurityDocumentationWindows
Descripción
## Problem and result
<!-- What triggered this change. How it behaves before and after. -->
Some OpenAI clients check that one model exists before they use it. They do this by calling `GET /v1/models/{model id}`. Visual Studio's model picker does this. Strata only had the list (`GET /v1/models`, `GET /models`), so that call got a 404, and the client treated the model as missing.
- **Before:** `GET /v1/models/<served id>` → 404.
- **After:** `GET /v1/models/<served id>` → 200. The response is the same entry `/v1/models` lists under that id, plus OpenAI's `created` (when the server started) and `owned_by` (`"strata"`). Strict SDKs check these two fields.
- This works for the model id and for every alias.
- An id this server does not have → 404 with `code: "model_not_found"`.
- When an API key is set, the key is needed, the same as for the list.
- Asking about a model never loads or unloads it.
- **Unchanged:** `GET /v1/models` and `GET /models` give the same list as before. `GET /models/{id}` still answers 404, because llama.cpp's bare `/models` has never taken an id.
## Related discussion
<!-- The issue URL and the maintainer's agreement on scope, when the change needs one (features, refactors, defaults). Write "none" if not applicable. -->
This reopens Niko1221/Strata#2494, which was closed in the tracker reset for 0.2.0-beta. There is no separate issue. The change is a small addition to the API and does not change a default.
## Approach
<!-- Why this fix. Compatibility effects. Keep unrelated cleanup out of the PR. -->
- The code that builds the `/v1/models` list moved from the request handler into `Service.model_view()` without changes. The list and the new detail endpoint share it, so they cannot drift apart.
- `Service.model_detail(id)` picks one entry from that list and adds `created` and `owned_by`. If the list is empty (the engine is gone and nothing loads it on use), the id answers 404, the same as an unknown id.
- Only the versioned path `/v1/models/{id}` takes an id. The id is URL-decoded. `/v1/models/` with a trailing slash is still the list.
- Compatibility: no existing response changed. The only new behavior is on a path that answered 404 before. No settings or defaults changed. No engine (C++/CUDA/HIP/SYCL/Metal) code changed.
- Docs: `docs/DETAILS.md` (endpoint table and the metadata paragraph) and the module docstring of `serve/server.py`.
## Validation
<!-- Exact commands, the revision and the environment tested, what you saw. Keep the three lists apart. -->
Revision: the two commits of this PR applied on top of `upstream/main` `cbfd5b92` (2026-10-20). They applied without conflicts. Environment: Windows, Python 3.14.7, jinja2 3.1.6, no GPU (the tests use the fake engine).
**Passed:**
<!-- command, revision/environment, observed result, log -->
- `python -m unittest -v serve.test_lifecycle` → `Ran 13 tests … OK`. This includes the 4 new tests:
- `test_model_detail_endpoint_answers_for_every_id_it_serves`: model id and alias give 200 with the same fields as the list, an unknown id gives 404, `/v1/models/` is still the list, and the engine is never started.
- `test_bare_models_path_still_only_lists`: `/models/{id}` gives 404 and `/models` still lists.
- `test_model_detail_endpoint_is_empty_while_the_engine_is_gone`: 404 while nothing is served, 200 with `loaded` once it is.
- `test_model_detail_endpoint_needs_the_api_key_like_the_list`: 401 without the key, 200 with it.
- `python -m unittest serve.test_server` → `Ran 344 tests … OK (skipped=3)`
- `python -m unittest serve.test_security` → `Ran 28 tests … OK`
- `python -m unittest serve.test_images` → `Ran 19 tests … OK` (the image model in the list)
**Failed:**
<!-- command and failure, or "none observed" -->
None observed.
**Not run:**
<!-- check, why, and what stays unverified (for example CUDA, HIP, SYCL or Metal builds you could not do) -->
- CUDA, HIP, SYCL and Metal builds: not needed, because no engine code changed (only `serve/server.py`, its tests and `docs/DETAILS.md`).
- An end-to-end run with a real model on a GPU, and a check with Visual Studio's model picker on this revision. These are not verified here.
- `tests/terminal` and `apps/host` tests: they do not touch `serve/`.
## Limits
<!-- Known limitations or remaining work. -->
- `created` is the server's start time, not the date of the model files. Strata has no better value for this.
- `owned_by` is always `"strata"`.
- There is no detail endpoint on the bare `/models/{id}` path. Nothing that is known to us asks for one there.En el sitio
Enlaces a install, modelos, releases.