Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
91eb27e
initial commit of rust v2 sdk
samuel100 Jun 22, 2026
3dcb833
bug fixes
samuel100 Jun 22, 2026
b76c4bd
WebGpu error fix
samuel100 Jun 24, 2026
d92a1e5
Make FoundryLocalManager a shared (Arc) resettable singleton
samuel100 Jun 24, 2026
8ef0679
Tie native handle lifetimes to the manager; serialize native create/r…
samuel100 Jun 24, 2026
3891878
Merge remote-tracking branch 'origin/main' into samuel100/sdkv2-rust
samuel100 Jun 24, 2026
ee7082c
Realign Rust FFI item vtable with new speech result types in C ABI
samuel100 Jun 24, 2026
c631717
Read speech result items in live audio transcription
samuel100 Jun 24, 2026
f129168
Address PR #836 review comments (sdk_v2/rust)
samuel100 Jun 29, 2026
f754f7d
Merge remote-tracking branch 'origin/main' into samuel100/sdkv2-rust
samuel100 Jul 27, 2026
bb939b1
Add idiomatic Session/Item/Request/Response inference API to Rust SDK
samuel100 Jul 27, 2026
c1c7793
Fix OpenAI direct chat request JSON and deprecate OpenAI direct clien…
samuel100 Jul 27, 2026
e06ff9e
samples(rust): migrate SDK examples to the Session API
samuel100 Jul 27, 2026
9de7fe0
fix(rust): resolve Copilot PR review comments
samuel100 Jul 30, 2026
2d8203b
Fix manager singleton lifetime when derived handles outlive the outer…
samuel100 Jul 30, 2026
fc497a9
Align Rust SDK to unified single runtime package (drop WinML flavor)
samuel100 Jul 30, 2026
a9df530
Add sdk_v2 Rust SDK CI/CD pipeline (build/test/pack parity)
samuel100 Jul 30, 2026
1dc1670
Fix Rust toolchain setup in v2 pipeline
samuel100 Aug 5, 2026
008a51a
Merge main into Rust SDK branch
samuel100 Aug 5, 2026
51fcd6c
Update Rust SDK for current ORT packages
samuel100 Aug 5, 2026
0eee006
Stabilize Rust SDK integration tests
samuel100 Aug 5, 2026
65ed610
Release Rust test manager before process teardown
samuel100 Aug 5, 2026
4e03bb6
Fix stale Rust model cache metadata
samuel100 Aug 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk_v2/rust/.clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Clippy configuration for Foundry Local Rust SDK
msrv = "1.70"
3 changes: 3 additions & 0 deletions sdk_v2/rust/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
edition = "2021"
max_width = 100
use_field_init_shorthand = true
50 changes: 50 additions & 0 deletions sdk_v2/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "foundry-local-sdk"
version = "2.0.0"
edition = "2021"
license = "MIT"
readme = "README.md"
description = "Local AI model inference powered by the Foundry Local Core engine"
homepage = "https://www.foundrylocal.ai/"
repository = "https://github.com/microsoft/Foundry-Local"
documentation = "https://github.com/microsoft/Foundry-Local/blob/main/sdk_v2/rust/docs/api.md"
include = ["src/**", "build.rs", "Cargo.toml", "README.md", "LICENSE.txt", "deps_versions.json"]
Comment thread
samuel100 marked this conversation as resolved.

[features]
default = []
winml = []
nightly = []

[dependencies]
libloading = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync"] }
tokio-stream = "0.1"
tokio-util = "0.7"
futures-core = "0.3"
reqwest = { version = "0.12", features = ["json"] }
urlencoding = "2"
async-openai = { version = "=0.33.1", default-features = false, features = ["chat-completion-types", "embedding-types"] }

[build-dependencies]
ureq = "3"
zip = "2"
serde_json = "1"
serde = { version = "1", features = ["derive"] }

[[example]]
name = "chat_completion"
path = "examples/chat_completion.rs"

[[example]]
name = "tool_calling"
path = "examples/tool_calling.rs"

[[example]]
name = "interactive_chat"
path = "examples/interactive_chat.rs"

[lints.clippy]
all = { level = "warn", priority = -1 }
41 changes: 41 additions & 0 deletions sdk_v2/rust/GENERATE-DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generating API Reference Docs

The Rust SDK uses `cargo doc` to generate API documentation from `///` doc comments in the source code.

## Viewing Docs Locally

To generate and open the API docs in your browser:

```bash
cd sdk_v2/rust
cargo doc --no-deps --open
```

This generates HTML documentation at `target/doc/foundry_local_sdk/index.html`.

## Public API Surface

The SDK re-exports all public types from the crate root. Key modules:

| Module / Type | Description |
|---|---|
| `FoundryLocalManager` | Entry point — SDK initialisation, web service lifecycle |
| `FoundryLocalConfig` | Configuration (app name, log level, service endpoint) |
| `Catalog` | Model discovery and lookup |
| `Model` | Grouped model (alias → best variant) |
| `DownloadBuilder` | Builder for model downloads (progress, cancellation) |
| `ChatClient` | OpenAI-compatible chat completions (sync + streaming) |
| `AudioClient` | OpenAI-compatible audio transcription (sync + streaming) |
| `CreateChatCompletionResponse` | Typed chat completion response (from `async-openai`) |
| `CreateChatCompletionStreamResponse` | Typed streaming chat chunk (from `async-openai`) |
| `AudioTranscriptionResponse` | Typed audio transcription response |
| `FoundryLocalError` | Error enum with variants for all failure modes |

## Notes

- Unlike the C# and JS SDKs which commit generated markdown docs, Rust's convention is to generate HTML docs on demand with `cargo doc`.
- Once the crate is published to crates.io, docs will be automatically hosted at [docs.rs](https://docs.rs).
- Use `--document-private-items` to include internal/private API in the generated docs:
```bash
cargo doc --no-deps --document-private-items --open
```
21 changes: 21 additions & 0 deletions sdk_v2/rust/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading