7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createApp } from '../../app.js';
import { initDb } from '../../db/index.js';
// CLIENT_DIST relocates the built dashboard for embedders (the desktop app
// ships client/dist in extraResources, out of reach of the default
// __dirname-relative path).
describe('CLIENT_DIST override', () => {
let tmpDir: string;
beforeAll(() => {
process.env.ENCRYPTION_KEY = '0'.repeat(64);
initDb(':memory:');
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'freeapi-client-dist-'));
fs.writeFileSync(path.join(tmpDir, 'index.html'), '<!doctype html><title>custom-dist</title>');
});
afterAll(() => {
delete process.env.CLIENT_DIST;
fs.rmSync(tmpDir, { recursive: true, force: true });
});
it('serves the SPA from the overridden directory', async () => {
process.env.CLIENT_DIST = tmpDir;
const app = createApp();
const server = app.listen(0, '127.0.0.1');
if (!server.listening) await new Promise<void>(resolve => server.once('listening', () => resolve()));
const port = (server.address() as any).port;
const res = await fetch(`http://127.0.0.1:${port}/`);
const html = await res.text();
server.close();
expect(res.status).toBe(200);
expect(html).toContain('custom-dist');
});
});