llm#
A small client for any OpenAI-compatible chat completions API with tool calling.
OpenRouter, OpenAI, Google’s OpenAI-compatible Gemini endpoint, Groq and a local Ollama all speak this shape, so the provider and model are just settings.
Reasoning models (Claude Haiku 5.5, GPT-6 Luna) think by default and bill thinking as output. reasoning sets
OpenRouter’s reasoning.effort for every request. When a model does think, its reasoning_details are kept on
the assistant message so they go back with the tool results, which Claude needs to carry on after a tool call.
- sidequest_bot.lib.llm.RATE_LIMIT_RETRIES: Final = 3#
- sidequest_bot.lib.llm.MAX_RETRY_WAIT_SECONDS: Final = 20.0#
- exception sidequest_bot.lib.llm.LLMError#
Bases:
ExceptionThe model API failed or answered with something that isn’t a chat completion.
- class sidequest_bot.lib.llm.ToolCall[source]#
One tool call the model asked for.
argumentsis None when the model sent JSON that doesn’t parse.- id: str#
- name: str#
- arguments: dict[str, Any] | None#
- class sidequest_bot.lib.llm.Usage[source]#
Tokens a request used, and what it cost in USD when the API says (OpenRouter does).
- input_tokens: int = 0#
- output_tokens: int = 0#
- cost: float | None = None#
- class sidequest_bot.lib.llm.Reply[source]#
One model turn:
messagegoes back into the history verbatim;textandtool_callsare parsed.- message: dict[str, Any]#
- text: str#