ProviderDescriptor

org.llm4s.llmconnect.spi.ProviderDescriptor
See theProviderDescriptor companion object

Everything llm4s needs to know about one LLM provider, supplied by the provider itself.

A descriptor is the whole extension point: implement it, register it (by listing it in an Llm4sProviderModule, or by handing it to ProviderRegistry.of), and the provider becomes reachable from configuration, validation, client construction and model discovery without editing anything in llm4s-core. Before this existed, adding a provider meant edits to roughly eight shared files — see #1131.

Attributes

Example
object BedrockProvider extends ProviderDescriptor:
 val id         = ProviderId("bedrock")
 val configSpec = ProviderConfigSpec(requiresApiKey = true, requiresEndpoint = true)
 def buildConfig(providerName: String, section: NamedProviderConfig)(using
   ContextWindowResolver
 ): Result[ProviderConfig] = ...
 def buildClient(config: ProviderConfig, options: LlmClientOptions)(using
   ModelRegistryService
 ): Result[LLMClient] =
   ProviderDescriptor.expectConfig[BedrockConfig](id, config).flatMap(BedrockClient(_, options.metrics))
Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

Constructs the client for a ProviderConfig this provider produced.

Constructs the client for a ProviderConfig this provider produced.

config is whatever the caller passed, so implementations must check the type rather than cast — ProviderDescriptor.expectConfig does that and produces the standard mismatch error.

Attributes

def buildConfig(providerName: String, section: NamedProviderConfig)(using ContextWindowResolver): Result[ProviderConfig]

Turns a validated config section into the runtime ProviderConfig for this provider.

Turns a validated config section into the runtime ProviderConfig for this provider.

The section has already been checked against configSpec, so required fields are present; a Left here means something configSpec cannot express (a malformed value, say).

Value parameters

providerName

the user's instance name (llm4s.providers.<name>), for error messages.

Attributes

Which config fields this provider requires, and its default endpoint.

Which config fields this provider requires, and its default endpoint.

Attributes

def id: ProviderId

Canonical id, e.g. ProviderId("openai"). Must be unique within a registry.

Canonical id, e.g. ProviderId("openai"). Must be unique within a registry.

Attributes

Concrete methods

def aliases: Set[String]

Alternative spellings accepted in provider = "...", folded onto id.

Alternative spellings accepted in provider = "...", folded onto id.

For example Gemini accepts "google". Aliases are matched after the same trim/lowercase canonicalisation as id itself.

Attributes

What this provider's client implements. Defaults to the full interface.

What this provider's client implements. Defaults to the full interface.

Attributes

Live model discovery, when the provider's API offers it.

Live model discovery, when the provider's API offers it.

Attributes