skills/ai-apis/xai-grok/SKILL.md
xAI Grok API: OpenAI-compatible at api.x.ai/v1, grok-3/grok-3-mini for fast AI reasoning
npx skillsauth add alphaonedev/openclaw-graph xai-grokInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill enables interaction with the xAI Grok API, an OpenAI-compatible service for fast AI reasoning tasks. It provides access to models like grok-3 and grok-3-mini via api.x.ai/v1, allowing developers to integrate advanced AI capabilities for text generation, reasoning, and more.
Use this skill when you need quick AI inference for applications requiring natural language processing, such as chatbots, code generation, or data analysis. Opt for it over other APIs if you're already using OpenAI-compatible tools and want xAI's specialized models for faster responses, especially in scenarios with real-time constraints like live customer support or dynamic content creation.
To use this skill, set the API key in your environment (e.g., export XAI_API_KEY=your_key), then make HTTP requests to api.x.ai/v1. Structure requests as POST calls with JSON bodies. For chat interactions, specify the model and messages array. Always include error checking in your code loops. If using in a script, handle retries for rate limits. For asynchronous patterns, use webhooks or polling on response IDs.
Integrate by setting $XAI_API_KEY as an environment variable before runtime. In Python, use requests library: import os; api_key = os.environ.get('XAI_API_KEY'). For Node.js, use fetch with headers. Avoid hardcoding keys; use secure vaults. If proxying requests, ensure HTTPS passthrough. Test with a simple script first, and handle rate limits by checking response headers for X-RateLimit-Remaining. For embedding, map xAI models to OpenAI formats in your codebase.
Check HTTP status codes: 401 for invalid API key (retry with correct $XAI_API_KEY); 429 for rate limits (implement exponential backoff, e.g., wait 5 seconds then retry). Parse JSON errors for messages like "context_length_exceeded" and truncate input accordingly. In code, wrap requests in try-except blocks: try: response = requests.post(url, headers=headers, json=data) except requests.exceptions.RequestException as e: log_error(e) and raise. For model-specific errors, validate inputs before sending, e.g., ensure messages array is not empty.
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui