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 consistent way for PHP developers to interact with various generative AI models without needing to write custom code for each specific AI provider. It removes the complexity of managing different APIs, allowing developers to switch between models or providers seamlessly.

How it works

It acts as a provider-agnostic SDK that you install via Composer. You use a unified API to send prompts for text or image generation, or to create embeddings. The client handles the communication with the underlying AI services. You can either specify a particular model or let the client select a compatible one automatically. It also supports PSR-14 event dispatching, which allows you to hook into the generation process for tasks like logging or monitoring.

Who it’s for

This tool is designed for PHP developers who want to integrate generative AI features into their applications. While it is stewarded by the WordPress AI team, it is technically agnostic and can be used in any PHP project, not just WordPress plugins.

Highlights

  • Uniform API for text generation, image generation, and embedding creation.
  • Provider-agnostic design allows easy switching between different AI services.
  • Built-in support for PSR-14 event dispatching to monitor prompt lifecycles.
  • Flexible configuration options for system instructions, temperature, and token limits.
  • Robust validation to ensure selected models support requested capabilities before execution.

Related

  • Project
  • Project
  • Project
  • Project
  • Project