xAI Grok API authentication and setup. An agent skill from majiayu000/claude-skill-registry.

MITAuto-check: notesBackend & APIs

Install Xai Auth

skills CLI
$ npx skills add majiayu000/claude-skill-registry --skill xai-auth -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install majiayu000/claude-skill-registry xai-auth --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/majiayu000/claude-skill-registry.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/ai-llm/xai-auth .claude/skills/xai-auth && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
xai-auth
GitHub stars
666
Used in
1 other repo
Token cost
~1k tokens
SKILL.md length
279 words
Files
2
Skills in repo
1,273
Repo updated
First seen
Licence
MIT

At a glance

xAI Grok API authentication and setup. An agent skill from majiayu000/claude-skill-registry.

  • Works in 3 steps: Get API Key → Set Environment Variable → Test Connection
  • Configuring xAI API access
  • SKILL.md covers Quick Start, Authentication Methods, API Compatibility and Free Credits, plus 7 more sections
  • Calls curl; reaches api.x.ai; needs XAI_API_KEY

What it does

Xai Auth is an agent skill from majiayu000/claude-skill-registry. xAI Grok API authentication and setup. Use when configuring xAI API access, setting up API keys, or troubleshooting authentication issues.

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `metadata.json`).

It sits in Backend & APIs, covering Authentication. It works with xAI Grok and X (Twitter). The repository describes itself as: Searchable Claude Code skills catalog with source-linked guides and generated registry artifacts. The licence is MIT.

When your agent uses it

  • Configuring xAI API access
  • Setting up API keys
  • Troubleshooting authentication issues

Example prompts

  • “/xai-auth”

Requirements

  • Python 3
  • A credential in XAI_API_KEY

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Get API Key
  2. Set Environment Variable
  3. Test Connection

What it can do on your machine

Read from SKILL.md and the folder at commit 2d14a69. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.x.ai

    Also links to:

    • console.x.ai
    • docs.x.ai

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • XAI_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Xai Auth loads about 1k tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 279 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:22
    # Add to .bashrc, .zshrc, or .env
  • NoteMentions a .env fileSKILL.md:99
    Create `.env.xai`:
  • NoteMentions a .env fileSKILL.md:147
    .env
  • NoteMentions a .env fileSKILL.md:148
    .env.*

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from majiayu000/claude-skill-registry at commit 2d14a69, republished under its MIT licence (© majiayu000). 279 words, ~1,041 tokens.

Download SKILL.mdSave it as .claude/skills/xai-auth/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
xai-auth
description
xAI Grok API authentication and setup. Use when configuring xAI API access, setting up API keys, or troubleshooting authentication issues.
version
1.0.0

xAI Grok API Authentication

Complete guide for setting up and managing xAI API authentication for Grok models with Twitter/X integration.

Quick Start

1. Get API Key
  1. Go to console.x.ai
  2. Sign in with your X (Twitter) account
  3. Navigate to "API Keys" section
  4. Click "Create API Key"
  5. Copy and save the key (starts with xai-)
2. Set Environment Variable
bash
# Add to .bashrc, .zshrc, or .env
export XAI_API_KEY="xai-your-key-here"
3. Test Connection
bash
curl https://api.x.ai/v1/models \
  -H "Authorization: Bearer $XAI_API_KEY"

Authentication Methods

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("XAI_API_KEY"),
    base_url="https://api.x.ai/v1"
)
Method 2: Direct Key
python
from openai import OpenAI

client = OpenAI(
    api_key="xai-your-key-here",
    base_url="https://api.x.ai/v1"
)
Method 3: Using xai-sdk
python
from xai_sdk import Client

client = Client(api_key=os.getenv("XAI_API_KEY"))

API Compatibility

xAI API is fully compatible with OpenAI SDK:

python
# Just change base_url - everything else works the same
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("XAI_API_KEY"),
    base_url="https://api.x.ai/v1"  # Only difference
)

response = client.chat.completions.create(
    model="grok-3-fast",  # Use Grok models
    messages=[{"role": "user", "content": "Hello!"}]
)

Free Credits

$150/Month Free Credits
  1. Go to console.x.ai
  2. Navigate to Settings → Data Sharing
  3. Enable data sharing opt-in
  4. Receive $150/month in API credits
Credit Usage
ActionCost
Grok 4.1 Fast (input)$0.20/1M tokens
Grok 4.1 Fast (output)$0.50/1M tokens
X Search / Web Search$5/1,000 calls
Code Execution$5/1,000 calls

Configuration File

Create .env.xai:

bash
# xAI API Configuration
XAI_API_KEY=xai-your-key-here
XAI_BASE_URL=https://api.x.ai/v1
XAI_DEFAULT_MODEL=grok-3-fast

Error Handling

Common Errors
ErrorCauseSolution
no creditsNo credits on accountAdd credits or enable free tier
invalid_api_keyWrong or expired keyGenerate new key at console.x.ai
rate_limit_exceededToo many requestsImplement backoff, reduce frequency
model_not_foundInvalid model nameCheck available models
Python Error Handling
python
from openai import OpenAI, APIError, RateLimitError

client = OpenAI(
    api_key=os.getenv("XAI_API_KEY"),
    base_url="https://api.x.ai/v1"
)

try:
    response = client.chat.completions.create(
        model="grok-3-fast",
        messages=[{"role": "user", "content": "Hello"}]
    )
except RateLimitError:
    print("Rate limit hit, waiting...")
    time.sleep(60)
except APIError as e:
    print(f"API error: {e}")

Security Best Practices

  1. Never commit API keys to git
  2. Use environment variables instead of hardcoding
  3. Rotate keys regularly via console.x.ai
  4. Use separate keys for dev/prod environments
  5. Add to .gitignore:
    .env
    .env.*
    **/secrets.*

Rate Limits

ModelRequests/MinTokens/Min
Grok 4.1 Fast60100,000
Grok 43050,000
Grok 3 Mini100200,000

Endpoints

EndpointDescription
https://api.x.ai/v1/chat/completionsChat completions
https://api.x.ai/v1/modelsList available models
https://api.x.ai/v1/responsesAgent Tools API
  • xai-models - Model selection guide
  • xai-x-search - Twitter/X search
  • xai-sentiment - Sentiment analysis

References

© majiayu000, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/ai-llm/xai-auth of majiayu000/claude-skill-registry.

  • SKILL.md
  • metadata.json

Open the folder on GitHubat commit 2d14a69

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in majiayu000/claude-skill-registry, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Xai Auth next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Xai Auth compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Xai Auth this skillmajiayu000/claude-skill-registry6661 repos~1kAutomated safety check: NotesMIT
Socialite Developmenthexlet-volunteers/hexlet-sicp1145 repos~1.2kAutomated safety check: PassMIT
Twitter X HubOpenMinis/MinisSkills444—~2.9kAutomated safety check: PassMIT
Copy ResearchVKirill/claude-lane-stack122—~827Automated safety check: PassMIT
Yichen Grok Consultmcncarl/yichen-skills4.3k—~2.1kAutomated safety check: PassCustom licence
Grok Searchsundial-org/awesome-openclaw-skills663—~620Automated safety check: PassNone

Similar skills

  • Socialite Development

    hexlet-volunteers/hexlet-sicp

    Manages OAuth social authentication with Laravel Socialite. An agent skill from hexlet-volunteers/hexlet-sicp.

    114 GitHub starsUsed in 5 repos~1.2k tokens
    Backend & APIsAuto-check passed
  • Twitter X Hub

    OpenMinis/MinisSkills

    Skill for reading and writing Twitter/X data with Python + UV, with zero third-party dependencies (pure standard library), by directly passing the authtoken + ct0 cookies for authentication.

    444 GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Copy Research

    VKirill/claude-lane-stack

    Dispatch copy-lead helpers: Tavily, Codex luna/terra, grok/X, OpenCode DeepSeek, Cursor Grok 4.6 medium-fast.

    122 GitHub stars~827 tokensUpdated yesterday
    Productivity & AutomationAuto-check passed
  • Yichen Grok Consult

    mcncarl/yichen-skills

    Consult or search with xAI Grok from a GPT-led Codex conversation without switching the main model.

    4.3k GitHub stars~2.1k tokensUpdated 4 days ago
    Productivity & AutomationAuto-check passed
  • Grok Search

    sundial-org/awesome-openclaw-skills

    Search the web or X/Twitter using xAI Grok server-side tools (websearch, xsearch) via the xAI Responses API.

    663 GitHub stars~620 tokensUpdated 7 mo ago
    Productivity & AutomationAuto-check passed
  • Xai Search

    sundial-org/awesome-openclaw-skills

    Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools.

    663 GitHub stars~730 tokensUpdated 7 mo ago
    Productivity & AutomationAuto-check passed

More from majiayu000/claude-skill-registry

All 1,273 skills in this repo
  • Deep Research

    majiayu000/claude-skill-registry

    Multi-source deep research using firecrawl and exa MCPs. An agent skill from majiayu000/claude-skill-registry.

    666 GitHub starsUsed in 6 repos~1.1k tokens
    Auto-check passed
  • Exa Search

    majiayu000/claude-skill-registry

    Neural search via Exa MCP for web, code, and company research.

    666 GitHub starsUsed in 5 repos~856 tokens
    Auto-check passed
  • Fal AI Media

    majiayu000/claude-skill-registry

    Unified media generation via fal.ai MCP — image, video, and audio.

    666 GitHub starsUsed in 5 repos~1.7k tokens
    Auto-check passed
  • Pyzotero

    majiayu000/claude-skill-registry

    Interact with Zotero reference management libraries using the pyzotero Python client.

    666 GitHub starsUsed in 5 repos~1.6k tokens
    Auto-check: notes
  • Bgpt Paper Search

    majiayu000/claude-skill-registry

    Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server.

    666 GitHub starsUsed in 4 repos~619 tokens
    Auto-check: notes
  • Bio Alignment Pairwise

    majiayu000/claude-skill-registry

    Perform pairwise sequence alignment using Biopython Bio.Align.PairwiseAligner.

    666 GitHub starsUsed in 4 repos~1.7k tokens
    Auto-check passed

Categories

Questions about Xai Auth

What does Xai Auth do?

xAI Grok API authentication and setup. An agent skill from majiayu000/claude-skill-registry. Xai Auth is an agent skill from majiayu000/claude-skill-registry. xAI Grok API authentication and setup.

When should I use Xai Auth?

Xai Auth fits situations like: configuring xAI API access; setting up API keys; troubleshooting authentication issues.

How do I install Xai Auth in Claude Code?

Run `npx skills add majiayu000/claude-skill-registry --skill xai-auth -a claude-code`. Or copy the skill folder (skills/ai-llm/xai-auth in majiayu000/claude-skill-registry) into .claude/skills/xai-auth in your project. Claude Code loads it when a task matches its description.

How do I install Xai Auth in Codex?

Run `npx skills add majiayu000/claude-skill-registry --skill xai-auth -a codex`. Or copy the skill folder (skills/ai-llm/xai-auth in majiayu000/claude-skill-registry) into .agents/skills/xai-auth in your project. Codex loads it when a task matches its description.

Can I use Xai Auth in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add majiayu000/claude-skill-registry --skill xai-auth -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/xai-auth, .gemini/skills/xai-auth, .github/skills/xai-auth and .opencode/skills/xai-auth in your project.

What does Xai Auth need to run?

Going by SKILL.md and its folder, Xai Auth needs the command-line tools its instructions call (curl) and credentials named XAI_API_KEY. Our summary lists: Python 3; A credential in XAI_API_KEY.

Does Xai Auth access the network?

SKILL.md names 3 domains. In commands or code: api.x.ai; the agent is likely to contact it when it follows the instructions. As links in the text: console.x.ai and docs.x.ai. This is read from the text; nothing was executed.

Is Xai Auth safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Xai Auth use?

Xai Auth is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Xai Auth use?

About 1k tokens (SKILL.md is roughly 4.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Xai Auth?

Skills that share tags, products or a category with Xai Auth: Socialite Development (hexlet-volunteers/hexlet-sicp, 114 stars), Twitter X Hub (OpenMinis/MinisSkills, 444 stars), Copy Research (VKirill/claude-lane-stack, 122 stars) and Yichen Grok Consult (mcncarl/yichen-skills, 4.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Xai Auth?

majiayu000 (a GitHub user) maintains it in majiayu000/claude-skill-registry, which has 666 GitHub stars. The repository holds 1,273 skills in this directory. The repository was last updated on October 7, 2026.

Source: majiayu000/claude-skill-registry on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.