C# · .NET 10 · GGUF · Local inference

TensorSharp

Local AI. Native .NET.

Run text and multimodal models, generate images and video, and build agent workflows with one C# inference engine. Use the CLI, browser chat, Ollama- and OpenAI-compatible APIs, or your own .NET application.

Your models. Your hardware. Local inference with no metered API required.

What you can do with TensorSharp

From a first local chat to an application that serves models and uses tools.

Choose how you want to run it

Start with the interface that fits your task. All three use TensorSharp.

Terminal

Run a model locally

Use the CLI for chat, multimodal input, batches and benchmarks. The first-run guide covers SDK setup, model downloads and backends.

CLI quick start →

Browser & APIs

Serve your applications

Run the server and Web UI, then connect clients through chat, Responses and embedding endpoints.

Server and Web UI guide →

Desktop app

Use TensorAgent

Install on Apple Silicon Mac or Windows x64, download a model in the app, and start chatting or working with tools.

Download and install →

Pick a model and backend

New to source builds? Start with the Gemma 4 E4B walkthrough. See compute backends for Apple Silicon, NVIDIA, Vulkan and CPU setup. Model weights download separately.

Packages reflect their release tag; current source can include newer features. Check the desktop guide for available assets and platform requirements. iPhone and iPad use source builds.

See it running

One engine, four ways to use it, each an unedited capture of a real run. Select one to see it full size.

TensorSharp.Cli in a terminal: an interactive chat with Gemma 4 E4B on Metal that reads the project README and answers two questions about it

TensorSharp.Cli

Run models, chats and benchmarks from a terminal.

Command Line →
The TensorSharp Web UI: Qwen3.8 27B compared two mortgages by writing and running a Python script, answered with a table and a recommendation, and offered the script and the CSV as downloads

Web UI chat · TensorSharp.Server.Host

A browser chat plus Ollama- and OpenAI-compatible APIs.

Server & Web UI →
TensorAgent in the iPhone simulator: Gemma 4 E2B scaled a recipe from 4 to 10 people by running a Python script in the app's built-in Python, and answered with a table

TensorAgent for iPhone

Local chat and code tools, shown in the iPhone simulator.

TensorAgent for iOS →
TensorAgent on a Mac: Qwen-Image 2.1 edits a TensorSharp banner to a deep blue night sky with stars while preserving the text, with Compare original and Edit again controls below the result

TensorAgent on the desktop

Qwen-Image 2.1 edits an attached image from an instruction. Text chat, files, code, browser skills and video share the same app.

TensorAgent on the Mac and Windows →

Supported model families

Image & video generation

Embeddings · BERT / XLM-R

Backend availability, input modalities, tool calling, and validation vary by family. Compare model capabilities →

Built for repeated and concurrent work

Reuse context and batch requests

Continuous batching and paged KV caching with Radix prefix sharing are enabled by default. Optional speculative decoding offers another path to lower latency on supported models.

Explore serving features →

Use more of your hardware

Selected architectures support multi-GPU layer placement, tensor parallelism and multi-node execution. SSD-backed expert offload can make selected large MoE models fit beyond RAM.

Check scaling support →

Go deeper

For developers, researchers and anyone learning how local inference works: follow the architecture, APIs, model cards and measured results.

Learn with the books

Two books by Zhongkai Fu turn the TensorSharp source into guided implementation journeys.

Cover of Building LLM Inference Engines and Agentic Runtimes from Scratch: Qwen Dense and MoE Models with TensorSharp and TensorAgent by Zhongkai Fu

Qwen · Inference & agents

Building LLM Inference Engines and Agentic Runtimes from Scratch

Qwen Dense and MoE Models with TensorSharp and TensorAgent

Follow a C# implementation from tensors and tokenization to Qwen dense and MoE inference, then to agent tools, skills, code execution, and sandbox boundaries. TensorSharp and TensorAgent connect the design to GPU optimization, multimodal input, and desktop and mobile deployment.

Cover of From Tensors to Tokens: Building a Multimodal LLM Inference Engine from Scratch with TensorSharp and Gemma 4 E4B by Zhongkai Fu

Gemma 4 · Multimodal inference

From Tensors to Tokens

Building a Multimodal LLM Inference Engine from Scratch with TensorSharp and Gemma 4 E4B

Build a multimodal inference engine in C# and .NET using Gemma 4 E4B. Work through tensor storage, GGUF loading, quantization, and tokenization, then explore image, video, and audio inputs, numerical checks, caching, and batching.

Support the project

TensorSharp and TensorAgent are free. If they help you, a coffee supports continued development.

Buy Me A Coffee