本地免费AI,云端白嫖顶配 | Local Free AI, Cloud Freeload Flagship
把 AI 请回家自己养——Ollama 和 LM Studio 让你的电脑变成不联网、不收月费、也不偷看你聊天记录的私人智囊;嘴馋云端顶配的,Puter.js 和那份免费清单也能让你零成本蹭上 GPT、Claude。唯一的小情绪是:本地模型偶尔"智商掉线",显存不够还会喘粗气;云端免费额度像自助餐——管饱,但别当饭天天吃。总之省下的订阅费够加好几顿鸡腿,隐私还稳稳攥在自己兜里。
Adopt an AI and raise it at home—Ollama and LM Studio turn your laptop into a private brain that never phones home, never charges rent, and never reads your diary. Craving flagship cloud models? Puter.js and that free-API list let you freeload GPT and Claude for $0. The only drama: local models occasionally brain-fart and wheeze when VRAM runs low, and free cloud quotas are a buffet—filling, but don't move in. Net result: enough saved subscription cash for extra fried chicken, privacy firmly in your own pocket.
思路很简单,一句话:本地优先,免费云端兜底。先问你电脑里的 Ollama 本地模型(离线、零成本、不外传数据),本地没装或跑不动时,再自动切到一个免费云端接口。
The idea fits in one line: local-first, free-cloud fallback. Ask the Ollama model on your own machine first (offline, zero-cost, data never leaves home); if it isn't installed or can't cope, auto-switch to a free cloud endpoint.
操作步骤/Step by step guide
1. 装 Ollama(官网一键装,Mac/Win/Linux),拉个模型:ollama pull qwen3(它会自动在 11434 起服务)。
2. (图形党可选)装 LM Studio → 下模型 → 开发者页开 server(1234)。脚本里把 base_url 改成 :1234 就切过去了。
3. 免费云端兜底:去 cheahjs/free-llm-api-resources 挑一个免费 key(例:Groq,OpenAI 兼容、无需信用卡,注册需邮箱)。
4. 装依赖(用公司内部 registry,别走公网 pypi):
pip install openai --index-url https://nexus.apps.origin.com.au/repository/shared-pypi-proxy/simple
5. 跑脚本:python ai_assistant.py
# ai_assistant.py — 本地优先 + 免费云端兜底 的命令行 AI 助手
from openai import OpenAI
# 1) 本地引擎:Ollama 默认端口 11434
# 想改用 LM Studio?把下面的 base_url 换成 "http://localhost:1234/v1" 即可
LOCAL = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
LOCAL_MODEL = "qwen3" # 先执行过 ollama pull qwen3
# 2) 免费云端兜底:从 cheahjs/free-llm-api-resources 挑一个免费 key
# 这里以 Groq 免费额度为例(OpenAI 兼容、无需信用卡)
CLOUD = OpenAI(
base_url="https://api.groq.com/openai/v1",
api_key="在此粘贴你的免费_Groq_key",
)
CLOUD_MODEL = "llama-3.3-70b-versatile"
def ask(prompt: str) -> str:
for client, model, where in [
(LOCAL, LOCAL_MODEL, "本地"),
(CLOUD, CLOUD_MODEL, "云端"),
]:
try:
r = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
)
return f"[{where}] " + r.choices[0].message.content
except Exception as e:
print(f"{where}引擎不可用({e}),尝试下一个…")
return "两个引擎都失败了:确认 Ollama 是否在运行,或云端 key 是否填了。"
if __name__ == "__main__":
print("输入问题开始聊天(输入 q 退出)")
while True:
q = input("\n你:").strip()
if q.lower() in {"exit", "quit", "q", ""}:
break
print(ask(q))
6. 可选:Puter.js 零安装网页版(把下面存成 puter_bonus.html,双击即可)。注意 Puter.js 是 User-Pays——开发者免费,用户轻量额度用完需自己登录 Puter 付费:
html<!-- puter_bonus.html -->
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat("用一句话解释什么是本地大模型", { model: "claude-sonnet-5" })
.then(r => document.body.innerText = r.message.content[0].text);
</script>
相关链接(related links)
https://ollama.com
https://github.com/ollama/ollama
https://lmstudio.ai
https://developer.puter.com
https://puter.com/
https://js.puter.com/v2/
https://docs.puter.site/
https://github.com/HeyPuter/puter
https://github.com/cheahjs/free-llm-api-resources
https://console.groq.com
评论
发表评论