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

Send Semantic Kernel traces to Toqan Router with OpenTelemetry.

AI Gateway

Overview

Microsoft Semantic Kernel is an SDK that integrates Large Language Models (LLMs) with conventional programming languages. By connecting Semantic Kernel to Toqan Router’s AI Gateway, you transform experimental AI agents into production-ready systems with enterprise-grade capabilities.

Key Benefits

Toqan Router’s AI Gateway enhances your Semantic Kernel applications with:

Complete Observability

Track every agent step, tool use, and interaction with detailed traces and analytics

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 Semantic Kernel with Toqan Router, ensure you have:
  • A Toqan Router account and API Key
  • Python 3.10 or higher
  • Semantic Kernel SDK installed
To setup your API key, see API keys & Endpoints.

Installation

Install Semantic Kernel and the OpenAI SDK:

Configuration

Configure Semantic Kernel to use Toqan Router’s AI Gateway by creating an OpenAI client with a custom base URL:
base_url: https://router.toqan.ai/eu/v3/router

Basic Example

Here’s a complete example of using Semantic Kernel with Toqan Router:

Using Plugins (Functions)

Semantic Kernel’s power comes from combining LLMs with plugins. Here’s how to use them with Toqan Router:

Model Selection

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

Streaming Responses

Semantic Kernel supports streaming with Toqan Router:

Observability

The AI Gateway records model requests routed through it. To capture Semantic Kernel’s own spans, including kernel function calls, configure OpenTelemetry in the application.

Install dependencies

Bash

Enable model diagnostics

Set this variable before starting Python so Semantic Kernel also emits model spans:
Bash
This experimental setting includes model names and token usage without enabling prompt or response capture. See Semantic Kernel’s telemetry documentation for the available diagnostics settings.

Send traces to Toqan Router

Set TOQAN_API_KEY to a Toqan Router API key, then run this example. Initialize one tracer provider for the application and shut it down when the application exits.
Python
Open Traces to inspect the exported spans from semantic-kernel-app.