WordPress 7.0 introduces a built-in AI Client PHP API that lets plugins send prompts to AI providers in a provider-agnostic way. This tutorial walks through building a complete WordPress plugin that generates images directly in the Media Library using this new API. Key concepts covered include the fluent WP_AI_Client_Prompt_Builder interface, model preferences vs. requirements, support checks to gate AI features, two REST API endpoints (one for generation, one for uploading to the Media Library), conditional script enqueuing, and a TypeScript frontend using @wordpress/api-fetch. The plugin is intentionally minimal — the actual AI integration is only ~10 lines of PHP — demonstrating how the AI Client abstracts provider communication, authentication, and model selection.
Sort: