pub trait Llm: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn generate_content<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
stream: bool,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LlmResponse, AdkError>> + Send>>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn schema_adapter(&self) -> &dyn SchemaAdapter { ... }
fn uses_interactions_api(&self) -> bool { ... }
}Expand description
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling The core trait for all LLM providers.
Implementations wrap a specific model API (Gemini, OpenAI, Anthropic, etc.) and produce a stream of responses for a given request.
Required Methods§
Sourcefn generate_content<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
stream: bool,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LlmResponse, AdkError>> + Send>>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn generate_content<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
stream: bool,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LlmResponse, AdkError>> + Send>>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Generates content from the given request, optionally streaming.
Provided Methods§
Sourcefn schema_adapter(&self) -> &dyn SchemaAdapter
fn schema_adapter(&self) -> &dyn SchemaAdapter
Returns the schema adapter for this provider.
The schema adapter normalizes raw JSON Schema from MCP tools into the format accepted by this provider’s function-calling API.
Default implementation returns GenericSchemaAdapter, which applies
safe transforms suitable for most providers. Override this method to
return a provider-specific adapter (e.g., GeminiSchemaAdapter,
OpenAiStrictSchemaAdapter).
Sourcefn uses_interactions_api(&self) -> bool
fn uses_interactions_api(&self) -> bool
Returns true if this model is configured to use a server-managed
environment (e.g., Gemini Interactions API) where the provider owns
the tool-calling loop and filesystem.
This is used at agent build time to detect conflicts with client-side sandbox tools that would produce competing filesystems.
Default implementation returns false. Override in providers that
support server-managed environments.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".