Semantic Kernel

Semantic Kernel is an open-source SDK from Microsoft that connects LLMs with programming languages including C#, Python, and Java. The framework enables developers to build AI applications by integrating AI services, data sources, and custom logic into cohesive solutions.

This guide covers capturing telemetry from Semantic Kernel applications using InteractiveAI. While this documentation focuses on Python, the integration principles apply to other supported languages including C# and Java.

Prerequisites

  • InteractiveAI account with API credentials

  • LLM provider credentials (OpenAI, Ollama, or other supported provider)


Installation

pip install interactiveai openlit semantic-kernel

Configuration

Set your API credentials as environment variables:

import os

# InteractiveAI credentials
# Obtain keys from Settings > API Keys in the dashboard
os.environ["INTERACTIVEAI_PUBLIC_KEY"] = "pk-ia-..."
os.environ["INTERACTIVEAI_SECRET_KEY"] = "sk-ia-..."
os.environ["INTERACTIVEAI_HOST"] = "https://app.interactiveai.com"

# Model provider credentials
os.environ["OPENAI_API_KEY"] = "sk-proj-..."
os.environ["OPENAI_CHAT_MODEL_ID"] = "gpt-4o"

Initialize the client and confirm connectivity:


Enabling Trace Capture

OpenLIT provides automatic instrumentation for Semantic Kernel. Connect it to the InteractiveAI tracer:

The disable_batch=True flag processes traces immediately rather than buffering them.


Building a Semantic Kernel Application

Create a kernel and add a chat completion service:

Define a prompt template and register it as a function:


Running the Application

Invoke the function with a sample question:

OpenLIT captures this interaction and routes the trace data to InteractiveAI automatically.


Enriching Traces with Context

Combine OpenLIT instrumentation with the InteractiveAI SDK to attach identifiers and metadata:


Trace Visibility

The InteractiveAI dashboard displays:

  • Kernel function invocations and plugin calls

  • LLM requests with prompts and completions

  • Prompt template rendering and variable substitution

  • Token consumption and latency metrics

Last updated

Was this helpful?