[PR #3500] [Engine] add GET /v1/models/{id} so Visual Studio can use Strata #4659

Open
opened 2026-11-07 15:38:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3500
Author: @MajMcCloud
Created: 10/20/2026
Status: 🔄 Open

Base: main ← Head: main


📝 Commits (10+)

  • 95686ca Add single-model metadata endpoint
  • 00bb095 Limit model detail endpoint to /v1/models/{id}
  • 2f773af Merge branch 'Niko1221:main' into main
  • c7f08ef Merge branch 'Niko1221:main' into main
  • 0ecb98e Merge branch 'Niko1221:main' into main
  • be98f1f Merge branch 'Niko1221:main' into main
  • d30f50b Merge branch 'Niko1221:main' into main
  • d20263c Merge branch 'main' into main
  • 6d897ea Merge branch 'Niko1221:main' into main
  • e08e3d5 Merge branch 'Niko1221:main' into main

📊 Changes

3 files changed (+137 additions, -19 deletions)

View changed files

📝 docs/DETAILS.md (+42 -1)
📝 serve/server.py (+52 -18)
📝 serve/test_lifecycle.py (+43 -0)

📄 Description

Problem and result

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.

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

  • 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

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:

  • 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:

None observed.

Not run:

  • 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

  • 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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3500 **Author:** [@MajMcCloud](https://github.com/MajMcCloud) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`95686ca`](https://github.com/Niko1221/Strata/commit/95686cacc2bb1498d731ebce1dd06d6e6b98b7ad) Add single-model metadata endpoint - [`00bb095`](https://github.com/Niko1221/Strata/commit/00bb095dc5fb4fc75c4731b955be8d33367c3876) Limit model detail endpoint to /v1/models/{id} - [`2f773af`](https://github.com/Niko1221/Strata/commit/2f773afeb1d39eac9dc909c51df6fd81cdf78bf8) Merge branch 'Niko1221:main' into main - [`c7f08ef`](https://github.com/Niko1221/Strata/commit/c7f08efcd2502801b1f2cf0e668e2befb0ce9892) Merge branch 'Niko1221:main' into main - [`0ecb98e`](https://github.com/Niko1221/Strata/commit/0ecb98e44e2657e7e5314a9de3c2a0d81a045d59) Merge branch 'Niko1221:main' into main - [`be98f1f`](https://github.com/Niko1221/Strata/commit/be98f1fa55c2baa462de8cf204778b0b9c9753ff) Merge branch 'Niko1221:main' into main - [`d30f50b`](https://github.com/Niko1221/Strata/commit/d30f50ba760f6963fe067513f0aec064b2fd1aed) Merge branch 'Niko1221:main' into main - [`d20263c`](https://github.com/Niko1221/Strata/commit/d20263c0a07de933757a7af13a8ed267c1532225) Merge branch 'main' into main - [`6d897ea`](https://github.com/Niko1221/Strata/commit/6d897ea9159e995dcfff3d12d60a05d1b0e57f46) Merge branch 'Niko1221:main' into main - [`e08e3d5`](https://github.com/Niko1221/Strata/commit/e08e3d552ac0a3c5d05aa4ea6dc15204e2d8db7f) Merge branch 'Niko1221:main' into main ### 📊 Changes **3 files changed** (+137 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+42 -1) 📝 `serve/server.py` (+52 -18) 📝 `serve/test_lifecycle.py` (+43 -0) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4659
No description provided.