Skip to main content

.NET SDK

Use the Betalgo.OpenAI SDK with GonkaGate. Works with .NET 6+, .NET Core, and .NET Framework.

Community SDK

We recommend using Betalgo.OpenAI, the most popular .NET client for OpenAI-compatible APIs.

Betalgo.OpenAI on NuGet

For API keys, base URL, and your first request, start with the Quickstart guide .

Installation

Install the SDK using the .NET CLI:

terminal
dotnet add package Betalgo.OpenAI

Or using Package Manager Console:

Package Manager Console
Install-Package Betalgo.OpenAI

Configuration

Configure the client to use GonkaGate's API endpoint:

Configuration.cs
using OpenAI;
using OpenAI.Managers;
using OpenAI.ObjectModels.RequestModels;

var openAiService = new OpenAIService(new OpenAiOptions
{
    ApiKey = "gp-your-api-key",
    BaseDomain = "https://api.gonkagate.com/"
});

Basic Usage

Make your first chat completion request:

BasicUsage.cs
using OpenAI;
using OpenAI.Managers;
using OpenAI.ObjectModels;
using OpenAI.ObjectModels.RequestModels;

var openAiService = new OpenAIService(new OpenAiOptions
{
    ApiKey = "gp-your-api-key",
    BaseDomain = "https://api.gonkagate.com/"
});

var completionResult = await openAiService.ChatCompletion.CreateCompletion(
    new ChatCompletionCreateRequest
    {
        Messages = new List<ChatMessage>
        {
            ChatMessage.FromSystem("You are a helpful assistant."),
            ChatMessage.FromUser("Hello, how are you?")
        },
        Model = "qwen/qwen3-235b-a22b-instruct-2507-fp8",
        Temperature = 0.7f,
        MaxTokens = 1000
    });

if (completionResult.Successful)
{
    Console.WriteLine(completionResult.Choices.First().Message.Content);
}
else
{
    Console.WriteLine($"Error: {completionResult.Error?.Message}");
}

Dependency Injection

Register the OpenAI service for ASP.NET Core applications:

Program.cs
// Program.cs or Startup.cs
using OpenAI.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add OpenAI service with GonkaGate configuration
builder.Services.AddOpenAIService(settings =>
{
    settings.ApiKey = builder.Configuration["GonkaGate:ApiKey"]!;
    settings.BaseDomain = "https://api.gonkagate.com/";
});

var app = builder.Build();

Then inject the service into your controllers:

Language-specific notes

A few .NET-specific tips before you ship:

  • Reuse HttpClient via IHttpClientFactory.
  • Use CancellationToken for long-running requests.
  • Prefer async APIs to avoid blocking threads.

See Streaming and Error handling for real-time responses and retry guidance.

Was this page helpful?