ModelFetcher
Queries LLM provider APIs to enumerate available models.
| Inherits | QObject |
| Group | libllm |
Declared in src/libs/libllm/llm/ModelFetcher.hpp.
Detailed description
Sends HTTP requests to provider model-listing endpoints and parses the responses into LLMModel objects. Supports OpenAI-compatible APIs (OpenAI, Groq, OpenRouter, self-hosted servers) and Google AI. Anthropic models are returned from a hardcoded catalog when no key is set.
For a self-hosted provider it also reads the server's properties at `{serverRoot}/props`, which a llama.cpp server gives (llm-openai-compatible §OCP-M2). test() is the one test of a provider: the health probe of a self-hosted server, the list, the properties and the verdict (§OCP-M).
See also LLMProvider, LLMModel, AnthropicModelCatalog, LLMConnectionTester.
Member function documentation
applyServerProperties
[static] void ModelFetcher::applyServerProperties(const ModelFetcher::ServerProperties &props, const QList<QSharedPointer<LLMModel>> &models)
Fill models with props: the server's running settings win over the list (§OCP-M2). The context and the vision go to the model that the server names, or to the one model of the list.
healthStop
[static] QString ModelFetcher::healthStop(int status, QNetworkReply::NetworkError error, const QString &root)
The text that stops the test of a self-hosted server after its health probe answered status, or failed with error, at root. Empty when the test goes on (§OCP-M3): 200, and every answer of a server with no health endpoint.
merge
[static] int ModelFetcher::merge(LLMRegistry ®istry, const QString &providerId, const QList<QSharedPointer<LLMModel>> &models)
Add to registry the models of the provider providerId that it does not have, as the editor's Fetch models does, and return how many it added (§OCP-G5). A model that the registry has gets what discovery found: the context, the maximum when it had none, and, for a self-hosted server, the vision, because the server says what it runs (§OCP-D6).
readModelList
[static] QList<QSharedPointer<LLMModel>> ModelFetcher::readModelList(const QByteArray &body, const QString &providerId, bool selfHosted)
The models of an OpenAI-form list body of the provider providerId (§OCP-M1). Each field of a server that is there fills the model; a field of the wrong type is ignored. A model of a provider that is selfHosted costs 0.
readServerProperties
[static] ModelFetcher::ServerProperties ModelFetcher::readServerProperties(int status, const QByteArray &body)
The properties of a llama.cpp server in the answer status, body of `GET /props` (§OCP-M2). A status that is not 200, or a body that is not this JSON, means "not a llama.cpp server": found is false.
statusFailure
[static] QString ModelFetcher::statusFailure(const LLMProvider &provider, int status)
The text of a failed list of provider that answered status (§OCP-M4). A self-hosted provider with no key that gets 401 needs a key, which is not the text of a refused key.
test
void ModelFetcher::test(QSharedPointer<LLMProvider> provider)
Test provider, and end in tested() (§OCP-M). A self-hosted provider first gets the health probe of §OCP-M3, with no key. Then the model list and the server's properties are fetched, and LLMConnectionTester::verdict() decides. A provider that is not self-hosted needs a key, so a test with none fails before any request.