Deepseek.AspClient 1.0.0

dotnet add package Deepseek.AspClient --version 1.0.0
                    
NuGet\Install-Package Deepseek.AspClient -Version 1.0.0
                    
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="Deepseek.AspClient" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Deepseek.AspClient" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Deepseek.AspClient" />
                    
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 Deepseek.AspClient --version 1.0.0
                    
#r "nuget: Deepseek.AspClient, 1.0.0"
                    
#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=Deepseek.AspClient&version=1.0.0
                    
Install Deepseek.AspClient as a Cake Addin
#tool nuget:?package=Deepseek.AspClient&version=1.0.0
                    
Install Deepseek.AspClient as a Cake Tool

Deepseek.ASPClient

Deepseek.ASPClient is a lightweight ASP.NET wrapper for the Deepseek AI API, designed to simplify AI-driven text processing in .NET applications.

Features

  • ✅ Simple and fluent API
  • ✅ Supports Dependency Injection
  • ✅ Built-in error handling
  • ✅ Uses HttpClient best practices
  • ✅ Asynchronous and thread-safe

Installation

You can install the package via NuGet:

dotnet add package Deepseek.ASPClient

Usage Example

using Deepseek.ASP.Client;

var client = new DeepseekClient("your-api-key");
var response = await client.GenerateResponseAsync("Hello Deepseek!");
Console.WriteLine(response.Choices[0].Message.Content);

Dependency Injection Example (ASP.NET Core)

// In Program.cs or Startup.cs
services.AddSingleton<IDeepseekClient>(provider =>
    new DeepseekClient(Configuration["Deepseek:ApiKey"]));

// In a Controller
public class AiController : Controller
{
    private readonly IDeepseekClient _client;

    public AiController(IDeepseekClient client)
    {
        _client = client;
    }

    public async Task<IActionResult> Generate(string prompt)
    {
        try
        {
            var response = await _client.GenerateResponseAsync(prompt);
            return Ok(response.Choices.First().Message.Content);
        }
        catch (DeepseekException ex)
        {
            return StatusCode((int)ex.StatusCode, ex.Message);
        }
    }
}

API Methods

Method Description
Task<DeepseekResponse> GenerateResponseAsync(DeepseekRequest request) Generates a response based on a structured request.
Task<DeepseekResponse> GenerateResponseAsync(string prompt) Generates a response from a simple text prompt.

Exception Handling

All API errors are wrapped inside DeepseekException. Handle exceptions as follows:

try
{
    var response = await client.GenerateResponseAsync("Hello Deepseek!");
    Console.WriteLine(response.Choices[0].Message.Content);
}
catch (DeepseekException ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Added new feature").
  4. Push to the branch (git push origin feature-name).
  5. Open a Pull Request.

Reporting Issues

If you encounter any issues, please create an issue on GitHub: Report an Issue

License

This project is licensed under the MIT License. See LICENSE for details.

Author

Created by Anwar Al-Hitar.

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. 
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.0 307 1/29/2025