GitHub - microsoft/Foundry-Local (original) (raw)

Foundry Local is an end-to-end local AI solution for building applications that run entirely on the user's device. It provides native SDKs (C#, JavaScript, Python, and Rust), a curated catalog of optimized models, and automatic hardware acceleration — all in a lightweight package (~20 MB). The compact size makes it easy to integrate into your application and distribute to end users.

User data never leaves the device, responses start immediately with zero network latency, and your app works offline. No per-token costs, no API keys, no backend infrastructure to maintain, and no Azure subscription required.

Key Features

🚀 Quickstart

Tip

The following shows a quickstart for Python and JavaScript. C# and Rust language bindings are also available. Take a look at the samples for more details.

JavaScript

  1. Install the SDK:

Windows (recommended for hardware acceleration)

npm install foundry-local-sdk-winml

macOS/linux

npm install foundry-local-sdk 2. Run your first chat completion:
import { FoundryLocalManager } from 'foundry-local-sdk';
const manager = FoundryLocalManager.create({ appName: 'my-app' });
// Download and load a model (auto-selects best variant for user's hardware)
const model = await manager.catalog.getModel('qwen2.5-0.5b');
await model.download((progress) => {
process.stdout.write(\rDownloading... ${progress.toFixed(2)}%);
});
await model.load();
// Create a chat client and get a completion
const chatClient = model.createChatClient();
const response = await chatClient.completeChat([
{ role: 'user', content: 'What is the golden ratio?' }
]);
console.log(response.choices[0]?.message?.content);
// Unload the model when done
await model.unload(); Python

  1. Install the SDK:

Windows (recommended for hardware acceleration)

pip install foundry-local-sdk-winml

macOS/Linux

pip install foundry-local-sdk 2. Run your first chat completion:
from foundry_local_sdk import Configuration, FoundryLocalManager
config = Configuration(app_name="foundry_local_samples")
FoundryLocalManager.initialize(config)
manager = FoundryLocalManager.instance

Select and load a model from the catalog

model = manager.catalog.get_model("qwen2.5-0.5b")
model.download()
model.load()

Get a chat client

client = model.get_chat_client()

Create and send message

messages = [
{"role": "user", "content": "What is the golden ratio?"}
]
response = client.complete_chat(messages)
print(f"Response: {response.choices[0].message.content}")
model.unload()

💬 Audio Transcription (Speech-to-Text)

The SDK also supports audio transcription via Whisper models (available in JavaScript, C#, Python and Rust):

import { FoundryLocalManager } from 'foundry-local-sdk';

const manager = FoundryLocalManager.create({ appName: 'my-app' });

const whisperModel = await manager.catalog.getModel('whisper-tiny'); await whisperModel.download(); await whisperModel.load();

const audioClient = whisperModel.createAudioClient(); audioClient.settings.language = 'en';

// Transcribe an audio file const result = await audioClient.transcribe('recording.wav'); console.log('Transcription:', result.text);

// Or stream in real-time for await (const chunk of audioClient.transcribeStreaming('recording.wav')) { process.stdout.write(chunk.text); }

await whisperModel.unload();

Tip

A single FoundryLocalManager can manage both chat and audio models simultaneously. See the chat-and-audio sample for a complete example.

📦 Samples

Explore complete working examples in the samples/ folder:

Language Samples Highlights
C# 12 Native chat, audio transcription, tool calling, model management, web server, tutorials
JavaScript 12 Native chat, audio, Electron app, Copilot SDK, LangChain, tool calling, tutorials
Python 9 Chat completions, audio transcription, LangChain, tool calling, tutorials
Rust 8 Native chat, audio transcription, tool calling, web server, tutorials

🖥️ CLI

The Foundry Local CLI lets you explore models and experiment interactively.

Install (public preview):

Download the asset for your platform from the cli-preview-0.10.0 GitHub release.

Run a model:

List available models:

For the full CLI reference and advanced usage, see the CLI documentation on Microsoft Learn.

Reporting Issues

Please report issues or suggest improvements in the GitHub Issues section.

🎓 Learn More

❔ Frequently asked questions

Is Foundry Local a web server and CLI tool?

No. Foundry Local is an end-to-end local AI solution that your application ships with. It handles model acquisition, hardware acceleration, and inference inside your app process through the SDK. The optional web server and CLI are available for development workflows, but the core product is the local AI runtime and SDK that you integrate directly into your application.

Why doesn't Foundry Local support every available model?

Foundry Local is designed for shipping production applications, not for general-purpose model experimentation. The model catalog is intentionally curated to include models that are optimized for specific application scenarios, tested across a range of consumer hardware, and small enough to distribute to end users. This approach ensures that every model in the catalog delivers reliable performance when embedded in your application — rather than offering a broad selection of models with unpredictable on-device behavior.

Can Foundry Local run on a server?

Foundry Local is optimized for hardware-constrained devices where a single user accesses the model at a time. While you can technically install and run it on server hardware, it isn't designed as a server inference stack.

Server-oriented runtimes like vLLM or Triton Inference Server are built for multi-user scenarios — they handle concurrent request queuing, continuous batching, and efficient GPU sharing across many simultaneous clients. Foundry Local doesn't provide these capabilities. Instead, it focuses on lightweight, single-user inference with automatic hardware detection, KV-cache management, and model lifecycle handling that make sense for client applications.

If you need to serve models to multiple concurrent users, use a dedicated server inference framework. Use Foundry Local when the model runs on the end user's own device.

What platforms are supported?

Foundry Local supports Windows, macOS (Apple silicon), and Linux.

⚖️ License

Foundry Local SDK is licensed under the MIT license. For more details, see the LICENSE file. Foundry Local CLI is licensed under the Microsoft Software License Terms. For more details, read the LICENSE file.

Individual models made available for use with Foundry Local are subject to the each model's license terms, notices, and use restrictions. Refer to the model's documentation or download/listing page for the applicable terms before using or redistributing a model.