papi-ai / grok
Grok (xAI) provider for PapiAI
v0.9.1
2026-03-08 18:14 UTC
Requires
- php: ^8.2
- ext-curl: *
- papi-ai/papi-core: ^0.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^3.0
- vimeo/psalm: ^6.0
README
Grok (xAI) provider for PapiAI - A simple but powerful PHP library for building AI agents.
Installation
composer require papi-ai/grok
Usage
use PapiAI\Core\Agent; use PapiAI\Grok\GrokProvider; $provider = new GrokProvider( apiKey: $_ENV['XAI_API_KEY'], ); $agent = new Agent( provider: $provider, instructions: 'You are a helpful assistant.', ); $response = $agent->run('Hello!'); echo $response->text;
Available Models
GrokProvider::MODEL_GROK_3 // 'grok-3' (default) GrokProvider::MODEL_GROK_3_MINI // 'grok-3-mini' (fast) GrokProvider::MODEL_GROK_2 // 'grok-2'
Features
- Tool/function calling
- Vision/multimodal support
- Structured output (JSON mode)
- Streaming support
License
MIT