gadk-model
The LLM abstraction of gadk. The Llm trait is what an LLM agent calls: generate_content
takes an LlmRequest (model name, contents, GenerateContentConfig, HTTP options, tools) and
returns a stream of LlmResponses, one final response or partial responses followed by the
final one; models with live (bidirectional streaming) support also implement connect_live.
gadk-gemini, gadk-anthropic and gadk-openai implement it.
The crate also holds what those providers share:
Registry: an opt-in, name-based model registry. Register a factory under a model-name pattern (a regex such as"^(?i)gemini-.*"), then build a model from a name withnew_llm; exactly one pattern must match. Provider crates do not register themselves.HttpClient: the HTTP seam every provider sends through (ReqwestClientby default), so tests and applications can supply their own client.rest: the REST transport ofgadk-anthropicandgadk-openai: onePOSTwith a retry policy, call timeouts and per-attempt headers, and the Google API error type.sse: the incremental server-sent-events parser.StreamingResponseAggregator,ModelErrorand the Gemini model-name helpers (is_gemini_model,is_gemini2_or_above, …).
Most applications use this crate through the gadk façade (gadk::model).
Example
use Arc;
use ;
// Inside an async fn returning Result.
let factory: Factory = new;
global.register?;
let model = global.new_llm.await?;
Features
gcp-auth:gcp_auth, Google Application Default Credentials and the request headers they produce, shared by the Google Cloud clients.test-util:rest::test_util, a scripted in-processHttpClient, a 127.0.0.1 fake server and fixed-header Google credentials for the provider crates' tests.