Skip to main content

NeuralBridge - AI Agent 自愈引擎。三层故障自愈:L1 自动重试 → L2 语义等价降级 → L3 Failover 兜底。内置本地监控面板,依赖 httpx + aiohttp,pip install 即可接入。

Project description

NeuralBridge SDK — AI Agent 自愈引擎

PyPI version Python Downloads License

开发者优先的 AI API 平台。SDK 嵌入你的进程,控制台观测一切。 不是 Gateway,不需要 Docker,一行 pip install 获得生产级容错。

pip install neuralbridge-sdk
  • SDK-first — 核心价值在代码里,不在网页上。pip install 直接进入你的 Python 进程。
  • 嵌入式 — 进程内运行,零外部依赖,不是外部 Gateway 服务。
  • 控制台观测层 — 实时延迟监控、Provider 健康、自愈记录、成本分析,全部在 neuralbridge.cn 控制台。
  • 混合计费 — 免费体验 + 按量计费(¥0.1/次起)+ 月付订阅(¥99/¥199/¥699),灵活匹配使用规模。

🚀 一行代码接入自愈引擎

import neuralbridge as nb
import asyncio

engine = nb.SelfHealingEngine()
engine.add_provider(nb.ProviderConfig(
    name="deepseek",
    base_url="https://api.deepseek.com/v1",
    api_key="sk-your-key",
    models=["deepseek-v4-flash"],
))

result = asyncio.run(engine.call("你好,请用一句话介绍自己"))
print(result.text)
# Output: 你好!我是 NeuralBridge 自愈引擎...

🔥 核心能力

能力 说明 竞品对比
🩺 自愈恢复 API 故障自动切换备用 Provider LiteLLM 只转发不恢复
✅ 输出验证 Contract 机制确保恢复结果有效 LangSmith 只看不验证
📌 断点续跑 Agent 中途崩溃可从中断处恢复 L1-L4 级联恢复
🛡️ 国内支持 原生支持 DeepSeek/阿里云/月之暗面 LangSmith 需翻墙
💰 BYOK 客户用自己的 API Key,不走中转 省钱又安全
📊 监控面板 实时延迟/Provider 健康/自愈记录/成本
♻️ 智能路由 成本/延迟/质量多策略路由
🌱 碳追踪 LLM 调用碳排放统计

📦 安装

pip install neuralbridge-sdk

支持 Python 3.8+。包体积 ~1MB,仅 1 个运行时依赖(httpx)。

🎯 为什么选择 NeuralBridge?

vs LiteLLM

LiteLLM 是 API 网关——它转发请求,如果挂了就报错。NeuralBridge 是 SDK 内建的自愈引擎——如果 A 挂了,自动切换到 B,并验证 B 的输出是否有效

vs LangSmith / Langfuse

它们是观测平台——告诉你系统出了问题。NeuralBridge 是修复平台——发现问题后自动修复。自带 Web 控制台用于观测和管理。

vs 自研容灾

你需要投入团队维护。NeuralBridge 是开箱即用的一行代码。

🏗️ 架构

用户请求 → SelfHealingEngine → Monitor(监控)
                                   ↓
                              Analyze(诊断) 
                                   ↓
                              Plan(计划恢复)
                                   ↓
                              Execute(执行切换)
                                   ↓
                              Knowledge(学习优化)
                                   ↓
                              Contract Validation(输出验证)
                                   ↓
                             ✅ 有效结果

SDK 运行在你的进程内,控制台通过 neuralbridge.cn 访问,实时展示:

观测维度 内容
📈 API 延迟实时波形 60 秒滚动,基线/阈值线,P50/P95/P99
🏥 Provider 健康 8 个 Provider 在线/降级/离线实时状态
🔔 异常事件推送 Provider 离线、降级、恢复实时通知
🛡️ 自愈记录 L1-L4 各层级触发次数、耗时、节省成本
💰 用量 & 成本 实时调用量、费用、余额

🧪 更多示例

BYOK 模式(自备 Key)

nb-doctor setup --provider deepseek --key sk-your-key

Contract 输出验证

contract = nb.Contract(
    required_entities=["def ", "return"],
)
result = asyncio.run(engine.call(
    "写一个 Python 函数",
    model="deepseek-v4-pro",
    contract=contract,
))
# 输出不符合合约时自动重试

OpenAI 兼容代理模式

import neuralbridge as nb

server = nb.serve(
    host="127.0.0.1", port=8080,
    providers=["deepseek"],
    api_keys={"deepseek": "sk-your-key"},
)
server.serve_forever()
# Codex/任何 OpenAI 客户端可接入:
# base_url=http://localhost:8080/v1

💳 定价

方案 价格 适用场景
🎁 免费体验 ¥0 12 项 API 安全检查、基础诊断、报告生成
💰 按量计费 ¥0.1/次起 余额永久有效,按调用量扣费
👤 个人版 ¥99/月 个人开发者,每月 10 万次调用
🚀 专业版 ¥199/月 小团队,每月 50 万次调用
🔬 深度版 ¥699/月 企业级,每月 500 万次调用
🏢 企业定制 另议 私有部署、SLA、专属支持

在线购买/充值: neuralbridge.cn/buy

🗺️ 路线图

  • 智能路由与自愈
  • Contract 输出验证
  • Checkpoint 断点续跑
  • BYOK 自备 Key 模式
  • Web 控制台(实时监控/自愈记录/成本分析)
  • 按量计费 & 订阅支付
  • Windows .pyd 原生支持
  • 企业版私有化部署
  • 中文文档站

📄 许可证

Apache 2.0

🤝 联系

Real-World Performance (from Flywheel Logs)

Metric Data
Self-Heal Rate 84.1%
Successful Recoveries 5,085
Failed 964
Learned Rules 84
Health Check Overhead 0.0025ms
Package Size 357KB
Dependencies 1 (httpx)

⚠️ 以上数据来自内部 Flywheel 日志统计,基于特定测试环境和故障场景。实际表现可能因网络、Provider 状态和配置不同而有差异。

vs The Competition

Capability NeuralBridge LiteLLM LangSmith Langfuse AgentRx
Self-Healing L1-L4 cascading Fallback only Read-only Read-only Diagnosis only
Output Validation Contract Academic
Checkpoint/Resume
三合一 (自愈+验证+续跑)
Web Console (Observability)
自愈可视化 (Failover 时间线) ✅ 独家

Three months. One person. One dependency. One line of code. pip install neuralbridge-sdk

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

neuralbridge_sdk-5.6.0-cp313-cp313-musllinux_1_2_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

neuralbridge_sdk-5.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

neuralbridge_sdk-5.6.0-cp312-cp312-musllinux_1_2_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

neuralbridge_sdk-5.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

neuralbridge_sdk-5.6.0-cp311-cp311-musllinux_1_2_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

neuralbridge_sdk-5.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

neuralbridge_sdk-5.6.0-cp310-cp310-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

neuralbridge_sdk-5.6.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

neuralbridge_sdk-5.6.0-cp39-cp39-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

neuralbridge_sdk-5.6.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file neuralbridge_sdk-5.6.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1668b78f1d60c3408aa009fb32ffd8c66e223f38ac852f5fd4c0689d7000a3df
MD5 423256d117a736936c9baeb09fbfb217
BLAKE2b-256 fb74b988b94fbd522ed2b40eac014a08aaf921bca4b864268f31438562cefdc7

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e6b8da4002ab73f1a0f8e75bce537d52e98051551e34dca42af5cab0de79e466
MD5 458cb4b207c8a1700a6bc0b698643ea8
BLAKE2b-256 6689481ab30de701defe6ed8082565fe548edcc076ca7cfda942c9ab01ca1d5e

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 46a25d9282071777f38f9faa8197e50edb6b730cf4c3695212ab773c215d8daf
MD5 c4f83495c5c2d0b279ac499423330370
BLAKE2b-256 6ed6bb7b881dbc4aadc6c421f9517e252a9890af28cc98db25f9bfc7a7b5f89c

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 14d71ff3f76e5380e84b546db49e0ace21108efa57f1908a7bef6ecf1fcf1f52
MD5 02663f8fda0b8f808a6dd2605dc5bbc5
BLAKE2b-256 34f53fc2259a30fc2d477b5767808347ad6b4c8368663695b20a9785b4f5f295

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 337a17d765e000da27e384202895231eaea3e99b9ac6806b56261bd9da1f780a
MD5 a05391f72e3d5b9139e8fb313bc7aeb4
BLAKE2b-256 06aca24141fcc309d893fea03ac14c982acebfba2826ef3f3dd88632c735b50e

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7101afd17029cb10c0fbcd1a8edfe823e7658e11720e2a8a95c571a52af36b7d
MD5 0f9184ff52281532206629702276d348
BLAKE2b-256 57857a067ab8909be0b38b4c0b2746f358bc827a54139f41fbea1569468ea5b8

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c11d97745b5fddcb7ff631536556ff840ea461c3382c00f2b34cb44b9e8f8acf
MD5 e00a6daadf132776a44660dd52f1047c
BLAKE2b-256 630574c5d0a5074f306e7222de946132f5b177f2dfd33e8d1b3d7ac46deb9195

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9fa9bff7dd4a31075c61ec1fff586b0a58163d360fc166962010a8816535b2e9
MD5 23d794cc008a57caa118b14842f74ed7
BLAKE2b-256 5b0d693051a8586167fc3fae0cb09054cd8bc92ea145b1f364cefc8dd9728f99

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fbaf91f137666c09aa2d7c23516d1a16d26f0779e6c791d79c9d092bac570cba
MD5 a6bff120e429d0a273c67aa10cbc6297
BLAKE2b-256 0359b9709544af47ccf7020445a390ffadcb22776dfb6479c03e5d546685fef7

See more details on using hashes here.

File details

Details for the file neuralbridge_sdk-5.6.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for neuralbridge_sdk-5.6.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 adddf106adc460357a41af0593ebdf1705425ca0bfeb2ba23eb694c2b1ab3305
MD5 1174a714060059d929890f098647c54e
BLAKE2b-256 4a5b1fd59c036d133efd8236244a10fa49810d7f6d5ddd31de0d41c44a61dedb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page