Fitomad.DeepSeek 1.0.1

dotnet add package Fitomad.DeepSeek --version 1.0.1
                    
NuGet\Install-Package Fitomad.DeepSeek -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="Fitomad.DeepSeek" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fitomad.DeepSeek" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Fitomad.DeepSeek" />
                    
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 Fitomad.DeepSeek --version 1.0.1
                    
#r "nuget: Fitomad.DeepSeek, 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.
#:package Fitomad.DeepSeek@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fitomad.DeepSeek&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Fitomad.DeepSeek&version=1.0.1
                    
Install as a Cake Tool

DeepSeek API Client for .NET 9

Fitomad.DeepSeek is a community-maintained .NET library that allows you to access the powerful AI models from DeepSeek, such as deepseek-chat or deepseek-resoner, through a simple and intuitive interface. You can use this framework to generate text or code with just a few lines of code.

Fitomad.DeepSeek provides various options to customize your requests and responses. Whether you want to create a chatbot, a content generator, a sentiment analyzer, a translator, or any other AI-powered application, Fitomad.DeepSeek can help you achieve your goals with ease and efficiency.

The framework makes a heavy usage of the Builder pattern to create requests and settings objects.

Currently I bring support for the following OpenAI models:

  • Chat Completion
    • Text
  • Models

DeepSeek API key storage recommendations

API key is a sensitive information part that must be keep safe during your development and deployment process.

I strongly recommend the usage of environment variables when you deploy your solution to store your DeepSeek API key.

During the development stage you could use user-secrets technology to store the API key.

User secrets

This is the recommended storage system for development. For a detailed information about the usage of this storage system, please refer to Safe storage of app secrets in development in ASP.NET Core article.

var configuration = new ConfigurationBuilder()
    .AddUserSecrets<ImageTests>()
    .Build();

_apiKey = configuration.GetValue<string>("DeepSeek:ApiKey");

Environment variables

Environment variables are used to avoid storage of app secrets in code or in local configuration files. Environment variables override configuration values for all previously specified configuration sources.

using Fitomad.DeepSeek;

...

var deepSeekSettings = new DeepSeekSettingsBuilder()
    .WithApWithApiKeyFromEnvironmentVariableiKey("DeepSeek:ApiKey")
    .Build();

Dependency Injection. Create an DeepSeekClient instance

To create a DeepSeekClient instance, the entry point to the whole Fitomad.DeepSeek framework, developers must use DI.

I provide a helper method registered as an IServiceCollection extension named AddDeepSeekHttpClient which receives an DeepSeekSettings object as parameter.

This is an example of DI in an Unit Testing (xunit) environment.

var deepSeekSettings = new DeepSeekSettingsBuilder()
    .WithApiKey(_apiKey)
    .Build();

var services = new ServiceCollection();
services.AddDeepSeekHttpClient(settings: aiSettings);

Below this lines you will find an example of the usage of DI in ASP.NET

using Fitomad.DeepSeek;

...

var developApiKey = builder.Configuration["DeepSeek:ApiKey"];

var deepSeekSettings = new DeepSeekSettingsBuilder()
    .WithApiKey(developApiKey)
    .Build();

builder.Services.AddDeepSeekHttpClient(settings: deepSeekSettings);

And now, thanks to the built-on DI container available in .NET we can use the DeepSeekClient registered type

...

[ApiController]
[Route("games")]
public class GameController: ControllerBase
{
    private IDeepSeekClient _deepSeekClient;

    public GameController(IDeepSeekClient deepSeekClient)
    {
        _deepSeekClient = deepSeekClient;
    }

    ...
}

Models

Fetch a list of models available in the API. Fitomad.DeepSeek framework bring support for list operation.

This is one of the most simple endpoints, and you will not need a builder object to create a request, simply invoke the methods presented in the ModelEndpoint class.

List operation

ModelListResponse response = await _client.Models.List();

Changes

1.0.1

  • DeepSeekException now contains a nested enumeration of type Failure to help exception description.

1.0.0

  • Chat endpoint models brings support the following:
    • deepseek-chat
    • deepseek-reasoner
  • Model endpoint
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 152 1/28/2025
1.0.0 108 1/28/2025