xAI Provider

Use xAI Grok models with PraisonAI TypeScript

Diagram

Input

Agent

Output

xAI Provider

Use xAI’s Grok models including Grok-4 and Grok-3.

Environment Variables

bash
export XAI_API_KEY=xai-...

Supported Modalities

ModalitySupported
Text/Chat✅
Embeddings❌
Image✅
Tools✅

Quick Start

  1. Simple Usage
    typescript
    import { Agent } from 'praisonai';
    
    const agent = new Agent({
      name: 'Grok',
      instructions: 'You are a helpful assistant.',
      llm: 'xai/grok-3'
    });
    
    const response = await agent.chat('Hello!');
    console.log(response);
  2. With Configuration

    Adjust provider credentials and model settings for production — see the sections above.

Available Models

ModelDescription
grok-4Latest Grok model
grok-3Grok 3
grok-3-fastFast variant
grok-3-miniLightweight

Troubleshooting

Missing API Key

bash
export XAI_API_KEY=xai-your-key

Related