OpenRouterProvider

org.llm4s.llmconnect.provider.OpenRouterProvider
@Stable

Registration for OpenRouter.

OpenRouter speaks the OpenAI wire format and so reuses OpenAIConfig, but it has its own client: OpenRouterClient adds the referer/title headers the service expects, reasoning parameters and its own tool-call parsing.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete 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 and section.extras holds exactly the declared provider-specific keys that have a value (defaults applied, deprecated aliases resolved). 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

Inherited 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

Inherited from:
ProviderDescriptor

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

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

Attributes

Inherited from:
ProviderDescriptor

Concrete fields

val DEFAULT_BASE_URL: String

The OpenRouter API base URL used when a provider section sets no baseUrl.

The OpenRouter API base URL used when a provider section sets no baseUrl.

This was DefaultConfig.DEFAULT_OPENROUTER_BASE_URL in llm4s-core until the provider moved to llm4s-openai-compatible (#1132).

Attributes

Accepts organization, which it passes on in its OpenAIConfig as OpenAI and Requesty do.

Accepts organization, which it passes on in its OpenAIConfig as OpenAI and Requesty do.

Attributes

val 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

override val modelLister: Option[ProviderModelLister]

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

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

Attributes