DeepSeek.ApiClient is a .NET API Client designed to interact with the DeepSeek API, allowing developers to easily send and receive messages from DeepSeek’s AI models.
$ dotnet add package DeepSeek.ApiClientApi for DeepSeek
DeepSeek.ApiClient is a .NET library for interacting with the DeepSeek API, enabling developers to send and receive messages from DeepSeek�s AI models with ease.
enum.HttpClient with built-in serialization.You can install the package via NuGet:
dotnet add package DeepSeek.ApiClient
To integrate the DeepSeek.ApiClient into your .NET application, add the client to your dependency injection container:
var services = new ServiceCollection();
services.AddDeepSeekClient("your-api-key");
var serviceProvider = services.BuildServiceProvider();
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace DeepSeekExample
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Application is started.");
var services = new ServiceCollection();
services.AddDeepSeekClient(AppConstants.API_KEY);
var serviceProvider = services.BuildServiceProvider();
var deepSeekClient = serviceProvider.GetRequiredService<IDeepSeekClient>();
Console.WriteLine("Send message is started.");
var request = new DeepSeekRequestBuilder()
.SetModel(DeepSeekModel.V3)
.SetStream(false)
.SetTemperature(0)
.SetSystemMessage("You are a professional technical assistant.")
.AddUserMessage("How can I improve my C# skills?");
string response = await deepSeekClient.SendMessageAsync(request.Build());
Console.WriteLine("Response: " + response);
}
}
}
string response = await deepSeekClient.SendMessageAsync("Explain SOLID principles", DeepSeekModel.DeepSeekV3);
var messages = new List<string>
{
"How can I improve my C# skills?",
"What are the best design patterns in C#?",
"Explain SOLID principles with examples."
};
foreach (var message in messages)
{
string response = await deepSeekClient.SendMessageAsync(message);
Console.WriteLine($"User: {message}\nAssistant: {response}\n");
}
The DeepSeek API returns structured responses. The library deserializes these responses into a DeepSeekResponse class, which includes:
Choices: Contains the AI-generated message.Usage: Provides token usage details.Model: Identifies the DeepSeek model used.This package is released under the MIT License. See LICENSE for details.
Feel free to open issues or pull requests.