ai-speedometer 1.3.1 → 1.3.2

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 CHANGED
@@ -17,6 +17,12 @@ npm install -g ai-speedometer
17
17
  - **Tokens/Second** - Real-time throughput
18
18
  - **Token Counts** - Input, output, and total tokens used
19
19
 
20
+ ## New Features
21
+
22
+ - **REST API Default** - REST API benchmarking is now the default method for better compatibility
23
+ - **Headless Mode** - Run benchmarks without interactive CLI using command-line arguments
24
+ - **Streaming Support** - Full streaming support now available in REST API benchmarks
25
+
20
26
  ## Quick Setup
21
27
 
22
28
  1. **Set Model**
@@ -41,7 +47,8 @@ npm install -g ai-speedometer
41
47
  4. **Run Benchmark**
42
48
  ```bash
43
49
  ai-speedometer
44
- # Select "Run Benchmark (AI SDK)" → Choose models → Press ENTER
50
+ # Select "Run Benchmark (REST API)" → Choose models → Press ENTER
51
+ # Note: REST API is now the default benchmark method
45
52
  ```
46
53
 
47
54
  ## Usage
@@ -55,6 +62,13 @@ aispeed
55
62
 
56
63
  # Debug mode
57
64
  ai-speedometer --debug
65
+
66
+ # Headless mode - run benchmark directly
67
+ ai-speedometer --bench openai:gpt-4
68
+ # With custom API key
69
+ ai-speedometer --bench openai:gpt-4 --api-key "sk-your-key"
70
+ # Use AI SDK instead of REST API
71
+ ai-speedometer --bench openai:gpt-4 --ai-sdk
58
72
  ```
59
73
 
60
74
  ## Configuration Files
package/cli.js CHANGED
@@ -36,6 +36,7 @@ function parseCliArgs() {
36
36
  bench: null,
37
37
  apiKey: null,
38
38
  useAiSdk: false,
39
+ formatted: false,
39
40
  help: false
40
41
  };
41
42
 
@@ -50,6 +51,8 @@ function parseCliArgs() {
50
51
  parsed.apiKey = args[++i];
51
52
  } else if (arg === '--ai-sdk') {
52
53
  parsed.useAiSdk = true;
54
+ } else if (arg === '--formatted') {
55
+ parsed.formatted = true;
53
56
  } else if (arg === '--help' || arg === '-h') {
54
57
  parsed.help = true;
55
58
  }
@@ -69,6 +72,7 @@ function showHelp() {
69
72
  console.log(' --bench <provider:model> ' + colorText('Run benchmark in headless mode', 'dim'));
70
73
  console.log(' --api-key <key> ' + colorText('Override API key (optional)', 'dim'));
71
74
  console.log(' --ai-sdk ' + colorText('Use AI SDK instead of REST API', 'dim'));
75
+ console.log(' --formatted ' + colorText('Format JSON output for human readability', 'dim'));
72
76
  console.log(' --debug ' + colorText('Enable debug logging', 'dim'));
73
77
  console.log(' --help, -h ' + colorText('Show this help message', 'dim'));
74
78
  console.log('');
@@ -76,6 +80,7 @@ function showHelp() {
76
80
  console.log(' ai-speedometer --bench openai:gpt-4');
77
81
  console.log(' ai-speedometer --bench anthropic:claude-3-opus --api-key "sk-..."');
78
82
  console.log(' ai-speedometer --bench openai:gpt-4 --ai-sdk');
83
+ console.log(' ai-speedometer --bench openai:gpt-4 --formatted');
79
84
  console.log('');
80
85
  }
81
86
 
@@ -1826,9 +1831,11 @@ async function benchmarkSingleModelRest(model) {
1826
1831
  if (isFirstChunk && !firstTokenTime) {
1827
1832
  firstTokenTime = Date.now();
1828
1833
  isFirstChunk = false;
1829
- // Show live TTFT result
1834
+ // Show live TTFT result (only in interactive mode, not headless)
1830
1835
  const ttftSeconds = ((firstTokenTime - startTime) / 1000).toFixed(2);
1831
- console.log(colorText(`TTFT received at ${ttftSeconds}s for ${model.name}`, 'green'));
1836
+ if (!cliArgs.bench) {
1837
+ console.log(colorText(`TTFT received at ${ttftSeconds}s for ${model.name}`, 'green'));
1838
+ }
1832
1839
  }
1833
1840
 
1834
1841
  buffer += decoder.decode(value, { stream: true });
@@ -2281,10 +2288,11 @@ async function runHeadlessBenchmark(benchSpec, apiKey, useAiSdk) {
2281
2288
  outputTokens: result.tokenCount,
2282
2289
  promptTokens: result.promptTokens,
2283
2290
  totalTokens: result.totalTokens,
2291
+ is_estimated: !!(result.usedEstimateForOutput || result.usedEstimateForInput),
2284
2292
  error: result.error || null
2285
2293
  };
2286
2294
 
2287
- console.log(JSON.stringify(jsonOutput, null, 2));
2295
+ console.log(JSON.stringify(jsonOutput, null, cliArgs.formatted ? 2 : 0));
2288
2296
  process.exit(result.success ? 0 : 1);
2289
2297
  } catch (error) {
2290
2298
  console.error(colorText('Error: ' + error.message, 'red'));