LangChain chat model that routes prompts through Duel Agents proxy.
# Source: https://github.com/2aronS/Duel-Agents | License: MIT | Copyright 2026 Duel Agents
# Provided via justclaw.it.com; keep this notice with the code.
"""Duel Agents chat model for LangChain."""
from __future__ import annotations
import os
from typing import Any
from langchain_openai import ChatOpenAI
from pydantic import model_validator
DUEL_API_BASE = "https://duelagents.com/v1"
DEFAULT_MODEL = "duel-auto"
class ChatDuel(ChatOpenAI):
"""Duel Agents chat model.
Routes prompts through the Duel Agents proxy, which runs the request against
multiple models and bills the cheapest answer that still wins. The proxy is
wire compatible with the OpenAI chat completions API, so this class builds on
:class:`~langchain_openai.ChatOpenAI` and only changes the defaults.
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key