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
Copy
Ask AI
# Your Helicone API keyexport HELICONE_API_KEY=<your-helicone-api-key>
Create a .env file in your project:
Copy
Ask AI
HELICONE_API_KEY=sk-helicone-...
3
Add the AI Gateway endpoint to your Semantic Kernel configuration
Copy
Ask AI
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();
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:
Copy
Ask AI
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);
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.