ai-speedometer 1.0.0
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/README.md +309 -0
- package/ai-benchmark-config.json.template +21 -0
- package/cli.js +1773 -0
- package/dist/ai-speedometer +172 -0
- package/docs/README.md +147 -0
- package/docs/models-dev-integration.md +344 -0
- package/docs/token-counting-fallback.md +345 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# Ai-speedometer
|
|
2
|
+
|
|
3
|
+
A comprehensive, modern CLI tool for benchmarking AI models across multiple providers with **parallel execution**, **professional tables**, **arrow key navigation**, and **advanced metrics**.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/aptdnfapt/Ai-speedometer
|
|
9
|
+
# Install dependencies
|
|
10
|
+
npm install
|
|
11
|
+
# Set up your API keys and providers (see Setup Guide below)
|
|
12
|
+
# Start the CLI
|
|
13
|
+
npm run cli
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Debug
|
|
18
|
+
```bash
|
|
19
|
+
# Start with debug logging (for troubleshooting)
|
|
20
|
+
npm run cli:debug
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup Guide
|
|
24
|
+
|
|
25
|
+
### Before You Begin
|
|
26
|
+
|
|
27
|
+
Before running the benchmark, you need to configure your AI providers with API keys and base URLs. The tool supports two types of providers:
|
|
28
|
+
|
|
29
|
+
1. **OpenAI-Compatible providers** (OpenAI, local models, custom endpoints)
|
|
30
|
+
2. **Anthropic providers** (Claude models)
|
|
31
|
+
|
|
32
|
+
### Step 1: Get Your API Keys
|
|
33
|
+
|
|
34
|
+
#### OpenAI-Compatible Providers
|
|
35
|
+
- **OpenAI**: Get your API key from [OpenAI API Keys](https://platform.openai.com/api-keys)
|
|
36
|
+
- **Other providers**: Check your provider's documentation for API key access
|
|
37
|
+
|
|
38
|
+
#### Anthropic Providers
|
|
39
|
+
- **Anthropic**: Get your API key from [Anthropic Console](https://console.anthropic.com/settings/keys)
|
|
40
|
+
|
|
41
|
+
### Step 2: Configure Providers
|
|
42
|
+
|
|
43
|
+
You have two ways to configure providers:
|
|
44
|
+
|
|
45
|
+
#### Method A: Use the Interactive CLI (Recommended)
|
|
46
|
+
|
|
47
|
+
1. Run the CLI:
|
|
48
|
+
```bash
|
|
49
|
+
npm run cli
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Select "Set Model" from the main menu
|
|
53
|
+
|
|
54
|
+
3. Choose "Add New Provider"
|
|
55
|
+
|
|
56
|
+
4. Select the provider type:
|
|
57
|
+
- **OpenAI Compatible**: For OpenAI, local models, or custom endpoints
|
|
58
|
+
- **Anthropic**: For Claude models
|
|
59
|
+
|
|
60
|
+
5. Enter the required information:
|
|
61
|
+
- **Provider name**: A friendly name (e.g., "My OpenAI", "Local Ollama")
|
|
62
|
+
- **Base URL**: The API endpoint (see examples below)
|
|
63
|
+
- **API Key**: Your secret API key
|
|
64
|
+
- **Model name**: The specific model you want to test
|
|
65
|
+
|
|
66
|
+
#### Method B: Manual Configuration
|
|
67
|
+
|
|
68
|
+
1. Copy the template:
|
|
69
|
+
```bash
|
|
70
|
+
cp ai-benchmark-config.json.template ai-benchmark-config.json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. Edit `ai-benchmark-config.json` with your provider details:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"providers": [
|
|
78
|
+
{
|
|
79
|
+
"id": "my_openai",
|
|
80
|
+
"name": "OpenAI",
|
|
81
|
+
"type": "openai-compatible",
|
|
82
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
83
|
+
"apiKey": "sk-your-openai-key-here",
|
|
84
|
+
"models": [
|
|
85
|
+
{
|
|
86
|
+
"name": "gpt-4",
|
|
87
|
+
"id": "gpt4_model"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "my_anthropic",
|
|
93
|
+
"name": "Anthropic",
|
|
94
|
+
"type": "anthropic",
|
|
95
|
+
"baseUrl": "https://api.anthropic.com",
|
|
96
|
+
"apiKey": "sk-ant-your-anthropic-key-here",
|
|
97
|
+
"models": [
|
|
98
|
+
{
|
|
99
|
+
"name": "claude-3-sonnet-20240229",
|
|
100
|
+
"id": "claude3_sonnet"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Step 3: Common Base URL Examples
|
|
109
|
+
|
|
110
|
+
#### OpenAI-Compatible Providers
|
|
111
|
+
- **OpenAI**: `https://api.openai.com/v1`
|
|
112
|
+
- **Local Ollama**: `http://localhost:11434/v1`
|
|
113
|
+
- **Groq**: `https://api.groq.com/openai/v1`
|
|
114
|
+
- **Together AI**: `https://api.together.xyz/v1`
|
|
115
|
+
- **Anyscale**: `https://api.endpoints.anyscale.com/v1`
|
|
116
|
+
- **Fireworks AI**: `https://api.fireworks.ai/inference/v1`
|
|
117
|
+
|
|
118
|
+
#### Anthropic Providers
|
|
119
|
+
- **Anthropic Official**: `https://api.anthropic.com`
|
|
120
|
+
- **Custom Anthropic endpoints**: Check with your provider
|
|
121
|
+
|
|
122
|
+
### Step 4: Security
|
|
123
|
+
|
|
124
|
+
Your configuration file contains sensitive API keys. The `.gitignore` file already excludes `ai-benchmark-config.json` to prevent accidental commits.
|
|
125
|
+
|
|
126
|
+
**Never commit your API keys to version control!**
|
|
127
|
+
|
|
128
|
+
### Step 5: Verify Configuration
|
|
129
|
+
|
|
130
|
+
After setting up, run the CLI and check that your providers appear in the model selection menu. If you see your providers and models listed, you're ready to benchmark!
|
|
131
|
+
|
|
132
|
+
### Troubleshooting
|
|
133
|
+
|
|
134
|
+
- **"Provider not found"**: Check your base URL and API key
|
|
135
|
+
- **"Model not available"**: Verify the model name is correct for your provider
|
|
136
|
+
- **"Connection failed"**: Ensure your base URL is accessible and you have internet access
|
|
137
|
+
- **"Invalid API key"**: Double-check your API key is correct and has proper permissions
|
|
138
|
+
- **Debug Mode**: Use `npm run cli:debug` to enable detailed logging. This creates a `debug.log` file with API request/response details for troubleshooting connection issues.
|
|
139
|
+
|
|
140
|
+
## Usage Examples
|
|
141
|
+
|
|
142
|
+
### Main Menu (Modern Arrow Navigation)
|
|
143
|
+
```
|
|
144
|
+
Ai-speedometer
|
|
145
|
+
=============================
|
|
146
|
+
Note: opencode uses ai-sdk
|
|
147
|
+
|
|
148
|
+
Use ↑↓ arrows to navigate, ENTER to select
|
|
149
|
+
Navigation is circular
|
|
150
|
+
|
|
151
|
+
● Set Model
|
|
152
|
+
○ Run Benchmark (AI SDK)
|
|
153
|
+
○ Run Benchmark (REST API)
|
|
154
|
+
○ Exit
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Model Selection (Circle-Based UI)
|
|
158
|
+
```
|
|
159
|
+
Select Models for Benchmark
|
|
160
|
+
|
|
161
|
+
Use ↑↓ arrows to navigate, SPACE to select/deselect, ENTER to confirm
|
|
162
|
+
Navigation is circular - moving past bottom/top wraps around
|
|
163
|
+
Press "A" to select all models, "N" to deselect all
|
|
164
|
+
Circle states: ●=Current+Selected ○=Current+Unselected ●=Selected ○=Unselected
|
|
165
|
+
|
|
166
|
+
Available Models:
|
|
167
|
+
● gpt-4 (OpenAI)
|
|
168
|
+
○ claude-3-sonnet (Anthropic)
|
|
169
|
+
|
|
170
|
+
Selected: 1 models
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Provider Management (Vertical Stacking)
|
|
174
|
+
```
|
|
175
|
+
Available Providers
|
|
176
|
+
|
|
177
|
+
1. chutes (openai-compatible)
|
|
178
|
+
Models:
|
|
179
|
+
1. zai-org/GLM-4.5-turbo
|
|
180
|
+
2. deepseek-ai/DeepSeek-V3.1-turbo
|
|
181
|
+
|
|
182
|
+
2. zai (openai-compatible)
|
|
183
|
+
Models:
|
|
184
|
+
1. glm-4.5
|
|
185
|
+
|
|
186
|
+
3. zai-anthropic (anthropic)
|
|
187
|
+
Models:
|
|
188
|
+
1. claude-3-sonnet-20240229
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Benchmark Results (Professional Tables + Enhanced Charts)
|
|
192
|
+
```
|
|
193
|
+
BENCHMARK RESULTS
|
|
194
|
+
=========================
|
|
195
|
+
Method: AI SDK
|
|
196
|
+
|
|
197
|
+
COMPREHENSIVE PERFORMANCE SUMMARY
|
|
198
|
+
Note: AI SDK method does not count thinking tokens as first token. REST API method does not use streaming.
|
|
199
|
+
┌─────────────────────────┬─────────────────────┬─────────────────┬────────────┬─────────────────┬─────────────────┬─────────────────┬─────────────────┐
|
|
200
|
+
│ Model │ Provider │ Total Time(s) │ TTFT(s) │ Tokens/Sec │ Output Tokens │ Prompt Tokens │ Total Tokens │
|
|
201
|
+
├─────────────────────────┼─────────────────────┼─────────────────┼────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┤
|
|
202
|
+
│ zai-org/GLM-4.5-turbo │ chutes │ 11.47 │ 1.00 │ 81.5 │ 935 │ 14 │ 1205 │
|
|
203
|
+
│ deepseek-ai/DeepSeek-V3 │ chutes │ 5.21 │ 0.83 │ 178.6 │ 930 │ 14 │ 742 │
|
|
204
|
+
│ glm-4.5 │ zai │ 11.30 │ 5.30 │ 72.9 │ 824 │ 14 │ 1087 │
|
|
205
|
+
└─────────────────────────┴─────────────────────┴─────────────────┴────────────┴─────────────────┴─────────────────┴─────────────────┴─────────────────┘
|
|
206
|
+
|
|
207
|
+
PERFORMANCE COMPARISON CHARTS
|
|
208
|
+
──────────────────────────────────────────────────────────────────────────────────────────
|
|
209
|
+
|
|
210
|
+
TOTAL TIME COMPARISON (lower is better)
|
|
211
|
+
5.21s | 178.6 tok/s | deepseek-ai/DeepSeek-V3.1-turbo | ████████████████████████████████████████████████
|
|
212
|
+
11.30s | 72.9 tok/s | glm-4.5 | ████████████████████████████████████░░░░░░░░░
|
|
213
|
+
11.47s | 81.5 tok/s | zai-org/GLM-4.5-turbo | ████████████████████████████████████░░░░░░░░░
|
|
214
|
+
|
|
215
|
+
TOKENS PER SECOND COMPARISON (higher is better)
|
|
216
|
+
178.6 tok/s | 5.21s | deepseek-ai/DeepSeek-V3.1-turbo | █████████████████████████████████████████████████████
|
|
217
|
+
81.5 tok/s | 11.47s | zai-org/GLM-4.5-turbo | ████████████████████████████████░░░░░░░░░░░░░░░░
|
|
218
|
+
72.9 tok/s | 11.30s | glm-4.5 | ████████████████████████████████░░░░░░░░░░░░░░░░
|
|
219
|
+
|
|
220
|
+
Benchmark completed!
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Configuration
|
|
224
|
+
|
|
225
|
+
### Adding Providers (Arrow Key Navigation)
|
|
226
|
+
|
|
227
|
+
#### OpenAI-Compatible Providers
|
|
228
|
+
```
|
|
229
|
+
Add New Provider
|
|
230
|
+
|
|
231
|
+
Use ↑↓ arrows to navigate, ENTER to select
|
|
232
|
+
Navigation is circular
|
|
233
|
+
|
|
234
|
+
Select provider type:
|
|
235
|
+
|
|
236
|
+
● OpenAI Compatible
|
|
237
|
+
○ Anthropic
|
|
238
|
+
○ Back to main menu
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### Anthropic Providers (Now Supports Custom Base URLs)
|
|
242
|
+
```
|
|
243
|
+
Enter provider name (e.g., MyAnthropic):
|
|
244
|
+
Enter base URL (e.g., https://api.anthropic.com):
|
|
245
|
+
Enter Anthropic API key: [your-key]
|
|
246
|
+
Enter model name (e.g., claude-3-sonnet-20240229):
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Note**: The system automatically handles `/v1` path requirements for custom Anthropic endpoints. If you encounter issues with custom base URLs, run `npm run cli:debug` to see detailed API request logs.
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
## Performance Metrics Explained
|
|
253
|
+
|
|
254
|
+
### Core Metrics
|
|
255
|
+
- **Total Time**: Complete request duration (seconds)
|
|
256
|
+
- **Time to First Token (TTFT)**: Latency until first streaming token arrives (0 for REST API since it doesn't use streaming)
|
|
257
|
+
- **Tokens per Second**: Real-time throughput calculation
|
|
258
|
+
- **Output Tokens**: Number of tokens in the AI response
|
|
259
|
+
- **Prompt Tokens**: Number of tokens in the input prompt
|
|
260
|
+
- **Total Tokens**: Combined prompt + output tokens
|
|
261
|
+
|
|
262
|
+
### Benchmark Methods
|
|
263
|
+
- **AI SDK Method**: Uses streaming with Vercel AI SDK, doesn't count thinking tokens as first token
|
|
264
|
+
- **REST API Method**: Uses direct HTTP calls, no streaming, TTFT is always 0
|
|
265
|
+
|
|
266
|
+
### Chart Features
|
|
267
|
+
- **Dual Comparison Charts**: Both time and performance perspectives
|
|
268
|
+
- **Left-Side Metrics**: Shows actual values alongside bar charts
|
|
269
|
+
- **Color Coding**: Red bars for time (lower is better), green for performance (higher is better)
|
|
270
|
+
- **Dynamic Scaling**: Bars scale proportionally to the best/worst performers
|
|
271
|
+
|
|
272
|
+
## Tech Stack
|
|
273
|
+
|
|
274
|
+
- **AI SDK**: Vercel AI SDK with streaming support (opencode uses it)
|
|
275
|
+
- **Table Rendering**: `cli-table3` for professional tables
|
|
276
|
+
- **Providers**: OpenAI-compatible and Anthropic APIs with custom baseUrl support
|
|
277
|
+
- **Navigation**: Circular arrow key navigation throughout
|
|
278
|
+
- **Colors**: ANSI escape codes for terminal styling
|
|
279
|
+
- **Configuration**: JSON-based persistent storage
|
|
280
|
+
- **Security**: .gitignore protection for sensitive files
|
|
281
|
+
- **Debug Logging**: Built-in debugging system for troubleshooting API connections
|
|
282
|
+
|
|
283
|
+
## Requirements
|
|
284
|
+
|
|
285
|
+
- Node.js 18+
|
|
286
|
+
- API keys for AI providers
|
|
287
|
+
- Terminal that supports ANSI colors and arrow keys
|
|
288
|
+
- Git (for security configuration)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
## Advanced Features
|
|
292
|
+
|
|
293
|
+
### Parallel Execution
|
|
294
|
+
- **Speed**: Runs all selected models simultaneously
|
|
295
|
+
- **Efficiency**: No sequential waiting between models
|
|
296
|
+
- **Results**: Comprehensive comparison across all models
|
|
297
|
+
|
|
298
|
+
### Advanced Navigation
|
|
299
|
+
- **Universal Pattern**: All menus use the same arrow key navigation
|
|
300
|
+
- **Circular Movement**: Navigation wraps at top/bottom for seamless UX
|
|
301
|
+
- **Visual Feedback**: Clear indicators for current selections
|
|
302
|
+
- **Keyboard Shortcuts**: Quick actions like select all ('A') and deselect all ('N')
|
|
303
|
+
|
|
304
|
+
### Professional Output
|
|
305
|
+
- **Table Format**: Clean, aligned columns with proper spacing
|
|
306
|
+
- **Color Coding**: Different colors for different metric types
|
|
307
|
+
- **Comprehensive Data**: All relevant metrics in one view
|
|
308
|
+
- **Visual Charts**: Bar charts for quick visual comparison
|
|
309
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"verifiedProviders": {
|
|
3
|
+
"openai": "sk-your-openai-api-key",
|
|
4
|
+
"anthropic": "sk-ant-your-anthropic-api-key"
|
|
5
|
+
},
|
|
6
|
+
"customProviders": [
|
|
7
|
+
{
|
|
8
|
+
"id": "my-custom-provider",
|
|
9
|
+
"name": "My Custom Provider",
|
|
10
|
+
"type": "openai-compatible",
|
|
11
|
+
"baseUrl": "https://api.custom.com/v1",
|
|
12
|
+
"apiKey": "YOUR_API_KEY_HERE",
|
|
13
|
+
"models": [
|
|
14
|
+
{
|
|
15
|
+
"name": "custom-model",
|
|
16
|
+
"id": "custom_model_1"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|