WordPress/php-ai-client
A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.
What it solves
This project provides a uniform API for PHP developers to interact with various generative AI models. It removes the need to write provider-specific code when switching between different AI providers (like OpenAI or Google), allowing developers to use a single, consistent interface for common AI tasks.
How it works
It is a provider-agnostic PHP SDK that can be installed via Composer. The SDK uses a builder pattern to configure requests. Developers can specify a specific model, a specific provider, or let the library handle model selection. It supports text generation, image generation, and embedding generation, with strict verification to ensure the requested model supports the required capabilities before a request is sent.
Who it’s for
PHP developers, including those building WordPress plugins, though the SDK is technically agnostic to WordPress and can be used in any PHP project.
Highlights
- Provider Agnostic: Use a single API to communicate with multiple AI providers.
- Multi-modal Support: Supports text, image, and embedding generation.
- Flexible Configuration: Allows setting system instructions, temperature, and max tokens for text generation.
- Batch Processing: Supports generating embeddings for multiple inputs simultaneously.
- Event Dispatching: Implements PSR-14 event dispatching to allow logging and monitoring of the prompt lifecycle.
- Model Verification: Automatically verifies if a model supports the required capabilities before sending requests.
Related
- Project
- Project
- Project
- Project
- Project