文档
这里是 FreeAITokens 背后的细节,写给开发者和好奇的人。如果你只想让它跑起来,请下载应用并按设置操作。
命令行
装有 Node.js 20 或更新版本的话,你不需要应用:
npx freeaitokens # start the local endpoint
npx freeaitokens add # add a free provider key (guided)
npx freeaitokens list # providers, key status, what is left today
npx freeaitokens remove <id> # delete a stored key
或者一次性安装:npm install -g freeaitokens。本地接口只监听 127.0.0.1:4949,并且需要启动横幅里显示的本地令牌。应用和命令行共用同样的密钥和设置。
配合你的工具使用
| 工具 | 方法 |
|---|---|
| Claude Code | npx freeaitokens claude(后面可以跟任何 Claude Code 的参数) |
| Codex | npx freeaitokens codex |
| Gemini CLI | npx freeaitokens gemini |
| OpenCode | npx freeaitokens setup opencode,然后选择模型 freeaitokens/free |
| Kilo Code CLI、Qwen Code、Goose、Aider | npx freeaitokens kilo / qwen / goose / aider |
| Zed、JetBrains AI、VS Code | npx freeaitokens setup zed / jetbrains / vscode 会打印出该粘贴的内容 |
| Continue、Cline、Crush、Roo Code | npx freeaitokens setup cline(或该工具的名字)会打印出要填的值 |
| 任何兼容 OpenAI 的工具 | Base URL http://127.0.0.1:4949/v1,模型 free,密钥取自启动横幅 |
| Anthropic、Gemini 或 Ollama 客户端 | Base URL http://127.0.0.1:4949,密钥相同 |
启动器只影响那一次会话,不会往你工具的配置里写任何东西。setup opencode 会在你已有的服务商旁边添加一个,并保留备份;用 --undo 可以恢复。
它做了什么
- 每个请求选一个模型。只选能胜任的模型:上下文够长、工具需要时支持工具调用、有图片时支持看图。它偏好对你来说又快又稳的更好的模型,并且在一次对话中会一直用同一个模型,除非另一个明显更合适。
- 自动切换。遇到限流、服务器错误或超时,它会在你的工具察觉之前就换下一个模型。如果所有模型都忙,而额度会在 30 秒内恢复,它会等待;否则会告诉你什么时候能恢复。
- 追踪免费额度,按服务商、模型和密钥分别统计,精确到每分钟和每天,并根据服务商返回的额度信息自行校正。
- 支持五种格式:OpenAI chat completions、Anthropic Messages(Claude Code)、OpenAI Responses(Codex)、Gemini(Gemini CLI)和 Ollama(
/api/chat)。 - 保持服务商列表最新,列表带签名,使用前会校验,所以新的免费模型不用更新应用就能用上。
不止对话
同一个接口还支持 OpenAI 的这些路径:向量嵌入(/v1/embeddings)、普通文本补全(/v1/completions)、图片(/v1/images/generations)、文字转语音(/v1/audio/speech)、语音转文字(/v1/audio/transcriptions)和视频(/v1/videos)。每种请求都会发给提供该功能的免费服务商,同样有自动切换和额度限制。
- 目前免费的有:向量嵌入(Gemini、OpenRouter、SEA-LION、Cloudflare、OVH)、文本补全(Cerebras、OpenRouter、OVH)、图片(Cloudflare Flux、OpenRouter)、文字转语音(Groq、OpenRouter、Cloudflare)、语音转文字(Groq、Cloudflare、OVH)。目前还没有服务商提供免费视频。
- 向量嵌入:不同模型生成的向量不能互相比较。请发送响应里告诉你的模型名(例如
gemini-embedding-001),之后的请求就会一直用它。
付费密钥与选项
付费密钥可以排在免费密钥之后,作为最后的备选:只有在没有免费模型能处理请求时才会用,每次付费请求都会打印出来,并且有每日上限。
| 选项 | 作用 |
|---|---|
--port <n> | 本地接口的端口(默认 4949) |
--free-only | 从不使用付费密钥 |
--paid-cap <n> | 每天最多的付费请求数(默认 200) |
全部 27 家服务商
它们加起来每月最多公布 约 75.2亿 个免费 token。这个数字是把各家公布的免费额度加总得到的,只公布了请求次数限制的,按每次请求 2,000 个 token 计算;其中大部分来自少数几份大额度,而且你只有为每家服务商都添加密钥才能用上。没有公布额度的服务商按零计算。
| 服务商 | 是否需要密钥 | 免费额度 | 须知 |
|---|---|---|---|
| Kilo Gateway | 否 | 未公布 | No account needed. About 200 requests an hour per IP address. Free prompts and answers may be used for training. |
| Groq | 免费密钥 | 每个模型每天最多 500,000 个 token | |
| Cerebras | 免费密钥 | 每个模型每天最多 216,000,000 个 token | |
| OpenRouter | 免费密钥 | 每个模型每天最多 50 次请求 | Free models allow about 50 requests a day on an account with no credit. |
| Google Gemini | 免费密钥 | 每个模型每天最多 1,000 次请求 | Google's terms limit the API to professional or business use. Free-tier prompts may be used to improve Google's products. |
| SEA-LION | 免费密钥 | 每分钟 10 次请求 | Google sign-in, one trial key per user, and the terms allow AI Singapore to use content to improve its services. |
| Typhoon | 免费密钥 | 每分钟 200 次请求 | A free research showcase API: SCB 10X collects usage data to improve its models and API. |
| NVIDIA NIM | 免费密钥 | 未公布 | Free access is a trial for prototyping and testing only; production use needs an NVIDIA AI Enterprise license, and rate limits vary by model and load. |
| Z.ai (GLM) | 免费密钥 | 未公布 | Only the Flash models are free. Their rate limits are not published and show only in the Z.ai console. |
| Nabh Cloud | 免费密钥 | 每个模型每天最多 500 次请求 | Reseller. Only GPT OSS 20B is free, at 5 requests a minute and 500 a day. |
| KiosAPI | 免费密钥 | 未公布 | Reseller (Indonesia). A small daily free quota on its free-tier models; the amounts are not published. One account per person. |
| Kenari | 免费密钥 | 每个模型每天最多 50 次请求 | Reseller (Indonesia), no company named. Free models are capped at 5 a minute and 50 a day; upstream providers' policies apply. |
| Plugsky | 免费密钥 | 每个模型每天最多 50,000 个 token | Reseller. 100 free requests and 50K tokens a day. The free model does not say what runs underneath, and failover may switch models. |
| ZRO (MoonMath) | 免费密钥 | 未公布 | Reseller. The $0 plan gives some DeepSeek V4.1 Flash use each day; the amount is not stated. |
| Requesty | 免费密钥 | 每个模型每天最多 200 次请求 | Reseller. Free models at 200 a day and 20 a minute. Logs are kept 30 days and Requesty may train on free-plan content. |
| BazaarLink | 免费密钥 | 每分钟 10 次请求 | Reseller (Taiwan). 10 a minute and a small daily allowance. Failed, flagged and sampled requests are kept in full. |
| Logfare | 免费密钥 | 每个模型每天最多 5,000 次请求 | Reseller. 5,000 free requests a day, but you must link Discord and stay in its server. Everything is logged and used for evals unless you opt out. |
| CheapLLM | 免费密钥 | 未公布 | Small reseller on its own GPUs. Free during its beta; afterwards only about 5K tokens in and 1K out per hour. One request at a time. |
| OVHcloud AI Endpoints | 否 | 每分钟 2 次请求 | No account needed. About 2 requests a minute per IP address for each model. |
| LLM7.io | 免费密钥 | 未公布 | Small operator with no published free-tier terms or limits; data handling is unclear. |
| AI Horde | 免费密钥 | 未公布 | Volunteer workers run the models and can see your prompts; it is queued, slow, has no tool calls, and the model list changes often. |
| BlockRun | 免费密钥 | 每分钟 30 次请求 | |
| Electron Hub | 免费密钥 | 每个模型每天最多 10 次请求 | Providers behind :free models may train on your prompts. A Neutrino is spent even when a request fails, and going over 5 rpm triggers a 3-minute cooldown. |
| Septor Labs | 免费密钥 | 每个模型每天最多 250,000 个 token | Free requests go to third-party aggregators (some hosted in China) that may keep prompts; not for personal or sensitive data. |
| Api.Airforce | 免费密钥 | 每个模型每天最多 1,000 次请求 | Small reseller with unclear upstream sources; logs IPs and usage, and the free plan allows only 1 request per minute. |
| Routeway | 免费密钥 | 每个模型每天最多 200 次请求 | Operator is not named in its terms, and requests are scanned before routing to upstream providers. |
| Cloudflare Workers AI | 免费密钥 | 未公布 | 10,000 free Neurons a day, shared by every Cloudflare model you use (chat, embeddings, images, speech, transcription); resets at 00:00 UTC. The key is your Account ID plus an API token. |
暂不支持
- Cursor:它会让自定义接口的流量经过它自己的服务器,而那些服务器连不到本地地址。
- ChatGPT 应用:它不能使用自定义接口。
- 图片编辑、音频翻译、实时语音。
- Codex 的已连接应用(MCP)工具和网页搜索不会传给免费模型:它们带来的上下文比免费模型能接受的更多。
源代码、问题反馈和完整的 README:GitHub。