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

# LLMCouncil Guide

> Have several agents answer a question, rank each other's anonymized answers, and let a chairman write the final answer

`LLMCouncil` runs a question through three stages. First, every council member answers it on its own, in parallel. Next, every member reads all the answers, relabelled `Response A`, `Response B` and so on in a shuffled order, and ranks them without knowing who wrote which. Last, a Chairman agent reads the answers, the rankings and who wrote what, and writes one final answer.

It is based on Andrej Karpathy's llm-council. Use it when you want several models or personas to check each other's work before you get an answer.

Reference: [LLMCouncil](https://docs.swarms.world/api/llm-council.md).

## 1. Run a council with your own members

Pass any agents as `council_members`. The council builds the Chairman itself, on `chairman_model`, which defaults to `gpt-5.1`. With `output_type="final"`, `run` returns only the Chairman's answer.

```python theme={null}
from swarms import Agent, LLMCouncil

members = [
    Agent(
        agent_name="Security-Expert",
        agent_description="Security and privacy specialist",
        system_prompt="You are a security expert. Answer in one short paragraph.",
        model_name="gpt-5.4-mini",
        max_loops=1,
    ),
    Agent(
        agent_name="Cost-Expert",
        agent_description="Cloud cost specialist",
        system_prompt="You are a cloud cost expert. Answer in one short paragraph.",
        model_name="gpt-5.4-mini",
        max_loops=1,
    ),
    Agent(
        agent_name="DX-Expert",
        agent_description="Developer experience specialist",
        system_prompt="You care about developer experience. Answer in one short paragraph.",
        model_name="gpt-5.4-mini",
        max_loops=1,
    ),
]

council = LLMCouncil(
    council_members=members,
    chairman_model="gpt-5.4-mini",
    output_type="final",
)

answer = council.run(
    "Should a small team run its own Kubernetes cluster or use a managed "
    "platform such as Cloud Run?"
)
print(answer)
```

A run makes `2 * len(council_members) + 1` model calls: each member answers once and ranks once, then the Chairman writes once. Every `run` resets the members and the Chairman to a fresh conversation, so one council can take many questions.

With the default `verbose=True`, the council logs one line per stage. Pass `verbose=False` to turn those off.

## 2. Read the whole session

The default `output_type` is `"dict-all-except-first"`: every message after the question, as a list of `{"role", "content"}` dicts.

| Role | Content |
| - | - |
| Each member's `agent_name` | Its answer |
| `<agent_name>-Evaluation` | Its ranking of the anonymized answers, with reasons |
| `Chairman` | The final answer |

This continues from the block above and reuses `members`:

```python theme={null}
council = LLMCouncil(
    council_members=members,
    chairman_model="gpt-5.4-mini",
    verbose=False,
)

messages = council.run("Is a monorepo a good idea for a team of five?")

for message in messages:
    print(f"--- {message['role']}")
    print(message["content"][:200])
```

Each evaluation starts with a `RANKINGS:` list such as `1. Response C: ...`. Members rank their own answer too, without knowing which one it is. The labels are shuffled on every run, and only the Chairman gets the mapping from labels to members.

Other `output_type` values:

* `"final"` returns the Chairman's answer as a string.
* `"dict"` or `"list"` include the question as the first `User` message.
* `"str"`, `"json"` and `"yaml"` return the whole session as one string.

## 3. Use the preset councilors

Without `council_members`, the council builds four preset members, each with its own persona prompt:

| Agent name | Default model | Persona |
| - | - | - |
| `GPT-Councilor` | `gpt-6-luna` | Analytical and thorough |
| `Gemini-Councilor` | `gemini/gemini-3.5-flash-lite` | Concise and structured |
| `Claude-Councilor` | `anthropic/claude-haiku-5-5` | Thoughtful and balanced |
| `Grok-Councilor` | `xai/grok-4.3` | Creative and innovative |

The defaults call four providers, so you need an OpenAI, Gemini, Anthropic and xAI key. `council_models` replaces the four models, in that order, and keeps the personas. It must hold exactly four names, or the constructor raises `ValueError`. Here every seat runs on one provider:

```python theme={null}
from swarms import LLMCouncil
from swarms.structs.llm_council import DEFAULT_COUNCIL_MODELS

print(DEFAULT_COUNCIL_MODELS)

# Keep the four preset councilors, but run every seat on one provider
council = LLMCouncil(
    council_models=["gpt-5.4-mini"] * 4,
    chairman_model="gpt-5.4-mini",
    output_type="final",
    verbose=False,
)
print([member.agent_name for member in council.council_members])
print(council.run("Name one underrated habit of senior engineers."))

try:
    LLMCouncil(council_models=["gpt-5.4-mini"])
except ValueError as error:
    print(error)
```

To give your own agents the same personas, use the prompt functions in `swarms.prompts.llm_council_prompts`, such as `get_gpt_councilor_prompt()`, as their `system_prompt`.

## 4. Many questions and token usage

`batched_run(tasks)` runs the council once per task, one after another, and returns a list of results in task order. `usage` sums the token counts of every member and the Chairman across every run. This continues from the first block:

```python theme={null}
council = LLMCouncil(
    council_members=members,
    chairman_model="gpt-5.4-mini",
    output_type="final",
    verbose=False,
)

answers = council.batched_run(
    [
        "Tabs or spaces for a new Python project?",
        "Should code review require two approvals?",
    ]
)
for answer in answers:
    print(answer[:300], "\n")

print(council.usage)
```

## Errors

* `run` raises `ValueError` if the task is not a string, is empty or is only whitespace.
* If any member fails while answering or ranking, `run` raises that member's error, such as `AgentLLMError`, and the Chairman does not run. With the preset council, a missing or empty key for any one of the four providers stops the run this way.

## Tips

* **Diverse members rank better.** Members on different models or with different personas disagree more, which gives the rankings something to decide.
* **Keep member answers short.** Every member reads every answer in the ranking stage, so long answers multiply the input tokens.
* **Use a strong Chairman.** The Chairman writes the only answer most callers read. A small model for members and a stronger one for `chairman_model` is a good split.

## Next steps

* [LLMCouncil reference](https://docs.swarms.world/api/llm-council.md)
* [MajorityVoting guide](https://docs.swarms.world/examples/multi-agent/majority-voting-example.md), where a consensus agent picks between answers
* [CouncilAsAJudge guide](https://docs.swarms.world/examples/multi-agent/council-as-a-judge-example.md), to grade one answer on several dimensions
* [Runnable scripts](https://github.com/kyegomez/swarms/tree/master/examples/multi_agent/council/llm_council)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.