Skip to main content

AI Gateway

Route your LLM calls through the AI Gateway with a single base URL change. Zero vendor lock-in: always run on the best model at the lowest cost for your use case.

Observability

Instrument your code with OpenTelemetry to capture traces, logs, and metrics for every LLM call, agent step, and tool use.

AI Gateway

Overview

Microsoft AutoGen is a framework for building multi-agent conversational AI systems with collaborative problem-solving through automated agent interactions. By connecting AutoGen to Toqan Router’s AI Gateway, you get access to 500+ models for your multi-agent workflows with a single configuration change.

Key Benefits

Toqan Router’s AI Gateway enhances your AutoGen applications with:

Complete Observability

Track every agent conversation, tool use, and multi-agent interaction

Built-in Reliability

Automatic fallbacks, retries, and load balancing for production resilience

Cost Optimization

Real-time cost tracking and spend management across all your AI operations

Multi-Provider Access

Access 500+ LLMs and 30+ providers through a single, unified integration

Prerequisites

Before integrating AutoGen with Toqan Router, ensure you have:
  • A Toqan Router account and API Key
  • Python 3.10 or higher
To setup your API key, see API keys & Endpoints.

Installation

Configuration

Configure AutoGen to use Toqan Router’s AI Gateway via OpenAIChatCompletionClient with a custom base_url:
Python
base_url: https://router.toqan.ai/eu/v3/router
Set model_info for models AutoGen does not recognize, including provider-prefixed AI Gateway model IDs. It describes the model’s capabilities.AutoGen can emit a Resolved model mismatch warning when the model name returned in a response differs from the requested model or AutoGen’s model mapping. The warning does not by itself mean the request failed, and model_info does not suppress it. Check the returned model against the intended model and keep using a model ID supported by the AI Gateway.

Basic Agent Example

Python

Multi-Agent Team

Orchestrate multiple specialized agents with RoundRobinGroupChat:
Python

Model Selection

With Toqan Router, you can use any supported model from 30+ providers:
Python

Observability

Getting Started

Microsoft AutoGen enables sophisticated multi-agent conversations and collaborative AI systems. Tracing AutoGen with Toqan Router provides deep insights into agent interactions, conversation flows, tool usage, and multi-agent coordination patterns to optimize your conversational AI applications.

Prerequisites

Before you begin, ensure you have:
  • A Toqan Router account and API Key
  • Python 3.8+
  • Microsoft AutoGen installed in your project
  • OpenAI API key (or other LLM provider credentials)

Install Dependencies

Configure Toqan Router

Set up your environment variables to connect to Toqan Router’s OpenTelemetry collector: Unix/Linux/macOS:
Windows (PowerShell):
Using .env file:

Integration

AutoGen has built-in OpenTelemetry support. Configure the tracer provider and pass it to the AutoGen runtime.
Set up OpenTelemetry tracing in your application:
All AutoGen agent conversations and interactions will be instrumented and exported to Toqan Router through the OTLP exporter. For more details, see Traces.

Advanced Examples

Multi-Agent Group Chat
Agent with Custom Tools
AutoGen is also usable through our AI Gateway. To learn more, see AutoGen Gateway.