Ater.DeepSeek.Core 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ater.DeepSeek.Core --version 1.0.1
                    
NuGet\Install-Package Ater.DeepSeek.Core -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ater.DeepSeek.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ater.DeepSeek.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Ater.DeepSeek.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ater.DeepSeek.Core --version 1.0.1
                    
#r "nuget: Ater.DeepSeek.Core, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Ater.DeepSeek.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Ater.DeepSeek.Core&version=1.0.1
                    
Install as a Cake Tool

DeepSeekSDK-NET

NuGet Version

DeepSeek API SDK specifically for .NET developers

中文文档

🚀 Features

  • List models
  • Dialogue completion
  • Dialog completion (streaming processing)

Usage Requirements

Please go to official website, register and apply for DeepSeek's ApiKey

Supported .NET version: .NET8

Free to fork the repository to support other versions

Usage

Instantiate DeepSeekClient

Two methods are provided for instantiation:

public DeepSeekClient(string apiKey);
public DeepSeekClient(HttpClient http, string apiKey);

The first type only requires providing the 'apiKey' to create an instance;

The second method provides a HttpClient parameter, which is suitable for maintaining the HttpClient through the HttpClientFactory and then instance it.

Calling method

Three asynchronous methods are provided:

Task<ModelResponse?> ListModelsAsync(CancellationToken cancellationToken);
Task<ChatResponse?> ChatAsync(ChatRequest request, CancellationToken cancellationToken);
Task<IAsyncEnumerable<Choice>?> ChatStreamAsync(ChatRequest request, CancellationToken cancellationToken)

List Models Sample

// Create an instance using the apiKey
var client = new DeepSeekClient(apiKey);

var modelResponse = await client.ListModelsAsync(new CancellationToken());
if (modelResponse is null)
{
    Console.WriteLine(client.ErrorMsg);
    return;
}
foreach (var model in modelResponse.Data)
{
    Console.WriteLine(model);
}

Chat Examples

// Create an instance using the apiKey
var client = new DeepSeekClient(apiKey);
// Construct the request body
var request = new ChatRequest
{
    Messages = [
        Message.NewSystemMessage("You are a language translator"),
        Message.NewUserMessage("Please translate 'They are scared! ' into English!")
    ],
    // Specify the model
    Model = Constant.Model.ChatModel
};

var chatResponse = await client.ChatAsync(request, new CancellationToken());
if (chatResponse is null)
{
    Console.WriteLine(client.ErrorMsg);
}
Console.WriteLine(chatResponse?.Choices.First().Message?.Content);

Chat Examples (Stream)

// Create an instance using the apiKey
var client = new DeepSeekClient(apiKey);
// Construct the request body
var request = new ChatRequest
{
    Messages = [
        Message.NewSystemMessage("You are a language translator"),
        Message.NewUserMessage("Please translate 'They are scared! ' into English!")
    ],
    // Specify the model
    Model = Constant.Model.ChatModel
};

var choices = await client.ChatStreamAsync(request, new CancellationToken());
if (choices is null)
{
    Console.WriteLine(client.ErrorMsg);
    return;
}
await foreach (var choice in choices)
{
    Console.Write(choice.Delta?.Content);
}
Console.WriteLine();

You can also refer to the usage example in this repository

Product 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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ater.DeepSeek.Core:

Package Downloads
Ater.DeepSeek.AspNetCore

DeepSeek API SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.5 1,458 4/18/2025
1.1.4 3,506 3/4/2025
1.1.3 888 2/11/2025
1.1.2 227 2/10/2025
1.1.1 160 2/8/2025
1.1.0 1,635 1/23/2025
1.0.1 626 5/16/2024
1.0.0 142 5/16/2024
1.0.0-RC1 120 5/11/2024

publish RC Version