SharpInference.Server
0.7.2-alpha.0.10
See the version list below for details.
dotnet add package SharpInference.Server --version 0.7.2-alpha.0.10
NuGet\Install-Package SharpInference.Server -Version 0.7.2-alpha.0.10
<PackageReference Include="SharpInference.Server" Version="0.7.2-alpha.0.10" />
<PackageVersion Include="SharpInference.Server" Version="0.7.2-alpha.0.10" />
<PackageReference Include="SharpInference.Server" />
paket add SharpInference.Server --version 0.7.2-alpha.0.10
#r "nuget: SharpInference.Server, 0.7.2-alpha.0.10"
#:package SharpInference.Server@0.7.2-alpha.0.10
#addin nuget:?package=SharpInference.Server&version=0.7.2-alpha.0.10&prerelease
#tool nuget:?package=SharpInference.Server&version=0.7.2-alpha.0.10&prerelease
SharpInference.Server
ASP.NET Core endpoints, options, and DI extensions that expose SharpInference as a drop-in OpenAI- and Anthropic-compatible HTTP API. Bring your own host (Kestrel, IIS, YARP, …); this package only ships the routes, request/response shapes, and DI wiring.
For the bare inference library, use SharpInference. For the standalone CLI, use SharpInference.Cli.
Install
dotnet add package SharpInference.Server
This transitively pulls in SharpInference (the bundled inference engine + CPU/Vulkan/CUDA backends). You must be on the Microsoft.NET.Sdk.Web SDK — the package's Microsoft.AspNetCore.App framework reference is propagated.
Quick start
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSharpInference(opt =>
{
opt.ModelPath = "models/SmolLM2-1.7B-Instruct-Q4_K_M.gguf";
opt.GpuLayers = -1; // -1 = all layers on GPU; 0 = pure CPU
});
var app = builder.Build();
app.MapSharpInference();
app.Run();
Bind from configuration instead:
// appsettings.json: { "SharpInference": { "ModelPath": "...", "GpuLayers": -1 } }
builder.Services.AddSharpInference(builder.Configuration);
What you get
| Endpoint | Wire-compatible with |
|---|---|
POST /v1/chat/completions |
OpenAI Chat Completions |
POST /v1/completions |
OpenAI Completions |
POST /v1/messages |
Anthropic Messages |
POST /v1/responses |
OpenAI Responses |
GET /v1/models |
OpenAI Models |
GET /health, /metrics |
Liveness + Prometheus |
Streaming (SSE) is enabled for every chat/completion endpoint, and the JSON pipeline is wired through a source-generated JsonSerializerContext so the package is AOT-friendly even though the project itself is not AOT-published.
Configuration
SharpInferenceServerOptions is the single options record (Options pattern, validated on first request):
public sealed class SharpInferenceServerOptions
{
public string ModelPath { get; set; } = "";
public int GpuLayers { get; set; } // -1 = all, 0 = CPU-only
public int MaxContext { get; set; } = 4096;
public string? Architecture { get; set; } // override GGUF detection
public Func<IServiceProvider, LoadedEngine>? EngineFactory { get; set; } // tests
// …
}
Override EngineFactory in tests to inject a fake IInferenceEngine; the rest of the DI graph (chat-template renderer, metrics, JSON context) stays intact.
Links
License
MIT. Copyright (c) 2026 Pekka Heikura.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- SharpInference (>= 0.7.2-alpha.0.10)
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 |
|---|---|---|
| 0.7.2-alpha.0.12 | 20 | 6/7/2026 |
| 0.7.2-alpha.0.11 | 24 | 6/7/2026 |
| 0.7.2-alpha.0.10 | 28 | 6/7/2026 |
| 0.7.2-alpha.0.9 | 26 | 6/7/2026 |
| 0.7.2-alpha.0.8 | 34 | 6/7/2026 |
| 0.7.2-alpha.0.7 | 31 | 6/7/2026 |
| 0.7.2-alpha.0.6 | 36 | 6/6/2026 |
| 0.7.2-alpha.0.5 | 44 | 6/6/2026 |
| 0.7.2-alpha.0.4 | 40 | 6/6/2026 |
| 0.7.2-alpha.0.3 | 38 | 6/6/2026 |
| 0.7.2-alpha.0.2 | 43 | 6/5/2026 |
| 0.7.2-alpha.0.1 | 37 | 6/5/2026 |
| 0.7.1 | 51 | 6/4/2026 |
| 0.7.1-alpha.0.1 | 41 | 6/4/2026 |
| 0.7.0 | 38 | 6/4/2026 |
| 0.6.1-alpha.0.9 | 39 | 6/4/2026 |
| 0.6.1-alpha.0.8 | 39 | 6/4/2026 |
| 0.6.1-alpha.0.7 | 38 | 6/4/2026 |
| 0.6.1-alpha.0.6 | 43 | 6/4/2026 |
| 0.6.1-alpha.0.5 | 39 | 6/4/2026 |