PHP and WP AI Client SDK
๐ **Source:** [PHP and WP AI Client SDK](https://www.youtube.com/watch?v=PjCgcnrd8P0)
> [!note]+ Document Notes
> tags: [wordpress, ai-client, php]
> author: [MISSING]
> source: YouTube
> reference: https://www.youtube.com/watch?v=PjCgcnrd8P0
> date created: 2025-01-03 12:00
>
> # ๐ท๏ธ Title: PHP and WP AI Client SDK
>
<!-- deep-read:sections start -->
## ๐งฐ Action Inbox
- [H1] Install WP AI Client package for WordPress projects โ main composer package #wordpress
- [H2] Initialize AI client class to enable credentials screen โ automatic admin integration #setup
- [H3] Increase timeout for image generation requests โ prevent timeout errors #configuration
## ๐งญ Table of Contents
- [๐ Summary](#-summary)
- [๐ Main Content](#-main-content)
- [๐๏ธ Notes](#๏ธ-notes)
- [๐ References](#-references)
- [๐ฃ๏ธ Paraphrase](#๏ธ-paraphrase)
- [๐ฐ Newsletter](#-newsletter)
- [โ
Action Items](#-action-items)
- [๐งช Hypotheses](#-hypotheses)
- [๐ Methodology](#-methodology)
- [โ Questions](#-questions)
- [๐ฎ Future Research](#-future-research)
- [๐ก Implications](#-implications)
- [๐ง Learning Styles Assessment](#-learning-styles-assessment)
- [๐ Accessibility Assessment](#-accessibility-assessment)
- [๐ DEIB Assessment](#-deib-assessment)
- [โ
Logical Validity](#-logical-validity)
- [๐ก๏ธ DARVO Analysis](#-darvo-analysis)
- [๐ฏ Conclusion](#-conclusion)
### ๐ References
- [PHP AI Client GitHub](https://github.com/wordpress/wp-ai-client)
- [WordPress Developer Resources](https://developer.wordpress.org/)
## ๐ Summary
- Tutorial covering PHP and WordPress AI Client SDK packages released after July 2025
- Demonstrates automatic credential management through WordPress admin integration
- Shows practical examples of text and image generation with proper timeout configuration
- Key stakeholders are WordPress plugin developers wanting to integrate AI functionality
- Bottom line: WP AI Client simplifies AI integration with automatic credential handling and admin UI
## ๐ Main Content
The video explains the WordPress AI Client SDK architecture, which consists of two main packages: the generic PHP AI Client and the WordPress-specific WP AI Client built on top of it. For WordPress development, developers should focus on the WP AI Client package as it provides WordPress-specific integrations.
The key innovation is automatic credential management through WordPress admin integration. When developers initialize the AI client class using the static `init()` method, it automatically creates an admin screen where users can enter API credentials, eliminating manual credential handling.
The SDK supports both text and image generation. Text generation uses simple prompt methods, while image generation requires increased timeout settings (beyond the default 30 seconds) and returns base64-encoded data that needs conversion to usable WordPress media files.
## ๐๏ธ Notes
#### โฑ๏ธ [00:00](https://youtu.be/PjCgcnrd8P0?t=0) โ Introduction to PHP AI Client SDK
- Key idea: Summary of Friday stream about PHP AI client development
- Evidence: "I want to summarize a little bit the ideas that we covered in the last stream"
#### โฑ๏ธ [00:30](https://youtu.be/PjCgcnrd8P0?t=30) โ Two Package Architecture Clarification
- Key idea: Two separate composer packages with different purposes
- Evidence: "PHP AI client and the other one is the WP AI client"
#### โฑ๏ธ [01:15](https://youtu.be/PjCgcnrd8P0?t=75) โ WordPress-Specific Package Focus
- Key idea: WP AI Client is built on PHP AI Client for WordPress projects
- Evidence: "This is really the starting point for any plug-in that wants to use this AI client"
#### โฑ๏ธ [01:45](https://youtu.be/PjCgcnrd8P0?t=105) โ Automatic Credentials Integration
- Key idea: Built-in WordPress admin integration for API credentials
- Evidence: "It integrates with ZVP admin for credentials"
#### โฑ๏ธ [02:30](https://youtu.be/PjCgcnrd8P0?t=150) โ Admin Screen Automatic Generation
- Key idea: Initialization creates credential entry screen automatically
- Evidence: "If we initialized a specific class... we will get automatically a screen where we can enter the API credentials"
#### โฑ๏ธ [03:00](https://youtu.be/PjCgcnrd8P0?t=180) โ Code Implementation Example
- Key idea: Static init method enables admin credentials screen
- Evidence: "When we do this or the AI client class we use the static method in it this is enabling this"
#### โฑ๏ธ [04:00](https://youtu.be/PjCgcnrd8P0?t=240) โ Text Generation Demonstration
- Key idea: Simple prompt method generates text content
- Evidence: "We can prompt something and then from that prompt, we can generate some text"
#### โฑ๏ธ [04:45](https://youtu.be/PjCgcnrd8P0?t=285) โ Random Plugin Description Example
- Key idea: AI generates WordPress plugin descriptions on demand
- Evidence: "We are asking for a random description of a WordPress plugin"
#### โฑ๏ธ [05:30](https://youtu.be/PjCgcnrd8P0?t=330) โ Multiple Generation Results
- Key idea: Each call produces different creative outputs
- Evidence: "Dolby social sharer pro... social share boost... completely invented"
#### โฑ๏ธ [06:00](https://youtu.be/PjCgcnrd8P0?t=360) โ Image Generation Setup
- Key idea: Image generation requires timeout configuration
- Evidence: "We can use the prompt method... then we can call the generate image"
#### โฑ๏ธ [06:30](https://youtu.be/PjCgcnrd8P0?t=390) โ Timeout Configuration Importance
- Key idea: Default 30-second timeout insufficient for image generation
- Evidence: "30 seconds is usually not enough for image generation"
#### โฑ๏ธ [07:15](https://youtu.be/PjCgcnrd8P0?t=435) โ Base64 Output Handling
- Key idea: Image generation returns base64 data requiring conversion
- Evidence: "It actually returns a I think it's a base 64 format which is a bunch of characters"
#### โฑ๏ธ [08:00](https://youtu.be/PjCgcnrd8P0?t=480) โ File Processing Implementation
- Key idea: Additional code needed to save base64 as WordPress media files
- Evidence: "Generate to save that into a file to generate the proper urls and path file"
#### โฑ๏ธ [08:45](https://youtu.be/PjCgcnrd8P0?t=525) โ Live Image Generation Demo
- Key idea: Working demonstration of complete image generation workflow
- Evidence: "Here's the image. If we click here, we can actually see the image being generated"
## ๐ References
- [WordPress AI Client Package](https://github.com/wordpress/wp-ai-client)
- [PHP AI Client Package](https://github.com/wordpress/php-ai-client)
- [WordPress Developer Documentation](https://developer.wordpress.org/)
## ๐ฃ๏ธ Paraphrase
- WordPress released two AI client packages: a generic PHP version and a WordPress-specific version that builds on the first
- The WordPress AI Client automatically integrates with admin screens for credential management, eliminating manual setup complexity
- Both text and image generation work through simple prompt methods, though images need longer timeouts and file conversion processing
## ๐ฐ Newsletter
WordPress developers now have streamlined AI integration with the new WP AI Client SDK! This package automatically handles the tricky parts of AI implementation - credential management gets its own admin screen when you initialize the client, and both text and image generation work through simple prompt methods.
The key insight: focus on the WordPress-specific package rather than the generic PHP version. It handles the WordPress integration automatically and saves significant development time.
Ready to add AI to your plugins? Start with the WP AI Client package and let the automatic credential handling do the heavy lifting.
Resources: [Learn WordPress](https://learn.wordpress.org/), [Developer Docs](https://developer.wordpress.org/), [WP-CLI](https://wp-cli.org/)
## โ
Action Items
#### WordPress
- Core: Evaluate AI client integration patterns for core features
- Plugins: Develop guidelines for AI client usage in plugin directory
- Documentation: Create comprehensive guides for AI client implementation
- Community: Share best practices for AI integration in WordPress projects
#### DevRel
- Education: Create workshops on AI client SDK usage and implementation
- Developer experience: Improve AI client documentation and examples
- Community management: Gather feedback on AI client developer experience
## ๐งช Hypotheses
- WordPress developers will prefer the integrated credential management over manual API key handling
- Image generation timeout issues will be a common developer pain point requiring documentation
- The two-package architecture will reduce adoption confusion compared to single monolithic package
- Automatic admin screen generation will significantly reduce AI integration development time
### ๐ Methodology
- Survey WordPress developers on AI integration preferences and pain points
- Measure adoption rates between PHP AI Client vs WP AI Client packages
- Track support requests related to timeout configuration and credential setup
### โ Questions
- How will the AI client handle rate limiting and quota management across different providers?
- What security considerations exist for storing API credentials in WordPress admin?
- How extensible is the current architecture for adding new AI service providers?
### ๐ฎ Future Research
- Integration patterns for AI client with WordPress multisite installations
- Performance optimization strategies for AI-powered WordPress plugins
- Accessibility considerations for AI-generated content in WordPress
### ๐ก Implications
- Practice: Significantly simplifies AI integration for WordPress plugin developers
- Policy: May require updated plugin directory guidelines for AI-powered plugins
- Security: Automatic credential handling reduces security implementation burden on developers
- Education: Need for new training materials on AI integration best practices
### ๐ง Learning Styles Assessment
Reading level estimate: 8th grade (Flesch-Kincaid)
#### ๐ Visual learners
- Present: Code examples, admin screen demonstrations
- Improve: Architecture diagrams showing package relationships, credential flow charts
#### ๐ Aural learners
- Present: Video walkthrough with narration
- Improve: Podcast version, audio-only explanation of concepts
#### ๐ฃ๏ธ Verbal learners
- Present: Clear explanations of technical terms, analogies
- Improve: Glossary of AI terms, comparison to familiar WordPress patterns
#### ๐งฉ Kinesthetic learners
- Present: Live coding demonstration, interactive examples
- Improve: Step-by-step tutorial, downloadable starter plugin
#### ๐ง Logical learners
- Present: Clear package hierarchy, sequential implementation steps
- Improve: Decision trees for package selection, troubleshooting flowcharts
#### ๐งโ๐คโ๐ง Social learners
- Present: Reference to community streams, collaborative development
- Improve: Discussion forums, peer review opportunities
#### ๐งโโ๏ธ Solitary learners
- Present: Self-contained examples, independent exploration
- Improve: Self-assessment checklists, reflection prompts
#### ๐ฟ Naturalistic learners
- Present: Real-world plugin examples, practical applications
- Improve: Case studies, ecosystem impact discussions
### ๐ Accessibility Assessment
#### Screen reader semantics
- Present: Clear heading structure, descriptive code comments
- Improve: Alt text for visual demonstrations, ARIA labels for interactive elements
#### Keyboard navigation
- Present: Standard video controls
- Improve: Keyboard shortcuts for code examples, accessible admin interfaces
#### Contrast and readability
- Present: Standard video quality
- Improve: High contrast code examples, readable font sizing
#### Media and captions
- Present: Audio narration
- Improve: Closed captions, transcript availability
### ๐ DEIB Assessment
#### Cultural breadth
- Present: English-only content
- Improve: Multilingual documentation, global use cases
#### Inclusive language
- Present: Technical terminology with explanations
- Improve: Plain language alternatives, defined jargon
#### Neurodiversity support
- Present: Structured presentation, clear examples
- Improve: Multiple explanation formats, consistent pacing
#### Representation
- Present: Technical focus without personal references
- Improve: Diverse contributor acknowledgment, varied use cases
### โ
Logical Validity
#### Strong reasoning
- Deductive strength: Clear package hierarchy reasoning (WP builds on PHP client)
- Inductive strength: Timeout recommendations based on practical experience
- Causal reasoning: Credential integration reduces setup complexity
- Analogical strength: WordPress admin pattern familiar to developers
#### Fallacies
- None identified: Technical demonstration stays within factual bounds
#### Tone of voice
- Overall tone: Informal but informative, developer-focused, practical
### ๐ก๏ธ DARVO Analysis
- Deny: No defensive patterns identified
- Attack: No attacking language present
- Reverse victim/offender: Not applicable to technical content
- Emotional cues and rhetoric: Neutral technical presentation
## ๐ฏ Conclusion
The WordPress AI Client SDK represents a significant simplification of AI integration for WordPress developers. The automatic credential management through admin screens and the clear separation between generic PHP and WordPress-specific packages provides a solid foundation for AI-powered plugins. Developers should focus on the WP AI Client package and pay attention to timeout configuration for image generation to avoid common implementation pitfalls.
## ๐งฑ Refactor Appendix
### ๐ Literature Split Pad
### [H1] WordPress AI Client provides automatic credential management
> [!quote] PHP and WP AI Client SDK by [MISSING] via YouTube. Published 2025. Accessed 2025-01-03.
> "If we initialized a specific class provided by this package, we will get automatically a screen where we can enter the API credentials."
Eliminates manual credential handling complexity in WordPress AI integration.
[view highlight](https://youtu.be/PjCgcnrd8P0?t=105#H1) #wordpress #automation ID:rw_001
### [H2] Image generation requires increased timeout configuration
> [!quote] PHP and WP AI Client SDK
> "30 seconds is usually not enough for image generation."
Critical configuration to prevent timeout errors in AI image workflows.
[view highlight](https://youtu.be/PjCgcnrd8P0?t=390#H2) #configuration #troubleshooting ID:rw_002
### ๐ Atomic Split Pad
#### [Z1] Two-package architecture separates concerns effectively
- WordPress-specific vs generic PHP implementations
- Pointer to 1:15 timestamp
- Links: [[Software-Architecture]] [[WordPress-Development]]
#### [Z2] Base64 output requires conversion for WordPress media
- AI-generated images need file processing for WordPress integration
- Pointer to 7:15 timestamp
- Links: [[Media-Handling]] [[File-Processing]]
### โ๏ธ Fleeting Queue
- [F1] Research AI client rate limiting strategies โ developer experience #fleeting #research
- [F2] Document common timeout configurations โ best practices #fleeting #documentation
- [F3] Explore multisite AI client patterns โ scalability considerations #fleeting #architecture
---
## Full Transcript
[00:00] Hi there.<br>[00:01] I want to I wanted to create this um<br>[00:04] this quick video to summarize a little<br>[00:08] bit the<br>[00:10] content of the stream we did last Friday<br>[00:13] about the PHP AI client. So in this<br>[00:18] video I want to summarize a little bit<br>[00:22] the ideas that we covered in the last<br>[00:27] stream but also to clarify a few things<br>[00:31] that I learned after the session. So<br>[00:34] yeah let's go for it.<br>[00:39] Okay so we talked about the PHP AI<br>[00:43] client SDK. One of the things I wanted<br>[00:46] to clarify is that in the<br>[00:52] in the post<br>[00:57] where<br>[01:00] this idea was announced, the idea of<br>[01:03] creating a PHP AI client.<br>[01:07] There was this section here that talked<br>[01:12] about two composer packages. And<br>[01:18] one of the things that I learned after<br>[01:19] the the stream last Friday was that<br>[01:22] these two packages,<br>[01:24] this was the idea of the packages as<br>[01:28] published on July 2025.<br>[01:33] But after that there has been like two<br>[01:37] packages released.<br>[01:41] One of them was the PHP AI client and<br>[01:45] the other one is the WP AI client. So<br>[01:49] this is the agnostic WordPress one and<br>[01:52] this is the specific WordPress one. This<br>[01:55] one the WordPress one is built on top of<br>[02:00] the PHP one.<br>[02:04] And this is<br>[02:06] really the starting point for any<br>[02:09] plug-in that wants to use this<br>[02:13] AI client because this package<br>[02:16] internally uses this one. So we kind we<br>[02:20] can<br>[02:22] forget about this one unless we<br>[02:26] are working on a project that is not<br>[02:28] specifically related to WordPress. We<br>[02:31] can just focus on this one. And this<br>[02:34] other one can be used in other projects<br>[02:36] outside of workers. Let's focus on this<br>[02:39] one.<br>[02:44] In the code we created the other day, I<br>[02:47] struggled a bit<br>[02:52] with the with the credentials. But one<br>[02:55] of the cool things about this<br>[03:01] about this Dolbyp AI client as announced<br>[03:06] here<br>[03:07] is that it integrates with uh ZVP admin<br>[03:12] for credentials.<br>[03:15] That means that if we initialized a<br>[03:19] specific um<br>[03:22] class um<br>[03:25] provided by this package, we will get<br>[03:29] automatically a a screen from where we<br>[03:32] can enter the API credentials and that<br>[03:35] will unblock the rest of the things. So<br>[03:37] I think this is a a clear idea that<br>[03:42] I wanted to highlight here.<br>[03:46] If we check the code,<br>[03:51] we can see how we are doing this here.<br>[03:56] So with the auto load, we are um<br>[04:00] automatically loading the name spacesh<br>[04:03] as we use them. And here when we do this<br>[04:10] or the AI client class we use the static<br>[04:13] method in it this is enabling this it's<br>[04:20] enabling<br>[04:23] let me see if I can find yeah it's<br>[04:27] enabling this AI credentials screen<br>[04:31] inside the DVP admin which I I think<br>[04:35] it's um<br>[04:37] it's a great thing to take into account<br>[04:40] and a clear idea to start<br>[04:43] implementing<br>[04:45] um enabling AI in our plugins. this idea<br>[04:49] of okay if I initialize this method I<br>[04:52] get a screen where<br>[04:55] the final user can enter the credentials<br>[04:58] and that unblocks the use of the rest of<br>[05:01] the methods because for example here the<br>[05:05] code once we have the credentials we can<br>[05:08] do things like this and<br>[05:17] If we enter in the cell, well, let me<br>[05:21] clear<br>[05:26] from here. We can call the different<br>[05:28] functions that are internally using the<br>[05:31] static methods of the of the class. For<br>[05:34] example, we can prompt something and<br>[05:38] then from that prompt, we can generate<br>[05:41] some text. So here<br>[05:46] we are prompting<br>[05:49] for a we are asking for a random<br>[05:51] description of a WordPress plugin.<br>[05:57] That means that if we do<br>[06:01] this,<br>[06:06] it will properly use the credentials to<br>[06:09] call the specific models. This is<br>[06:12] something managed internally by the by<br>[06:15] the class and we will get uh the output.<br>[06:19] In this case, this is a random<br>[06:21] description of a plug-in. If we call<br>[06:25] this again, we will get a diff different<br>[06:27] one. This is the Dolby Dolbyp social<br>[06:30] sharer pro. This is completely<br>[06:34] um invented.<br>[06:39] We have social shader pro<br>[06:44] and social share boost. So it's another<br>[06:46] one. Okay, cool.<br>[06:49] Another cool thing that we can do is to<br>[06:52] generate an image using the AI models.<br>[06:56] To do that, we can use the prompt method<br>[06:59] of the AI client. This is a static<br>[07:01] method.<br>[07:03] And then we can call the<br>[07:09] generate image. But for images is<br>[07:14] recommended to increase the<br>[07:18] the time out because by default I think<br>[07:21] is um<br>[07:26] yeah 30 seconds and 30 seconds is<br>[07:29] usually<br>[07:31] not enough for image generation. So<br>[07:33] yeah,<br>[07:36] configuring the request so to increment<br>[07:38] the timeout for images is um recommended<br>[07:43] to not get errors because if we don't do<br>[07:45] this, we will probably get a timeout<br>[07:49] error.<br>[07:51] So with this in place,<br>[07:53] we can call this function.<br>[07:57] This function besides getting an image<br>[08:01] generated by the model,<br>[08:04] it<br>[08:06] wraps it in the proper format to be<br>[08:10] consumed by<br>[08:12] other uh code in WordPress. I mean this<br>[08:18] method prompt and the generate image it<br>[08:22] actually returns a I think it's a base<br>[08:25] 64 format which is a bunch of characters<br>[08:29] like numbers and and letters. So we need<br>[08:34] to do something with that if we want to<br>[08:36] really use it in our code. So this is<br>[08:39] non AI related code but what I'm doing<br>[08:42] here is to generate to save that into a<br>[08:46] file to generate the proper uh urls and<br>[08:51] and path<br>[08:53] file<br>[08:56] to file name paths.<br>[09:00] So we can try this function inside the<br>[09:05] shell.<br>[09:09] It's going to take a little bit<br>[09:43] There you go. Here's the image. If we<br>[09:46] click here,<br>[09:50] we can actually<br>[09:54] see the image being generated is this<br>[09:57] one.<br>[09:59] So<br>[10:00] there you go.
<!-- deep-read:sections end -->