360 Secure SkillHub
360 安全技能中心

xAI

该 Skill 用 Node 脚本封装 xAI API:chat.js 调 Grok 模型做文本问答与图像理解,models.js 列出可用模型,search-x.js 借 xAI Responses 的 x_search 工具检索实时 X 帖子并附引用。需配置 XAI_API_KEY,并把提示词或图片发送到外部服务。

mvanhorn
mvanhorn
热度 95.06
最近更新 2026-05-11 15:50:48
分类:知识依赖:代码执行 / 读写文件 / 第三方 API / 内部调用大模型应用场景:研究 / 概念解释 / 社交媒体

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add xai
Metadata
name
xai
version
1.1.0
description
Chat with Grok models via xAI API. Supports Grok-4, Grok-4.20, Grok-3, Grok-3-mini, vision, and real-time X search.
author
mvanhorn
license
MIT
repository
https://github.com/mvanhorn/clawdbot-skill-xai
homepage
https://docs.x.ai
triggers
["grok","xai","ask grok"]
metadata
{"openclaw":{"emoji":"🤖","requires":{"env":["XAI_API_KEY"]},"primaryEnv":"XAI_API_KEY","tags":["xai","grok","llm","vision","x-search"]}}

xAI / Grok

Chat with xAI's Grok models. Supports text and vision.

Setup

Set your API key in the skill config:

# Via openclaw config
openclaw config set skills.entries.xai.apiKey "xai-YOUR-KEY"

# Or environment variable
export XAI_API_KEY="xai-YOUR-KEY"

Get your API key at: https://console.x.ai

Commands

Chat with Grok

node {baseDir}/scripts/chat.js "What is the meaning of life?"

Use a specific model

node {baseDir}/scripts/chat.js --model grok-3-mini "Quick question: 2+2?"

Vision (analyze images)

node {baseDir}/scripts/chat.js --image /path/to/image.jpg "What's in this image?"

🔍 Search X/Twitter (Real-time!)

node {baseDir}/scripts/search-x.js "Remotion video framework"
node {baseDir}/scripts/search-x.js --days 7 "Claude AI tips"
node {baseDir}/scripts/search-x.js --handles @remotion_dev "updates"

Uses xAI Responses API with x_search tool for real X posts with citations.

List available models

node {baseDir}/scripts/models.js

Available Models

  • grok-3 - Most capable, best for complex tasks
  • grok-3-mini - Fast and efficient
  • grok-3-fast - Optimized for speed
  • grok-2-vision-1212 - Vision model for image understanding

Example Usage

User: "Ask Grok what it thinks about AI safety" Action: Run chat.js with the prompt

User: "Use Grok to analyze this image" (with attached image) Action: Run chat.js with --image flag

User: "What Grok models are available?" Action: Run models.js

API Reference

xAI API Docs: https://docs.x.ai/api

Environment Variables

  • XAI_API_KEY - Your xAI API key (required)
  • XAI_MODEL - Default model (optional, defaults to grok-3)