yera.models.interfaces.llms.openrouter

Yera LLM interface for models invoked through OpenRouter.

Symbols

class OpenRouterLLM — LLM interface for models invoked through OpenRouter.

OpenRouterLLM

LLM interface for models invoked through OpenRouter.

Methods

__init__ — Initialize an OpenRouter interface without starting its API client.
start — Initialise the OpenRouter client.
stop — Clear the OpenRouter client.
chat — Stream a chat response through OpenRouter.
make_struct — Stream JSON conforming to a strict schema through OpenRouter.
make_request_struct — Stream a forced structured tool call through OpenRouter.

OpenRouterLLM.__init__

__init__(
    config: LLMConfig,
    connection: OpenRouterConnection,
    overrides: dict,
) → None

Initialize an OpenRouter interface without starting its API client.

Parameters

config
type: LLMConfig

Model identity, capabilities, and default inference settings.

connection
type: OpenRouterConnection

OpenRouter connection used when the client is started.

overrides
type: dict

Inference values to apply over the model defaults.

Raises

TypeError

If the model does not declare OpenRouter capabilities.

OpenRouterLLM.start

start() → None

Initialise the OpenRouter client.

OpenRouterLLM.stop

stop() → None

Clear the OpenRouter client.

OpenRouterLLM.chat

chat(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a chat response through OpenRouter.

Parameters

messages
type: list[Message]

Conversation history to send through OpenRouter.

reasoning_level
type: ReasoningLevel | None = None

Optional reasoning effort overriding the configured default.

**overrides
type: str | float | int | bool

Per-call inference settings applied over the configured defaults.

OpenRouterLLM.make_struct

make_struct(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream JSON conforming to a strict schema through OpenRouter.

Parameters

messages
type: list[Message]

Conversation history to send through OpenRouter.

cls
type: type[TStruct]

Struct class defining the required JSON response schema.

reasoning_level
type: ReasoningLevel | None = None

Optional reasoning effort overriding the configured default.

**overrides
type: str | float | int | bool

Per-call inference settings applied over the configured defaults.

Raises

ValueError

If the model does not support structured outputs.

OpenRouterLLM.make_request_struct

make_request_struct(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a forced structured tool call through OpenRouter.

Parameters

messages
type: list[Message]

Conversation history to send through OpenRouter.

cls
type: type[TStruct]

Struct class defining the forced function call and its arguments.

reasoning_level
type: ReasoningLevel | None = None

Optional reasoning effort overriding the configured default.

**overrides
type: str | float | int | bool

Per-call inference settings applied over the configured defaults.

Raises

ValueError

If the model does not support tool calling or forced tool choice.