Skip to main content

Crate gadk_model

Crate gadk_model 

Source
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): one POST with the retry loop of the official Anthropic and OpenAI SDKs, parameterised by a RetryPolicy, a CallTimeout and a per-attempt RequestHeaders provider.
sse
Incremental server-sent-events parser, shared by the model backends (moved from gadk-gemini, where it parsed streamGenerateContent?alt=sse).

Structs§

HttpOptions
Per-request HTTP options.
LiveConnError
A failure on a live connection. message is 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 Factory functions.
ReqwestClient
HttpClient backed by reqwest.
StreamingResponseAggregator
Aggregates partial streaming responses: it yields an LlmResponse for every (partial) model response, and builds one aggregated response from their content, returned by close once 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.
LiveConnErrorKind
What kind of failure a LiveConnError is, as LiveConnError::is_resumable checks it.
ModelError
Errors produced by model backends.
RealtimeInput
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.
RegistryError
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§

HttpClient
An HTTP transport. Backends send every request through this trait so tests can substitute a recorder/replayer.
LiveConnection
A live (bidi streaming) connection to a model, model-agnostic. recv must be cancel-safe and may run concurrently with a send.
Llm
Access to an underlying LLM.

Functions§

api_error_from_body
Builds a ModelError::Api from an HTTP error status and body.
body_prefix
The first ≤ 2048 bytes of body as lossy UTF-8, never cutting a multi-byte character.
can_use_output_schema_with_tools
Whether llm supports an output schema together with tools natively: only Vertex AI for Gemini 2.0+.
collect_body
Reads a BodyStream to the end, concatenating all chunks.
error_chain
err and 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), or None when unspecified.
is_gemini1_model
Whether model names a Gemini 1.x model.
is_gemini2_or_above
Whether model names a Gemini 2.0 or above model.
is_gemini25_or_lower
Whether model names a Gemini 2.5 or lower model.
is_gemini_3x_live
Whether model names a Gemini 3.x Live model other than Live Translate (adk-python _is_gemini_3_x_live).
is_gemini_35_live_translate
Whether model names a Gemini 3.5 Live Translate model.
is_gemini_api_variant
Whether llm is served by the Gemini API (not Vertex AI).
is_gemini_model
Whether model names a Gemini model.
is_internal_live_artifact_part
Whether part is an artifact:// 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 LlmResponse built from its first candidate.
needs_output_schema_processor
Whether llm is a Gemini model that needs the set_model_response tool workaround because it does not support output schema with tools natively.
redact_url
url for Debug output: 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 value as compact JSON with HTML-escaped strings, the float formatting above, and map keys sorted (as serde_json::Map is without preserve_order).
transport_error_detail
The text of a ModelError::Transport cause: a reqwest::Error loses its URL, then the source chain is joined with ": " (error_chain).

Type Aliases§

BodyStream
A streaming response body.
ExtrasRequestProvider
Hook that may add or rewrite fields of the outgoing JSON request body.
Factory
Constructs an Llm for the given model name.