unified-ai-router 3.0.0 โ 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/readme.md +76 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unified-ai-router",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "A unified interface for multiple LLM providers with automatic fallback. This project includes an OpenAI-compatible server and a deployable Telegram bot with a Mini App interface. It supports major providers like OpenAI, Google, Grok, and more, ensuring reliability and flexibility for your AI applications.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "mlibre",
|
|
@@ -55,4 +55,4 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"vercel": "^45.0.9"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
# Unified AI Router
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
Unified AI Router is a comprehensive toolkit for AI applications, featuring:
|
|
4
|
+
|
|
5
|
+
- A unified interface for multiple LLM providers with automatic fallback (the core router library)
|
|
6
|
+
- An OpenAI-compatible server for seamless API integration
|
|
7
|
+
- A deployable Telegram bot with Mini App interface
|
|
8
|
+
|
|
9
|
+
It supports major providers like OpenAI, Google, Grok, and more, ensuring reliability and flexibility.
|
|
10
|
+
|
|
11
|
+
- [๐ Features](#-features)
|
|
12
|
+
- [๐ ๏ธ Installation](#๏ธ-installation)
|
|
13
|
+
- [๐ Usage](#-usage)
|
|
14
|
+
- [๐ Basic Library Usage](#-basic-library-usage)
|
|
15
|
+
- [๐ OpenAI-Compatible Server](#-openai-compatible-server)
|
|
16
|
+
- [๐งช Testing](#-testing)
|
|
17
|
+
- [๐ง Supported Providers](#-supported-providers)
|
|
18
|
+
- [๐ API Keys](#-api-keys)
|
|
19
|
+
- [๐ผ Vercel Deployment (Telegram Bot)](#-vercel-deployment-telegram-bot)
|
|
20
|
+
- [๐ Prerequisites](#-prerequisites)
|
|
21
|
+
- [๐ Deployment Steps](#-deployment-steps)
|
|
22
|
+
- [๐ฑ Enable Telegram Mini App](#-enable-telegram-mini-app)
|
|
23
|
+
- [๐ Project Structure](#-project-structure)
|
|
24
|
+
- [๐ License](#-license)
|
|
19
25
|
|
|
20
26
|
## ๐ Features
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
- **Multi-Provider Support**: Works with OpenAI, Google, Grok, OpenRouter, Z.ai, Qroq, Cohere, Vercel, Cerebras, and LLM7
|
|
29
|
+
- **Automatic Fallback**: If one provider fails, automatically tries the next
|
|
30
|
+
- **Simple API**: Easy-to-use interface for all supported providers
|
|
31
|
+
- **OpenAI-Compatible Server**: Drop-in replacement for the OpenAI API, enabling easy integration with existing tools and clients
|
|
32
|
+
- **Streaming and Non-Streaming Support**: Handles both streaming and non-streaming responses
|
|
33
|
+
- **Tool Calling**: Full support for tools in LLM interactions
|
|
34
|
+
- **Telegram Bot Integration**: Deployable as a Telegram bot with an interactive Mini App interface
|
|
29
35
|
|
|
30
36
|
## ๐ ๏ธ Installation
|
|
31
37
|
|
|
@@ -76,17 +82,17 @@ const response = await llm.chatCompletion(messages, {
|
|
|
76
82
|
console.log(response);
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
###
|
|
85
|
+
### ๐ OpenAI-Compatible Server
|
|
80
86
|
|
|
81
|
-
The
|
|
87
|
+
The OpenAI-compatible server provides a drop-in replacement for the OpenAI API. It routes requests through the unified router with fallback logic, ensuring high availability.
|
|
82
88
|
|
|
83
|
-
To start the server, run:
|
|
89
|
+
To start the server locally, run:
|
|
84
90
|
|
|
85
91
|
```bash
|
|
86
92
|
npm start
|
|
87
93
|
```
|
|
88
94
|
|
|
89
|
-
The server
|
|
95
|
+
The server listens at `http://localhost:3000/v1/chat/completions` and supports standard OpenAI endpoints like `/v1/chat/completions`.
|
|
90
96
|
|
|
91
97
|
### ๐งช Testing
|
|
92
98
|
|
|
@@ -108,32 +114,32 @@ node tests/tools.js
|
|
|
108
114
|
|
|
109
115
|
## ๐ง Supported Providers
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
- OpenAI
|
|
118
|
+
- Google Gemini
|
|
119
|
+
- Grok
|
|
120
|
+
- OpenRouter
|
|
121
|
+
- Z.ai
|
|
122
|
+
- Qroq
|
|
123
|
+
- Cohere
|
|
124
|
+
- Vercel
|
|
125
|
+
- Cerebras
|
|
126
|
+
- LLM7
|
|
121
127
|
|
|
122
128
|
## ๐ API Keys
|
|
123
129
|
|
|
124
130
|
Get your API keys from the following providers:
|
|
125
131
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
- **OpenAI**: [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
|
|
133
|
+
- **Google Gemini**: [aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)
|
|
134
|
+
- **Grok**: [console.x.ai](https://console.x.ai/)
|
|
135
|
+
- **OpenRouter**: [openrouter.ai/keys](https://openrouter.ai/keys)
|
|
136
|
+
- **Z.ai**: [api.z.ai](https://api.z.ai)
|
|
137
|
+
- **Qroq**: [console.groq.com/keys](https://console.groq.com/keys)
|
|
138
|
+
- **Cohere**: [dashboard.cohere.com/api-keys](https://dashboard.cohere.com/api-keys)
|
|
139
|
+
- **Vercel AI Gateway**: [vercel.com/docs/ai/ai-gateway](https://vercel.com/docs/ai-gateway)
|
|
140
|
+
- **Cerebras**: [cloud.cerebras.ai](https://cloud.cerebras.ai)
|
|
141
|
+
- **LLM7**: [token.llm7.io](https://token.llm7.io/)
|
|
142
|
+
- Seems like it does not support tool calling
|
|
137
143
|
|
|
138
144
|
## ๐ผ Vercel Deployment (Telegram Bot)
|
|
139
145
|
|
|
@@ -141,9 +147,9 @@ This section describes how to deploy the AIRouter as a Telegram bot using Vercel
|
|
|
141
147
|
|
|
142
148
|
### ๐ Prerequisites
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
- A Telegram Bot Token (@BotFather)
|
|
151
|
+
- API keys for various AI providers
|
|
152
|
+
- Vercel account
|
|
147
153
|
|
|
148
154
|
### ๐ Deployment Steps
|
|
149
155
|
|
|
@@ -196,16 +202,16 @@ curl "https://ai-router-flame.vercel.app/api?register_webhook=true"
|
|
|
196
202
|
After deploying the bot, you need to configure the Telegram Mini App and menu button:
|
|
197
203
|
|
|
198
204
|
1. **Configure Mini App:**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
- Go to [@BotFather](https://t.me/botfather)
|
|
206
|
+
- Send `/mybots` and select your bot
|
|
207
|
+
- Go to `Bot Settings` โ `Configure Mini App`
|
|
208
|
+
- Set the Mini App URL to: `https://ai-router-flame.vercel.app`
|
|
203
209
|
|
|
204
210
|
2. **Configure Menu Button:**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
- Go to [@BotFather](https://t.me/botfather)
|
|
212
|
+
- Send `/mybots` and select your bot
|
|
213
|
+
- Go to `Bot Settings` โ `Menu Button`
|
|
214
|
+
- Ensure the URL shown is: `https://ai-router-flame.vercel.app`
|
|
209
215
|
|
|
210
216
|
Once configured, users can access the Mini App by sending `/start` or `/app` to your bot, or through the menu button.
|
|
211
217
|
|
|
@@ -213,17 +219,17 @@ An example of a deployed bot is accessible on Telegram: [https://t.me/freePulseA
|
|
|
213
219
|
|
|
214
220
|
## ๐ Project Structure
|
|
215
221
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
- `main.js` - Core AIRouter library implementing the unified interface and fallback logic
|
|
223
|
+
- `provider.js` - Configuration for supported AI providers
|
|
224
|
+
- `openai-compatible-server/index.js` - OpenAI-compatible API server
|
|
225
|
+
- `tests/` - Comprehensive tests for the library, server, and tools
|
|
226
|
+
- `bruno/` - Bruno API collection for testing endpoints
|
|
227
|
+
- `vercel-project/` - Ready-to-deploy Vercel setup for the Telegram bot
|
|
228
|
+
- `api/index.js` - Telegram webhook handler
|
|
229
|
+
- `api/search.js` - Search proxy endpoint
|
|
230
|
+
- `public/` - Mini App frontend (HTML, CSS, JS)
|
|
231
|
+
- `src/config.js` - Bot configuration
|
|
232
|
+
- `src/telegram.js` - Telegram API integration
|
|
227
233
|
|
|
228
234
|
## ๐ License
|
|
229
235
|
|