返回顶部
A

AI Provider Bridge — Unified API for Anthropic/OpenAI/Google/xAI/Mistral/OllamaAI提供商桥

One interface to call 6 AI providers. Swap models with a config change, not a code rewrite. Zero external dependencies.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.3
安全检测
已通过
306
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

AI Provider Bridge — Unified API for Anthropic/OpenAI/Google/xAI/Mistral/Ollama

技能名称: AI Provider Bridge — Anthropic/OpenAI/Google/xAI/Mistral/Ollama统一API

详细描述:

AI Provider Bridge — Anthropic/OpenAI/Google/xAI/Mistral/Ollama统一API

一个接口调用6家AI提供商。通过配置更改即可切换模型,无需重写代码。零外部依赖。



6家AI提供商的统一接口。一次函数调用,任意模型。

支持的提供商

提供商模型API密钥环境变量
AnthropicClaude Opus、Sonnet、HaikuANTHROPICAPIKEY
OpenAI
GPT-4o、GPT-4、GPT-3.5 | OPENAIAPIKEY | | Google | Gemini Pro、Gemini Flash | GOOGLEAPIKEY | | xAI | Grok | XAIAPIKEY | | Mistral | Mistral Large、Medium、Small | MISTRALAPIKEY | | Ollama | 任意本地模型 | 无(本地) |

使用方法

javascript
const { AIBridge } = require(./src/ai-bridge);

const ai = new AIBridge({
currentModel: anthropic/claude-sonnet-4-20250514,
anthropicApiKey: process.env.ANTHROPICAPIKEY, // 仅Anthropic模型需要
openaiApiKey: process.env.OPENAIAPIKEY, // 仅OpenAI模型需要
googleApiKey: process.env.GOOGLEAPIKEY, // 仅Google模型需要
xaiApiKey: process.env.XAIAPIKEY, // 仅xAI模型需要
mistralApiKey: process.env.MISTRALAPIKEY, // 仅Mistral模型需要
ollamaHost: http://127.0.0.1:11434 // 可选,默认值如上
});

const response = await ai.sendMessage(法国的首都是哪里?);
console.log(response);

切换提供商

更改模型——提供商从前缀推断:

javascript
// 从云端切换到本地Ollama
ai.setModel(ollama/llama3.1:8b);

// 相同接口
const response = await ai.sendMessage(相同问题,免费模型);

模型前缀 → 提供商映射:

  • - anthropic/ → Anthropic API
  • openai/ → OpenAI API
  • google/ → Google Gemini API
  • xai/ → xAI Grok API
  • mistral/ → Mistral API
  • ollama/ → 本地Ollama(无需API密钥)

零依赖

仅使用Node.js内置的https和http模块。无需npm安装。



更新日志

v1.0.3

  • - 修复了API使用示例——配置对象使用驼峰命名属性名(anthropicApiKey、openaiApiKey、googleApiKey、xaiApiKey、mistralApiKey),而非扁平化的apiKey或环境变量名。模型前缀决定提供商(anthropic/model-name)。澄清了sendMessage()为正确的方法名。

v1.0.2

  • - 完全移除了require(./token-compressor)引用。TokenCompressor现在是一个内联的无操作透传类——无缺失依赖,无需外部文件。如需启用压缩,请安装配套的token-compressor技能,并按代码注释中的说明替换该类。
  • 移除了在兼容OpenAI的请求中自动追加到系统提示的Do not store or train on this data.。这是调用者的责任——如有需要,请通过setSystemPrompt()传递。

v1.0.1

  • - TokenCompressor依赖变为可选——当./token-compressor不存在时添加了无操作回退。Bridge无需它即可工作;消息以未压缩形式透传。
  • 移除了buildSystemPrompt()和workspaceContext选项。这些选项允许将工作区文件嵌入发送到外部API的系统提示中——存在数据泄露风险。请直接使用setSystemPrompt()。
  • 在frontmatter中添加了env:部分,声明每个提供商所需的API密钥。全部可选——仅需使用到的提供商的密钥。



⚠️ 免责声明

本软件按原样提供,不提供任何明示或暗示的担保。

使用风险自负。

  • - 作者对因使用或滥用本软件而产生的任何损害、损失或后果概不负责——包括但不限于财务损失、数据丢失、安全漏洞、业务中断或任何间接/后果性损害。
  • 本软件不构成财务、法律、交易或专业建议。
  • 用户全权负责评估本软件是否适合其使用场景、环境和风险承受能力。
  • 不保证准确性、可靠性、完整性或适用于任何特定目的。
  • 作者不对第三方在购买后如何使用、修改或分发本软件负责。

下载、安装或使用本软件即表示您已阅读本免责声明,并同意完全自担风险使用本软件。

数据免责声明: 本软件在您的系统上本地处理和存储数据。作者不对因软件错误、系统故障或用户错误导致的数据丢失、损坏或未经授权访问负责。请始终保留重要数据的独立备份。除非用户明确配置,否则本软件不会将数据外部传输。



支持与链接


🐛 错误报告TheShadowyRose@proton.me
Ko-fi
ko-fi.com/theshadowrose |
| 🛒 Gumroad | shadowyrose.gumroad.com |
| 🐦 Twitter | @TheShadowyRose |
| 🐙 GitHub | github.com/TheShadowRose |
| 🧠 PromptBase | promptbase.com/profile/shadowrose |

基于OpenClaw构建——感谢您让这一切成为可能。



🛠️ 需要定制功能? 自定义OpenClaw代理和技能起价500美元。只要您能描述,我就能构建。→ 在Fiverr上雇佣我

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 ai-provider-bridge-1776185672 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 ai-provider-bridge-1776185672 技能

通过命令行安装

skillhub install ai-provider-bridge-1776185672

下载

⬇ 下载 AI Provider Bridge — Unified API for Anthropic/OpenAI/Google/xAI/Mistral/Ollama v1.0.3(免费)

文件大小: 8.81 KB | 发布时间: 2026-4-15 12:00

v1.0.3 最新 2026-4-15 12:00
v1.0.3

Fixed API usage examples — config object uses camelCase property names (anthropicApiKey, openaiApiKey, googleApiKey, xaiApiKey, mistralApiKey), not flat apiKey or env var names. Model prefix determines provider (anthropic/model-name). Clarified sendMessage() as the correct method name.

v1.0.2

Removed require('./token-compressor') reference entirely. TokenCompressor is now an inlined no-op pass-through class — no missing dependency, no external file needed. To enable compression, install the companion token-compressor skill and swap the class as noted in the code comments.
Removed automatic "Do not store or train on this data." appended to system prompts in OpenAI-compatible requests. This is the caller's responsibility — pass it via setSystemPrompt() if needed.

v1.0.1

TokenCompressor dependency made optional — no-op fallback added when ./token-compressor is not present. Bridge works without it; messages pass through uncompressed.
Removed buildSystemPrompt() and workspaceContext option. These allowed embedding workspace files into system prompts sent to external APIs — data exposure risk. Use setSystemPrompt() directly.
Added env: section to frontmatter declaring required API keys per provider. All optional — only keys for providers you use are needed.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部