serve: /v1/models/:id answers the model object, not a list of one

OpenAI's retrieve returns the entry itself, and its SDK reads `id` off the top level, where
the list of one this route answered before has none. /v1/models still answers the list.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 15:57:51 +02:00
1 parent 86128c2e75
commit 3a3345951f
6 files changed
+65 -22

No files matched your search

+13 -5
View File
@@ -2205,19 +2205,27 @@ std::string embeddings_body(const OaiRequest& r, const std::vector<std::vector<f
return o.dump();
}
std::string models_body(const std::string& model_id, int64_t created, int64_t max_model_len) {
static json model_card(const ModelCard& c) {
json m;
m["id"] = model_id;
m["id"] = c.id;
m["object"] = "model";
m["created"] = created;
m["created"] = c.created;
m["owned_by"] = "radiance";
if (max_model_len > 0) m["max_model_len"] = max_model_len;
if (c.max_model_len > 0) m["max_model_len"] = c.max_model_len;
return m;
}
std::string models_body(const ModelCard& c) {
json o;
o["object"] = "list";
o["data"] = json::array({m});
o["data"] = json::array({model_card(c)});
return o.dump();
}
std::string model_body(const ModelCard& c) {
return model_card(c).dump();
}
/* ================================================================== SSE */
std::string sse_event(const std::string& json_text) {