Consensus Configuration
Updated
The chaos.council.consensus sub-namespace controls how council votes are aggregated into a final decision. Explore available algorithms and their tunable parameters, check the current configuration, and set a new one.
Method Reference
| Method | HTTP | Endpoint | Returns |
|---|---|---|---|
algorithms() | GET | /v1/council/consensus/algorithms | AvailableConsensusResponse |
get() | GET | /v1/council/consensus | ConsensusConfig |
set(params) | PUT | /v1/council/consensus | ConsensusConfig |
Explore Available Algorithms
List all consensus algorithms available to your account. Each algorithm includes a description and its tunable parameters.
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
const { algorithms, default_algorithm } = await chaos.council.consensus.algorithms();
console.log(`Default algorithm: ${default_algorithm}\n`);
for (const algo of algorithms) {
console.log(`${algo.algorithm} — ${algo.name}`);
console.log(` ${algo.description}`);
if (algo.parameters && algo.parameters.length > 0) {
console.log(' Parameters:');
for (const p of algo.parameters) {
const req = p.required ? 'required' : 'optional';
const def = p.default !== undefined ? ` (default: ${p.default})` : '';
console.log(` ${p.name} (${p.type}, ${req})${def}`);
if (p.description) console.log(` ${p.description}`);
}
} else {
console.log(' No configurable parameters');
}
console.log();
}Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
AvailableConsensusResponse
interface AvailableConsensusResponse {
algorithms: ConsensusAlgorithmInfo[];
default_algorithm: string;
}
interface ConsensusAlgorithmInfo {
algorithm: string;
name: string;
description: string;
parameters?: AlgorithmParameter[] | null;
}
interface AlgorithmParameter {
name: string;
type: string;
description?: string;
required?: boolean;
default?: unknown;
}Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
Get Current Configuration
Retrieve the default consensus configuration for your account.
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
const config = await chaos.council.consensus.get();
console.log(`Algorithm: ${config.algorithm}`);
if (config.parameters) {
for (const p of config.parameters) {
console.log(` ${p.name}: ${p.value}`);
}
}
if (config.modified_at) {
console.log(`Last modified: ${config.modified_at}`);
}Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
ConsensusConfig
interface ConsensusConfig {
algorithm: string;
parameters?: ConsensusParameter[] | null;
modified_at?: string | null;
}
interface ConsensusParameter {
name: string;
value: unknown;
}Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
Set Consensus Configuration
Update the default consensus algorithm and its parameters. The new configuration applies to all councils that do not specify their own algorithm.
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
// Set to weighted voting with a minimum confidence threshold
const updated = await chaos.council.consensus.set({
algorithm: 'weighted_vote',
parameters: [
{ name: 'min_confidence', value: 0.7 },
],
});
console.log(`Algorithm: ${updated.algorithm}`);
console.log(`Modified: ${updated.modified_at}`);
if (updated.parameters) {
for (const p of updated.parameters) {
console.log(` ${p.name}: ${p.value}`);
}
}
// Set to simple majority with no extra parameters
const simple = await chaos.council.consensus.set({
algorithm: 'majority_vote',
});Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
SetConsensusConfigParams
| Field | Type | Required | Description |
|---|---|---|---|
algorithm | string | Yes | Algorithm identifier from algorithms() |
parameters | Array<{ name: string; value: unknown }> | No | Algorithm-specific tuning parameters |
Was this helpful?