Skip to content

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: 4096

Advanced 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: 40

Multi-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: 4096

Configuration 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 tokens
    • topP: Nucleus sampling parameter
    • topK: Sampling candidates count
    • frequencyPenalty: Frequency penalty
    • presencePenalty: Presence penalty
    • stopSequences: Stop sequences

Environment Variables

bash
# ~/.bashrc or ~/.zshrc
export XAI_API_KEY="your-xai-api-key"

Getting API Key

  1. Visit xAI Console
  2. Register and log in to account
  3. Create new key in API Keys page
  4. 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: 2048

Creative Writing

yaml
models:
  - name: "creative-writing"
    provider: "xai"
    model: "grok-beta"
    apiKey: "${XAI_API_KEY}"
    roles: ["chat"]
    defaultCompletionOptions:
      temperature: 0.9
      maxTokens: 4096

Technical Analysis

yaml
models:
  - name: "tech-analysis"
    provider: "xai"
    model: "grok-beta"
    apiKey: "${XAI_API_KEY}"
    roles: ["chat", "edit"]
    defaultCompletionOptions:
      temperature: 0.3
      maxTokens: 4096

Model 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

  1. 401 Unauthorized: Check if API key is correct
  2. 429 Too Many Requests: Rate limit reached
  3. Content Policy Violation: Content violates usage policy
  4. Service Unavailable: Service temporarily unavailable

Debugging Steps

  1. Verify API key format and validity
  2. Check request content complies with policy
  3. Confirm rate limits and quotas
  4. View error logs
  5. 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