Council Quick Start

New
Updated

Build a multi-model consensus system in under 5 minutes. The Council namespace lets multiple AI models debate a question and reach a consensus decision — with full auditability of each model's reasoning.

In this guide you'll:

  1. Create AI members backed by different LLMs
  2. Form a council
  3. Resolve a query
  4. Audit the decision process
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

Step 1: Create Members

Each member is an AI persona backed by a specific model. Give them distinct perspectives via system prompts.

create-members.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
// See available models
const { models } = await chaos.council.members.models();
console.log('Available:', models.map(m => `${m.provider}/${m.model_id}`).join(', '));
 
// Create members with different perspectives
const { created } = await chaos.council.members.bulkCreate({
  members: [
    {
      name: 'Risk Analyst',
      provider: 'anthropic',
      model_id: 'claude-sonnet-4-20250514',
      system_prompt: 'You are a conservative risk analyst. Prioritize safety and downside protection.',
    },
    {
      name: 'Growth Strategist',
      provider: 'openai',
      model_id: 'gpt-4o',
      system_prompt: 'You are a growth-oriented strategist. Focus on opportunity and upside potential.',
    },
    {
      name: 'Quant Researcher',
      provider: 'anthropic',
      model_id: 'claude-sonnet-4-20250514',
      system_prompt: 'You are a quantitative researcher. Base decisions on data and statistical evidence.',
    },
  ],
});
 
console.log(`Created ${created.length} members`);
const memberIds = created.map(m => m.id);

Step 2: Form a Council

Group your members into a council with a consensus algorithm.

form-council.ts
const council = await chaos.council.councils.create({
  name: 'DeFi Advisory Board',
  member_ids: memberIds,
  consensus_algorithm: 'majority_vote',
});
 
console.log(`Council: ${council.name} (${council.id})`);
console.log(`Members: ${council.members.length}`);
console.log(`Algorithm: ${council.consensus_algorithm}`);

Step 3: Resolve a Query

Submit a question for the council to deliberate on.

resolve-query.ts
const resolution = await chaos.council.resolve({
  query: 'Should we increase the WETH collateral factor on Aave v3 from 80% to 85%?',
  council_id: council.id,
  answer_options: ['Yes, increase to 85%', 'No, keep at 80%', 'Increase to 82.5% as compromise'],
});
 
console.log(`Resolution ID: ${resolution.session_id}`);
console.log(`Status: ${resolution.status}`);

Step 4: Audit the Decision

See how each member voted, their reasoning, and any dissenting opinions.

audit-decision.ts
// Wait for resolution to complete
await new Promise(r => setTimeout(r, 10_000));
 
const detail = await chaos.council.resolutions.get(resolution.session_id);
console.log(`\nFinal Result: ${detail.finalResult}`);
 
const audit = await chaos.council.resolutions.audit(resolution.session_id);
 
console.log('\nMember Votes:');
for (const vote of audit.memberVotes) {
  const status = vote.status === 'completed' ? '✓' : '✗';
  console.log(`  ${status} ${vote.model_name}: ${vote.choice}`);
  console.log(`    Confidence: ${vote.confidence}`);
  console.log(`    Reasoning: ${vote.reasoning?.slice(0, 100)}...`);
  console.log(`    Time: ${vote.elapsed_ms}ms`);
}
 
console.log(`\nVote Tally:`);
for (const [choice, count] of Object.entries(audit.voteTally.choices)) {
  console.log(`  ${choice}: ${count} votes`);
}
 
if (audit.dissentSummary.length > 0) {
  console.log('\nDissenting Opinions:');
  for (const d of audit.dissentSummary) {
    console.log(`  ${d.member_id}: ${d.reasoning}`);
  }
}
Was this helpful?