---
title: "Connecting Third-Party Models to ADK with LiteLLM: Claude, OpenAI, Mistral"
date: "2026-11-25T08:36:00+07:00"
description: "How ADK's LiteLLM connector exposes Claude, GPT, Mistral, and 100+ providers to agents — setup, model naming, configuration gotchas, and cross-provider routing patterns."
author: "AI Assistant"
image: "https://blog.redlinesoft.net/images/post/adk-litellm-third-party-models-claude-openai-mistral.jpg"
alt: "Gateway diagram connecting ADK to Claude, OpenAI, and Mistral through LiteLLM"
tags: ['google-adk', 'litellm', 'claude', 'openai', 'multi-model', 'python']
---

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](/blog/adk-dynamic-model-routing-task-complexity) 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

```bash
uv add "google-adk[litellm]" litellm>=1.84
```

Then per-provider credentials in the environment:

```bash
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:

```python
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-4` alone is ambiguous to LiteLLM; `anthropic/claude-sonnet-4` is 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

1. **Config validation is stricter than it looks.** Setting `http_options.base_url` inside `generate_content_config` raises `ValueError` on `LlmAgent` — provider endpoint configuration belongs to the model object, not the sampling config.
2. **Extra body passthrough.** Provider-specific parameters (OpenAI's `reasoning` fields, response formats) travel via `extra_body` on the `LiteLlm` call rather than through ADK's generic config.
3. **Streaming semantics.** LiteLLM normalizes provider streaming into ADK events, but chunk cadence differs; UI code that assumes Gemini's chunk sizes may need smoothing.
4. **Structured output fidelity.** Gemini enforces schemas at the API level; for other providers the same `output_schema` may rely on prompt-level enforcement plus parsing — keep the [defensive parsing and evals](/blog/adk-pydantic-response-schema-structured-outputs).
5. **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](/blog/adk-dynamic-model-routing-task-complexity).

```python
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](/blog/adk-agent-exceptions-graceful-fallback) 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.84` and 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](/blog/adk-ollama-local-models-litellm-integration); for self-hosted high-throughput inference, [vLLM endpoints](/blog/adk-vllm-endpoints-low-latency-self-hosted-inference). The routing policy itself is covered in [dynamic model routing](/blog/adk-dynamic-model-routing-task-complexity).

## References

- [LiteLLM connector for ADK agents](https://adk.dev/agents/models/litellm/)
- [Model routing](https://adk.dev/agents/models/routing/)
- [LiteLLM documentation](https://docs.litellm.ai/)
- [google/adk-python](https://github.com/google/adk-python)
