The Blind Protocol Engine - A pure, URL-agnostic adapter for LLM services.
Installation • Usage • Philosophy • Documentation • Synergy
🚀 The Pure Protocol Engine
llm-connector is a minimalist, standalone driver layer for AI providers. Unlike other libraries that maintain lists of provider endpoints, llm-connector adopts a Pure Gateway Architecture: it handles protocol adaptation, streaming, and token normalization, but remains completely "blind" to API endpoints.
- Zero Hardcoded URLs: No default endpoints. You provide the
base_url, we provide the protocol. - Pure Positioning: We don't care where the model is hosted (SaaS, Local, Private Cloud). We only care about the dialect (Protocol) it speaks.
- Standalone & Light:
llm-connectoris self-contained. It does not depend on any endpoint management projects or external databases.
🤝 Ecosystem Decoupling
While llm-connector is the engine (Protocol), it is designed to work seamlessly with (but not depend on) configuration managers like llm-providers.
- llm-connector: Handles how to talk (Request/Response logic).
- llm-providers: (External) Handles where to talk (URL/Region discovery).
This decoupling ensures that llm-connector remains a stable, logic-only library while the rapidly changing landscape of AI endpoints is managed elsewhere.
📊 Comparison
| Feature | llm-connector (Protocol Engine) |
Traditional SDKs / Libraries |
|---|---|---|
| Endpoint Logic | ❌ None. Mandatory base_url. |
✅ Hardcoded/Default URLs. |
| Maintenance | 🛠️ Low. Logic-only updates. | ⚠️ High. Constant URL/Region list syncing. |
| Self-Hosted | ✅ Native. Any URL works. | ⚠️ Often requires hacky overrides. |
| SaaS Gateway | ✅ Optimized. Perfect for proxies. | ❌ Often inflexible. |
🛠️ Installation
MSRV: Rust 1.85+ (Rust 2024 edition)
[]
= "1.0.2"
= { = "1", = ["full"] }
📖 Usage
Unified Chat
All client constructions now mandatorily require a base_url.
use ;
// Positioned as a blind protocol engine: You must provide the base_url
let client = openai?;
let request = new
.add_message;
let response = client.chat.await?;
println!;
Universal Streaming
use ;
use StreamExt;
let client = anthropic?;
let request = new.stream;
let mut stream = client.chat_stream.await?;
while let Some = stream.next.await
Fluent Builder
let client = builder
.openai
.base_url // Mandatory
.timeout
.build?;
Per-Request Overrides (Gateway Pattern)
Ideal for building unified AI gateways or multi-tenant proxies.
let request = new
.with_api_key
.with_base_url;
let response = client.chat.await?;
Advanced Features
Reasoning & Thinking
Support for reasoning models like OpenAI o1/o3 and Claude 3.7 Sonnet.
use ReasoningEffort;
let request = new
.add_message
.with_thinking_budget // Enable thinking with 16k token budget
.with_max_tokens; // Ensure max_tokens > thinking_budget
let response = client.chat.await?;
Dynamic Service Resolution
Resolve API keys and endpoints dynamically based on model name.
use ;
let resolver = new
.with_mapping
.with_mapping;
let target = resolver.resolve.await?;
// Use target.api_key and target.endpoint to configure your request
Request Overrides (Gateway Mode)
For gateway scenarios, you can override the API Key and Base URL per request without creating a new client.
let request = new
.with_api_key // Override API Key
.with_base_url; // Override Endpoint
let response = client.chat.await?;
File & Image Upload
Easily upload local files (Images, PDFs) with automatic Base64 encoding and MIME type detection.
use MessageBlock;
let request = new
.add_message
.add_message_block;
let response = client.chat.await?;
📂 Recent Changelogs
- v1.0.2 (2026-03-03)
+Google Gemini support: Full tool calling and reasoning (thinking) for Gemini 2.x and 3.x models.+Gemini 3.xthoughtSignature: Automatically captures and replays the mandatorythoughtSignaturefield required by Gemini 3.x for multi-turn tool conversations.+Gemini role mapping: Tool (function) responses correctly mapped to theuserrole required by thev1betaAPI.^ToolCall/FunctionCall: Added optionalthought_signaturefield for cross-provider extensibility.
- v1.0.1 (2026-03-02)
!BREAKING: Rebranded as a Pure Protocol Engine.!BREAKING: Removed all default/hardcoded URLs.base_urlis now mandatory for all client constructors.!BREAKING: Removed redundant provider files (deepseek,moonshot,volcengine, etc.) in favor of generic Protocol adapters.+Endpoints Module: Addedllm_connector::endpointsconstants for common API addresses (optional reference only).
- v0.7.1
+Embedding API: Unified.embed()support for major providers.+Document Support: AddedMessageBlock::Documentfor PDFs and files.^Usage: Addedprompt_cache_hit_tokenssupport.
📜 License
MIT