xai-grok-api-guide

xai-grok-api-guide is a skill for Claude Code, Codex from nirholas/three.ws. It costs 63 tokens per session (1,071 once invoked), scanned A, original, Apache-2.0.

A guide to using the xAI Grok API, an online service for sending requests to Grok language models. It covers text generation, image understanding, function calling, long prompts, and searches of current posts on X, formerly Twitter.

In plain words
What is it for?
It helps build API requests, add tool or function calls, process images, handle long context, and retrieve current X data.
Why use it?
It gives developers a reference for connecting applications to Grok and choosing among its documented model options.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/nirholas/three.ws/xai-grok-api-guide
Any agent
npx skills add nirholas/three.ws --skill xai-grok-api-guide
Clone the repo
git clone --depth 1 https://github.com/nirholas/three.ws

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for xai-grok-api-guide

README.md
[![agentmods](https://agentmods.dev/badge/skills/nirholas/three.ws/xai-grok-api-guide.svg)](https://agentmods.dev/skills/nirholas/three.ws/xai-grok-api-guide)
Your own site
<a href="https://agentmods.dev/skills/nirholas/three.ws/xai-grok-api-guide"><img src="https://agentmods.dev/badge/skills/nirholas/three.ws/xai-grok-api-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,071 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00063 $0.01071
Opus 5 $0.00032 $0.00535
Sonnet 5 $0.00013 $0.00214
Haiku 4.5 $0.00006 $0.00107

Measured yesterday against content hash 8822aa421173, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

xai-grok-api-guide scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl https://api.x.ai/v1/chat/completions \
data/skills/general/xai-grok-api-guide/SKILL.md · 152 lines

How it starts

The opening of the file, as written. The whole thing — 152 lines — stays where its author put it; the contents beside it link to each section on GitHub.

xAI Grok API Guide

Grok is xAI's frontier AI model with native X (Twitter) data access. This guide covers API usage, models, and integration patterns.

Why Grok?

Feature Grok Advantage
Real-time X data Access to live tweets, trending topics
No knowledge cutoff Trained on latest data continuously
Humor/personality More engaging conversational style
Function calling Full tool support
Vision Image understanding
Long context 128K+ context window

Models

Model Context Best For Price (1M tokens)
Grok-3 128K Complex reasoning, analysis $5 / $15
Grok-2 128K General tasks, faster $2 / $10
Grok-2-mini 128K Quick responses, budget $0.50 / $2

Quick Start

curl https://api.x.ai/v1/chat/completions \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-3",
    "messages": [
      {"role": "user", "content": "What is trending in crypto on X right now?"}
    ]
  }'

OpenAI-Compatible API

import OpenAI from 'openai';

const xai = new OpenAI({
  baseURL: 'https://api.x.ai/v1',
  apiKey: process.env.XAI_API_KEY,
});

const response = await xai.chat.completions.create({
  model: 'grok-3',
  messages: [
    { role: 'system', content: 'You are a crypto market analyst.' },
    { role: 'user', content: 'Analyze $SPA on X/Twitter.' }
  ]
});

Function Calling

const response = await xai.chat.completions.create({
  model: 'grok-3',
  messages: [{ role: 'user', content: 'What is the price of SPA?' }],
  tools: [
    {
      type: 'function',
      function: {
        name: 'getTokenPrice',
        description: 'Get the current price of a cryptocurrency token',
        parameters: {
          type: 'object',
          properties: {
            symbol: { type: 'string', description: 'Token symbol (e.g., SPA, ETH)' },
            chain: { type: 'string', description: 'Blockchain (e.g., arbitrum)' }
          },
          required: ['symbol']
        }
      }
    }
  ]
});

Read the full file on GitHub · 152 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 152 lines · 63 tokens per session scan A 8822aa421173

Subscribe to this mod's changes

xai-grok-api-guide is a skill published in the GitHub repository nirholas/three.ws (110 stars, last pushed today), licensed Apache-2.0. It adds 63 tokens to every session and 1,071 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

Prompt craft for ComfyUI generation

Use when writing prompts for ComfyUI image or video models: choosing tags vs literary format, fixing composition and anatomy artifacts, picking samplers per LoRA, and writing short movement prompts for video. Neutral examples only.

howdeploy/deploychan_mcp · 52 tokens

seedance-vocab-en

This skill should be used when an English Seedance 2.0 prompt is slop-heavy, generic, padded with empty quality words, tripping false-positive filters, or needs precise English production vocabulary for camera, lighting, motion, VFX, audio, and constraints.

Emily2040/seedance-2.0 · 61 tokens

llm-router

Selects the optimal LLM model and provider for each task based on complexity, cost budget, and capability requirements. Routes cheap tasks to Haiku/GPT-4o-mini and complex tasks to Sonnet/Opus/o1. Use when deciding which model to call, optimizing LLM costs, or building multi-model agent systems. Activate on "which…

curiositech/some_claude_skills · 121 tokens

qwen-image-prompting

Prompt Alibaba's Qwen-Image line for the typography work it is built for — quoting exact copy so the model stops inventing it, switching prompt expansion off before it rewrites your strings, describing layout in relative position and weight rather than point sizes, writing non-Latin scripts as characters, and…

nodetool-ai/nodetool · 180 tokens

system2-attention

System 2 attention mechanisms for deliberate, slow reasoning in transformer architectures.

plurigrid/asi · 19 tokens

security-copilot

Guidance for Microsoft Security Copilot - the generative-AI security platform that helps analysts investigate, hunt, summarise, and respond using natural language, plugins, promptbooks, and embedded experiences. Covers SCU provisioning, plugins, promptbooks, governance, and the standalone vs embedded experience…

vinayaklatthe/microsoft-security-skills · 154 tokens