itzmekhokan/ai-provider-for-xai

AI Provider for xAI (Grok) for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.

Maintainers

Package info

github.com/itzmekhokan/ai-provider-for-xai

pkg:composer/itzmekhokan/ai-provider-for-xai

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2026-06-20 16:17 UTC

This package is auto-updated.

Last update: 2026-06-25 03:59:24 UTC


README

AI Provider for xAI (Grok) for the WordPress AI Client. Works as both a Composer package and a WordPress plugin.

This provider registers xAI with the AI Client, exposing the Grok model family for text generation through xAI's OpenAI-compatible Chat Completions API.

Requirements

How it works

xAI exposes an OpenAI-compatible API, so this provider is intentionally thin:

Class Responsibility
Provider\XaiProvider Registers the provider, base URL (https://api.x.ai/v1), API-key auth, and metadata.
Metadata\XaiModelMetadataDirectory Lists models from GET /v1/models and maps capabilities/options.
Models\XaiTextGenerationModel Sends POST /v1/chat/completions via the shared OpenAI-compatible base class.

Because Grok speaks the Chat Completions format, XaiTextGenerationModel extends AbstractOpenAiCompatibleTextGenerationModel from the SDK and only overrides request construction.

Supported capabilities

  • Text generation (chat) with the Grok model family
  • Multimodal (image) input for vision-capable models (e.g. the Grok 4 family)
  • Function calling and JSON / structured output

Installation

As a WordPress plugin

Copy this directory into wp-content/plugins/ and activate it alongside the WordPress AI Client.

As a Composer package

composer require itzmekhokan/ai-provider-for-xai

Author

Khokan Sardar

License

GPL-2.0-or-later