Janitorial cleanup from the May 2026 audit:
1. Deleted server/src/providers/groq.ts and cerebras.ts (and their tests).
Both were unreachable code: providers/index.ts has registered Groq and
Cerebras via the generic OpenAICompatProvider since at least V4. The
dedicated subclasses were only instantiated by their own tests.
2. Updated openai-compat.test.ts platform-instance fixture:
- Dropped 'fireworks' row — Fireworks AI was never a registered platform.
Test was passing only because of an 'as any' cast that silenced the
Platform type error.
- Updated 'github' baseUrl from the legacy 'models.inference.ai.azure.com'
to the current 'models.github.ai/inference' (matches the actual
registration after PR #18).
- Added rows for 'groq', 'cerebras', and 'zhipu' so the fixture mirrors
the live provider registry. Future drift between fixture and live
registry will fail loudly.
3. Added '*.bak' to .gitignore — '*.db' covers freeapi.db.bak today
…
Six related fixes from the recent codebase audit:
1. Auth bypass on /v1/chat/completions — guard was 'if (authHeader && !isLocal)'
so any non-local caller that simply omitted the Authorization header skipped
the check entirely. Server binds 0.0.0.0; this exposed the proxy to any LAN
peer. Fix: 'if (!isLocal)' always require a valid Bearer for non-local.
2. Health-check auto-disable conflated network errors with bad keys. Three
transient timeouts (15 min) silently flipped enabled=0 on perfectly valid
keys (burned us this session). Fix:
- validateKey() in OpenAICompatProvider/google/cohere/cloudflare no longer
swallows transport errors — they propagate.
- health.ts catch branch sets status='error' but does NOT increment the
consecutive-failure counter. Only confirmed 401/403 (validateKey returns
false) counts toward auto-disable.
3. Removed Hugging Face / Moonshot / MiniMax direct integrations from the
live surface (PLATFORMS allowlist, providers…
fix(github): route GitHub Models via models.github.ai/inference (#18)
* fix(proxy): honor explicit model field in chat-completions requests
The schema parsed `model` but the destructure dropped it, so
`routeRequest` only ever saw the sticky-session fallback. Effect:
the playground's model picker (and any OpenAI SDK client passing
`model`) was silently ignored — every request landed on whatever
was top of fallback_config.
Fix: when `model` is present, look it up in the catalog
(`models WHERE model_id = ? AND enabled = 1`) and pass its db id
as `preferredModelDbId`. Sticky-session is preserved as a fallback
for multi-turn flows that don't re-send the model field.
Unknown / disabled models silently fall through to the auto-route
chain rather than 400ing — keeps behavior compatible with SDKs that
hardcode foreign model names like 'gpt-4o'.
* fix(github): route GitHub Models via models.github.ai/inference
The provider was pointed at the legacy Azure endpoint
(`models.inference.ai.azure.com`), which rejects the new
publisher-prefixed model ids the catalog…
* fix(server): guard errorHandler against headers-already-sent
When an LLM completion errors mid-stream, the response is already
flushing tokens to the client. The handler then unconditionally called
res.status().json(), throwing ERR_HTTP_HEADERS_SENT and triggering a
pm2 restart. Short-circuit to Express's default handler once headers
have been sent so the socket closes cleanly.
* feat(providers): configurable per-provider HTTP timeout
OpenAICompatProvider now accepts an optional timeoutMs constructor
option (default 15000ms). Cloud APIs respond well within the existing
default, but locally-hosted OpenAI-compatible inference (llama.cpp,
vLLM on CPU) can take 30-120s for long prompts and was being aborted
mid-generation, causing the proxy to mark the key invalid.
* fix(keys): add zhipu, moonshot, minimax to platform allowlist
These three platforms exist in the Platform type union and have
provider registrations, but were missing from the PLATFORMS array
in the keys route. Without …
fix(cloudflare): normalize null content to empty string for tool round-trips
Cloudflare's OpenAI-compat endpoint rejects assistant messages with
content: null, even when tool_calls are present (standard OpenAI format).
Added normalizeMessages() that converts null content to "" before dispatch,
plus a regression test covering the null-content + tool_calls case.
Also credits @moaaz12-web in README Contributors for the tool-calling PR.