Chart Builder registers one WordPress Ability for AI chart generation. The Chart Library admin calls a companion REST route with the same inputs because that UI sits outside the block editor Abilities client.
Ability: prc-chart-builder/generate
| Field | Value |
|---|---|
| Name | prc-chart-builder/generate |
| Label | Generate Chart |
| Category | data-retrieval |
| Permission | current_user_can( 'edit_posts' ) |
| REST exposure | show_in_rest: true |
Description: Generates chart block markup from a text description, CSV data, and/or a reference image using a selectable Claude model.
Source: includes/ai-experiment/class-chart-ai-ability.php
Input
Object. additionalProperties is not allowed. Only chartType is required.
Input properties
-
chartTypestring required -
Chart type slug such as bar, line, pie, or sankey.
-
descriptionstring -
Free-text description of the desired chart.
-
imagestring -
Base64-encoded PNG or JPEG chart image.
-
csvDatastring -
Raw CSV text containing chart data.
-
modelenum -
Claude model. The ability schema has no JSON Schema default; the execute callback falls back to claude-sonnet-4-6.
No fields match this filter.
Output
Output properties
-
contentstring -
Serialized WordPress block markup ready to submit to /wp/v2/chart.
-
errorstring -
Error message when generation fails; empty on success.
No fields match this filter.
Annotations
{
"annotations": {
"instructions": "Generates WordPress block markup for PRC Chart Builder blocks from a description, CSV data, and/or a chart image.",
"readonly": false,
"destructive": false,
"idempotent": false
},
"show_in_rest": true
}
Companion REST route
POST /wp-json/prc-chart-builder/v1/ai/generate
- Same five inputs and
edit_postspermission - REST args set
modeldefault toclaude-sonnet-4-6 - Delegates to the same
generate_chart()execution path as the ability - Returns
{ content, error }with HTTP 200 even when generation fails (error string populated)
Full request field table: rest-api.md
Side effects
The ability does not create or update posts. It returns serialized block markup only.
Accepting a preview in the Chart Library can create a chart CPT by posting that markup to /wp/v2/chart. That step is outside the ability.
Other abilities
No other wp_register_ability() call exists under plugins/prc-chart-builder.