> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agents-squads.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-LLM Usage

> Mix different LLM providers and models for optimal results

## CLI Delegation

Agents Squads enables multi-LLM support by delegating to native provider CLIs. No SDK integrations needed—just shell out to `claude`, `gemini`, `codex`, `grok`, etc.

### Check Available Providers

```bash theme={null}
squads providers
```

```
Provider              CLI       Status
────────────────────────────────────────
Anthropic             claude    ● ready
DeepSeek (via aider)  aider     ● ready
Google                gemini    ● ready
OpenAI                codex     ● ready
Mistral               vibe      ● ready
xAI                   grok      ● ready
Ollama                ollama    ● ready
```

### Run with Specific Provider

```bash theme={null}
# Override provider for this run
squads run research/analyst --execute --provider=google

# Uses Gemini CLI instead of Claude
```

### Provider Resolution

The CLI resolves providers in this order:

1. **Agent frontmatter** - `provider:` field in the agent's .md file
2. **CLI flag** - `--provider=deepseek`
3. **Squad default** - `providers.default` in SQUAD.md
4. **Fallback** - `anthropic`

## File-Based Executors

Some providers run as *file-based executors*. DeepSeek (added in v0.8.0) delegates to `aider`: the executor reads and edits files and the result is committed, but it runs no shell commands and has no web access. File-based executors fit validators, formatters, and summarizers — agents whose job is read files → write files.

Executor output is harvested from an isolated git worktree, so completed work is never lost even if the run ends abnormally. Every provider run is recorded in observability (`squads exec list`) with real token and cost figures parsed from the executor's output.

***

## Configuration

### Squad-Level Providers

Configure default providers in SQUAD.md frontmatter:

```yaml theme={null}
---
name: intelligence
mission: Market research and competitive analysis

providers:
  default: anthropic      # CLI: claude
  vision: openai          # CLI: codex (for image analysis)
  realtime: xai           # CLI: grok (for real-time data)
  cheap: google           # CLI: gemini (for high-volume)
---
```

### Agent-Level Override

Override the provider for specific agents:

<Tabs>
  <Tab title="Frontmatter">
    ```markdown theme={null}
    ---
    provider: xai
    ---

    # Social Monitor

    ## Purpose
    Real-time X/Twitter trend detection using Grok.
    ```
  </Tab>

  <Tab title="Header">
    ```markdown theme={null}
    # Social Monitor

    ## Provider
    xai

    ## Purpose
    Real-time X/Twitter trend detection.
    ```
  </Tab>
</Tabs>

***

## Supported CLIs

| Provider  | CLI      | Install                                                 | Non-Interactive Flag      |
| --------- | -------- | ------------------------------------------------------- | ------------------------- |
| Anthropic | `claude` | `npm i -g @anthropic-ai/claude-code`                    | `--print`                 |
| Google    | `gemini` | `npm i -g @google/gemini-cli`                           | `--prompt`                |
| OpenAI    | `codex`  | `npm i -g @openai/codex`                                | `exec` subcommand         |
| Mistral   | `vibe`   | `curl -LsSf https://mistral.ai/vibe/install.sh \| bash` | `--prompt --auto-approve` |
| xAI       | `grok`   | `bun add -g @vibe-kit/grok-cli`                         | `--prompt`                |
| Multi     | `aider`  | `pip install aider-install && aider-install`            | `--message --yes`         |
| Local     | `ollama` | `brew install ollama`                                   | `run <model> "<prompt>"`  |

### Environment Variables

Each CLI reads its own API keys:

```bash theme={null}
# .env (or shell profile)
ANTHROPIC_API_KEY=sk-ant-...   # claude
GOOGLE_API_KEY=AIza...          # gemini (or OAuth)
OPENAI_API_KEY=sk-...           # codex
MISTRAL_API_KEY=...             # vibe
XAI_API_KEY=...                 # grok
```

***

## Why Use Multiple LLMs?

Different LLMs excel at different tasks. A well-designed agent system can leverage:

* **Claude** - Complex reasoning, nuanced analysis, long context
* **GPT-4** - General purpose, wide knowledge, tool use
* **Gemini** - Multimodal, Google ecosystem integration
* **Grok** - Real-time data, X/Twitter integration
* **Llama/Open models** - Privacy, self-hosting, cost control

## Provider Comparison

| Provider           | Strengths                       | Best For                         |
| ------------------ | ------------------------------- | -------------------------------- |
| Claude (Anthropic) | Reasoning, safety, long context | Complex analysis, code review    |
| GPT-4 (OpenAI)     | Versatility, ecosystem          | General tasks, plugins           |
| Gemini (Google)    | Multimodal, speed               | Vision tasks, Google integration |
| Grok (xAI)         | Real-time, humor                | Social media, current events     |
| Llama (Meta)       | Open source, self-host          | Privacy-sensitive, offline       |
| Mistral            | European, efficient             | EU compliance, edge deployment   |

## Model Tiers (Within Providers)

Each provider offers different capability tiers:

<Tabs>
  <Tab title="Anthropic (Claude)">
    | Model         | Use Case           | Cost   |
    | ------------- | ------------------ | ------ |
    | Claude Opus   | Complex reasoning  | \$\$\$ |
    | Claude Sonnet | Balanced default   | \$\$   |
    | Claude Haiku  | Fast, simple tasks | \$     |
  </Tab>

  <Tab title="OpenAI">
    | Model       | Use Case             | Cost     |
    | ----------- | -------------------- | -------- |
    | GPT-4o      | Multimodal, flagship | \$\$\$   |
    | GPT-4o-mini | Fast, efficient      | \$       |
    | o1/o3       | Deep reasoning       | \$\$\$\$ |
  </Tab>

  <Tab title="Google">
    | Model        | Use Case        | Cost   |
    | ------------ | --------------- | ------ |
    | Gemini Ultra | Most capable    | \$\$\$ |
    | Gemini Pro   | Balanced        | \$\$   |
    | Gemini Flash | Speed optimized | \$     |
  </Tab>

  <Tab title="xAI">
    | Model       | Use Case         | Cost   |
    | ----------- | ---------------- | ------ |
    | Grok-2      | Full capability  | \$\$\$ |
    | Grok-2-mini | Faster responses | \$\$   |
  </Tab>
</Tabs>

## Squad Configuration

### Agent-Level Provider Selection

Assign different providers to different agents:

```markdown theme={null}
# SQUAD.md - Intelligence Squad

## Agents

### market-researcher
**Provider**: Claude Sonnet
**Purpose**: Deep market analysis requiring nuanced reasoning

### social-monitor
**Provider**: Grok
**Purpose**: Real-time X/Twitter monitoring and trend detection

### data-analyst
**Provider**: GPT-4o
**Purpose**: Spreadsheet analysis with vision capabilities

### summarizer
**Provider**: Gemini Flash
**Purpose**: Fast summarization of research findings
```

### Environment Configuration

Set up API keys for each provider:

```bash theme={null}
# .env
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=AIza...
XAI_API_KEY=xai-...
```

### Provider Selection Per Agent

No SDK code to write — set `provider:`/`model:` in the agent's frontmatter and
`squads run` shells out to that CLI instead:

<Tabs>
  <Tab title="Claude">
    ```markdown theme={null}
    ---
    provider: anthropic
    model: claude-sonnet-4-20250514
    ---

    # Agent: Market Researcher

    ## Instructions
    Analyze market trends using deep reasoning...
    ```
  </Tab>

  <Tab title="OpenAI">
    ```markdown theme={null}
    ---
    provider: openai
    model: gpt-4o
    ---

    # Agent: Chart Generator
    ```
  </Tab>

  <Tab title="Gemini">
    ```markdown theme={null}
    ---
    provider: google
    model: gemini-1.5-flash
    ---

    # Agent: Fast Summarizer
    ```
  </Tab>

  <Tab title="Grok">
    ```markdown theme={null}
    ---
    provider: xai
    model: grok-2
    ---

    # Agent: Trend Scanner
    ```
  </Tab>
</Tabs>

## Routing Patterns

### Task-Based Routing

Route tasks to the best provider:

| Task Requirement   | Best Provider          |
| ------------------ | ---------------------- |
| Real-time data     | Grok                   |
| Image analysis     | GPT-4o / Gemini        |
| Deep reasoning     | Claude Opus            |
| Google integration | Gemini                 |
| General tasks      | Claude Sonnet / GPT-4o |

### Cascade Pattern

Start cheap, escalate when needed:

<Steps>
  <Step title="Start cheap">
    Gemini Flash (fastest, cheapest)
  </Step>

  <Step title="If insufficient">
    Escalate to Claude Sonnet
  </Step>

  <Step title="If still insufficient">
    Escalate to Claude Opus
  </Step>
</Steps>

### Consensus Pattern

Use multiple providers for critical decisions:

<Frame>
  **Critical Decision** → Run in parallel across Claude, GPT-4o, and Gemini → **Voting/Synthesis** → Final Answer
</Frame>

## Cost Optimization

### Price Comparison (approximate per 1M tokens)

| Provider      | Input   | Output  |
| ------------- | ------- | ------- |
| Claude Haiku  | \$0.25  | \$1.25  |
| GPT-4o-mini   | \$0.15  | \$0.60  |
| Gemini Flash  | \$0.075 | \$0.30  |
| Claude Sonnet | \$3.00  | \$15.00 |
| GPT-4o        | \$2.50  | \$10.00 |
| Gemini Pro    | \$1.25  | \$5.00  |
| Claude Opus   | \$15.00 | \$75.00 |

<Note>
  Prices change frequently. Check provider pricing pages for current rates.
</Note>

### Cost Strategy

```markdown theme={null}
## Budget Allocation Example

- 60% → Gemini Flash / GPT-4o-mini (high-volume tasks)
- 30% → Claude Sonnet / GPT-4o (standard tasks)
- 10% → Claude Opus / o1 (complex reasoning)
```

## Implementation Examples

### Multi-Provider Squad

The squad-level `providers:` block sets the default; each agent's own
frontmatter overrides it for that agent specifically:

```markdown theme={null}
---
# .agents/squads/intelligence/SQUAD.md
name: intelligence
mission: Multi-provider research and analysis

providers:
  default: anthropic
---

## Agents

| Agent | Role | Provider | Model |
|-------|------|----------|-------|
| `trend-scanner` | Real-time social trend detection | grok | grok-2-mini |
| `deep-researcher` | In-depth analysis and synthesis | anthropic | claude-sonnet-4-20250514 |
| `data-visualizer` | Chart and image generation | openai | gpt-4o |
| `fast-summarizer` | Quick summaries and translations | google | gemini-1.5-flash |
```

Each agent's own `.md` file carries the `provider:`/`model:` frontmatter shown
in [Provider Selection Per Agent](#provider-selection-per-agent) above — the
table here is just the roster view.

### The CLI Is the Abstraction

There's no adapter layer to build — `squads` itself is the unified interface.
Set `providers.default` (and per-purpose overrides) once in `SQUAD.md`, as
shown in [Squad-Level Providers](#squad-level-providers) above, and every
agent in the squad resolves its provider through the same precedence chain
(frontmatter → `--provider` flag → squad default → `anthropic` fallback) with
no code on your side.

## Best Practices

<Check>
  * Match provider strengths to task requirements
  * Use cheaper models for high-volume, simple tasks
  * Reserve expensive models for complex reasoning
  * Monitor costs per provider (`squads exec list`, `squads usage`)
  * Set `providers.default` at the squad level so switching is a one-line edit
</Check>

<Warning>
  **Avoid:**

  * Using one provider for everything (miss optimizations)
  * Ignoring rate limits (each provider has different limits)
  * Routing file-based executors (DeepSeek/aider) to roles that need shell or web access — they have neither
  * Forgetting about latency differences
</Warning>

## Related

<CardGroup cols={2}>
  <Card title="Token Economics" icon="coins" href="/guides/token-economics">
    Optimize costs across providers
  </Card>

  <Card title="Agent Parallelization" icon="arrows-split-up-and-left" href="/guides/parallelization">
    Run multi-provider agents concurrently
  </Card>
</CardGroup>
