---
title: "How to build an image generation plugin with the WordPress AI Client"
url: https://daily.dev/posts/how-to-build-an-image-generation-plugin-with-the-wordpress-ai-client-ch3lqpcyn
source_url: https://developer.wordpress.org/news/2026/05/how-to-build-an-image-generation-plugin-with-the-wordpress-ai-client
type: article
source: "WordPress Developer"
published: 2026-05-14T14:57:00.119Z
updated: 2026-05-21T02:15:06.252Z
tags: ["ai-image-generation", "php", "wordpress"]
reading_time: 19
upvotes: 5
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to build an image generation plugin with the WordPress AI Client

**[WordPress Developer](https://daily.dev/sources/wordpressdev)** · 19 min read · 5 upvotes · 0 comments

## Summary

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.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://developer.wordpress.org/news/2026/05/how-to-build-an-image-generation-plugin-with-the-wordpress-ai-client>

## Similar posts on daily.dev

- [Introducing the AI Client in WordPress 7.0](https://daily.dev/posts/introducing-the-ai-client-in-wordpress-7-0-mphydbhjz) · Make WordPress Core · 13 upvotes · 0 comments
- [Build your first AI-Powered WordPress plugin](https://daily.dev/posts/build-your-first-ai-powered-wordpress-plugin-kss2sm0my) · WordPress Developer · 4 upvotes · 0 comments
- [Introducing the WordPress AI Client SDK](https://daily.dev/posts/introducing-the-wordpress-ai-client-sdk-miqmgfjkx) · Make WordPress Core · 1 upvotes · 0 comments

---

Tags: [#ai-image-generation](https://daily.dev/tags/ai-image-generation), [#php](https://daily.dev/tags/php), [#wordpress](https://daily.dev/tags/wordpress)

[View this post on daily.dev](https://daily.dev/posts/how-to-build-an-image-generation-plugin-with-the-wordpress-ai-client-ch3lqpcyn)
