CHAD exposes a comprehensive API to the Open WebUI frontend for interacting with the AI cluster and tool framework.
User Request
↓
Open WebUI (Frontend)
↓
IPC Bridge (window.chad)
↓
Orchestrator
↓
┌─────────────┬──────────────┐
│ AI Cluster │ Tool Registry│
├─────────────┼──────────────┤
│ • Planner │ • Filesystem│
│ • Coder │ • Terminal │
│ • Architect │ • Web │
│ • Vision │ • ...more │
└─────────────┴──────────────┘
Send a request to the CHAD orchestrator. The planner will analyze the request, execute tools, and delegate to appropriate AIs.
const response = await window.chad.chat("Create a new React component for user profiles");
console.log(response);
// { success: true, response: "..." }Get all available AI models in the cluster.
const models = await window.chad.model.list();
// [
// { name: "planner", role: "Reasoning, planning, and tool orchestration", ... },
// { name: "coder", role: "Fast implementation", ... },
// ...
// ]Directly chat with a specific model, bypassing the orchestrator.
const response = await window.chad.model.chat("coder", [
{ role: "user", content: "Write a function to sort an array" }
]);Get all available tools.
const tools = await window.chad.tools.list();
// [
// { name: "fs_read", description: "Read a file", ... },
// { name: "terminal_powershell", description: "Execute PowerShell", ... },
// ...
// ]Get the tool schema with parameter definitions.
const schema = await window.chad.tools.schema();
// {
// "fs_read": {
// description: "Read the contents of a file",
// parameters: { ... },
// requiresApproval: false
// },
// ...
// }Execute a tool directly. If the tool requires approval, an approval request will be emitted.
const result = await window.chad.tools.execute("fs_read", {
path: "C:\\Users\\example\\file.txt"
});Listen for tool approval requests.
window.chad.tools.onApprovalRequest((data) => {
console.log(`Approval required for: ${data.tool}`);
console.log("Params:", data.params);
// Show UI to user...
const approved = confirm(`Allow ${data.tool}?`);
window.chad.tools.approve({
taskId: data.taskId,
toolName: data.tool,
params: data.params,
approved
});
});Get all active tasks.
const tasks = await window.chad.tasks.list();
// [
// {
// id: "task_1234",
// userRequest: "...",
// status: "executing",
// activeModel: "coder",
// ...
// }
// ]Get a specific task by ID.
const task = await window.chad.tasks.get("task_1234");Check system health and get available models/tools.
const health = await window.chad.health();
// {
// status: "healthy",
// models: ["planner", "coder", "architect", "vision"],
// tools: ["fs_read", "fs_write", "terminal_powershell", ...]
// }- Role: Central coordinator
- Responsibilities: Planning, tool selection, task delegation
- Does NOT: Write code directly
- Role: Fast implementation
- Responsibilities: Day-to-day coding tasks
- Best for: React, TypeScript, Node, utilities
- Role: Deep reasoning
- Responsibilities: Large refactors, architecture decisions
- Use when: Complex changes, multi-file reasoning
- Role: Visual understanding
- Responsibilities: Screenshot analysis, UI reconstruction
- Use when: Working with images or UI mockups
All tools are:
- Explicit: AIs request tools, don't execute them directly
- Permission-based: Destructive tools require user approval
- Auditable: All tool calls are logged
- Extensible: New tools can be added without changing AI roles
-
Filesystem (
fs_*)- Read, write, list, search, patch files
- Write operations require approval
-
Terminal (
terminal_*)- PowerShell and WSL execution
- All commands require approval
-
Web (
web_*)- Search (Exa API)
- Fetch URLs
See /src/tools/README.md for tool development guide.
// 1. User makes a request
const response = await window.chad.chat(
"Refactor the authentication system to use JWT instead of sessions"
);
// Behind the scenes:
// - Planner analyzes the request
// - Planner requests fs_search to find auth-related files
// - Planner delegates to @architect for architectural analysis
// - Architect analyzes files and proposes changes
// - Planner delegates to @coder for implementation
// - Coder uses fs_patch to modify files
// - User approves each file modification
// - Response returned to user
console.log(response);
// {
// success: true,
// response: "Authentication system successfully refactored to use JWT..."
// }CHAD's API is available in the Open WebUI context. You can:
- Add custom chat handlers that route to CHAD
- Create UI components for tool approval
- Display task progress in the UI
- Show model selection/status
See /docs/OPEN_WEBUI_INTEGRATION.md for integration examples.