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.jsonSince 0.8.0, default features select the reusable library with metrics and tracing. Gateway and database dependencies are opt-in. The previous 0.7.0 release used gateway defaults; gateway consumers must explicitly select a storage feature such as sqlite or postgres.
```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 --features sqlite
Or install the gateway binary:
cargo install litellm-rs --version 0.8.2 --locked --bin gateway --no-default-features \
--features postgres,sqlite,redis,s3,metrics,tracing,websockets,providers-extra,providers-extended,mcp-validation,a2a
mkdir -p config
curl -L https://raw.githubusercontent.com/majiayu000/litellm-rs/v0.8.2/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. The explicit sqlite feature enables the storage needed by the gateway binary. The registry install selects the same feature profile as release archives and containers, including MCP, A2A and Realtime. Binary and example config versions must match. See the 0.8 artifact verification for source and published-artifact verification.
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.
API-key budgets currently use process-local definitions and counters. Persisting a key's budget_id does not restore its budget after restart or share its balance with another gateway; an unavailable binding fails closed. The key management API rejects max_budget. Redis-backed provider/model budgets are a separate scope; see the budget capability boundary.
For a first HTTP request or setup failure, use the gateway setup and compatibility questions.
Add Tokio with macros and rt-multi-thread features. The application must install its configured RuntimeBinding with install_default_runtime before calling completion; the verified consumer example shows runtime setup and successful calls against a local mock.
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 | feature-gated | gateway,mcp mounts authenticated Streamable HTTP at /{server_name}/mcp (/mcp for one enabled server). See [MCP gateway](docs/gateway/mcp.md) for configuration and stateless transport limits. Responses API MCP descriptors pass through independently. |
core/a2a | experimental-gate | Opt-in gateway,a2a exposes authenticated A2A 1.0 agent cards, messages, task queries/cancellation and SSE. Task ownership is process-local; see [A2A gateway](docs/gateway/a2a.md). |
server/routes/ai/realtime | feature-gated | gateway,websockets mounts the [manual OpenAI Realtime gateway](docs/gateway/realtime.md). The unused legacy core/realtime client has been removed. |
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. Domain records and async batch helpers remain; the unreachable BatchProcessor has been removed. |
Former core/webhooks | removed | The unused library and webhooks feature have been removed in 0.8.0. Budget-alert delivery and provider-native webhook fields remain separate. |
Former core/semantic_cache and core/analytics | removed | Removed in 0.8.0 after the expired 0.7 deadline. Deterministic caching, request metrics and callbacks remain; see the migration guide for removed fields/features. |
core/virtual_keys | wire | Runtime virtual keys use the canonical core::keys::KeyManager; the duplicate legacy manager has been removed. Storage record types remain in use. |
core/user_management | internal | Domain records back current auth/storage paths. The unused UserManager and its user-management feature have been removed. |
[dependencies] litellm-rs = { version = "0.8", default-features = false }
```bash
LITELLM_VERBOSE=true # Enable verbose logging ```
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"]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 不对第三方内容的准确性作法律背书。