
一个开源、高性能的网关,统一了多个提供商,从本地解决方案如 Ollama 到主要云提供商如 OpenAI、Groq、Cohere、Anthropic、Cloudflare 和 DeepSeek
一个开源、高性能的网关,统一了多个提供商,从本地解决方案如 Ollama 到主要云提供商如 OpenAI、Groq、Cohere、Anthropic、Cloudflare 和 DeepSeek,推理网关是一个代理服务器,旨在方便访问各种语言模型 API。它允许用户通过统一的界面与不同的语言模型进行交互,简化了配置以及向多个模型发送请求和接收响应的过程,使得混合专家的使用变得简单。
一、软件介绍
文末提供程序和源码下载学习
一个开源、高性能的网关,统一了多个提供商,从本地解决方案如 Ollama 到主要云提供商如 OpenAI、Groq、Cohere、Anthropic、Cloudflare 和 DeepSeek,推理网关是一个代理服务器,旨在方便访问各种语言模型 API。它允许用户通过统一的界面与不同的语言模型进行交互,简化了配置以及向多个模型发送请求和接收响应的过程,使得混合专家的使用变得简单。
二、Key Features 关键特性
- 📜 开源:遵循 MIT 许可证可用。
- 🚀 统一 API 访问:代理请求多个语言模型 API,包括 OpenAI、Ollama、Groq、Cohere 等。
- ⚙️ 环境配置:通过环境变量轻松配置 API 密钥和 URL。
- 🔧 工具使用支持:通过统一的 API 启用跨支持提供商的功能调用。
- 🌊 流式响应:实时流式传输从语言模型生成的标记。
- 🐳 Docker 支持:使用 Docker 和 Docker Compose 实现轻松设置和部署。
- ☸️ Kubernetes 支持:适用于 Kubernetes 环境部署。
- 📊 OpenTelemetry:监控和分析性能。
- 🛡️ 生产就绪:以生产为导向构建,具有可配置的超时和 TLS 支持。
- 轻量级:仅包含必需的库和运行时,生成大小约为 10.8MB 的二进制文件。
- 📉 资源消耗最小化:设计用于消耗最少资源并具有更小的占用空间。
- 📚 文档:有详细的示例和指南,文档完善。
- 🧪 测试:经过广泛的单元测试和集成测试。
- 🛠️ 维护:积极维护和开发。
- 📈 可扩展:易于扩展,可在分布式环境中使用 - 带有 Kubernetes 中的 HPA。
- 🔒 合规与数据隐私:此项目不收集数据或分析,确保合规和数据隐私。
- 🏠 自托管:可自托管以完全控制部署环境。
三、Overview 概述
您可以将推理网关水平扩展以处理来自客户端的多个请求。推理网关将请求转发到相应的提供商,并将响应返回给客户端。以下图示说明了流程:
Client is sending: 客户端发送:
curl -X POST http://localhost:8080/v1/chat/completions
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a pirate."
},
{
"role": "user",
"content": "Hello, world! How are you doing today?"
}
],
}'
** Internally the request is proxied to OpenAI, the Inference Gateway inferring the provider by the model name.
内部请求被代理到 OpenAI,推理网关通过模型名称推断提供商。
You can also send the request explicitly using ?provider=openai
or any other supported provider in the URL.
您也可以通过 ?provider=openai
或任何其他支持的提供者在 URL 中显式发送请求。
Finally client receives:
最后客户端接收:
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Ahoy, matey! 🏴☠️ The seas be wild, the sun be bright, and this here pirate be ready to conquer the day! What be yer business, landlubber? 🦜",
"role": "assistant"
}
}
],
"created": 1741821109,
"id": "chatcmpl-dc24995a-7a6e-4d95-9ab3-279ed82080bb",
"model": "N/A",
"object": "chat.completion",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0
}
}
For streaming the tokens simply add to the request body stream: true
.
只需将内容添加到请求体中即可进行令牌流式传输。 stream: true
Supported API's 支持的 API
OpenAI
Ollama
Groq
Cloudflare 云 flare
Cohere
Anthropic
DeepSeek
Configuration 配置
The Inference Gateway can be configured using environment variables. The following environment variables are supported.
推理网关可以使用环境变量进行配置。以下环境变量受支持。
Examples 示例
- Using Docker Compose 使用 Docker Compose
- Using Kubernetes 使用 Kubernetes
- Using standard REST endpoints
使用标准 REST 端点
SDKs
More SDKs could be generated using the OpenAPI specification. The following SDKs are currently available:
可以使用 OpenAPI 规范生成更多 SDK。目前可用的 SDK 有:
软件下载
本文信息来源于GitHub作者地址:https://github.com/inference-gateway/inference-gateway
更多推荐
所有评论(0)