r/WordpressPlugins • u/RoyPartha04 • 3d ago
[HELP] AI api integration in plugin
Wordpress plugin review is asking not to call AI APIs directly but to use the connectors / WP AI client, which is fair. But the ai client was introduced in wp 7 I think.
Two questions
What about sites running older version
Will they allow to connect to local host without using connector? For those who run vllm, ollama, llama.cpp etc
2
Upvotes
1
u/RoyPartha04 2d ago
Thanks for the help guys, really appreciate!
2
u/prajeshganatra 3d ago
For older WP versions, you can bundle
wordpress/wp-ai-clientvia Composer. It handles the transition to WP 7.0 automatically.For local models, there's already an Ollama connector. You could follow a similar approach for vLLM and llama.cpp.
I'd check with the review team before implementing direct localhost API calls, though. They might still expect you to use the connector architecture.
Hope this helps!
2
u/PeepSoWP 2d ago
One detail to add to Prajesh's answer: if you bundle the lower-level
wordpress/php-ai-clientdirectly, its autoloader needs to be conditional so it doesn't collide with the copy in WordPress 7.0+. Thewordpress/wp-ai-clientwrapper handles that transition; the official migration notes explain the distinction.Also,
localhostin a PHP request means the WordPress server or container. It won't reach Ollama on the visitor's laptop. That deployment detail is worth spelling out in your settings/help text. The review team still needs to answer the policy exception.2
u/WP_Dev_Studio 2d ago
I haven't shipped against the new AI client yet, so treat this as how I'd approach it, and confirm the exact review rules with the reviewer.
Older versions: keep the plugin working without AI, and make the AI features an optional layer. Detect whether the core AI client is available, show the AI features only when it is, and say in the readme which WordPress version they need. Don't bundle your own direct API calls as a fallback, since that's what the reviewer objected to.
Local models: ask the reviewer in the review thread, with a concrete example, such as "the user enters an OpenAI-compatible base URL like http://localhost:11434/v1 in settings." Tools like Ollama, vLLM and llama.cpp expose that style of API, so a connector that accepts a custom base URL may cover it. If the reviewers say it must go through a connector, that's the route to take.
One technical detail to plan for: wp_safe_remote_* functions reject localhost and private IP addresses by default. If your plugin ever calls a user-configured local endpoint itself, only allow it for a host the admin has explicitly entered, and don't let the URL be set by non-admin users. Otherwise you open a server-side request forgery risk.