lasagnastack.llm.openrouter¶
lasagnastack.llm.openrouter
¶
OpenRouterClient
¶
OpenRouterClient(
api_key: str | None = None,
model: str | None = None,
reasoning_max_tokens: int = 4000,
reasoning_effort: str | None = None,
total_max_tokens: int | None = None,
)
Bases: LLMClient
LLM client backed by OpenRouter (OpenAI-compatible API).
Supports text-only generation. Video input is not available on OpenRouter;
use GeminiClient for Stage 2 (analyse) when video upload is required.
Initialise the OpenRouter client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
OpenRouter API key. Falls back to the
|
None
|
model
|
str | None
|
Model name to use ( |
None
|
reasoning_max_tokens
|
int
|
Token budget forwarded as
|
4000
|
reasoning_effort
|
str | None
|
Qualitative effort level ( |
None
|
total_max_tokens
|
int | None
|
Passed as |
None
|
Source code in src/lasagnastack/llm/openrouter.py
session_stats
property
¶
Aggregated token and cost totals across all calls on this instance.
Returns:
| Type | Description |
|---|---|
dict[str, float | int]
|
A dict with keys |
dict[str, float | int]
|
|
dict[str, float | int]
|
|
dict[str, float | int]
|
field returned by OpenRouter — no static pricing table is needed. |
generate
¶
generate(
prompt: str,
response_schema: type[BaseModel],
*,
temperature: float = 0.4,
) -> BaseModel
Send a text-only prompt; return a validated response_schema instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The plain-text prompt to send. |
required |
response_schema
|
type[BaseModel]
|
Pydantic model class that defines the expected JSON structure of the response. |
required |
temperature
|
float
|
Sampling temperature passed to the model. |
0.4
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
A validated instance of |
Source code in src/lasagnastack/llm/openrouter.py
generate_with_video
¶
generate_with_video(
video_path: Path,
prompt: str,
response_schema: type[BaseModel],
*,
temperature: float = 0.4,
) -> BaseModel
Not supported — OpenRouter has no video upload API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
Path
|
Unused. |
required |
prompt
|
str
|
Unused. |
required |
response_schema
|
type[BaseModel]
|
Unused. |
required |
temperature
|
float
|
Unused. |
0.4
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always. Use |