Skip to main content
Learn how to use Portkey’s Universal API to orchestrate multiple LLMs in a structured debate while tracking performance and evaluating outputs with Arize.

Google Collab Link

Overview

This guide demonstrates how to:
  • Use Portkey’s Universal API to seamlessly switch between different LLMs (GPT-4, Claude, Gemini)
  • Implement distributed tracing with Arize and OpenTelemetry
  • Build a multi-agent debate system where LLMs take different roles
  • Export traces and run toxicity evaluations on outputs

Prerequisites

Before starting, you’ll need:

Installation

Install the required packages:

Setting Up Tracing

First, configure Arize tracing with Portkey’s instrumentor to capture all LLM calls:
Python

Implementing the Multi-LLM Debate

Here’s how to set up different LLMs for different roles using Portkey’s Universal API:
Python

Debate Round Function

Create a function that orchestrates a single debate round:
Python

Running Multiple Rounds

Execute the debate across multiple rounds with progressively refined prompts:
Python

Adding Evaluations

After running the debate, evaluate outputs for toxicity using Arize evals:

Export Traces to Dataset

Python

Run Toxicity Evaluation

Python

Send Results Back to Arize

Python

Benefits of This Approach

  1. Unified API: Use the same interface for all LLMs, making it easy to switch providers
  2. Automatic Tracing: All LLM calls are automatically traced without modifying your code
  3. Multi-Agent Orchestration: Different LLMs can play different roles based on their strengths
  4. Comprehensive Observability: Monitor latency, costs, and outputs across all providers
  5. Quality Assurance: Automated evaluations ensure outputs meet safety standards

Next Steps

  • Try different LLM combinations for various roles
  • Add more evaluation criteria beyond toxicity
  • Implement fallback strategies using Portkey’s gateway features
  • Set up alerts in Arize for performance degradation
Last modified on April 8, 2026