by GreyGunG
本地自托管的 Grok Build → Claude Code / OpenAI 兼容代理 | Local self-hosted Grok Build compatibility proxy
# Add to your Claude Code skills
git clone https://github.com/GreyGunG/grokbuild-proxyGuides for using ai agents skills like grokbuild-proxy.
grokbuild-proxy is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by GreyGunG. 本地自托管的 Grok Build → Claude Code / OpenAI 兼容代理 | Local self-hosted Grok Build compatibility proxy. It has 58 GitHub stars.
grokbuild-proxy's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/GreyGunG/grokbuild-proxy" and add it to your Claude Code skills directory (see the Installation section above).
grokbuild-proxy is primarily written in Go. It is open-source under GreyGunG on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh grokbuild-proxy against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
简体中文 | English
grokbuild-proxy 是一个本地、自托管的协议兼容代理,用于将使用者本人
合法持有的 Grok Build 账号接入 Claude Code、Anthropic SDK 和
OpenAI 兼容客户端。
项目将 Anthropic Messages 请求转换到 Grok Build Responses 后端,支持 流式输出、客户端工具、结构化输出、思考强度、CPA 风格 Thinking Block、 加密推理回放和 Grok 内置 Web Search。
[!CAUTION] 本项目是非官方、社区维护的技术学习与协议互操作研究项目,与 xAI、 Grok、Anthropic、OpenAI 及其关联公司无关,也未获得其授权、赞助或 认可。只能使用你本人合法持有并获准自动化操作的账号。使用本项目可能 违反相关服务条款或导致账号限制,全部风险由使用者自行承担。使用前请 阅读完整的免责声明。
POST /v1/messagesPOST /v1/responsesPOST /v1/chat/completionsGET /v1/modelsweb_search_* 映射到 Grok 内置 Web Searchtext.formatClaude Code / Anthropic SDK OpenAI SDK / 兼容客户端
| |
+-------------+----------------+
|
grokbuild-proxy
/v1/messages | /v1/responses
|
凭据池 / OAuth 刷新 / 重试切换
|
cli-chat-proxy.grok.com/v1
组件边界和协议决策见 DESIGN.md。
Linux / macOS:
curl -fsSL \
https://raw.githubusercontent.com/GreyGunG/grokbuild-proxy/main/scripts/install.sh \
| sh
Windows PowerShell:
irm https://raw.githubusercontent.com/GreyGunG/grokbuild-proxy/main/scripts/install.ps1 | iex
安装脚本会自动识别系统与架构、下载最新 Release、验证 SHA-256、安装
二进制并生成本地配置。可以通过 GROKBUILD_VERSION=v0.1.0 固定版本。
git clone https://github.com/GreyGunG/grokbuild-proxy.git
cd grokbuild-proxy
cp config.example.yaml config.yaml
go run ./cmd/grokbuild-proxy
默认监听 127.0.0.1:8080。
api_key 和 admin_key 留空时,首次启动会将随机密钥写入
data/meta.json。该文件包含敏感信息,禁止提交或分享。
jq -r .api_key data/meta.json
jq -r .admin_key data/meta.json
打开 Admin UI:
http://127.0.0.1:8080/admin
在 Admin UI 中完成浏览器登录、导入 Grok CLI 凭据、管理账号池,以及 创建或撤销客户端密钥。
建议优先使用代理自己的浏览器 Device Login。直接导入
~/.grok/auth.json 可能复制一份已经旋转或撤销的 Refresh Token。
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
export ANTHROPIC_AUTH_TOKEN="$(jq -r .api_key data/meta.json)"
export ANTHROPIC_MODEL=grok-4.5
claude --effort high
也可以使用配置过的 Claude 模型别名:
export ANTHROPIC_MODEL=claude-sonnet-5
通过 anthropic.model_aliases 可以把 Claude 模型映射到指定 Grok 模型。
export OPENAI_BASE_URL=http://127.0.0.1:8080/v1
export OPENAI_API_KEY="$(jq -r .api_key data/meta.json)"
curl --fail --silent --show-error \
http://127.0.0.1:8080/v1/responses \
-H "Authorization: Bearer ${OPENAI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.5",
"input": "Reply with exactly: ok",
"max_output_tokens": 16
}'
cp config.example.yaml config.yaml
docker compose up --build -d
docker compose exec grokbuild-proxy sh -c 'cat /app/data/meta.json'
Compose 只在宿主机发布 127.0.0.1:8080,运行状态保存在命名卷中。
预构建镜像:
ghcr.io/greygung/grokbuild-proxy
以 config.example.yaml 为起点。
| 配置项 | 用途 |
|---|---|
listen |
HTTP 监听地址,默认仅 Loopback |
allow_public_listen |
非 Loopback 监听必须显式开启 |
data_dir |
凭据、客户端密钥和启动密钥目录 |
api_key |
客户端 API 鉴权;留空自动生成 |
admin_key |
Admin API/UI 鉴权;留空自动生成 |
upstream.* |
Grok CLI 上游地址与客户端请求头 |
oauth.* |
xAI OAuth Issuer、Client、Scope 和回调 |
anthropic.model_aliases |
Claude 模型到 Grok 模型的映射 |
lb.* |
凭据选择、会话粘滞、刷新和冷却策略 |
limits.* |
Body、超时和并发限制 |
logging.level |
debug、info、warn 或 error |
未知 YAML 字段会导致启动失败。
curl http://127.0.0.1:8080/healthz
curl http://127.0.0.1:8080/readyz
curl http://127.0.0.1:8080/metrics
/healthz:进程存活/readyz:存储可用且至少存在一个可用凭据/metrics:Prometheus 文本格式指标本项目只实现文档中列出的 Anthropic / OpenAI 兼容子集。
count_tokens 尚未实现,返回 404。top_k 和 stop_sequences 不会转发给 Grok Reasoning 模型。完整矩阵见 COMPATIBILITY.md。
make build
make check
make release-snapshot
# 或直接使用 Go
gofmt -w ./cmd ./internal
go vet ./...
go test ./...
go test -race ./...
go build ./cmd/grokbuild-proxy
跨平台编译、Docker、GoReleaser、Live Probe 和故障排查见 构建与运行指南。
友情链接:LINUX DO
项目在设计和协议研究过程中参考了以下开源项目:
感谢上述项目公开的实现、文档和协议研究。它们均为独立项目,不代表其 作者认可、赞助或支持本仓库。
使用前请阅读完整免责声明。
请阅读 CONTRIBUTING.md。协议行为变更应同时补充测试 并更新 COMPATIBILITY.md。
本项目使用 MIT License。