AI Services ## Metadata - Author: [[AI Services: AI Client Plugin for WordPress]] - Full Title: AI Services - Category: #articles - Document Note: --- tags: [#wordpress #ai #plugin] - #wordpress - #ai - #plugin Author: Felix Arntz Source: [AI Services plugin page](https://wordpress.org/plugins/ai-services/) Reference: N/A date created: {{date:2025-04-29}} {{time:17:45}} --- # Title: AI Services – Centralized AI for WordPress Plugins ## Table of Contents: 1. 📝 [Summary](#summary) 2. 📖 [Main Content](#main-content) 3. 🗒️ [Notes](#notes) 4. 🗣️ [Paraphrase](#paraphrase) 5. 📰 [Newsletter](#newsletter) 6. ✅ [Action Items](#action-items) 7. 🧪 [Hypotheses](#hypotheses) 8. 📊 [Methodology](#methodology) 9. ❓ [Questions](#questions) 10. 🔮 [Future Research](#future-research) 11. 💡 [Implications](#implications) 12. 🧠 [Learning Styles Assessment](#learning-styles-assessment) 13. 📊 [Accessibility Assessment](#accessibility-assessment) 14. 🌍 [DEIB Assessment](#deib-assessment) 15. ✅ [Logical validity](#logical-validity) 16. 🔍 [DARVO Analysis](#darvo-analysis) 17. 🔍 [SEO Evaluation](#seo-evaluation) 18. 🎯 [Conclusion](#conclusion) ### References: - “AI Services – WordPress plugin”, WordPress.org :contentReference[oaicite:0]{index=0} ## 📝 Summary: AI Services provides a unified infrastructure for WordPress plugins to leverage any AI provider (OpenAI, Google, Anthropic, etc.) via PHP, JavaScript, REST API, or WP-CLI. It includes an AI Playground UI and settings screen for credentials, but no built-in AI features—making it a dependency hub for other plugins. :contentReference[oaicite:1]{index=1} ## 📖 Main Content: The plugin exposes agnostic APIs so that plugin authors call a single interface regardless of underlying AI service. Features include text generation (with streaming), chat history, multimodal input, function calling, and image generation. An admin “Playground” allows live testing of models and dynamic switching. Configuration is handled in a dedicated settings page. Developers can register custom providers beyond the built-in ones. :contentReference[oaicite:2]{index=2} ### 🗒️ Notes - **Abstraction Layer** - Uniform APIs in PHP, JS, REST, WP-CLI - Supports text gen, chat, multimodal, function calls, images - **Playground Screen** - Explore capabilities in Tools → AI Playground - Switch models mid-conversation - Save generated images to Media Library - **Settings Screen** - Enter credentials for Anthropic, Google, OpenAI, Chrome AI - **Extensibility** - Register additional providers via hooks - **Intended Use** - Dependency plugin for other AI-driven features - No direct front-end components except Playground ## 🗣️ Paraphrase: 1. **Original:** “This WordPress plugin introduces central infrastructure which allows other plugins to make use of AI capabilities.” **Paraphrase:** AI Services acts as a core layer, giving any plugin a standard way to access AI functions without binding to one vendor. 2. **Original:** “It exposes APIs that can be used in various contexts, whether you need to use AI capabilities in server-side or client-side code.” **Paraphrase:** The plugin’s interfaces work in PHP backends, JavaScript front-ends, REST endpoints, or command-line tasks alike. ## 📰 Newsletter: 🚀 **New Plugin Spotlight:** Tired of juggling multiple AI integrations? Check out **AI Services**, the dependency plugin that makes any AI provider—OpenAI, Google, Anthropic—available to your own plugins via PHP, JS, REST, or WP-CLI. No extra features built in, just a rock-solid API layer plus an AI Playground for testing. Perfect for developers building AI-powered tools! Learn more: https://wordpress.org/plugins/ai-services/ ## ✅ Action Items: - **Install & Test:** Add AI Services to your dev environment. - **Prototype:** Build a small plugin using its APIs for text generation. - **Feedback Loop:** Share issues and suggestions on the GitHub repo. ## 🧪 Hypotheses: - **H1:** Centralizing AI calls reduces integration time by 40%. - **H2:** Developers using AI Services will adopt AI features in 60% of new plugins. - **H3:** Plugin collisions drop by 70% when sharing a single AI dependency. ### 📊 Methodology: - **A/B Testing:** Compare two teams—one using AI Services, one direct SDKs—for a feature sprint. - **Surveys:** Gather developer satisfaction and time-to-prototype metrics. - **Telemetry:** Track adoption rates of AI Services in WP.org plugin directory. ### ❓ Questions: - What’s the latency impact of the abstraction layer? - How steep is the learning curve for first-time users? - Which AI capabilities are most in demand? ### 🔮 Future Research: - Benchmark performance across providers. - Study community contributions to provider extensions. ### 💡 Implications: A standardized AI layer could become a WordPress core feature, lowering barriers for plugin authors and improving ecosystem interoperability. ## 🧠 Learning Styles Assessment: - **Visual:** Good UI diagrams; add architecture flowchart. - **Aural:** No audio guide; consider screencast. - **Verbal:** Clear text; include real-world examples. - **Physical:** No interactive labs; add hands-on workshops. - **Logical:** Step-by-step code snippets present. - **Social:** Recommend community calls or forum threads. - **Solitary:** Reflection prompts on integration choices. - **Naturalistic:** Use nature analogies (AI “ecosystem”) for clarity. ## 📊 Accessibility Assessment: - **Screen Reader:** Semantic HTML; ensure alt text on Playground images. - **Keyboard:** Confirm full keyboard navigation in Playground. - **Contrast:** UI meets contrast ratios; split dense lists. - **Text Resizing:** Responsive to zoom. ## 🌍 DEIB Assessment: - **Cultural Relevance:** Examples from global AI providers. - **Inclusive Language:** Acronyms defined on first use. - **Neurodiversity:** Use bullet points and clear headings. - **Representation:** Feature quotes from diverse developers. - **Psychological Safety:** Encourage experimentation without fear. ## ✅ Logical validity: - **Strength:** Clear motivation vs plugin fragmentation strengthens argument (Notes §1). - **Fallacy:** Potential **false dilemma** by implying this is the only solution—acknowledge alternative integration strategies. ## 🔍 DARVO Analysis: No Deny, Attack, or Reverse Victim/Offender patterns. Tone is neutral and instructional. ## 🔍 SEO Evaluation: - **Keywords:** “AI Services,” “WordPress plugin,” “AI provider” in title and headers. - **Meta Description:** Missing—add 150-char summary with primary keyword. - **Headers:** Proper H2/H3 hierarchy. - **Links:** Add internal links to docs and GitHub. - **Schema:** Implement Article schema for rich snippets. ## 🎯 Conclusion: AI Services lays the groundwork for uniform AI integration across WordPress plugins. By decoupling features from providers, it streamlines development, fosters interoperability, and enables plugin authors to focus on innovation rather than compatibility. - Summary: Learn how to use the AI Services plugin, which makes AI centrally available in WordPress, whether via PHP, REST API, JavaScript, or WP-CLI - for any provider. - URL: https://felixarntz.github.io/ai-services/ The AI Services plugin makes AI centrally available in WordPress, whether via PHP, REST API, JavaScript, or WP-CLI - for any provider. | AI Services: Settings screen | AI Services: Playground screen | | --- | --- | | The AI Services settings screen where users can paste their AI service credentialsThe AI Services settings screen where users can paste their AI service credentials | Multimodal text generation in the AI Playground where users can explore the different AI model capabilitiesMultimodal text generation in the AI Playground where users can explore the different AI model capabilities | This WordPress plugin introduces central infrastructure which allows other plugins to make use of AI capabilities. It exposes APIs that can be used in various contexts, whether you need to use AI capabilities in server-side or client-side code. Furthermore, the APIs are agnostic of the AI service - whether that’s Anthropic, Google, or OpenAI, to only name a few, you can use any of them in the same way. You can also register your own implementation of another service, if it is not supported out of the box. The plugin does intentionally *not* come with specific AI driven features built-in, except for an AI Playground screen to explore AI capabilities as well as a settings screen to configure AI service credentials. The purpose of this plugin is to facilitate use of AI by other plugins. As such, it is a perfect use-case for [plugin dependencies](https://make.wordpress.org/core/2024/03/05/introducing-plugin-dependencies-in-wordpress-6-5/). Here’s a (non-comprehensive) feature list: * Abstraction layer and APIs to communicate with any AI service in a uniform way + APIs are available in both PHP and in JavaScript, as well as via the WordPress REST API and WP-CLI commands + Currently supports the following AI capabilities (with more on the way!): - text generation (including text streaming for more immediate feedback to users) - text chats with history - multimodal input - function calling - image generation * AI Playground administration screen (in the Tools menu) allows exploring the different AI capabilities + Explore all AI capabilities supported by the plugin via user interface + Select which AI service and model to use and set a few advanced configuration parameters + Define your own function declarations used for AI function calling + Generate images and save them to the WordPress media library + Exchange the AI service or model on the fly to continue a chat started with one model with another one * AI Services settings screen to configure services with API credentials * Built-in AI service implementations + [Anthropic (Claude)](https://www.anthropic.com/claude) + [Google (Gemini, Imagen)](https://ai.google.dev/gemini-api) + [OpenAI (GPT, Dall-E)](https://openai.com/chatgpt/) + Browser (client-side only; experimental support for [Chrome’s built-in AI APIs](https://developer.chrome.com/docs/ai/built-in-apis)) * Additional AI service integrations can be registered and will then be available in the same way as built-in ones #### Why? * A centralized AI infrastructure **facilitates user choice**. Users may prefer certain AI services over other ones, and for many common tasks, either of the popular AI services is suitable. Having a common API regardless of the AI service allows leaving the choice to the user, rather than the plugin author. * Since the centralized AI infrastructure comes with a common API that works the same for every AI service, it means **plugin developers don’t have to spend as much time familiarizing themselves with different services**, at least when it comes to simple tasks. For tasks where certain services may have advantages over others, there is still flexibility to focus on a specific AI service. * It also means **no more reinventing the wheel**: Since most AI services do not provide PHP SDKs for their APIs, many times this means WordPress plugins that want to leverage AI have to implement their own layer around the service’s API. Not only is that time consuming, it also distracts from working on the actual (AI driven) features that the plugin should offer to its users. In fact this directly facilitates the user choice aspect mentioned, as having APIs for various AI services already provided means you can simply make those available to your plugin users. * Having central AI infrastructure available **unlocks AI capabilities for smaller plugins or features**: It may not be worth the investment to implement a whole AI API layer for a simple AI driven feature, but when you already have it available, it can lead to more plugins (and thus more users) benefitting from AI capabilities. * Last but not least, a central AI infrastructure means **users will only have to configure the AI API once**, e.g. paste their API keys only in a single WordPress administration screen. Without central AI infrastructure, every plugin has to provide its own UI for pasting API keys, making the process more tedious for site owners the more AI capabilities their site uses. #### Code examples for using the API **Generate the answer to a prompt in PHP code:** ``` use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability; use Felix_Arntz\AI_Services\Services\API\Helpers; if ( ai_services()->has_available_services() ) { $service = ai_services()->get_available_service(); try { $candidates = $service ->get_model( array( 'feature' => 'my-test-feature', 'capabilities' => array( AI_Capability::TEXT_GENERATION ), ) ) ->generate_text( 'What can I do with WordPress?' ); $text = Helpers::get_text_from_contents( Helpers::get_candidate_contents( $candidates ) ); echo $text; } catch ( Exception $e ) { // Handle the exception. } } ``` **Generate the answer to a prompt in JavaScript code:** ``` const helpers = aiServices.ai.helpers; const { hasAvailableServices, getAvailableService } = wp.data.select( 'ai-services/ai' ); if ( hasAvailableServices() ) { const service = getAvailableService(); try { const candidates = await service.generateText( 'What can I do with WordPress?', { feature: 'my-test-feature' } ); const text = helpers.getTextFromContents( helpers.getCandidateContents( candidates ) ); console.log( text ); } catch ( error ) { // Handle the error. } } ``` **Generate the answer to a prompt using WP-CLI:** ``` wp ai-services generate-text "What can I do with WordPress?" --feature=my-test-feature ``` You can also use a specific AI service, if you have a preference, for example the `google` service. **Generate the answer to a prompt using a specific AI service, in PHP code:** ``` use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability; use Felix_Arntz\AI_Services\Services\API\Helpers; if ( ai_services()->is_service_available( 'google' ) ) { $service = ai_services()->get_available_service( 'google' ); try { $candidates = $service ->get_model( array( 'feature' => 'my-test-feature', 'capabilities' => array( AI_Capability::TEXT_GENERATION ), ) ) ->generate_text( 'What can I do with WordPress?' ); $text = Helpers::get_text_from_contents( Helpers::get_candidate_contents( $candidates ) ); echo $text; } catch ( Exception $e ) { // Handle the exception. } } ``` Refer to the [plugin documentation](https://felixarntz.github.io/ai-services/Documentation.html) for granular examples including explainers. For complete examples such as entire plugins built on top of the AI Services infrastructure, please see the [examples directory on GitHub](https://github.com/felixarntz/ai-services/tree/main/examples)., AI Services, AI Services: AI Client Plugin for WordPress, 01jswhwz7hmy4pks9hrstxytj2.