Semantic Kernel is Microsoft’s open-source SDK for building AI agents and orchestrating LLM workflows across multiple languages (.NET, Python, Java). By integrating Helicone AI Gateway with Semantic Kernel, you can:
Route to different models & providers with automatic failover through a single endpoint
Unified billing with pass-through billing or bring your own keys
Monitor all requests with automatic cost tracking in one dashboard
This integration requires only one line change to your existing Semantic Kernel code - adding the AI Gateway endpoint.
You’ll also need to configure your provider API keys (OpenAI, Anthropic, etc.) at Helicone Providers for BYOK (Bring Your Own Keys).
2
Set environment variables
# Your Helicone API keyexport HELICONE_API_KEY=<your-helicone-api-key>
Create a .env file in your project:
HELICONE_API_KEY=sk-helicone-...
3
Add the AI Gateway endpoint to your Semantic Kernel configuration
using Microsoft.SemanticKernel;using Microsoft.SemanticKernel.ChatCompletion;using DotNetEnv;// Load environment variablesEnv.Load();var heliconeApiKey = Environment.GetEnvironmentVariable("HELICONE_API_KEY");// Create kernel buildervar builder = Kernel.CreateBuilder();// Add OpenAI chat completion with Helicone AI Gateway endpointbuilder.AddOpenAIChatCompletion( modelId: "gpt-4.1-mini", // Any model from Helicone registry apiKey: heliconeApiKey, // Your Helicone API key endpoint: new Uri("https://ai-gateway.helicone.ai/v1") // Helicone AI Gateway);var kernel = builder.Build();
import semantic_kernel as skfrom semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletionimport os# Load environment variableshelicone_api_key = os.getenv("HELICONE_API_KEY")# Create kernelkernel = sk.Kernel()# Add OpenAI chat completion with Helicone AI Gateway endpointkernel.add_service( OpenAIChatCompletion( service_id="helicone-gateway", ai_model_id="gpt-4.1-mini", # Any model from Helicone registry api_key=helicone_api_key, # Your Helicone API key endpoint="https://ai-gateway.helicone.ai/v1" # Helicone AI Gateway ))
The only change from a standard Semantic Kernel setup is adding the endpoint parameter. Everything else stays the same!
4
Use the chat service normally
Your existing Semantic Kernel code continues to work without any changes:
using Microsoft.SemanticKernel.ChatCompletion;// Get the chat servicevar chatService = kernel.GetRequiredService<IChatCompletionService>();// Create chat historyvar chatHistory = new ChatHistory();chatHistory.AddUserMessage("What is the capital of France?");// Get responsevar response = await chatService.GetChatMessageContentAsync(chatHistory);Console.WriteLine(response.Content);
from semantic_kernel.contents import ChatHistory# Get the chat servicechat_service = kernel.get_service("helicone-gateway")# Create chat historychat_history = ChatHistory()chat_history.add_user_message("What is the capital of France?")# Get responseresponse = await chat_service.get_chat_message_content( chat_history=chat_history)print(response.content)
5
View requests in the Helicone dashboard
All your Semantic Kernel requests are now visible in your Helicone dashboard:
var builder = Kernel.CreateBuilder();builder.AddOpenAIChatCompletion( modelId: "gpt-4.1-mini", // Use Helicone model names apiKey: heliconeApiKey, // Your Helicone API key endpoint: new Uri("https://ai-gateway.helicone.ai/v1") // Add this line!);var kernel = builder.Build();
That’s it! Just one additional parameter and you’re routing through Helicone’s AI Gateway.