Skip to main content
All Python modules · Import and compatibility guidance

Exports

LiteLLMContext

Stable call context provided to every LiteLLM lifecycle hook.
Fields (— means no declared default):

LiteLLMLifecycle

Customize one LiteLLM model’s transport and call lifecycle. Override hooks with either ordinary or async methods. Async hooks require the framework’s async invocation path; Harnest never runs a private event loop to make them appear synchronous.

LiteLLMLifecycle.create_transport

Return a provider client accepted by LiteLLM’s client option.

LiteLLMLifecycle.before_request

Mutate request or return its replacement before LiteLLM runs.

LiteLLMLifecycle.after_response

Return a non-stream response replacement or observe stream exhaustion.

LiteLLMLifecycle.on_error

Observe a lifecycle or LiteLLM failure before it is re-raised.

LiteLLMLifecycle.close

Release resources created for this model instance.

LiteLLMModel

A provider-neutral model routed through a framework LiteLLM adapter. model must use LiteLLM’s explicit provider/model form. All keyword arguments reach the underlying LiteLLM completion call, including provider settings such as api_base, api_key, and generation options. thinking selects a portable on/off mode; omit it to use the provider default or pass reasoning_effort directly for provider-specific levels. prompt_cache enables provider prompt-cache breakpoints where the provider requires them; it defaults to True and never changes OpenAI or Gemini requests.
Fields (— means no declared default):

LiteLLMModel.build

Build ADK’s LiteLlm without contacting the provider.

LiteLLMModel.build_for

Build the connector for a supported Harnest framework.

LiteLLMModel.build_langgraph

Build LangChain’s LiteLLM chat model without contacting the provider.

LiteLLMModel.from_openai_environment

Use an explicitly configured OpenAI-compatible API, not a default vendor. OPENAI_MODEL and OPENAI_BASE_URL are required; OPENAI_API_KEY is optional. This reads the process environment without loading dotenv. Explicit completion arguments override environment values. Model IDs may contain slashes; the optional openai/ prefix selects the wire protocol only.

ModelCallRequest

Portable model input that a listener may replace or short-circuit.
Fields (— means no declared default):

ModelCallResponse

Portable visible model output.
Fields (— means no declared default):

ModelConnector

A lazily constructed model with ADK and LangGraph adapters. Connectors keep optional model-provider imports out of config discovery and agent validation. Plain model strings and already-built ADK BaseLlm objects do not need a connector.

ModelConnector.build

Build the model object accepted by ADK’s LlmAgent.

ModelConnector.build_for

Build the connector for a supported Harnest framework.

ModelConnector.build_langgraph

Build a LangChain chat model for LangGraph.

ModelLifecycleContext

Stable provider-neutral facts associated with one model call.
Fields (— means no declared default):

ModelLifecycleContext.next

Continue normally or pass a replacement to the next interceptor.

ModelLifecycleContext.finish

Return a final value without advancing to later execution.

ModelLifecycleError

A portable model listener returned an invalid transformation.

ModelMessage

One provider-independent text message in a model call.
Fields (— means no declared default):

resolve_model

Resolve a Harnest connector while preserving strings and ADK models.

resolve_model_for

Resolve a connector for one compiler backend.