LlmClient), backed by ADK models (Gemini or a LiteLLM endpoint) or a LiteRT-LM model on this machine.
llm.adk
LlmClient on top of ADK models: google.adk.models.Gemini or LiteLlm (a LiteLLM endpoint).
AdkLlmClient
Construct with AdkLlmClient(model: google.adk.models.base_llm.BaseLlm, config: LlmConfig, sleep=<function sleep at 0x102764b80>).
build_model
config.
create_client
config: a LiteRT-LM model on this machine for backend=“litert”, else an ADK model (Gemini or a LiteLLM endpoint).
relaxed_json_schema
maxItems/minItems on lists of objects, or None when there is nothing to remove.
llm.auth
Build a google.genai.Client from a config that has GoogleAuthFields. Used by the LLM client and the embedder.
GoogleAuthError
The sign-in cannot be built: a missing file or variable, or a key that is not a service account key.
build_genai_client
google.genai.Client for config, or None to let the library choose from the environment.
is_permanent_error
service_account_credentials
config, from a file or from an environment variable.
llm.base
The interface the extractor depends on, and the types around it.
GoogleAuthFields
How a Google client signs in.
LlmClient
Structured output: send a prompt, get back an instance of schema.
Construct with LlmClient(*args, **kwargs).
LlmConfig
LlmError
The call failed (network, quota, timeout, empty answer) after every retry.
LlmOutputError
The model answered, but not in the requested schema, even after repair attempts.
LlmUsage
check_google_auth
llm.fake
A scripted client for tests: no network, no ADK.
FakeLlmClient
Returns canned replies in order and records every request.
Construct with FakeLlmClient(replies: list[pydantic.main.BaseModel \| Exception \| Callable[[str, str, type], pydantic.main.BaseModel]] \| None = None, model: str = 'fake/model').
llm.litert
An LlmClient that runs a LiteRT-LM model on this machine (Gemma 4 E2B as a .litertlm file), for work that should not leave it: quick translation, short extraction. It is the local counterpart of AdkLlmClient, and takes the same complete / acomplete calls.
LiteRtLlmClient
Construct with LiteRtLlmClient(model_path: str \| pathlib.Path, *, device: str = 'cpu', max_output_tokens: int = 2048, repair_attempts: int = 1, constrained: bool = True, thinking: Literal['default', 'off', 'on'] = 'default', speculative_decoding: bool = False, cache_dir: str \| pathlib.Path \| None = None, engine: _Engine \| None = None).
llm.structured
Turning a model’s text into a pydantic object, for a backend that cannot constrain the output itself.
json_instruction
strip_fence
llm.translate
Vietnamese to English translation behind the LlmClient Protocol.
Glossary
Term
Translated
Translator
Translate with any LlmClient; gate every answer; retry with the reasons.
Construct with Translator(llm: LlmClient, glossary: Glossary \| None = None, *, retries: int = 1).
gate
english is not an acceptable translation of source.