Expand description
gadk-model: the LLM abstraction, the model registry, the HTTP seam and the shared SSE parser
(sse).
Modules§
- rest
- The shared REST transport of the provider crates (
gadk-anthropic,gadk-openai): onePOSTwith the retry loop of the official Anthropic and OpenAI SDKs, parameterised by aRetryPolicy, aCallTimeoutand a per-attemptRequestHeadersprovider. - sse
- Incremental server-sent-events parser, shared by the model backends (moved from
gadk-gemini, where it parsed
streamGenerateContent?alt=sse).
Structs§
- Http
Options - Per-request HTTP options.
- Live
Conn Error - A failure on a live connection.
messageis the full error text. - LlmRequest
- The raw LLM request.
- LlmResponse
- The raw LLM response. It provides the first candidate response from the model if available.
- Registry
- A registry mapping model-name patterns to
Factoryfunctions. - Reqwest
Client HttpClientbacked byreqwest.- Streaming
Response Aggregator - Aggregates partial streaming responses: it yields an
LlmResponsefor every (partial) model response, and builds one aggregated response from their content, returned bycloseonce the stream ends. Text is buffered and merged, function calls whose arguments are streamed as JSON-path-addressed partial arguments are assembled, and thought signatures are propagated to the function call they belong to.
Enums§
- Backend
- Which Google backend serves a model; an unspecified backend is represented as
None. - Live
Conn Error Kind - What kind of failure a
LiveConnErroris, asLiveConnError::is_resumablechecks it. - Model
Error - Errors produced by model backends.
- Realtime
Input - Realtime input for
LiveConnection::send_realtime: a blob, activity start/end markers and the end of the audio stream. Moved from gadk-gemini, which re-exports it. - Registry
Error - Errors returned by
Registry.
Constants§
- LIVE_
ARTIFACT_ NAMESPACE - The path segment the live audio cache stores its blobs under
when it builds an
artifact://reference. Callers that assemble such a URI and callers that recognize one must agree on this value.
Traits§
- Http
Client - An HTTP transport. Backends send every request through this trait so tests can substitute a recorder/replayer.
- Live
Connection - A live (bidi streaming) connection to a model, model-agnostic.
recvmust be cancel-safe and may run concurrently with a send. - Llm
- Access to an underlying LLM.
Functions§
- api_
error_ from_ body - Builds a
ModelError::Apifrom an HTTP error status and body. - body_
prefix - The first ≤ 2048 bytes of
bodyas lossy UTF-8, never cutting a multi-byte character. - can_
use_ output_ schema_ with_ tools - Whether
llmsupports an output schema together with tools natively: only Vertex AI for Gemini 2.0+. - collect_
body - Reads a
BodyStreamto the end, concatenating all chunks. - error_
chain errand its sources, joined with": "(moved from gadk-anthropic so every REST provider renders a cause chain the same way).- google_
variant - The Google LLM variant of
llm(Gemini API or Vertex AI), orNonewhen unspecified. - is_
gemini1_ model - Whether
modelnames a Gemini 1.x model. - is_
gemini2_ or_ above - Whether
modelnames a Gemini 2.0 or above model. - is_
gemini25_ or_ lower - Whether
modelnames a Gemini 2.5 or lower model. - is_
gemini_ 3x_ live - Whether
modelnames a Gemini 3.x Live model other than Live Translate (adk-python_is_gemini_3_x_live). - is_
gemini_ 35_ live_ translate - Whether
modelnames a Gemini 3.5 Live Translate model. - is_
gemini_ api_ variant - Whether
llmis served by the Gemini API (not Vertex AI). - is_
gemini_ model - Whether
modelnames a Gemini model. - is_
internal_ live_ artifact_ part - Whether
partis anartifact://reference to a blob the live flow cached for itself, such as the recorded input and output audio the audio cache saves. - llm_
response_ from_ genai - Converts a genai response into an
LlmResponsebuilt from its first candidate. - needs_
output_ schema_ processor - Whether
llmis a Gemini model that needs theset_model_responsetool workaround because it does not support output schema with tools natively. - redact_
url urlforDebugoutput: credentials embedded in it (https://user:secret@host) are removed; a URL without user info is returned as it is, and one that does not parse, has no host but contains@, or whose user info cannot be removed becomes<redacted>.- to_
go_ json - Serializes
valueas compact JSON with HTML-escaped strings, the float formatting above, and map keys sorted (asserde_json::Mapis withoutpreserve_order). - transport_
error_ detail - The text of a
ModelError::Transportcause: areqwest::Errorloses its URL, then the source chain is joined with": "(error_chain).
Type Aliases§
- Body
Stream - A streaming response body.
- Extras
Request Provider - Hook that may add or rewrite fields of the outgoing JSON request body.
- Factory
- Constructs an
Llmfor the given model name.