siinghd/freeai

Proxy that auto-selects the best free OpenRouter model with failover

★ 0Forks 0JavaScriptGitHub ↗Compare

README

freeai

Tiny proxy that exposes a single AI endpoint backed by OpenRouter's best currently-available free model — auto-discovers, scores, and falls back on failure.

What it does

  • Polls OpenRouter's /models every 5 min and filters to zero-price models
  • Scores by context length, parameter count, and recent failures; picks the top one
  • Proxies chat-completions requests to the selected model; transparently switches on errors
  • Persists rolling stats (request/error/switch counters) to data/stats.json

Stack

Bun runtime, no framework — a single server.js.

Run it

cp .env.example .env     # add your OpenRouter key
bun run start            # bun server.js

Server listens on PORT (default 3700).

Notes

  • Required env: OPENROUTER_API_KEY. Optional: PORT.
  • Generated state lives in data/models.json and data/stats.json — both git-ignored.
  • nginx.conf is an example reverse-proxy config.

Contributors

siinghd

Issues