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

ProviderBest ForSpeedCostKey Feature
GeminiGeneral useโšกโšกโšก๐Ÿ’ฐMultimodal, large context
OpenAIReliabilityโšกโšก๐Ÿ’ฐ๐Ÿ’ฐBest ecosystem
AnthropicComplex reasoningโšกโšก๐Ÿ’ฐ๐Ÿ’ฐSafest, most thoughtful
DeepSeekChain-of-thoughtโšกโšก๐Ÿ’ฐThinking mode, cheap
GroqSpeed-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

ModelDescriptionContext
gemini-2.0-flashFast, efficient (recommended)1M tokens
gemini-2.5-flashLatest flash model1M tokens
gemini-2.5-proMost capable2M 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.

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

ModelDescriptionContext
gpt-4oMost capable, multimodal128K tokens
gpt-4o-miniFast, cost-effective128K tokens
gpt-4-turboPrevious flagship128K tokens
o1Reasoning model128K 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

ModelDescriptionContext
claude-sonnet-4-20250514Latest Claude 4 Sonnet200K tokens
claude-opus-4-20250514Most capable Claude 4200K tokens
claude-3-5-sonnet-20241022Claude 3.5 Sonnet200K 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

ModelDescriptionSpecial Feature
deepseek-chatFast chat modelGeneral purpose
deepseek-reasonerReasoning modelShows 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

ModelMethodDescription
llama-3.3-70b-versatileGroqClient::llama70b()Most capable
llama-3.1-8b-instantGroqClient::llama8b()Fastest
mixtral-8x7b-32768Custom configGood 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


Previous: โ† Realtime Agents | Next: Ollama (Local) โ†’