xai-auth
xAI Grok API authentication and setup. Use when configuring xAI API access, setting up API keys, or troubleshooting authentication issues.
npx skills add majiayu000/claude-skill-registry --skill xai-auth --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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
- Quick Start
- 1. Get API Key
- 2. Set Environment Variable
- 3. Test Connection
- Authentication Methods
- Method 1: Environment Variable (Recommended)
- Method 2: Direct Key
- Method 3: Using xai-sdk
- API Compatibility
- Free Credits
- $150/Month Free Credits
- Credit Usage
- Configuration File
- Error Handling
Add to .bashrc, .zshrc, or .env export XAI_API_KEY="xai-your-key-here" curl https://api.x.ai/v1/models \ xAI API Configuration
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.
