freiheit 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +41 -2
- package/README.zh-CN.md +42 -0
- package/bin/freiheit.js +4 -0
- package/dist/cli.mjs +85 -0
- package/dist/index.mjs +3 -0
- package/dist/server-A5ihtQsE.mjs +4179 -0
- package/package.json +58 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-PRESENT Vincent-the-gamer <https://github.com/Vincent-the-gamer>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# freiheit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Set large models free: a CLI for free model endpoints, inspired by [dsh-our-free-model](https://github.com/Ebony-Vinyl/dsh-our-free-model).
|
|
6
|
+
|
|
7
|
+
An OpenAI / Anthropic compatible HTTP gateway that aggregates **free** model sources:
|
|
8
|
+
|
|
9
|
+
- **OpenCode Zen** free tier (`opencode.ai/inference/*`, `Bearer public`, with fingerprinting)
|
|
10
|
+
- **Kilo** free models (`ai-gateway.kilo.ai/api/v1`, `isFree: true`)
|
|
11
|
+
|
|
12
|
+
Only free tiers are included. Paid or restricted channels (EAC, ten-account, aggregate) are excluded.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx freiheit --help
|
|
18
|
+
|
|
19
|
+
# List available models
|
|
20
|
+
npx freiheit models
|
|
21
|
+
|
|
22
|
+
# Start the endpoint on the local network
|
|
23
|
+
npx freiheit serve --host 0.0.0.0
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Endpoints
|
|
27
|
+
|
|
28
|
+
- `GET /v1/models` (or `/models`) — aggregated list of free models
|
|
29
|
+
- `POST /v1/chat/completions` (or `/chat/completions`) — OpenAI chat
|
|
30
|
+
- `POST /v1/messages` (or `/messages`) — Anthropic messages (OpenCode models only)
|
|
31
|
+
- `GET /health`
|
|
32
|
+
|
|
33
|
+
## Bun dependency (OpenCode models)
|
|
34
|
+
|
|
35
|
+
OpenCode inference is routed through a Bun-based transport layer (the upstream `egressFetch` delegates POST requests to `opencode.ai` to `bun`). If `bun` is not on your PATH, requests for OpenCode models fail with a `laneConfig` error; the API response includes a hint and `laneConfig: true`. Kilo models and the `/v1/models` listing work fine without Bun.
|
|
36
|
+
|
|
37
|
+
Install Bun: https://bun.sh
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
- Some OpenCode free model ids are region-sensitive (beam/crouton/pulse/muse-spark).
|
|
42
|
+
- Free quota is pooled per egress IP and rate-limited; heavy use may trigger `FreeUsageLimitError`.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# freiheit
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
实现大模型自由,免费模型端点 CLI,灵感来自 [dsh-our-free-model](https://github.com/Ebony-Vinyl/dsh-our-free-model)。
|
|
6
|
+
|
|
7
|
+
兼容 OpenAI / Anthropic 的 HTTP 网关,聚合**免费**模型来源:
|
|
8
|
+
|
|
9
|
+
- **OpenCode Zen** 免费通道(`opencode.ai/inference/*`,`Bearer public`,带指纹)
|
|
10
|
+
- **Kilo** 免费模型(`ai-gateway.kilo.ai/api/v1`,`isFree: true`)
|
|
11
|
+
|
|
12
|
+
仅包含免费通道。付费/受限通道(EAC、ten-account、aggregate)已经排除。
|
|
13
|
+
|
|
14
|
+
## 使用
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx freiheit --help
|
|
18
|
+
|
|
19
|
+
# 列出可用模型
|
|
20
|
+
npx freiheit models
|
|
21
|
+
|
|
22
|
+
# 以局域网启动端点
|
|
23
|
+
npx freiheit --host 0.0.0.0
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 端点
|
|
27
|
+
|
|
28
|
+
- `GET /v1/models`(或 `/models`)—— 聚合的免费模型列表
|
|
29
|
+
- `POST /v1/chat/completions`(或 `/chat/completions`)—— OpenAI 对话
|
|
30
|
+
- `POST /v1/messages`(或 `/messages`)—— Anthropic messages(仅 OpenCode 模型)
|
|
31
|
+
- `GET /health`
|
|
32
|
+
|
|
33
|
+
## Bun 依赖(OpenCode 模型)
|
|
34
|
+
|
|
35
|
+
OpenCode 推理通过基于 Bun 的传输层路由(上游 `egressFetch` 将 opencode.ai 的 POST 请求委托给 `bun`)。如果 PATH 中没有 `bun`,OpenCode 模型请求会因 `laneConfig` 错误而失败;API 响应中会包含提示和 `laneConfig: true`。Kilo 模型和 `/v1/models` 列表在没有 Bun 的情况下也能正常工作。
|
|
36
|
+
|
|
37
|
+
安装 Bun:https://bun.sh
|
|
38
|
+
|
|
39
|
+
## 说明
|
|
40
|
+
|
|
41
|
+
- 部分 OpenCode 免费模型的 id 存在地区敏感性(beam/crouton/pulse/muse-spark)。
|
|
42
|
+
- 免费额度是按出口 IP 池化并限制配额的;大量使用可能触发 `FreeUsageLimitError`。
|
package/bin/freiheit.js
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as package_default, n as startServer, r as toPublicModels, t as listAllModels } from "./server-A5ihtQsE.mjs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
const { version } = package_default;
|
|
8
|
+
const DEFAULT_HOST = "127.0.0.1";
|
|
9
|
+
const DEFAULT_PORT = 8787;
|
|
10
|
+
const cli = cac("freiheit");
|
|
11
|
+
function parsePort(raw) {
|
|
12
|
+
const port = Number(raw);
|
|
13
|
+
return Number.isInteger(port) && port > 0 && port <= 65535 ? port : null;
|
|
14
|
+
}
|
|
15
|
+
function errorMessage(error) {
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
function serve(options) {
|
|
19
|
+
const port = parsePort(options.port ?? DEFAULT_PORT);
|
|
20
|
+
if (port === null) {
|
|
21
|
+
console.error(`Invalid port \`${options.port}\`: expected an integer between 1 and 65535.`);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
startServer(port, String(options.host ?? DEFAULT_HOST), { silent: !!options.silent });
|
|
26
|
+
}
|
|
27
|
+
function printModels(models) {
|
|
28
|
+
const header = [
|
|
29
|
+
"MODEL",
|
|
30
|
+
"SOURCE",
|
|
31
|
+
"CONTEXT"
|
|
32
|
+
];
|
|
33
|
+
const rows = models.map((m) => [
|
|
34
|
+
m.id,
|
|
35
|
+
m.source,
|
|
36
|
+
m.contextWindow ? String(m.contextWindow) : "-"
|
|
37
|
+
]);
|
|
38
|
+
const widths = header.map((h, i) => Math.max(h.length, ...rows.map((row) => row[i].length)));
|
|
39
|
+
const format = (cells) => cells.map((cell, i) => cell.padEnd(widths[i])).join(" ").trimEnd();
|
|
40
|
+
console.log(format(header));
|
|
41
|
+
console.log(widths.map((width) => "-".repeat(width)).join(" "));
|
|
42
|
+
for (const row of rows) console.log(format(row));
|
|
43
|
+
console.log(`\n${models.length} free model(s).`);
|
|
44
|
+
}
|
|
45
|
+
async function models(options) {
|
|
46
|
+
try {
|
|
47
|
+
const list = await listAllModels();
|
|
48
|
+
if (options.json) console.log(JSON.stringify({
|
|
49
|
+
object: "list",
|
|
50
|
+
data: toPublicModels(list)
|
|
51
|
+
}, null, 2));
|
|
52
|
+
else printModels(list);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(`Failed to list models: ${errorMessage(error)}`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
cli.usage("[options]\n freiheit models [--json]");
|
|
59
|
+
cli.option("--host <host>, -H <host>", "Host to bind.", { default: DEFAULT_HOST });
|
|
60
|
+
cli.option("--port, -p <port>", "Port to listen on.", { default: DEFAULT_PORT });
|
|
61
|
+
cli.option("--silent", "Suppress startup logs.");
|
|
62
|
+
cli.command("models", "List the aggregated free models.").option("--json", "Print the OpenAI-style model list as JSON.").action((options) => models(options));
|
|
63
|
+
cli.example("freiheit");
|
|
64
|
+
cli.example("freiheit --host 0.0.0.0 --port 8787");
|
|
65
|
+
cli.example("freiheit models");
|
|
66
|
+
cli.example("freiheit models --json");
|
|
67
|
+
cli.help();
|
|
68
|
+
cli.version(version);
|
|
69
|
+
let parsed;
|
|
70
|
+
try {
|
|
71
|
+
parsed = cli.parse();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(errorMessage(error));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
if (!cli.matchedCommand && !cli.options.help && !cli.options.version) {
|
|
77
|
+
if (parsed.args.length > 0) {
|
|
78
|
+
console.error(`Unknown command \`${parsed.args[0]}\`.`);
|
|
79
|
+
cli.outputHelp();
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
serve(cli.options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { };
|
package/dist/index.mjs
ADDED