Model calls and usage¶
call_llm routes scanner and semantic-judge requests by model prefix. Explicit prefixes are anthropic/, google/ (also gemini/), openai/, and openrouter/. Bare Claude/Gemini names select their native provider; other bare names use OpenAI. OpenRouter names retain the nested provider/model, for example openrouter/openai/gpt-4o-mini.
Provider errors become LLMError. A returned LLMResponse includes text, input/output token counts, and model. track_usage captures helper responses in the current context for scanner cost aggregation. AutoInject and offline victim calls do not use this routing helper.
llm ¶
LLMError ¶
LLMResponse
dataclass
¶
Source code in src/benchmark/utils/llm.py
track_usage ¶
Context manager that captures every LLMResponse produced within its scope.
Usage: with track_usage() as log: call_llm(...) call_llm(...) # log is a list[LLMResponse]
Source code in src/benchmark/utils/llm.py
call_llm ¶
call_llm(model: str, system: str, user: str, max_tokens: int = 2048, temperature: float | None = None) -> LLMResponse
Call an LLM and return an LLMResponse with text and token usage.
model format: 'provider/model-name' e.g. 'anthropic/claude-sonnet-4-6', 'google/gemini-2.5-flash', 'openai/gpt-4o', 'openrouter/openai/gpt-4o'. Bare model names are accepted with heuristic provider detection.