Grok Api
通过 LeonAI 代理调用 xAI Grok API,支持多模型文本对话、深度推理及图片视频生成与编辑,兼容 OpenAI 格式。
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 0 · 32 · 1 current installs · 1 all-time installs
by@lygjoey
MIT-0
Security Scan
OpenClaw
Suspicious
medium confidencePurpose & Capability
The name/description (call Grok via LeonAI proxy) aligns with the included code and SKILL.md: both show HTTP calls to a Grok API proxy and support chat/image/video endpoints. However the registry metadata lists no required environment variables while SKILL.md and the script expect GROK_API_KEY and GROK_BASE_URL, which is inconsistent and could lead to user confusion.
Instruction Scope
Instructions only direct the agent/user to call the proxy API endpoints (chat, images, videos) and to store GROK_API_KEY in personal-secrets.json; they do not instruct reading unrelated files or accessing other credentials. They do instruct sending potentially sensitive content to the configured BASE_URL, so the trustworthiness of that endpoint matters.
Install Mechanism
No install spec or remote downloads; the skill is instruction-only with a small pure-Python script that uses only the standard library. Nothing is written to disk beyond the included script when you install the skill.
Credentials
Only an API key and a base URL are required by the script, which is proportionate to the task. The concern is twofold: (1) the registry metadata does not declare these required env vars, and (2) the default BASE_URL points to a third-party proxy (https://apileon.leonai.top). Supplying an API key to an unverified proxy can expose your requests and data to that operator.
Persistence & Privilege
The skill does not request always:true, does not modify other skills or system config, and has no persistent/install-time privileged behavior. Agent autonomy remains at the platform default.
What to consider before installing
This skill appears to do what it says (calls Grok via a LeonAI proxy) and the Python script is small and readable. Before installing or providing keys: (1) verify who operates the default proxy URL (apileon.leonai.top) — if you don't trust it, change GROK_BASE_URL to an endpoint you trust or use an account/key dedicated to the proxy; (2) do not reuse high-privilege keys — create a scoped/test key if possible and avoid sending secrets or sensitive data through the proxy; (3) note the registry metadata omission: the skill requires GROK_API_KEY and GROK_BASE_URL even though the registry lists none, so make sure your environment/set-up matches the SKILL.md; (4) review the small grok_chat.py yourself (it only does HTTP calls) and test with non-sensitive inputs first. If you cannot verify the proxy operator, consider using an official xAI endpoint or another vetted integration instead.Like a lobster shell, security has layers — review code before you run it.
Current versionv1.0.0
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
SKILL.md
Grok API Skill
Description
通过 LeonAI 代理调用 xAI Grok API,支持文本对话、推理、图片生成/编辑、视频生成。兼容 OpenAI Chat Completions 格式。
触发场景
- 用户说"用 Grok 聊天/问问题/分析"
- 用户说"用 Grok 生成图片/画图"
- 用户说"用 Grok 生成视频"
- 用户提到 Grok 模型名(grok-3, grok-4, grok-4.1 等)
环境变量要求
GROK_API_KEY— LeonAI 代理的 API Key(存入 personal-secrets.json)GROK_BASE_URL— 默认https://apileon.leonai.top/grok/v1
可用模型
文本模型
| 模型 | 特点 | Tier | Cost |
|---|---|---|---|
| grok-3 | 基础文本 | basic | low |
| grok-3-mini | 轻量推理 | basic | low |
| grok-3-thinking | 深度推理 | basic | low |
| grok-4 | 进阶文本 | basic | low |
| grok-4-mini | 快速回复 | basic | low |
| grok-4-thinking | 进阶推理 | basic | low |
| grok-4-heavy | 重量级 | super | high |
| grok-4.1-mini | 最新快速 | basic | low |
| grok-4.1-fast | 极速 | basic | low |
| grok-4.1-expert | 专家级 | basic | high |
| grok-4.1-thinking | 最新推理 | basic | high |
| grok-4.20-beta | Beta测试 | basic | low |
图片/视频模型
| 模型 | 功能 |
|---|---|
| grok-imagine-1.0 | 图片生成 |
| grok-imagine-1.0-fast | 快速图片生成 |
| grok-imagine-1.0-edit | 图片编辑 |
| grok-imagine-1.0-video | 视频生成 |
使用方式
1. 文本对话
curl -s -X POST "$GROK_BASE_URL/chat/completions" \
-H "Authorization: Bearer $GROK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.1-mini",
"stream": false,
"messages": [{"role": "user", "content": "你好"}]
}'
2. 推理模式
curl -s -X POST "$GROK_BASE_URL/chat/completions" \
-H "Authorization: Bearer $GROK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.1-thinking",
"stream": false,
"reasoning_effort": "high",
"messages": [{"role": "user", "content": "分析量子计算的前景"}]
}'
3. 图片生成
curl -s -X POST "$GROK_BASE_URL/images/generations" \
-H "Authorization: Bearer $GROK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "描述文本",
"model": "grok-imagine-1.0",
"n": 1,
"size": "1024x1024",
"response_format": "url",
"enable_nsfw": true
}'
可选 size: 1024x1024 / 1280x720 / 720x1280 / 1792x1024 / 1024x1792
4. 视频生成
curl -s -X POST "$GROK_BASE_URL/videos" \
-H "Authorization: Bearer $GROK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "视频描述",
"model": "grok-imagine-1.0-video",
"size": "1792x1024",
"seconds": 6,
"quality": "standard"
}'
seconds: 6-30 | quality: standard(480p) / high(720p)
5. 脚本调用
# 文本
python3 scripts/grok_chat.py "你好Grok"
python3 scripts/grok_chat.py --model grok-4.1-thinking --reasoning high "分析问题"
# 图片
python3 scripts/grok_chat.py --image "描述"
# 视频
python3 scripts/grok_chat.py --video "描述"
# 列出模型
python3 scripts/grok_chat.py --list-models
推荐模型选择
- 日常对话/快速问答 →
grok-4.1-mini或grok-4.1-fast - 深度分析/推理 →
grok-4.1-thinking+reasoning_effort: high - 图片生成 →
grok-imagine-1.0(高质量)或grok-imagine-1.0-fast(快速) - 视频生成 →
grok-imagine-1.0-video
注意事项
- API 通过 LeonAI 代理转发,非 xAI 直连
- 额度:Basic tier 80次/20h,Super tier 140次/2h
- 图片/视频生成为异步,URL 有时效性,建议及时下载
enable_nsfw: true可开启 NSFW 内容生成
Files
2 totalSelect a file
Select a file to preview.
Comments
Loading comments…
