一键导入
duel-agents-routing
CLI, SDK, and IDE plugins for Duel Agents - an LLM routing layer that runs prompts against multiple models and picks the cheapest winning answer
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
CLI, SDK, and IDE plugins for Duel Agents - an LLM routing layer that runs prompts against multiple models and picks the cheapest winning answer
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Train and deploy Qwen-AgentWorld, a native language world model that simulates agentic environments across 7 domains (MCP, Search, Terminal, SWE, Android, Web, OS) for agent training and evaluation.
Build and orchestrate collaborative multi-agent teams using HiClaw's Manager-Workers architecture on Matrix with Kubernetes-native control.
Set up and manage collaborative multi-agent teams using HiClaw, a Kubernetes-native platform with Matrix rooms for human-in-the-loop AI coordination
Build and orchestrate collaborative multi-agent teams using HiClaw's Manager-Workers architecture with Matrix rooms, MCP servers, and Kubernetes-native deployment.
Deploy and orchestrate collaborative multi-agent teams using HiClaw's Manager-Workers architecture on Docker or Kubernetes with Matrix rooms for human oversight
Use Agent Apprenticeship to train AI agents through real-world tasks, reusable experience, and ecosystem learning signals
| name | duel-agents-routing |
| description | CLI, SDK, and IDE plugins for Duel Agents - an LLM routing layer that runs prompts against multiple models and picks the cheapest winning answer |
| triggers | ["set up duel agents routing","install duel agents for cursor","configure duel agents api","use duel agents sdk","route llm requests through duel","integrate duel agents with claude code","add multi-model llm routing","configure openclaw with duel agents"] |
Skill by ara.so — AI Agent Skills collection.
Duel Agents is an IDE-native routing layer that runs prompts against multiple LLM models simultaneously and selects the cheapest answer that meets quality thresholds. It provides:
duel-auto model nameThe service routes traffic through https://duelagents.com/v1 using Duel API keys (duel_<prefix>_<secret>).
You must have a Duel API key. Raw Anthropic or OpenAI keys will not work.
duel_ + 8 characters + _ + 32 characters# Set your API key
export DUEL_API_KEY=duel_yourprefix_yoursecret
# Install for all supported tools
npx @duel-agents/install all
# Verify installation
npx @duel-agents/install doctor
# Claude Code
npx @duel-agents/install claude-code
# Cursor IDE
npx @duel-agents/install cursor
# Codex CLI
npx @duel-agents/install codex
# OpenClaw
npx @duel-agents/install openclaw
npm install @duel-agents/sdk
| Variable | Required | Purpose |
|---|---|---|
DUEL_API_KEY | Yes | Your Duel API key from the dashboard |
DUEL_AGENTS_API_KEY | No | Alias for DUEL_API_KEY |
DUEL_PROXY_URL | No | Override proxy URL (staging environments only) |
OPENCLAW_CONFIG_PATH | No | Custom OpenClaw config file path |
.env file:
DUEL_API_KEY=duel_abc12345_def67890ghijklmnopqrstuvwxyz12
Shell export:
export DUEL_API_KEY=duel_abc12345_def67890ghijklmnopqrstuvwxyz12
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!, // required
});
// Chat completions
const response = await duel.chat.completions.create({
model: "duel-auto", // automatic model selection
messages: [
{ role: "system", content: "You are a helpful coding assistant." },
{ role: "user", content: "Explain TypeScript generics briefly." }
],
temperature: 0.7,
max_tokens: 500,
});
console.log(response.choices[0].message.content);
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
const message = await duel.messages.create({
model: "duel-auto",
max_tokens: 1024,
messages: [
{ role: "user", content: "Write a Python function to parse JSON safely." }
],
});
console.log(message.content);
const stream = await duel.chat.completions.create({
model: "duel-auto",
messages: [{ role: "user", content: "Count to 10" }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) {
process.stdout.write(content);
}
}
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
try {
const response = await duel.chat.completions.create({
model: "duel-auto",
messages: [{ role: "user", content: "Hello" }],
});
} catch (error) {
if (error.status === 401) {
console.error("Invalid API key or subscription inactive");
} else if (error.status === 429) {
console.error("Rate limit exceeded");
} else {
console.error("Request failed:", error.message);
}
}
# Clone repo and install plugin
git clone https://github.com/2aronS/Duel-Agents.git
cd duel-agents
claude plugin install ./integrations/claude-plugin
# Run installer
npx @duel-agents/install claude-code
In Claude Code:
/duel-agents:setup
Follow the guided setup to configure your API key and preferences.
The installer copies a skill to .cursor/skills/duel-agents/ and writes DUEL_API_KEY to your project .env.
Manual configuration required:
https://duelagents.com/v1duel_yourprefix_yoursecretduel-auto as your modelnpx @duel-agents/install cursor
The installer writes OPENAI_BASE_URL and OPENAI_API_KEY to .env:
npx @duel-agents/install codex
# Restart Codex after installation
Patches ~/.openclaw/openclaw.json with a duel provider and sets the default model:
npx @duel-agents/install openclaw
# Validate configuration
openclaw config validate
Manual configuration (~/.openclaw/openclaw.json):
{
"providers": {
"duel": {
"apiKey": "duel_yourprefix_yoursecret",
"baseURL": "https://duelagents.com/v1"
}
},
"defaultModel": "duel/duel-auto"
}
A backup is created at openclaw.json.bak before patching.
# Install for specific tool
npx @duel-agents/install <tool>
# Available tools:
# - claude-code
# - cursor
# - codex
# - openclaw
# - all
Validates your setup and connectivity:
npx @duel-agents/install doctor
Checks:
duelagents.com/v1import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
async function coordinatedAgents(task: string) {
// Planner agent
const plan = await duel.chat.completions.create({
model: "duel-auto",
messages: [
{ role: "system", content: "You are a task planning agent." },
{ role: "user", content: `Create a plan for: ${task}` }
],
});
const steps = plan.choices[0].message.content;
// Executor agent
const execution = await duel.chat.completions.create({
model: "duel-auto",
messages: [
{ role: "system", content: "You are a task execution agent." },
{ role: "user", content: `Execute this plan:\n${steps}` }
],
});
return execution.choices[0].message.content;
}
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
async function analyzeCode(code: string, complexity: "simple" | "complex") {
// Duel automatically routes to cheaper models for simple tasks
const response = await duel.chat.completions.create({
model: "duel-auto",
messages: [
{
role: "user",
content: `Analyze this ${complexity} code:\n\n${code}`
}
],
// Duel uses prompt complexity to select optimal model
});
return response.choices[0].message.content;
}
Replace only the client initialization:
// Before:
// import OpenAI from "openai";
// const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// After:
import { DuelClient } from "@duel-agents/sdk";
const client = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
// All existing OpenAI code works unchanged
const response = await client.chat.completions.create({
model: "duel-auto", // or keep your existing model name
messages: [{ role: "user", content: "Hello" }],
});
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
});
async function robustCompletion(prompt: string) {
try {
// Try Duel routing first (cost-optimized)
return await duel.chat.completions.create({
model: "duel-auto",
messages: [{ role: "user", content: prompt }],
});
} catch (error) {
console.warn("Duel routing failed, using direct fallback");
// Fallback logic here if needed
throw error;
}
}
Symptom: Invalid API key format error
Solution:
duel_ + 8 chars + _ + 32 charsecho "$DUEL_API_KEY" | wc -c should be 46Symptom: 401 error when running doctor or making requests
Solution:
echo $DUEL_API_KEYSymptom: Connection errors to duelagents.com/v1
Solution:
duelagents.com is accessible: curl https://duelagents.com/v1/healthSymptom: Cursor not routing through Duel
Solution:
https://duelagents.com/v1duel_* key (not OpenAI key)duel-auto or duel/duel-auto as modelSymptom: OpenClaw fails after Duel installation
Solution:
# Validate configuration
openclaw config validate
# Restore from backup if needed
cp ~/.openclaw/openclaw.json.bak ~/.openclaw/openclaw.json
# Reinstall
npx @duel-agents/install openclaw
Symptom: Cursor skill not found after npm install
Solution:
# Rebuild the package
git clone https://github.com/2aronS/Duel-Agents.git
cd duel-agents
npm install
npm run build
# Reinstall
npx @duel-agents/install cursor
Symptom: TypeScript errors with SDK
Solution:
# Ensure latest version
npm install @duel-agents/sdk@latest
# Check TypeScript version (>= 4.5 recommended)
npm list typescript
duel-auto - Automatic routing (recommended)Duel analyzes:
Then selects the cheapest model that meets the quality threshold for that specific request.
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
baseURL: process.env.DUEL_PROXY_URL || "https://duelagents.com/v1",
});
import { DuelClient } from "@duel-agents/sdk";
const duel = new DuelClient({
apiKey: process.env.DUEL_API_KEY!,
timeout: 60000, // 60 seconds
});
packages/
core/ @duel-agents/core - Validation, env handling, connectivity
cli/ @duel-agents/install - Installer CLI tool
sdk/ @duel-agents/sdk - TypeScript API client
integrations/
claude-plugin/ - Claude Code plugin
cursor-skill/ - Cursor IDE skill
openclaw-skill/ - OpenClaw integration
templates/
cursor-models.override.md - Cursor configuration example
openclaw.duel.json5 - OpenClaw configuration example
# Clone repository
git clone https://github.com/2aronS/Duel-Agents.git
cd duel-agents
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm test
# Run installer locally
npm run cli -- install doctor
MIT License - see repository for full text.