Connecting Third-Party Models to ADK with LiteLLM: Claude, OpenAI, Mistral
How ADK's LiteLLM connector exposes Claude, GPT, Mistral, and 100+ providers to agents — setup, model naming, configuration gotchas, and cross-provider routing patterns.
Published on • November 25, 2026
AI Assistant

Gemini is ADK’s home turf, but real systems rarely live on one provider. You have a Claude subscription you already pay for, an OpenAI model a customer mandates, a Mistral endpoint in the EU for data residency — and one agent codebase that shouldn’t care. ADK’s LiteLLM connector is the bridge: one wrapper class that speaks ADK’s model interface while LiteLLM translates to 100+ providers underneath.
The appeal isn’t just “use other models.” It’s one agent definition, many model backends — which turns provider choice into configuration, and provider outages into routing decisions instead of incidents.
How the connector fits together
LlmAgent(model="openai/gpt-4o")
│
▼
LiteLlm (google.adk.models.litellm)
│ litellm>=1.84 required
▼
LiteLLM gateway / provider APIs
│
OpenAI · Anthropic · Mistral · +100 more
ADK sees a standard model interface — stream, generate_content, the same events and callbacks as Gemini. LiteLLM owns the translation: request shapes, streaming formats, tool-calling conventions, error types.
Setup
uv add "google-adk[litellm]" litellm>=1.84
Then per-provider credentials in the environment:
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export MISTRAL_API_KEY=...
Pointing an agent at a non-Gemini model
The model string carries the provider prefix — LiteLLM’s naming convention:
from google.adk.agents import Agent
from google.adk.models.litellm import LiteLlm
agent = Agent(
model=LiteLlm(model="anthropic/claude-sonnet-4"),
name="contract_reviewer",
instruction=REVIEW_INSTRUCTION,
tools=[extract_clauses, check_policy],
)
# or OpenAI
gpt_agent = Agent(
model=LiteLlm(model="openai/gpt-4o"),
name="code_reviewer",
...
)
A few naming realities worth internalizing:
- Provider prefix is mandatory —
claude-sonnet-4alone is ambiguous to LiteLLM;anthropic/claude-sonnet-4is a contract. - Aliases vs. exact IDs. Alias names can drift as providers update models; pin the full model ID in production.
- Capabilities differ per provider. Tool calling, JSON modes, context sizes, and structured output enforcement vary — an agent that works on one provider may need prompt adjustments on another.
Configuration gotchas that bite
- Config validation is stricter than it looks. Setting
http_options.base_urlinsidegenerate_content_configraisesValueErroronLlmAgent— provider endpoint configuration belongs to the model object, not the sampling config. - Extra body passthrough. Provider-specific parameters (OpenAI’s
reasoningfields, response formats) travel viaextra_bodyon theLiteLlmcall rather than through ADK’s generic config. - Streaming semantics. LiteLLM normalizes provider streaming into ADK events, but chunk cadence differs; UI code that assumes Gemini’s chunk sizes may need smoothing.
- Structured output fidelity. Gemini enforces schemas at the API level; for other providers the same
output_schemamay rely on prompt-level enforcement plus parsing — keep the defensive parsing and evals. - Error mapping. Providers signal rate limits and refusals differently; LiteLLM maps most of them, but your fallback logic should catch the normalized classes, not provider-specific exception types.
Cross-provider routing patterns
Once LiteLLM makes the model string a variable, several patterns open up:
Capability routing. Some tasks need a provider’s specialty — long-document work on one model, code on another. Route by task class the same way tier routing works within Gemini.
def model_for(task_kind: str) -> LiteLlm:
return {
"long_doc": LiteLlm(model="anthropic/claude-sonnet-4"),
"code": LiteLlm(model="openai/gpt-4o"),
"eu_residency": LiteLlm(model="mistral/mistral-large-latest"),
}.get(task_kind, LiteLlm(model="gemini-flash-latest"))
Failover chains. Primary provider degraded → next provider → Gemini → honest failure. The graceful fallback ladder applies unchanged; LiteLLM just widens the chain beyond one vendor.
A/B evaluation. Same agent, same eval suite, two model strings — the cheapest way to answer “should we switch?”
Migration stepping stones. Swap providers behind the same agent while your prompts, tools, and evals stay fixed; only the model line changes, so the diff tells you exactly what the provider change did.
When not to use LiteLLM
- Pure Gemini deployments — use the native Gemini connector: fewer layers, first-class features (caching, thinking controls, safety config) without translation.
- When provider-specific features are core to the design — deep reasoning toggles, provider-native caching — verify LiteLLM exposes them before committing.
- When you need per-provider billing attribution — route through LiteLLM’s proxy for unified key management and cost tracking if that’s part of the requirement.
Operational checklist
- Pin
litellm>=1.84and the exact model IDs, not aliases - Normalize errors at the connector boundary; fallback on classes, not messages
- Run the same eval suite per provider before routing production traffic
- Verify structured-output fidelity per provider with real tests
- Log provider, model, tokens, and latency per invocation for cost attribution
- Keep one provider in reserve for failover — never build a chain of one
Where to go next
Cross-provider routing is one half of the model story; the other half is where the models run. If the goal is keeping data local, see running local models with Ollama; for self-hosted high-throughput inference, vLLM endpoints. The routing policy itself is covered in dynamic model routing.