Skip to content

AI gateway

The functions of llm_gateway.router, taken from their docstrings.

llm_gateway.router

One router for every AI connector (LiteLLM): the default AI first, then the fallback.

LLMGatewayError

Bases: Exception

Base class for all LLM Gateway exceptions.

LLMConnectionError

Bases: LLMGatewayError

Raised when an LLM provider is unreachable (timeout, network issues, etc.).

LLMAuthenticationError

Bases: LLMGatewayError

Raised when there is an authentication issue (invalid API key, missing permissions).

LLMQuotaExceededError

Bases: LLMGatewayError

Raised when the provider's API rate limit or billing quota has been exceeded.

LLMRouter

Central router that dispatches requests via LiteLLM based on active Watcher connectors.

has_primary()

Whether an AI other than the local one is set up and not paused.

generate_text(prompt, provider_name=None, **kwargs)

Text from the first connector that answers (the one asked for, or the chain), None if none does.

summarize(text, provider_name=None, **kwargs)

Summarizes text, automatically switching to fallback if the main provider fails.