Agent skill · Security

xai-auth

xAI Grok API authentication and setup. Use when configuring xAI API access, setting up API keys, or troubleshooting authentication issues.

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill xai-auth --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 4 KB
Bundled scripts: none
Version: 1.0.0
Path: skills/ai-llm/xai-auth/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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](https://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 ### Method 1: Environment Variable (Recommended) ```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

What's inside
Steps it walks through
  1. Quick Start
  2. 1. Get API Key
  3. 2. Set Environment Variable
  4. 3. Test Connection
  5. Authentication Methods
  6. Method 1: Environment Variable (Recommended)
  7. Method 2: Direct Key
  8. Method 3: Using xai-sdk
  9. API Compatibility
  10. Free Credits
  11. $150/Month Free Credits
  12. Credit Usage
  13. Configuration File
  14. Error Handling
Ships with 1 file
  • metadata.json
Commands it runs
Add to .bashrc, .zshrc, or .env
export XAI_API_KEY="xai-your-key-here"
curl https://api.x.ai/v1/models \
xAI API Configuration
More from claude-skill-registry
All skills →
About this skill
What does the xai-auth skill do?

xAI Grok API authentication and setup. Use when configuring xAI API access, setting up API keys, or troubleshooting authentication issues.

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill xai-auth --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going