AI Skill Hub 强烈推荐:高性能AI网关 是一款优质的AI工具。AI 综合评分 8.0 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。
高性能AI网关,支持100+LLM API调用
高性能AI网关 是一款基于 Rust 开发的开源工具,专注于 ai-gateway、async-rust、api-client 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
高性能AI网关,支持100+LLM API调用
高性能AI网关 是一款基于 Rust 开发的开源工具,专注于 ai-gateway、async-rust、api-client 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:cargo install(推荐) cargo install litellm-rs # 方式二:从源码编译 git clone https://github.com/majiayu000/litellm-rs cd litellm-rs cargo build --release # 二进制在 ./target/release/litellm-rs
# 查看帮助 litellm-rs --help # 基本运行 litellm-rs [options] <input> # 详细使用说明请查阅文档 # https://github.com/majiayu000/litellm-rs
# litellm-rs 配置说明 # 查看配置选项 litellm-rs --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export LITELLM_RS_CONFIG="/path/to/config.yml"
A high-performance self-hosted LLM gateway with a stable OpenAI-compatible HTTP contract. The litellm-rs crate is the gateway's reusable Rust kernel, with narrower support policies for runtime-backed APIs and legacy compatibility adapters.
GET /openapi.jsonGET /admin/openapi.json```toml
cargo test --lib --tests --no-default-features --features "lite"CARGO_BUILD_JOBS=4 cargo test --lib --tests --no-default-features --features "lite" -- --test-threads=4--all-features unless you are doing release/nightly validationRun the primary supported product from source:
git clone https://github.com/majiayu000/litellm-rs.git
cd litellm-rs
cp config/gateway.dev.yaml.example config/gateway.yaml
cargo run --bin gateway
Or install the gateway binary:
cargo install litellm-rs --bin gateway
mkdir -p config
curl -L https://raw.githubusercontent.com/majiayu000/litellm-rs/main/config/gateway.dev.yaml.example -o config/gateway.yaml
gateway
The development config starts without provider credentials or auth secrets and uses the local vllm catalog provider. Use config/gateway.yaml.example for production-style deployments with real provider keys and auth enabled. Default features include SQLite storage, which satisfies the gateway binary's storage requirement.
The gateway serves its stable inference contract at GET /openapi.json; the versioned source is docs/openapi/inference.json. The admin control-plane contract is served at GET /admin/openapi.json (admin-authenticated) from docs/openapi/admin.json.
use litellm_rs::{completion, user_message, system_message};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = completion(
"gpt-4",
vec![
system_message("You are a helpful assistant."),
user_message("Hello!"),
],
None,
).await?;
println!("{}", response.choices[0].message.content.as_ref().unwrap());
Ok(())
}
The gateway router config maps these fields into the runtime router:
router.strategy selects the deployment routing strategy.router.circuit_breaker.failure_threshold controls consecutive failures before cooldown.router.circuit_breaker.recovery_timeout controls cooldown duration in seconds.router.circuit_breaker.min_requests sets the sample size required before cooldown.router.circuit_breaker.success_threshold sets the successes required to recover from cooldown.router.load_balancer.health_check_enabled enables pre-call deployment health checks.Active provider probes are opt-in: a provider's health_check must differ from the defaults. Native probes are limited to provider types whose configured deployment is unambiguously a chat model (currently Anthropic and GitHub Copilot); they send a one-token request and may incur provider charges. OpenAI, Bedrock, OpenAI-compatible, Vertex AI, FalAI, and other multi-capability providers require a custom health_check.endpoint. Without an active probe policy, readiness remains fail-closed (Unknown).
router.load_balancer.sticky_sessions and router.load_balancer.session_timeout are reserved for future session affinity. Non-default values fail config validation until runtime affinity is implemented.
Gateway YAML can publish stable model names and deterministic primary/fallback tiers:
providers:
- name: openai-primary
provider_type: openai
api_key: "${OPENAI_API_KEY}"
models: [gpt-4o]
priority: 0
- name: openai-fallback
provider_type: openai
api_key: "${OPENAI_API_KEY}"
models: [gpt-4o]
priority: 10
model_aliases:
production-chat: gpt-4o
stable-chat: production-chat
router:
strategy: priority_based
Alias chains are validated and flattened at startup; empty values, cycles, canonical-name collisions, and targets without an enabled deployment fail startup. Alias names appear in /v1/models alongside canonical models. Lower numeric priority wins under priority_based; omitted provider priorities default to 0. When rolling back to a binary that predates these fields, remove model_aliases and priority from YAML before rolling back the binary, because unknown fields are rejected.
Runtime wiring decisions are tracked in src/core/subsystem_registry.rs, and tests assert that every module exported from src/core/mod.rs is either referenced by the gateway runtime or explicitly classified. The current issue-838 subsystem decisions are:
| Subsystem | Decision | Runtime status |
|---|---|---|
core/guardrails | wire | Default-on prompt-injection checks run before provider execution and on non-streaming output; guardrails.enabled: false is the explicit opt-out. |
core/ip_access | wire | Configured allow/block rules run as an outer Actix middleware and short-circuit before downstream side effects; empty/default rules allow all. |
core/mcp | experimental-gate | Deprecated in 0.6 and excluded from default builds behind mcp; enabling it exposes library types but mounts no HTTP route. Removal is scheduled for 0.7. Responses API MCP descriptors still pass through independently. |
core/a2a | experimental-gate | Deprecated in 0.6 and excluded from default builds behind a2a; enabling it exposes library types but mounts no HTTP route. Removal is scheduled for 0.7. |
core/realtime | experimental-gate | Deprecated in 0.6 and default-off behind websockets; no gateway route is mounted. Removal is scheduled for 0.7. |
core/observability and core/integrations | wire | Configured Langfuse, OpenTelemetry, and Datadog backends are initialized at startup and receive real chat, completion, response, and embedding lifecycle events. |
core/audit | wire | enterprise.audit_logging: true registers request audit middleware; events use structured JSON on stderr unless a file or custom output is configured. Default is off. |
core/batch | library-only | /v1/batches remains a wired provider proxy. The unreachable BatchProcessor is deprecated in 0.6 and scheduled for removal in 0.7. |
core/webhooks | experimental-gate | Deprecated in 0.6 and excluded from default builds behind webhooks; it is not a gateway runtime capability and is scheduled for 0.7 removal. |
core/semantic_cache | remove | Deprecated but retained with storage during the 0.6 compatibility window; cache.semantic_cache=true remains rejected before the planned 0.7 removal. |
core/analytics | remove | Deprecated and default-off behind analytics, with removal planned for 0.7. |
core/virtual_keys | wire | Runtime virtual keys use the canonical core::keys::KeyManager; the duplicate legacy VirtualKeyManager is deprecated for 0.7 removal. |
core/user_management | internal/gated | Compatibility records back current auth/storage paths; the deprecated UserManager implementation is default-off behind user-management and scheduled for 0.7 removal. |
```bash
LITELLM_VERBOSE=true # Enable verbose logging ```
[dependencies] litellm-rs = { version = "0.6", default-features = false }
[dependencies] litellm-rs = { version = "0.6", default-features = false, features = ["lite"] }
OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... GOOGLE_API_KEY=... AZURE_OPENAI_API_KEY=... AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_REGION=us-east-1 GROQ_API_KEY=... AI21_API_KEY=... HF_TOKEN=... BASETEN_API_KEY=... DEEPSEEK_API_KEY=... MOONSHOT_API_KEY=... ZHIPU_API_KEY=... MINIMAX_API_KEY=...
default-features = false with features = ["lite"][dependencies] litellm-rs = { version = "0.6", default-features = false, features = ["gateway"] } ```
The following modules exist under src/core/providers/ (gated on providers-extra or providers-extended) but are not wired into the unified Provider enum or the factory today. They compile but cannot be selected through create_provider/from_config_async. Treat them as experimental scaffolding subject to change:
custom_api
For self-hosted or unlisted OpenAI-compatible endpoints, prefer the generic openai_compatible provider type instead.
litellm-rs 是一个高性能的 Rust 库和网关,用于在 OpenAI 兼容格式下调用 LLM API。它内置了 50+ 个 OpenAI 兼容提供商,首选适配器包括 OpenAI、Anthropic、AWS Bedrock、Mistral 和 Cloudflare。
litellm-rs 的功能包括:60+ 个 runtime-wired 提供商,OpenAI 兼容 API,高性能,智能路由等。
安装 litellm-rs 可以使用 Cargo,具体步骤如下:
使用 litellm-rs 的快速入门(5 分钟,API-Only 推荐):
环境变量配置:
作为库使用 litellm-rs 的 API 文档:
工作流和模块说明:
常见问题解答:
高性能AI网关,支持多个LLM API调用,值得关注
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,高性能AI网关 是一款质量优秀的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | litellm-rs |
| 原始描述 | 开源AI工具:A high-performance AI Gateway written in Rust — call 100+ LLM APIs using OpenAI 。⭐66 · Rust |
| Topics | ai-gatewayasync-rustapi-client |
| GitHub | https://github.com/majiayu000/litellm-rs |
| License | MIT |
| 语言 | Rust |
收录时间:2026-06-06 · 更新时间:2026-06-06 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。