Guide

Chart Builder Abilities

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

FieldValue
Nameprc-chart-builder/generate
LabelGenerate Chart
Categorydata-retrieval
Permissioncurrent_user_can( 'edit_posts' )
REST exposureshow_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.

Reference

Input properties

Typed options, defaults, and constraints in one scannable reference.
5 fields
chartType string required
Chart type slug such as bar, line, pie, or sankey.
description string
Free-text description of the desired chart.
image string
Base64-encoded PNG or JPEG chart image.
csvData string
Raw CSV text containing chart data.
model enum
Claude model. The ability schema has no JSON Schema default; the execute callback falls back to claude-sonnet-4-6.

Output

Reference

Output properties

Typed options, defaults, and constraints in one scannable reference.
2 fields
content string
Serialized WordPress block markup ready to submit to /wp/v2/chart.
error string
Error message when generation fails; empty on success.

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_posts permission
  • REST args set model default to claude-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.

Was this helpful?