LLMProvider

Persisted record for a configured LLM provider endpoint.

Inherits QEnableSharedFromThis
Group libllm

Declared in src/libs/libllm/llm/LLMProvider.hpp.

Detailed description

Represents a single provider configuration such as an online API service, a local llama.cpp instance, or a remote node offering LLM inference. Each provider stores its type-specific connection details and encrypted credentials.

See also LLMModel, LLMRegistry.

Member function documentation

baseUrlPlaceholder

[static] QString LLMProvider::baseUrlPlaceholder(OnlineProviderKind kind, WireProtocol protocol, bool selfHosted)

The placeholder of the base URL field for kind, protocol and selfHosted, from the table of §OCP-D2.

baseUrlProblem

[static] QString LLMProvider::baseUrlProblem(const QString &url)

Why url cannot be a base URL, or empty when it can (§OCP-D2). An empty URL can: a named kind has its default. The editor and the OPAL task llm.provider.set refuse a URL with a query, a fragment or user information, and one whose scheme is not `http` or `https`.

cleanBaseUrl

[static] QString LLMProvider::cleanBaseUrl(const QString &url)

url without its spaces and with one trailing `/` removed (§OCP-D2).

credentialProblem

QString LLMProvider::credentialProblem() const

The user's text for a key that did not open, or empty.

credentialState

CredentialState LLMProvider::credentialState() const

The state of the key in memory (llm-openai-compatible §OCP-K2).

endpointUrl

QString LLMProvider::endpointUrl(const QString &path) const

The URL of path below the base URL, with exactly one `/` between them (§OCP-D2).

hasUsableCredentials

bool LLMProvider::hasUsableCredentials() const

Returns whether the provider's credentials let it serve (§OCP-D4): a key that opened, or no key at all for a self-hosted server. A key that did not open never counts: the server expects it.

joinUrl

[static] QString LLMProvider::joinUrl(const QString &base, const QString &path)

base and path with exactly one `/` between them.

onlineProblem

QString LLMProvider::onlineProblem() const

Why this online provider cannot serve a request now, or empty when it can: it is enabled, its key opened, it has a key or needs none (§OCP-D4), an OpenAI-form provider has a base URL (§OCP-W1), and its last test passed. LLMRegistry::usable() and the online driver factory read the same rule (§OCP-A2).

sealedCredentials

QString LLMProvider::sealedCredentials() const

The seal of a key that did not open, as it was read. Empty for every other state.

selfHosted

bool LLMProvider::selfHosted() const

Returns whether the user runs this provider's server (§OCP-D3).

serverRoot

QString LLMProvider::serverRoot() const

The base URL with a trailing `/v1` removed: where a llama.cpp server has `/health` and `/props` (§OCP-D2).

serverRootOf

[static] QString LLMProvider::serverRootOf(const QString &baseUrl)

baseUrl with a trailing `/v1` removed (§OCP-D2).

serverSlots

int LLMProvider::serverSlots() const

The number of requests that the provider's server takes at once, from `total_slots` of its properties, or 0 when no test or fetch read it (§OCP-M2). It is not saved: the server can change it at its next start.

See also setServerSlots().

setClearCredentials

void LLMProvider::setClearCredentials(const QString &credentials)

Set credentials, read in clear from a file of an earlier version. The key is used, and the registry seals it at its next save.

setCredentials

void LLMProvider::setCredentials(const QString &credentials)

Set the key to credentials, as the user entered it. The state becomes Open, or None for an empty key, and a seal kept from a key that did not open is dropped: the new key replaces it.

setOnlineProvider

void LLMProvider::setOnlineProvider(OnlineProviderKind kind)

Set the kind to kind. A change of kind sets the wire protocol: a named kind has its own, and Custom starts with OpenAIChat, which setWireProtocol() can change (llm-openai-compatible §OCP-D1). The same kind again keeps the protocol, as the editor sets the kind at each save.

setServerSlots

void LLMProvider::setServerSlots(int count)

Sets the number of the server's slots to count (§OCP-M2).

See also serverSlots().

setUnopenedCredentials

void LLMProvider::setUnopenedCredentials(CredentialState state, const QString &sealed)

Keep sealed, a seal that did not open, with state Foreign or Broken. The key is empty, so nothing uses it, and the registry writes sealed back until the user enters a new key.

setWireProtocol

void LLMProvider::setWireProtocol(WireProtocol protocol)

Set the wire protocol to protocol. Only a Custom provider has a choice: for a named kind, the kind's protocol stays.

See also wireProtocol().

wireProtocol

WireProtocol LLMProvider::wireProtocol() const

The wire protocol of an online provider (§OCP-D1).

See also setWireProtocol().

wireProtocolOfKind

[static] WireProtocol LLMProvider::wireProtocolOfKind(OnlineProviderKind kind)

The wire protocol of kind (§OCP-D1): Anthropic's own for Anthropic, OpenAIChat for every other kind, Google's through its OpenAI compatibility.

In this section