AgentSkillsCN

xai-grok

xAI Grok API可用于图像生成、聊天、视觉分析、实时搜索以及视频生成。当用户希望使用Grok、xAI或Grok Imagine生成图像、与Grok进行聊天、通过Grok Vision分析图像、使用Grok搜索网络/新闻/X,或生成视频时,可使用此功能。可通过“Grok”“xAI”“Grok Imagine”“询问Grok”“Grok Vision”“Grok搜索”等触发词来启动该操作。

SKILL.md
--- frontmatter
name: xai-grok
description: xAI Grok APIs for image generation, chat, vision, live search, and video. Use when the user asks to use Grok, xAI, or Grok Imagine for generating images, chatting with Grok, analyzing images with Grok Vision, searching the web/news/X with Grok, or generating videos. Triggers on "grok", "xai", "grok imagine", "ask grok", "grok vision", "grok search".
allowed-tools: mcp__xai__generate_image, mcp__xai__chat, mcp__xai__analyze_image, mcp__xai__live_search, mcp__xai__generate_video

xAI Grok MCP Server

Access xAI's Grok APIs through the MCP server.

When to Use This Skill

Use this skill when the user:

  • Asks to generate images with Grok or Grok Imagine
  • Wants to chat with Grok models
  • Asks Grok to analyze or describe an image
  • Wants to search the web, news, or X/Twitter with Grok
  • Asks to generate videos with Grok

Trigger phrases: "grok", "xai", "grok imagine", "ask grok", "grok vision", "use grok"

Available Tools

ToolDescription
generate_imageGenerate images using Grok Imagine
chatChat with Grok models (grok-3, grok-4, grok-3-mini)
analyze_imageAnalyze images with Grok Vision
live_searchReal-time web, news, and X/Twitter search
generate_videoGenerate videos from text prompts

Image Generation

Generate images with Grok Imagine:

code
User: "Using grok imagine, create a cyberpunk cityscape"
Tool: generate_image
Parameters:
  prompt: "cyberpunk cityscape at night with neon lights"
  n: 1 (optional, 1-10)
  aspect_ratio: "16:9" (optional)

Supported Parameters

ParameterTypeDefaultDescription
promptstringrequiredImage description
nnumber1Number of images (1-10)
modelstringgrok-2-imageImage model
aspect_ratiostring-"16:9", "1:1", "4:3", etc.
response_formatstringurl"url" or "b64_json"

Chat with Grok

Chat with Grok language models:

code
User: "Ask Grok to explain quantum computing"
Tool: chat
Parameters:
  message: "Explain quantum computing in simple terms"
  model: "grok-3" (optional)

Supported Parameters

ParameterTypeDefaultDescription
messagestringrequiredMessage to send
modelstringgrok-3grok-3, grok-4, grok-3-mini
system_promptstring-System context
temperaturenumber0.7Sampling temperature (0-2)
max_tokensnumber-Max response tokens

Image Analysis (Vision)

Analyze images with Grok Vision:

code
User: "Use Grok to analyze this image: https://example.com/photo.jpg"
Tool: analyze_image
Parameters:
  image_url: "https://example.com/photo.jpg"
  prompt: "What do you see in this image?"

Supported Parameters

ParameterTypeDefaultDescription
image_urlstringrequiredImage URL or base64
promptstring"Describe this image"Question/instruction
detailstringauto"low", "high", "auto"
modelstringgrok-2-vision-1212Vision model

Live Search

Search web, news, or X/Twitter:

code
User: "Search for the latest SpaceX news using Grok"
Tool: live_search
Parameters:
  query: "SpaceX launches"
  sources: ["news"]

Supported Parameters

ParameterTypeDefaultDescription
querystringrequiredSearch query
sourcesarray["web"]"web", "news", "x"
date_rangeobject-{start, end} YYYY-MM-DD
max_resultsnumber10Max results (1-20)

Video Generation

Generate videos from text:

code
User: "Generate a video of clouds moving across a blue sky"
Tool: generate_video
Parameters:
  prompt: "clouds moving across a blue sky, timelapse"
  duration: 5

Supported Parameters

ParameterTypeDefaultDescription
promptstringrequiredVideo description
modelstringgrok-2-videoVideo model
durationnumber5Duration (1-15 seconds)
imagestring-Input image to animate
videostring-Input video to edit
aspect_ratiostring-"16:9", "9:16", etc.
wait_for_completionbooleantrueWait for video

Troubleshooting

MCP Server Not Connected

  1. Check /mcp in Claude Code
  2. Verify ~/.claude/mcp.json has the xai entry
  3. Restart Claude Code

API Key Issues

Ensure XAI_API_KEY is set in ~/.claude/mcp.json:

json
"env": {
  "XAI_API_KEY": "xai-your-key-here"
}

Get your API key from: https://x.ai/api