你需要什么
AnyRouter 的 API 就是 HTTPS。能跑 curl 或 Python/Node.js 脚本的环境都能用 — 没有专用客户端,没有按 OS 分发的二进制,也不要 root。
你需要:
- AnyRouter 账号和 API key(在 anyrouter.dev 免费创建)
- curl、Python、Node.js,或任意 HTTP 客户端
- 能出站访问 anyrouter.dev 的 HTTPS
终端快速探测
一条 curl 验证连通:
curl -s https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-v1-placeholder" \
-H "Content-Type: application/json" \
-d '{"model":"anyrouter/free","messages":[{"role":"user","content":"Say hi"}]}'如果返回带 choices 的 JSON,就通了。401 说明 key 不对;网络超时说明出站 HTTPS 被拦。
环境常见坑
- HTTPS 代理 — 公司代理后面,设 HTTPS_PROXY,让 curl 和 SDK 能到 anyrouter.dev。
- 防火墙 — 无头服务器和 CI runner 确认出站 443 开着。
- TLS 证书 — 有的精简 Docker 镜像不带 CA。出现 SSL 错误就装 ca-certificates。
- 时钟偏差 — 服务器时间差几分钟以上,TLS 握手会失败。用 NTP 对时。
脚本和 CI
把 key 放环境变量。不要写死进会进版本库的脚本:
export ANYROUTER_API_KEY="sk-ar-v1-..."
# Then in Python:
# base_url="https://anyrouter.dev/api/v1"
# Or Node.js:
# baseURL: "https://anyrouter.dev/api/v1"CI 平台(GitHub Actions、GitLab CI 等)都支持加密 secrets — 把 key 放那里,在 workflow 里当环境变量引用。
状态和可靠性
anyrouter.dev 的当前状态看系统状态页,或打健康检查端点。间歇失败时,故障切换路由通常不用改代码就能扛过去。
按模型看请求级健康、延迟和错误率:chmonitor.dev。
Linux、WSL、CI,或任何能 HTTPS 的环境都能用。免费注册。
开始使用相关文章
Free LLM API access for students and side projects
You don't need a company card to build with real models. Between a no-spend free tier, a $2/mo plan if you outgrow it, and routing on free-tier keys you may already have from providers like Google AI Studio, there's a durable way to stay at $0 while a class project or side hustle is still finding its shape.
Run Claude Code on AnyRouter — wrapper script or CLI
Route Claude Code through AnyRouter in two ways: a wrapper that installs itself and maps Opus, Sonnet, and Haiku to one catalog model (override with --model), or the anyr CLI launcher. One key, unified billing, audit logs.