Model Providers (Cloud)
ADK-Rust supports multiple cloud LLM providers through the adk-model crate. All providers implement the Llm trait, making them interchangeable in your agents.
Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cloud Model Providers โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โข Gemini (Google) โญ Default - Multimodal, large context โ
โ โข OpenAI (GPT-4o) ๐ฅ Popular - Best ecosystem โ
โ โข Anthropic (Claude) ๐ง Smart - Best reasoning โ
โ โข DeepSeek ๐ญ Thinking - Chain-of-thought, cheap โ
โ โข Groq โก Ultra-Fast - Fastest inference โ
โ โ
โ For local/offline models, see: โ
โ โข Ollama โ ollama.md โ
โ โข mistral.rs โ mistralrs.md โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Quick Comparison
| Provider | Best For | Speed | Cost | Key Feature |
|---|---|---|---|---|
| Gemini | General use | โกโกโก | ๐ฐ | Multimodal, large context |
| OpenAI | Reliability | โกโก | ๐ฐ๐ฐ | Best ecosystem |
| Anthropic | Complex reasoning | โกโก | ๐ฐ๐ฐ | Safest, most thoughtful |
| DeepSeek | Chain-of-thought | โกโก | ๐ฐ | Thinking mode, cheap |
| Groq | Speed-critical | โกโกโกโก | ๐ฐ | Fastest inference |
Step 1: Installation
Add the providers you need to your Cargo.toml:
[dependencies]
# Pick one or more providers:
adk-model = { version = "0.2", features = ["gemini"] } # Google Gemini (default)
adk-model = { version = "0.2", features = ["openai"] } # OpenAI GPT-4o
adk-model = { version = "0.2", features = ["anthropic"] } # Anthropic Claude
adk-model = { version = "0.2", features = ["deepseek"] } # DeepSeek
adk-model = { version = "0.2", features = ["groq"] } # Groq (ultra-fast)
# Or all cloud providers at once:
adk-model = { version = "0.2", features = ["all-providers"] }
Step 2: Set Your API Key
export GOOGLE_API_KEY="your-key" # Gemini
export OPENAI_API_KEY="your-key" # OpenAI
export ANTHROPIC_API_KEY="your-key" # Anthropic
export DEEPSEEK_API_KEY="your-key" # DeepSeek
export GROQ_API_KEY="your-key" # Groq
Gemini (Google) โญ Default
Best for: General purpose, multimodal tasks, large documents
Key highlights:
- ๐ผ๏ธ Native multimodal (images, video, audio, PDF)
- ๐ Up to 2M token context window
- ๐ฐ Competitive pricing
- โก Fast inference
Complete Working Example
use adk_rust::prelude::*;
use adk_rust::Launcher;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("GOOGLE_API_KEY")?;
let model = GeminiModel::new(&api_key, "gemini-2.0-flash")?;
let agent = LlmAgentBuilder::new("gemini_assistant")
.description("Gemini-powered assistant")
.instruction("You are a helpful assistant powered by Google Gemini. Be concise.")
.model(Arc::new(model))
.build()?;
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
Available Models
| Model | Description | Context |
|---|---|---|
gemini-2.0-flash | Fast, efficient (recommended) | 1M tokens |
gemini-2.5-flash | Latest flash model | 1M tokens |
gemini-2.5-pro | Most capable | 2M tokens |
Example Output
๐ค User: What's in this image? [uploads photo of a cat]
๐ค Gemini: I can see a fluffy orange tabby cat sitting on a windowsill.
The cat appears to be looking outside, with sunlight illuminating its fur.
It has green eyes and distinctive striped markings typical of tabby cats.
OpenAI (GPT-4o) ๐ฅ Popular
Best for: Production apps, reliable performance, broad capabilities
Key highlights:
- ๐ Industry standard
- ๐ง Excellent tool/function calling
- ๐ Best documentation & ecosystem
- ๐ฏ Consistent, predictable outputs
Complete Working Example
use adk_rust::prelude::*;
use adk_rust::Launcher;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("OPENAI_API_KEY")?;
let model = OpenAIClient::new(OpenAIConfig::new(&api_key, "gpt-4o"))?;
let agent = LlmAgentBuilder::new("openai_assistant")
.description("OpenAI-powered assistant")
.instruction("You are a helpful assistant powered by OpenAI GPT-4o. Be concise.")
.model(Arc::new(model))
.build()?;
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
Available Models
| Model | Description | Context |
|---|---|---|
gpt-4o | Most capable, multimodal | 128K tokens |
gpt-4o-mini | Fast, cost-effective | 128K tokens |
gpt-4-turbo | Previous flagship | 128K tokens |
o1 | Reasoning model | 128K tokens |
Example Output
๐ค User: Write a haiku about Rust programming
๐ค GPT-4o: Memory so safe,
Ownership guards every byteโ
Compiler, my friend.
Anthropic (Claude) ๐ง Smart
Best for: Complex reasoning, safety-critical apps, long documents
Key highlights:
- ๐ง Exceptional reasoning ability
- ๐ก๏ธ Most safety-focused
- ๐ 200K token context
- โ๏ธ Excellent writing quality
Complete Working Example
use adk_rust::prelude::*;
use adk_rust::Launcher;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("ANTHROPIC_API_KEY")?;
let model = AnthropicClient::new(AnthropicConfig::new(&api_key, "claude-sonnet-4-20250514"))?;
let agent = LlmAgentBuilder::new("anthropic_assistant")
.description("Anthropic-powered assistant")
.instruction("You are a helpful assistant powered by Anthropic Claude. Be concise and thoughtful.")
.model(Arc::new(model))
.build()?;
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
Available Models
| Model | Description | Context |
|---|---|---|
claude-sonnet-4-20250514 | Latest Claude 4 Sonnet | 200K tokens |
claude-opus-4-20250514 | Most capable Claude 4 | 200K tokens |
claude-3-5-sonnet-20241022 | Claude 3.5 Sonnet | 200K tokens |
Example Output
๐ค User: Explain quantum entanglement to a 10-year-old
๐ค Claude: Imagine you have two magic coins. When you flip them, they always
land the same way - both heads or both tails - even if one coin is on Earth
and the other is on the Moon! Scientists call this "entanglement." The coins
are connected in a special way that we can't see, like invisible best friends
who always make the same choice at the exact same time.
DeepSeek ๐ญ Thinking
Best for: Complex problem-solving, math, coding, reasoning tasks
Key highlights:
- ๐ญ Thinking mode - shows chain-of-thought reasoning
- ๐ฐ Very cost-effective (10x cheaper than GPT-4)
- ๐ Context caching for repeated prefixes
- ๐งฎ Strong at math and coding
Complete Working Example
use adk_rust::prelude::*;
use adk_rust::Launcher;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("DEEPSEEK_API_KEY")?;
// Standard chat model
let model = DeepSeekClient::chat(&api_key)?;
// OR: Reasoning model with thinking mode
// let model = DeepSeekClient::reasoner(&api_key)?;
let agent = LlmAgentBuilder::new("deepseek_assistant")
.description("DeepSeek-powered assistant")
.instruction("You are a helpful assistant powered by DeepSeek. Be concise.")
.model(Arc::new(model))
.build()?;
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
Available Models
| Model | Description | Special Feature |
|---|---|---|
deepseek-chat | Fast chat model | General purpose |
deepseek-reasoner | Reasoning model | Shows thinking process |
Example Output (Reasoner with Thinking Mode)
๐ค User: What's 17 ร 23?
๐ค DeepSeek: <thinking>
Let me break this down:
17 ร 23 = 17 ร (20 + 3)
= 17 ร 20 + 17 ร 3
= 340 + 51
= 391
</thinking>
The answer is 391.
Groq โก Ultra-Fast
Best for: Real-time applications, chatbots, speed-critical tasks
Key highlights:
- โก Fastest inference - 10x faster than competitors
- ๐ง LPU (Language Processing Unit) technology
- ๐ฐ Competitive pricing
- ๐ฆ Runs LLaMA, Mixtral, Gemma models
Complete Working Example
use adk_rust::prelude::*;
use adk_rust::Launcher;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("GROQ_API_KEY")?;
let model = GroqClient::llama70b(&api_key)?;
let agent = LlmAgentBuilder::new("groq_assistant")
.description("Groq-powered assistant")
.instruction("You are a helpful assistant powered by Groq. Be concise and fast.")
.model(Arc::new(model))
.build()?;
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
Available Models
| Model | Method | Description |
|---|---|---|
llama-3.3-70b-versatile | GroqClient::llama70b() | Most capable |
llama-3.1-8b-instant | GroqClient::llama8b() | Fastest |
mixtral-8x7b-32768 | Custom config | Good balance |
Example Output
๐ค User: Quick! Name 5 programming languages
๐ค Groq (in 0.2 seconds):
1. Rust
2. Python
3. JavaScript
4. Go
5. TypeScript
Switching Providers
All providers implement the same Llm trait, so switching is easy:
use adk_agent::LlmAgentBuilder;
use std::sync::Arc;
// Just change the model - everything else stays the same!
let model: Arc<dyn adk_core::Llm> = Arc::new(
// Pick one:
// GeminiModel::new(&api_key, "gemini-2.0-flash")?
// OpenAIClient::new(OpenAIConfig::new(&api_key, "gpt-4o"))?
// AnthropicClient::new(AnthropicConfig::new(&api_key, "claude-sonnet-4-20250514"))?
// DeepSeekClient::chat(&api_key)?
// GroqClient::llama70b(&api_key)?
);
let agent = LlmAgentBuilder::new("assistant")
.instruction("You are a helpful assistant.")
.model(model)
.build()?;
Examples
# Gemini (default)
cargo run --example quickstart
# OpenAI
cargo run --example openai_basic --features openai
# Anthropic
cargo run --example anthropic_basic --features anthropic
# DeepSeek
cargo run --example deepseek_basic --features deepseek
cargo run --example deepseek_reasoner --features deepseek # Thinking mode
# Groq
cargo run --example groq_basic --features groq
Related
- Ollama (Local) - Run models locally with Ollama
- Local Models (mistral.rs) - Native Rust inference
- LlmAgent - Using models with agents
- Function Tools - Adding tools to agents
Previous: โ Realtime Agents | Next: Ollama (Local) โ