SharpInference.Server 0.7.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpInference.Server --version 0.7.0
                    
NuGet\Install-Package SharpInference.Server -Version 0.7.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="SharpInference.Server" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpInference.Server" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpInference.Server" />
                    
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 SharpInference.Server --version 0.7.0
                    
#r "nuget: SharpInference.Server, 0.7.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.
#:package SharpInference.Server@0.7.0
                    
#: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=SharpInference.Server&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=SharpInference.Server&version=0.7.0
                    
Install as a Cake Tool

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.

License

MIT. Copyright (c) 2026 Pekka Heikura.

Product 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. 
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
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
Loading failed