foundry_local/lib.rs
1//! # Foundry Local SDK
2//!
3//! A Rust SDK for interacting with the Microsoft Foundry Local service.
4//! This SDK allows you to manage and use AI models locally on your device.
5//!
6//! ## Features
7//! - Start and manage the Foundry Local service
8//! - Download models from the Foundry catalog
9//! - Load and unload models
10//! - List available, cached, and loaded models
11//! - Interact with loaded models using a simple API
12//!
13//! ## Example
14//!
15//! ```rust
16//! use foundry_local::FoundryLocalManager;
17//! use anyhow::Result;
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<()> {
21//! // Create a FoundryLocalManager instance for a model with default options
22//! let mut manager = FoundryLocalManager::builder()
23//! .alias_or_model_id("phi-4-mini")
24//! .build()
25//! .await?;
26//!
27//! // Use the OpenAI compatible API to interact with the model
28//! let client = reqwest::Client::new();
29//! let response = client.post(&format!("{}/chat/completions", manager.endpoint()?))
30//! .header("Content-Type", "application/json")
31//! .header("Authorization", format!("Bearer {}", manager.api_key()))
32//! .json(&serde_json::json!({
33//! "model": manager.get_model_info("phi-4-mini", true).await?.id,
34//! "messages": [{"role": "user", "content": "What is the golden ratio?"}],
35//! }))
36//! .send()
37//! .await?;
38//!
39//! let result = response.json::<serde_json::Value>().await?;
40//! println!("{}", result["choices"][0]["message"]["content"]);
41//!
42//! Ok(())
43//! }
44//! ```
45
46pub mod api;
47mod client;
48pub mod models;
49mod service;
50
51pub use api::FoundryLocalManager;