DeepSeek.ApiClient
1.0.6
dotnet add package DeepSeek.ApiClient --version 1.0.6
NuGet\Install-Package DeepSeek.ApiClient -Version 1.0.6
<PackageReference Include="DeepSeek.ApiClient" Version="1.0.6" />
paket add DeepSeek.ApiClient --version 1.0.6
#r "nuget: DeepSeek.ApiClient, 1.0.6"
// Install DeepSeek.ApiClient as a Cake Addin #addin nuget:?package=DeepSeek.ApiClient&version=1.0.6 // Install DeepSeek.ApiClient as a Cake Tool #tool nuget:?package=DeepSeek.ApiClient&version=1.0.6
DeepSeek API Client
Api for DeepSeek
Overview
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.
Features
- Supports DeepSeek models dynamically via an
enum
. - Uses Dependency Injection (DI) for seamless integration.
- Allows customizable system messages.
- Handles API calls using
HttpClient
with built-in serialization.
Installation
You can install the package via NuGet:
dotnet add package DeepSeek.ApiClient
Configuration
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();
Usage
Basic Example
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);
}
}
}
Using Enum for Model Selection
string response = await deepSeekClient.SendMessageAsync("Explain SOLID principles", DeepSeekModel.DeepSeekV3);
Handling Multiple Messages in a Conversation
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");
}
API Response Handling
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.
License
This package is released under the MIT License. See LICENSE for details.
Contribution
Feel free to open issues or pull requests.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added support for DeepSeek API and .NET 8.