xAI
xAI is an AI company founded by Elon Musk, providing Grok series models focused on artificial general intelligence and understanding the universe.
Supported Models
Grok Series
- grok-beta - Grok Beta version
- grok-vision - Vision multimodal model
- grok-instruct - Instruction-optimized version
Configuration
Basic Configuration
Configure in config.yaml or ~/.bytebuddy/config.yaml:
yaml
models:
- name: "xai-grok"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat"]
defaultCompletionOptions:
temperature: 0.7
maxTokens: 4096Advanced Configuration
yaml
models:
- name: "xai-advanced"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat", "edit"]
defaultCompletionOptions:
temperature: 0.5
maxTokens: 8192
topP: 0.9
topK: 40Multi-Model Configuration
yaml
models:
- name: "xai-grok"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat"]
defaultCompletionOptions:
temperature: 0.7
maxTokens: 4096
- name: "xai-vision"
provider: "xai"
model: "grok-vision"
apiKey: "${XAI_API_KEY}"
roles: ["chat"]
capabilities: ["image_input"]
defaultCompletionOptions:
temperature: 0.6
maxTokens: 4096Configuration Fields
Required Fields
- name: Unique identifier for the model configuration
- provider: Set to
"xai" - model: Model name
- apiKey: xAI API key
Optional Fields
- roles: Model roles [
chat,edit,apply] - capabilities: Model capabilities (e.g.,
image_input) - defaultCompletionOptions:
temperature: Control randomness (0-1)maxTokens: Maximum tokenstopP: Nucleus sampling parametertopK: Sampling candidates countfrequencyPenalty: Frequency penaltypresencePenalty: Presence penaltystopSequences: Stop sequences
Environment Variables
bash
# ~/.bashrc or ~/.zshrc
export XAI_API_KEY="your-xai-api-key"Getting API Key
- Visit xAI Console
- Register and log in to account
- Create new key in API Keys page
- Save the key to environment variable
Use Case Configurations
Real-Time Q&A
yaml
models:
- name: "real-time-qa"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat"]
defaultCompletionOptions:
temperature: 0.7
maxTokens: 2048Creative Writing
yaml
models:
- name: "creative-writing"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat"]
defaultCompletionOptions:
temperature: 0.9
maxTokens: 4096Technical Analysis
yaml
models:
- name: "tech-analysis"
provider: "xai"
model: "grok-beta"
apiKey: "${XAI_API_KEY}"
roles: ["chat", "edit"]
defaultCompletionOptions:
temperature: 0.3
maxTokens: 4096Model Features
Grok Beta
- Real-Time Information: Can access real-time internet information
- Multilingual: Supports multiple languages
- Reasoning Capabilities: Strong logical reasoning and analytical abilities
- Humor: Has unique humorous style
Grok Vision
- Multimodal: Supports image and text input
- Visual Understanding: Strong image analysis capabilities
- Cross-Modal Reasoning: Combined image-text understanding and generation
Use Cases
Real-Time Q&A
- Get latest information
- Analyze current news
- Provide real-time advice
Creative Writing
- Generate creative content
- Writing assistance
- Story creation
Technical Analysis
- Code analysis
- Technical problem solving
- Scientific computing
Troubleshooting
Common Errors
- 401 Unauthorized: Check if API key is correct
- 429 Too Many Requests: Rate limit reached
- Content Policy Violation: Content violates usage policy
- Service Unavailable: Service temporarily unavailable
Debugging Steps
- Verify API key format and validity
- Check request content complies with policy
- Confirm rate limits and quotas
- View error logs
- Visit xAI status page
Best Practices
1. Leverage Real-Time Information
- Design prompts that require real-time information
- Verify accuracy of important facts
- Combine with latest context
2. Optimize Dialogue Experience
- Leverage Grok's humorous characteristics
- Design natural conversation flow
- Provide clear context
3. Multimodal Applications
- Combine image and text input
- Utilize visual understanding capabilities
- Create rich interactive experiences
4. Content Management
- Comply with content usage policy
- Verify accuracy of generated content
- Implement appropriate content filtering
Limitations and Considerations
- Content Filtering: Comply with content policy
- Usage Limits: Has quota and rate limits
- Accuracy: Verify accuracy of important information
- Real-Time Nature: Real-time information may have delays