Expand description
§adk-model
LLM model integrations for ADK (Gemini, OpenAI, OpenRouter, Anthropic, DeepSeek, Groq, Ollama, Fireworks AI, Together AI, Mistral AI, Perplexity, Cerebras, SambaNova, Amazon Bedrock, Azure AI Inference).
§Overview
This crate provides LLM implementations for ADK agents. Currently supports:
GeminiModel- Google’s Gemini models (3 Pro, 2.5 Flash, etc.)OpenAIClient- OpenAI models (GPT-5, GPT-5-mini, o3, etc.) — requiresopenaifeatureAzureOpenAIClient- Azure OpenAI Service — requiresopenaifeatureOpenAICompatible- Any OpenAI-compatible API (xAI, Fireworks, Together, Mistral, Perplexity, Cerebras, SambaNova, or custom) — requiresopenaifeature, useOpenAICompatibleConfigpresetsAnthropicClient- Anthropic Claude models — requiresanthropicfeatureDeepSeekClient- DeepSeek models — requiresdeepseekfeatureGroqClient- Groq ultra-fast inference — requiresgroqfeatureOpenRouterClient- OpenRouter-native chat, responses, and discovery APIs — requiresopenrouterfeatureOllamaModel- Local LLMs via Ollama — requiresollamafeatureBedrockClient- Amazon Bedrock via AWS SDK — requiresbedrockfeatureAzureAIClient- Azure AI Inference endpoints — requiresazure-aifeatureMockLlm- Mock LLM for testing
§Quick Start
§Gemini
use adk_model::GeminiModel;
use std::sync::Arc;
let api_key = std::env::var("GOOGLE_API_KEY").unwrap();
let model = GeminiModel::new(&api_key, "gemini-2.5-flash").unwrap();§OpenAI
use adk_model::openai::{OpenAIClient, OpenAIConfig};
let model = OpenAIClient::new(OpenAIConfig::new(
std::env::var("OPENAI_API_KEY").unwrap(),
"gpt-5-mini",
)).unwrap();§OpenRouter
use adk_core::{Content, Llm, LlmRequest};
use adk_model::openrouter::{OpenRouterClient, OpenRouterConfig};
use futures::StreamExt;
let client = OpenRouterClient::new(
OpenRouterConfig::new(
std::env::var("OPENROUTER_API_KEY").unwrap(),
"openai/gpt-4.1-mini",
)
.with_http_referer("https://github.com/zavora-ai/adk-rust")
.with_title("ADK-Rust"),
).unwrap();
let request = LlmRequest::new(
"openai/gpt-4.1-mini",
vec![Content::new("user").with_text("Reply in one short sentence.")],
);
let mut stream = client.generate_content(request, true).await.unwrap();
while let Some(item) = stream.next().await {
let _response = item.unwrap();
}Native OpenRouter APIs such as model discovery, credits, routing configuration, plugins, and
exact Responses payload access remain available on OpenRouterClient itself.
§Anthropic
use adk_model::anthropic::{AnthropicClient, AnthropicConfig};
let model = AnthropicClient::new(AnthropicConfig::new(
std::env::var("ANTHROPIC_API_KEY").unwrap(),
"claude-sonnet-4-5-20250929",
)).unwrap();§DeepSeek
use adk_model::deepseek::{DeepSeekClient, DeepSeekConfig};
// Chat model
let chat = DeepSeekClient::chat(std::env::var("DEEPSEEK_API_KEY").unwrap()).unwrap();
// Reasoner with thinking mode
let reasoner = DeepSeekClient::reasoner(std::env::var("DEEPSEEK_API_KEY").unwrap()).unwrap();§OpenAI-Compatible Providers (Fireworks, Together, Mistral, Perplexity, Cerebras, SambaNova, xAI)
All OpenAI-compatible providers use OpenAICompatible with provider presets:
use adk_model::openai_compatible::{OpenAICompatible, OpenAICompatibleConfig};
// Fireworks AI
let model = OpenAICompatible::new(OpenAICompatibleConfig::fireworks(
std::env::var("FIREWORKS_API_KEY").unwrap(),
"accounts/fireworks/models/llama-v3p1-8b-instruct",
)).unwrap();
// Together AI
let model = OpenAICompatible::new(OpenAICompatibleConfig::together(
std::env::var("TOGETHER_API_KEY").unwrap(),
"meta-llama/Llama-3.3-70B-Instruct-Turbo",
)).unwrap();
// Or any custom OpenAI-compatible endpoint
let model = OpenAICompatible::new(
OpenAICompatibleConfig::new("your-api-key", "your-model")
.with_base_url("https://your-endpoint.com/v1")
.with_provider_name("my-provider"),
).unwrap();§Amazon Bedrock
use adk_model::bedrock::{BedrockClient, BedrockConfig};
// Uses AWS IAM credentials from the environment (no API key needed)
let config = BedrockConfig::new("us-east-1", "anthropic.claude-sonnet-4-20250514-v1:0");
let model = BedrockClient::new(config).await.unwrap();§Azure AI Inference
use adk_model::azure_ai::{AzureAIClient, AzureAIConfig};
let model = AzureAIClient::new(AzureAIConfig::new(
"https://my-endpoint.eastus.inference.ai.azure.com",
std::env::var("AZURE_AI_API_KEY").unwrap(),
"meta-llama-3.1-8b-instruct",
)).unwrap();§Ollama (Local)
use adk_model::ollama::{OllamaModel, OllamaConfig};
// Default: localhost:11434
let model = OllamaModel::new(OllamaConfig::new("llama3.2")).unwrap();§Supported Models
§Gemini
| Model | Description |
|---|---|
gemini-3.7-flash | Current balanced default (1M context) |
gemini-3.6-flash | Previous balanced generation (1M context) |
gemini-3.5-flash-lite | Cost-efficient high-volume model (1M context) |
§OpenAI
| Model | Description |
|---|---|
gpt-5.6-terra | Balanced default for agents |
gpt-5.6-sol | Flagship reasoning and coding |
gpt-5.6-luna | Cost-efficient high-volume model |
§Anthropic
| Model | Description |
|---|---|
claude-sonnet-5 | Balanced default |
claude-opus-5 | Flagship capability |
claude-fable-5 | Premium creative and long-form work |
§DeepSeek
| Model | Description |
|---|---|
deepseek-v4-flash | Fast balanced default |
deepseek-v4-pro | Advanced reasoning |
§Groq
| Model | Description |
|---|---|
openai/gpt-oss-120b | Production default via Groq LPU |
openai/gpt-oss-20b | Lower-latency economy model |
§OpenAI-Compatible Providers (via openai feature)
Use OpenAICompatibleConfig presets — one client, one feature flag:
| Provider | Preset | Env Var |
|---|---|---|
| Fireworks AI | OpenAICompatibleConfig::fireworks() | FIREWORKS_API_KEY |
| Together AI | OpenAICompatibleConfig::together() | TOGETHER_API_KEY |
| Mistral AI | OpenAICompatibleConfig::mistral() | MISTRAL_API_KEY |
| Perplexity | OpenAICompatibleConfig::perplexity() | PERPLEXITY_API_KEY |
| Cerebras | OpenAICompatibleConfig::cerebras() | CEREBRAS_API_KEY |
| SambaNova | OpenAICompatibleConfig::sambanova() | SAMBANOVA_API_KEY |
| xAI (Grok) | OpenAICompatibleConfig::xai() | XAI_API_KEY |
§Other Providers
| Provider | Feature Flag | Env Var |
|---|---|---|
| Amazon Bedrock | bedrock | AWS IAM credentials |
| Azure AI Inference | azure-ai | AZURE_AI_API_KEY |
| OpenRouter | openrouter | OPENROUTER_API_KEY |
§Features
- Async streaming with backpressure
- Tool/function calling support
- Multimodal input (text, images, audio, video, PDF)
- Generation configuration (temperature, top_p, etc.)
- OpenAI-compatible APIs (Ollama, vLLM, etc.)
§OpenRouter Scope Boundary
OpenRouterClient exposes the provider’s native surfaces:
- chat completions
- responses
- model discovery and credits
- provider routing and fallback
- OpenRouter plugins and built-in tools
- exact provider metadata and annotations
The generic Llm adapter exists for agent compatibility and covers text generation,
streaming, reasoning parts, tool/function calling, and OpenRouter request options through
openrouter::OpenRouterRequestOptions.
Use the native OpenRouter APIs whenever you need exact request or response parity, discovery,
or provider-specific features that do not fit the generic LlmRequest / LlmResponse
shape without information loss.
For end-to-end agentic validation, see the local examples/openrouter crate and the
adk-model/examples/openrouter_* binaries.
Re-exports§
pub use gemini::GeminiModel;pub use mock::MockLlm;pub use provider::ModelProvider;pub use retry::RetryConfig;pub use retry::ServerRetryHint;
Modules§
- catalog
- Curated provider model catalog, lifecycle metadata, and recommended defaults. Curated model identifiers, lifecycle metadata, and provider defaults.
- gemini
- Gemini model provider (Google AI Studio and Vertex AI).
- mock
- Mock LLM for testing without real API calls.
- part_
conversion - Conversion outcomes for content parts sent to a provider. What happened to each content part on the way to a provider.
- provider
- Canonical provider identifiers and metadata.
- retry
- Retry logic with exponential backoff for transient provider errors.
- tool_
call_ parser - Text-based tool call parser for models that emit tool calls as text tags.
- usage_
tracking - Stream wrapper that records token usage on the active tracing span.