Skip to content

Portkey

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Portkey OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using Portkey;

using var client = new PortkeyClient(apiKey);

Virtual Keys

Manage virtual keys for provider credentials.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using var client = new PortkeyClient(apiKey);

// List all virtual keys in your Portkey account.
// Virtual keys securely store provider API keys (e.g., OpenAI, Anthropic)
// and can be referenced in gateway configs without exposing raw credentials.
var response = await client.VirtualKeys.GetVirtualKeysAsync(
    currentPage: 1,
    pageSize: 10);

Console.WriteLine($"Total virtual keys: {response.Total}");

foreach (var key in response.Data!)
{
    Console.WriteLine($"  Key: {key.Name} (Slug: {key.Slug})");
}

Configs

Manage gateway configurations for routing and load balancing.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using var client = new PortkeyClient(apiKey);

// List all gateway configurations in your Portkey account.
// Configs define routing rules, load balancing strategies,
// fallbacks, retries, and other gateway behaviors.
var response = await client.Configs.ListConfigsAsync();

Console.WriteLine($"Success: {response.Success}");
Console.WriteLine($"Configs found: {response.Data!.Count}");

foreach (var config in response.Data)
{
    Console.WriteLine($"  Config: {config.Name} (Slug: {config.Slug})");
}

Prompts

Manage prompt templates for structured LLM interactions.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using var client = new PortkeyClient(apiKey);

// List all prompt templates in your Portkey account.
// Prompts are reusable templates with variables that can be
// rendered and completed through the Portkey gateway.
var response = await client.Prompts.ListPromptsAsync(
    currentPage: 1,
    pageSize: 10);

Console.WriteLine($"Total prompts: {response.Total}");

foreach (var prompt in response.Data!)
{
    Console.WriteLine($"  Prompt: {prompt.Name} (ID: {prompt.Id})");
}

Support

Priority place for bugs: https://github.com/tryAGI/Portkey/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Portkey/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.