@@ -19,24 +19,28 @@ func TestLmstudioEnricher(t *testing.T) {
1919 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2020 require.Equal(t, "/api/v1/models", r.URL.Path)
2121 w.Header().Set("Content-Type", "application/json")
22− json.NewEncoder(w).Encode(lmstudioModelsResponse{
23− Data: []lmstudioModelEntry{
22+ // Raw JSON matching LM Studio's real /api/v1/models wire
23+ // format: array under "models", not "data".
24+ _, _ = w.Write([]byte(`{
25+ "models": [
2426 {
25− Key: "qwen2.5-7b-instruct",
26− DisplayName: "Qwen 2.5 7B Instruct",
27− MaxContextLength: 32768,
27+ "key": "qwen2.5-7b-instruct",
28+ "display_name": "Qwen 2.5 7B Instruct",
29+ "max_context_length": 32768
2830 },
2931 {
30− Key: "llama-3.1-8b",
31− DisplayName: "Llama 3.1 8B",
32− MaxContextLength: 131072,
33− },
34− },
35− })
32+ "key": "llama-3.1-8b",
33+ "display_name": "Llama 3.1 8B",
34+ "max_context_length": 131072
35+ }
36+ ]
37+ }`))
3638 }))
3739 defer srv.Close()
3840
39− cfg := Config{ID: "test-lmstudio", BaseURL: srv.URL}
41+ // Base URL includes /v1 (as Crush configures it); the enricher
42+ // strips it so the native endpoint resolves at the server root.
43+ cfg := Config{ID: "test-lmstudio", BaseURL: srv.URL + "/v1"}
4044 models := []catwalk.Model{
4145 {ID: "qwen2.5-7b-instruct", Name: "qwen2.5-7b-instruct"},
4246 {ID: "llama-3.1-8b", Name: "llama-3.1-8b"},
@@ -60,7 +64,7 @@ func TestLmstudioEnricher(t *testing.T) {
6064 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
6165 w.Header().Set("Content-Type", "application/json")
6266 json.NewEncoder(w).Encode(lmstudioModelsResponse{
63− Data: []lmstudioModelEntry{
67+ Models: []lmstudioModelEntry{
6468 {
6569 Key: "m1",
6670 MaxContextLength: 131072,
@@ -87,7 +91,7 @@ func TestLmstudioEnricher(t *testing.T) {
8791 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
8892 w.Header().Set("Content-Type", "application/json")
8993 json.NewEncoder(w).Encode(lmstudioModelsResponse{
90− Data: []lmstudioModelEntry{
94+ Models: []lmstudioModelEntry{
9195 {
9296 Key: "m1",
9397 DisplayName: "Should Not Override",
@@ -132,7 +136,7 @@ func TestLmstudioEnricher(t *testing.T) {
132136 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
133137 w.Header().Set("Content-Type", "application/json")
134138 json.NewEncoder(w).Encode(lmstudioModelsResponse{
135− Data: []lmstudioModelEntry{
139+ Models: []lmstudioModelEntry{
136140 {Key: "m1", DisplayName: "API Name"},
137141 },
138142 })