[wp-trac] [WordPress Trac] #64873: WP AI Client: Add JavaScript client (`wp-ai-client`)

WordPress Trac noreply at wordpress.org
Tue Mar 17 12:51:49 UTC 2026


#64873: WP AI Client: Add JavaScript client (`wp-ai-client`)
-------------------------+-----------------------
 Reporter:  gziolo       |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  7.1
Component:  AI           |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:  javascript   |
-------------------------+-----------------------
 This ticket tracks landing the `wp-ai-client` JavaScript package into
 WordPress Core as a discrete unit of work for the 7.1 cycle. The REST API
 endpoints it depends on are intentionally out of scope here and tracked
 separately in #64872.

 The JS client was originally proposed as part of the broader WP AI Client
 merge (#64591) and has an existing implementation in
 [https://github.com/WordPress/wordpress-develop/pull/10915 PR #10915], but
 did not land in 7.0. This ticket scopes the JS surface for focused review
 and iteration, contingent on the REST API endpoints being available.

 == Proposed Surface

 A `wp.aiClient` global (registered as the `wp-ai-client` script handle)
 that provides:

 - **`wp.aiClient.prompt()`** — A fluent `PromptBuilder` class mirroring
 the PHP API: `.withText()`, `.usingModel()`, `.usingTemperature()`,
 `.generateText()`, `.generateImage()`, `.isSupported()`, etc. All
 generation methods return Promises that call the REST endpoints.
 - **Provider/model data store** — A `@wordpress/data` store (`wp-ai-client
 /providers-models`) with selectors/resolvers for `getProviders()`,
 `getProvider()`, `getProviderModels()`, `getProviderModel()`. Data is
 fetched lazily via the REST API and cached in the store.
 - **Enums** — JS constants for `Capability`, `MessageRole`, `FileType`,
 `FinishReason`, `Modality`, `ProviderType`, etc., matching the PHP SDK
 enums.
 - **`GenerativeAiResult`** wrapper with convenience extraction methods
 (`toText()`, `toTexts()`, `toFile()`, `toImageFile()`, `toAudioFile()`,
 etc.).

 == References

  * [https://github.com/WordPress/wordpress-develop/pull/10915 PR #10915] —
 existing implementation (REST + JS client combined; REST endpoints tracked
 separately)
  * #64591 — original WP AI Client merge proposal and discussion
  * [https://make.wordpress.org/core/2026/02/03/proposal-for-merging-wp-ai-
 client-into-wordpress-7-0/ Make post: Proposal for merging WP AI Client
 into WordPress 7.0]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64873>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list