Universal.DeepSeek.Client
1.0.2
dotnet add package Universal.DeepSeek.Client --version 1.0.2
NuGet\Install-Package Universal.DeepSeek.Client -Version 1.0.2
<PackageReference Include="Universal.DeepSeek.Client" Version="1.0.2" />
<PackageVersion Include="Universal.DeepSeek.Client" Version="1.0.2" />
<PackageReference Include="Universal.DeepSeek.Client" />
paket add Universal.DeepSeek.Client --version 1.0.2
#r "nuget: Universal.DeepSeek.Client, 1.0.2"
#:package Universal.DeepSeek.Client@1.0.2
#addin nuget:?package=Universal.DeepSeek.Client&version=1.0.2
#tool nuget:?package=Universal.DeepSeek.Client&version=1.0.2
Universal.DeepSeek.Client
A typed .NET client for DeepSeek's REST API. It supports chat completions, reasoning, tools, JSON output, SSE streaming, beta FIM completions, model listing, and account balance.
Quick start
using Universal.DeepSeek.Client;
using Universal.DeepSeek.Client.V1.Chat;
using var client = new DeepSeekClient("your-api-key");
var response = await client.V1.Chat.CreateCompletionAsync(new CreateCompletionRequest
{
Model = Models.DeepSeekV41Flash,
Messages = new Message[]
{
new SystemMessage("You are a helpful assistant."),
new UserMessage("Hello!")
},
Thinking = ThinkingConfiguration.Enabled,
ReasoningEffort = ReasoningEfforts.High
});
Console.WriteLine(response.Choices[0].Message.Content);
Streaming
await foreach (var chunk in client.V1.Chat.CreateCompletionStreamingAsync(
new CreateCompletionRequest
{
Model = Models.DeepSeekV41Flash,
Messages = new Message[] { new UserMessage("Explain monads simply.") },
Stream = true,
StreamOptions = new StreamOptions { IncludeUsage = true }
}))
{
Console.Write(chunk.Choices?[0]?.Delta?.Content);
}
The parser implements SSE framing, ignores DeepSeek keep-alive comments, supports multi-line data events, and stops at [DONE]. Use CreateCompletionStreamingRawAsync when relaying the HTTP stream directly.
Reasoning and tool calls
DeepSeek requires reasoning_content from an assistant tool-call turn to be sent back on subsequent requests in thinking mode. The response deserializes to AssistantMessage, so the same message can be appended directly:
var assistant = response.Choices[0].Message;
var followUp = await client.V1.Chat.CreateCompletionAsync(new CreateCompletionRequest
{
Model = Models.DeepSeekV41Flash,
Thinking = ThinkingConfiguration.Enabled,
Messages = new Message[]
{
new UserMessage("What is the weather in Sydney?"),
assistant,
new ToolMessage("{\"temperature\":18}", assistant.ToolCalls[0].Id)
},
Tools = tools
});
When thinking is enabled, use ToolChoiceOptions.Auto; the live API rejects a forced named function choice in that mode.
Strict tool schemas and chat prefix completion are beta features. Construct a resource client with a beta base URI when using them:
using var betaChat = new ChatClient(new Uri("https://api.deepseek.com/beta/"), "your-api-key");
FIM completion
client.V1.Completions automatically uses https://api.deepseek.com/beta/completions:
var fim = await client.V1.Completions.CreateCompletionAsync(
new Universal.DeepSeek.Client.V1.Completions.CreateCompletionRequest
{
Model = Models.DeepSeekV41Flash,
Prompt = "def fib(a):",
Suffix = "\n return fib(a - 1) + fib(a - 2)"
});
API failures are surfaced as Universal.Common.Net.Http.HttpException, consistently with the other Universal.* clients.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.12)
- Newtonsoft.Json (>= 13.0.4)
- Universal.Common.Json (>= 1.10.0)
- Universal.Common.Net.Http (>= 5.2.0)
- Universal.Common.Serialization (>= 2.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Universal.DeepSeek.Client:
| Package | Downloads |
|---|---|
|
Universal.Operative.Sdk.Discrete.DeepSeek
DeepSeek extensions for the Universal.Operative.Sdk. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Add typed multimodal chat content parts for text, image URLs/data URLs, and Files API references.