Skip to main content

el_cloud/
lib.rs

1//! `el-cloud` — opt-in frontier LLM cloud backend (ADR-010).
2//!
3//! Implements [`el_core::LlmProvider`] over `reqwest` using the OpenAI Chat
4//! Completions API, which is supported natively by OpenAI, Anthropic (via
5//! compatibility layer), Ollama, and any OpenAI-compatible endpoint.
6//!
7//! Provider routing is by model prefix:
8//! - `"openai/<model>"` → `https://api.openai.com/v1`
9//! - `"anthropic/<model>"` → `https://api.anthropic.com/v1` (compat)
10//! - `"gemini/<model>"` → `https://generativelanguage.googleapis.com/v1beta/openai`
11//! - `"ollama/<model>"` → `http://localhost:11434/v1` (no key required)
12//! - `"http(s)://…/<model>"` → custom base URL
13//!
14//! The air-gap guarantee (ADR-004) is preserved: this crate is excluded from
15//! the default workspace build. Only apps that explicitly construct a
16//! [`CloudProvider`] opt into outbound network calls.
17//!
18//! # wasm32 note
19//! `reqwest::blocking` is unavailable on `wasm32-unknown-unknown` (no threads).
20//! The async reqwest surface exists there, but `LlmProvider::chat()` is
21//! synchronous and cannot await the browser's `fetch`. The el-ffi wasm32
22//! `cloud` constructor therefore throws an explicit "unavailable" error
23//! (ADR-010 amendment), and this crate's network modules are gated to
24//! non-wasm32.
25
26#![forbid(unsafe_code)]
27
28#[cfg(not(target_arch = "wasm32"))]
29mod openai_wire;
30#[cfg(not(target_arch = "wasm32"))]
31mod routing;
32
33#[cfg(not(target_arch = "wasm32"))]
34pub use routing::CloudProvider;