The Skills API, offered in WordPress 6.9, establishes a shared language, permitting all WordPress parts—each core and plugins—to show their capability in a unified, comprehensible approach for people and machines alike. This makes your WordPress web site waiting for integration with exterior automation equipment in a standardized and safe method.

If you’re questioning what some use instances for the Skills API would possibly seem like, call to mind an AI fashion that guides a consumer in the course of the buying procedure or even lets them entire the acquisition with out visiting your e-commerce web page. Or call to mind a CI/CD pipeline on GitHub Movements that processes textual content extracted from an audio or video record and sends it to WordPress for e-newsletter. The use instances are unending.

The Skills API adjustments the very function of WordPress throughout the ecosystem. It’s not only a weblog, nor even a CMS; nowadays, WordPress acts as a allotted execution engine that may be orchestrated from the outdoor, like a type of working device, totally waiting for self sufficient brokers.

Curious to be told extra? Let’s dive in.

What a capability is meant for

A capability is a discoverable, actionable capacity on a WordPress web site that allows explicit operations for exterior entities (similar to AI fashions) or inside parts.

The API can be utilized for such things as:

  • Looking for content material or executing explicit database operations
  • Studying web site configuration settings
  • Making a submit
  • Changing a JSON construction into Gutenberg blocks

Exposing a capability way making a particular capability interoperable. Ahead of a capability can also be came upon and used, it will have to be registered in a centralized catalog. Simplest then can WordPress and AI fashions uncover it, perceive its intent, and invoke it when wanted.

Via default, your plugins’ capability is totally remoted. Via registering a capability, you claim that the underlying common sense is to be had as a carrier for all the ecosystem.

Let’s have a look at an instance. In case your plugin has a serve as that converts an preliminary JSON object into structured content material waiting for Gutenberg blocks, you’ll be able to sign in it as a capability. This permits different equipment with the desired permissions to cause the very same serve as.

In our earlier educational at the WordPress AI Consumer, the plugin treated the core common sense of sending an audio record to the AI fashion, which returned a JSON-structured reaction to generate Gutenberg blocks. Alternatively, that capability remained limited to our plugin. Via registering this procedure as a capability, you decouple the execution, and any exterior entity can cause all the plugin common sense by means of merely passing a JSON object containing an audio record ID.

A capability serves as a proper contract between the underlying PHP common sense and any entity that requests its execution. The contract specifies the information the facility expects as enter, its intent, and the information schema it returns as output.

While you sign in a capability, it’s added for your web site’s capacity registry. From that second on, WordPress acts as a safe gateway: it verifies authentication and validates incoming knowledge towards the schema established by means of the contract. WordPress routes the request to the underlying PHP serve as provided that the payload strictly complies with the contract.

A capability is agnostic. WordPress does no longer want to know the precise entity inquiring for entry; it best verifies that the request is permitted and meets the contract’s constraints.

Via registering a capability, your plugin is not simply an extension with its personal inside common sense; it turns into a carrier supplier for all the ecosystem. Whether or not this is a cell app, an automation script like Make.com or Zapier, an AI agent, or a server speaking by means of the MCP protocol, those entities will know precisely how you can cause structured operations in your web site.

Running with the Skills API

The Skills API supplies a complete set of purposes that can help you uncover registered skills in your web site, turn on them, and each sign in and unregister skills.

Paintings together with your web site’s skills

You’ll retrieve an inventory of all registered skills or fetch a person capacity object. You’ll additionally test prerequisites, similar to whether or not a particular capacity is registered or if the agent has the permissions to cause it.

Get an inventory of the talents registered in your web site

The wp_get_abilities() serve as returns an array of all registered skills. You’ll take a look at it the usage of WP-CLI. If you attach for your web site by means of SSH, navigate to the web site’s root listing, the place your wp-config.php record lives, the usage of the next instructions:

cd /trail/to/your/web site
ls wp-config.php

Subsequent, ensure that WP-CLI acknowledges your web site set up:

wp core is-installed
wp possibility get siteurl

Should you get your web site URL, you are prepared to move and run the next command:

wp eval '$skills = wp_get_abilities(); foreach ( $skills as $a ) { echo $a->get_name() . PHP_EOL; }'

This command executes PHP code on your terminal. The PHP requests the names of each and every registered capacity in your web site, and by means of default, it will have to give you the following reaction:

core/get-site-info
core/get-user-info
core/get-environment-info

You want to request a extra entire set of knowledge with the next command:

wp eval '
$all_abilities = wp_get_abilities();

foreach ( $all_abilities as $capacity ) {
	echo "Talent Title: " . esc_html( $ability->get_name() ) . "n";
	echo "Label: " . esc_html( $ability->get_label() ) . "n";
	echo "Class: " . esc_html( $ability->get_category() ) . "n";
	echo "Description: " . esc_html( $ability->get_description() ) . "n";
	echo "---n";
}
'

While you run this command on a recent WordPress 7.0 web site, the terminal will display the next reaction:

Talent Title: core/get-site-info
Label: Get Website Knowledge
Class: web site
Description: Returns web site knowledge configured in WordPress. Via default returns all fields, or optionally a filtered subset.
---
Talent Title: core/get-user-info
Label: Get Consumer Knowledge
Class: consumer
Description: Returns profile main points for the present authenticated consumer to improve personalization, auditing, and access-aware conduct. Via default returns all fields, or optionally a filtered subset.
---
Talent Title: core/get-environment-info
Label: Get Atmosphere Data
Class: web site
Description: Returns core information about the web site's runtime context for diagnostics and compatibility (surroundings, PHP runtime, database server facts, WordPress model). Via default returns all fields, or optionally a filtered subset.
---

Get a capability object

The wp_get_ability() serve as returns a unmarried capacity object by means of its identify. You’ll take a look at it in WP-CLI with the next command:

wp eval '
$capacity = wp_get_ability( "core/get-site-info" );

if ( ! $capacity ) {
	echo "Talent no longer foundn";
	go out( 1 );
}

echo "Title: " . $ability->get_name() . "n";
echo "Label: " . $ability->get_label() . "n";
echo "Class: " . $ability->get_category() . "n";
echo "Description: " . $ability->get_description() . "n";
echo "nInput Schema:n";
var_dump( $ability->get_input_schema() );
echo "nOutput Schema:n";
var_dump( $ability->get_output_schema() );
echo "nMeta:n";
var_dump( $ability->get_meta() );
'

If the facility is appropriately registered in your web site, you’ll obtain the next reaction on your terminal:

Title: core/get-site-info
Label: Get Website Knowledge
Class: web site
Description: Returns web site knowledge configured in WordPress. Via default returns all fields, or optionally a filtered subset.

Enter Schema:
array(4) {
  ["type"]=>
  string(6) "object"
  ["properties"]=>
  array(1) {
	["fields"]=>
	array(3) {
	  ["type"]=>
	  string(5) "array"
	  ["items"]=>
	  array(2) {
		["type"]=>
		string(6) "string"
		["enum"]=>
		array(8) {
		  [0]=>
		  string(4) "identify"
		  [1]=>
		  string(11) "description"
		  [2]=>
		  string(3) "url"
		  [3]=>
		  string(5) "wpurl"
		  [4]=>
		  string(11) "admin_email"
		  [5]=>
		  string(7) "charset"
		  [6]=>
		  string(8) "language"
		  [7]=>
		  string(7) "model"
		}
	  }
	  ["description"]=>
	  string(81) "Not obligatory: Prohibit reaction to precise fields. If neglected, all fields are returned."
	}
  }
  ["additionalProperties"]=>
  bool(false)
  ["default"]=>
  array(0) {
  }
}

Output Schema:
array(3) {
  ["type"]=>
  string(6) "object"
  ["properties"]=>
  array(8) {
	["name"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(10) "Website Identify"
	  ["description"]=>
	  string(15) "The web site identify."
	}
	["description"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(7) "Tagline"
	  ["description"]=>
	  string(17) "The web site tagline."
	}
	["url"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(18) "Website Deal with (URL)"
	  ["description"]=>
	  string(94) "The general public URL the place guests entry the web site. Might fluctuate from the WordPress set up URL."
	}
	["wpurl"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(23) "WordPress Deal with (URL)"
	  ["description"]=>
	  string(83) "The URL the place WordPress core information are served. Might fluctuate from the general public web site URL."
	}
	["admin_email"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(28) "Management E-mail Deal with"
	  ["description"]=>
	  string(37) "The web site administrator e mail cope with."
	}
	["charset"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(12) "Website Charset"
	  ["description"]=>
	  string(28) "The web site personality encoding."
	}
	["language"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(13) "Website Language"
	  ["description"]=>
	  string(42) "The web site locale in sprint shape (e.g. en-US)."
	}
	["version"]=>
	array(3) {
	  ["type"]=>
	  string(6) "string"
	  ["title"]=>
	  string(17) "WordPress Model"
	  ["description"]=>
	  string(48) "The WordPress core model working in this web site."
	}
  }
  ["additionalProperties"]=>
  bool(false)
}

Meta:
array(2) {
  ["annotations"]=>
  array(3) {
	["readonly"]=>
	bool(true)
	["destructive"]=>
	bool(false)
	["idempotent"]=>
	bool(true)
  }
  ["show_in_rest"]=>
  bool(true)
}

Take a look at if a capability is registered

The wp_has_ability() serve as lets you test whether or not a capability is registered. In WP-CLI, you’ll be able to use it like this:

wp eval '
if ( wp_has_ability( "core/get-site-info" ) ) {
	echo "✓ core/get-site-info is registeredn";
} else {
	echo "✗ core/get-site-info no longer foundn";
}
'

If the facility has been registered, the next message will seem at the terminal:

✓ core/get-site-info is registered

Take a look at agent permissions

You’ll test whether or not the present consumer has the permissions to execute a capability by means of the usage of the check_permissions() approach of the $capacity object. This returns true, false, or a WP_Error object. Let’s attempt to name this technique from the terminal the usage of the next WP-CLI command:

wp --user=1 eval '
$capacity = wp_get_ability( "core/get-site-info" );
if ( $capacity ) {
	$has_permissions = $ability->check_permissions();
	if ( true === $has_permissions ) {
		echo "You will have permissions to execute this capacity.";
	} else {
		if ( is_wp_error( $has_permissions ) ) {
			error_log( "Permissions test failed: " . $has_permissions->get_error_message() );
		}
		echo "You wouldn't have permissions to execute this capacity.";
	}
} else {
	echo "Talent no longer discovered.";
}
'

Right here we have now set --user=1, which is why you’ll obtain the next reaction:

You will have permissions to execute this capacity.

Sign in a capability

It’s now time to sign in a capability. To exhibit a real-world use case, we can prolong the plugin described in our article at the WordPress AI Consumer. The plugin sends an audio record to the AI fashion to extract the textual content and cause the era of Gutenberg blocks. On this segment, we can have a look at how you can sign in this procedure as a capability in order that any entity with the important permissions can uncover and use it.

Ahead of registering a brand new capacity, you will have to sign in a brand new capacity class.

For this, it is very important hook the wp_register_ability_category() serve as into the wp_abilities_api_categories_init hook.

The serve as accepts a singular class slug and an associative array of arguments.

Here’s how you can sign in your capacity class:

serve as aicb_register_ability_category(): void {

	if ( ! function_exists( 'wp_register_ability_category' ) ) {
		go back;
	}

	wp_register_ability_category(
		'content-generation',
		array(
			'label'       => 'Content material Era',
			'description' => 'AI-powered content material transformation and structuring skills',
		)
	);
}
add_action( 'wp_abilities_api_categories_init', 'aicb_register_ability_category' );

The next move is to sign in the facility. To do that, you’ll hook the wp_register_ability() serve as into the wp_abilities_api_init motion.

The serve as accepts two arguments: the identify of the facility, together with its namespace, and an array of arguments for the facility’s configuration.

Here’s the facility registration for the AI Content material Builder plugin:

serve as aicb_register_audio_to_gutenberg_blocks_ability(): void {

	if ( ! function_exists( 'wp_register_ability' ) ) {
		go back;
	}

	$input_schema = array( ... );

	$output_schema = array( ... );

	wp_register_ability(
		'ai-content-builder/audio-to-gutenberg-blocks',
		array(
			'class'            => 'content-generation',
			'label'               => 'Audio to Gutenberg Blocks',
			'description'         => 'Transcribes audio and converts the content material into WordPress Gutenberg-compatible block gadgets.',
			'input_schema'        => $input_schema,
			'output_schema'       => $output_schema,
			'execute_callback'    => 'aicb_audio_to_gutenberg_blocks_callback',
			'permission_callback' => static serve as (): bool {
				go back current_user_can( 'edit_posts' );
			},
			'meta'                => array(
				'show_in_rest' => true,
				'annotations'  => array(
					'readonly'     => false,
					'harmful'  => false,
					'idempotent'   => false,
					'directions' => 'Processes an audio attachment: transcribes it, generates structured weblog content material by means of AI, and returns Gutenberg-ready block gadgets.',
				),
			),
		)
	);
}
add_action( 'wp_abilities_api_init', 'aicb_register_audio_to_gutenberg_blocks_ability' );

Within the wp_register_ability serve as name, we configured the next arguments:

  • class: The class to which the facility belongs.
  • label: The show identify of the facility.
  • description: A temporary description of what the facility does and its function.
  • input_schema: The information schema for the incoming enter arguments.
  • output_schema: The information schema equipped and returned by means of the facility.
  • execute_callback: The callback serve as to be achieved when the facility is brought on.
  • permission_callback: A callback serve as achieved to make sure that the agent has the desired permissions to run the facility.
  • meta: An array of extra metadata fields for the facility.
  • show_in_rest: Determines whether or not or to not reveal the facility throughout the WordPress REST API.
  • annotations: An array of descriptive components defining the facility’s conduct.

input_schema is an array that defines the facility’s enter contract. It represents the JSON Schema definition for validating the facility’s enter. In our explicit use case, it’s outlined as follows:

$input_schema = array(
	'kind'       => 'object',
	'homes' => array(
		'audio_id' => array(
			'kind'        => 'integer',
			'description' => 'The ID of the audio attachment to procedure and convert into Gutenberg blocks.',
		),
	),
	'required'   => array( 'audio_id' ),
);

This JSON Schema represents the layout that the enter knowledge will have to practice to make use of this capacity.

output_schema is the output contract returned by means of the facility. In our instance, each and every merchandise is an object representing a JSON block:

$output_schema = array(
	'kind'       => 'object',
	'homes' => array(
		'identify'      => array( 'kind' => 'string' ),
		'sections'   => array(
			'kind'  => 'array',
			'pieces' => array( 'kind' => 'object' ),
		),
		'blocks'     => array(
			'kind'  => 'array',
			'pieces' => array( 'kind' => 'object' ),
		),
		'transcript' => array( 'kind' => 'string' ),
	),
	'required'   => array( 'blocks' ),
);

The next move is to outline the callback serve as that executes when the facility is brought on (see the complete code on GitHub):

serve as aicb_audio_to_gutenberg_blocks_callback( array $args ) {

	// lacking code
	// see GitHub
	...

	$structured_json = wp_ai_client_prompt( $advised )
		->using_system_instruction( $directions )
		->using_temperature( 0.4 )
		->as_json_response( $schema )
		->generate_text();

	if ( is_wp_error( $structured_json ) ) {
		go back $structured_json;
	}

	$structured = json_decode( (string) $structured_json, true );
	if ( ! is_array( $structured ) ) {
		go back new WP_Error(
			'invalid_ai_json',
			'May just no longer parse structured AI reaction.',
			array( 'standing' => 500 )
		);
	}

	// Normalize the output.
	$normalized = aicb_normalize_structured_post( $structured );

	if ( '' === $normalized['title'] && empty( $normalized['sections'] ) ) {
		go back new WP_Error(
			'empty_structured_content',
			'The AI supplier returned empty structured content material.',
			array( 'standing' => 500 )
		);
	}

	// Convert to Gutenberg blocks.
	$blocks = aicb_sections_to_blocks( $normalized['title'], $normalized['sections'] );

	go back $blocks;
}

This serve as invokes two customized purposes. The primary one (aicb_normalize_structured_post) normalizes the AI’s output right into a predefined layout and sanitizes knowledge:

serve as aicb_normalize_structured_post( array $structured ): array {
	$identify = isset( $structured['title'] )
		? sanitize_text_field( (string) $structured['title'] )
		: '';

	$sections = array();

	if ( isset( $structured['sections'] ) && is_array( $structured['sections'] ) ) {
		foreach ( $structured['sections'] as $segment ) {
			if ( ! is_array( $segment ) ) {
				proceed;
			}

			$heading = isset( $segment['heading'] )
				? sanitize_text_field( (string) $segment['heading'] )
				: '';

			$stage = 2;

			$paragraphs = array();
			if ( isset( $segment['paragraphs'] ) && is_array( $segment['paragraphs'] ) ) {
				foreach ( $segment['paragraphs'] as $paragraph ) {
					$clean_paragraph = trim( sanitize_textarea_field( (string) $paragraph ) );
					if ( '' !== $clean_paragraph ) {
						$paragraphs[] = $clean_paragraph;
					}
				}
			}

			$bullet_points = array();
			if ( isset( $segment['bullet_points'] ) && is_array( $segment['bullet_points'] ) ) {
				foreach ( $segment['bullet_points'] as $bullet_point ) {
					$clean_bullet_point = trim( sanitize_text_field( (string) $bullet_point ) );
					if ( '' !== $clean_bullet_point ) {
						$bullet_points[] = $clean_bullet_point;
					}
				}
			}

			if ( '' === $heading || empty( $paragraphs ) ) {
				proceed;
			}

			$sections[] = array(
				'heading'       => $heading,
				'stage'         => $stage,
				'paragraphs'    => $paragraphs,
				'bullet_points' => $bullet_points,
			);
		}
	}

	go back array(
		'identify'    => $identify,
		'sections' => $sections,
	);
}

The serve as accepts a structured array of JSON gadgets, normalizes and sanitizes the information, and returns an array containing the identify and sections.

The second one serve as (aicb_sections_to_blocks) converts the normalized knowledge into block descriptor gadgets and is outlined as follows:

serve as aicb_sections_to_blocks( string $identify, array $sections ): array {
	$blocks = array();

	foreach ( $sections as $segment ) {
		if ( ! is_array( $segment ) ) {
			proceed;
		}

		$heading = isset( $segment['heading'] ) ? trim( (string) $segment['heading'] ) : '';
		if ( '' === $heading ) {
			proceed;
		}

		$paragraphs = array();
		if ( isset( $segment['paragraphs'] ) && is_array( $segment['paragraphs'] ) ) {
			foreach ( $segment['paragraphs'] as $paragraph ) {
				$blank = trim( (string) $paragraph );
				if ( '' !== $blank ) {
					$paragraphs[] = $blank;
				}
			}
		}

		if ( empty( $paragraphs ) ) {
			proceed;
		}

		$blocks[] = array(
			'identify'       => 'core/heading',
			'attributes' => array(
				'content material' => $heading,
				'stage'   => 2,
			),
		);

		foreach ( $paragraphs as $paragraph ) {
			$blocks[] = array(
				'identify'       => 'core/paragraph',
				'attributes' => array(
					'content material' => $paragraph,
				),
			);
		}

		if ( isset( $segment['bullet_points'] ) && is_array( $segment['bullet_points'] ) ) {
			$bullet_items_html = '';

			foreach ( $segment['bullet_points'] as $bullet_point ) {
				$clean_bullet = trim( sanitize_text_field( (string) $bullet_point ) );
				if ( '' === $clean_bullet ) {
					proceed;
				}

				// core/record expects HTML within the `values` characteristic.
				$bullet_items_html .= '
  • ' . esc_html( $clean_bullet ) . '
  • '; } if ( '' !== $bullet_items_html ) { $blocks[] = array( 'identify' => 'core/record', 'attributes' => array( 'values' => '
      ' . $bullet_items_html . '
    ', ), ); } } } go back $blocks; }

    Listed here are the important thing highlights of this serve as:

    • The serve as accepts 2 arguments: a string representing the submit identify and an array of the sections generated by means of the AI fashion.
    • For each and every segment, the serve as generates a heading and a minimum of one paragraph.
    • If bullet issues are provide, it generates a corresponding selection of record pieces.
    • The serve as returns a $blocks array of block descriptor gadgets, which is the output contract returned by means of the facility ($output_schema).

    Notice that the serve as’s output isn’t the uncooked block markup. This can be generated client-side the usage of the JavaScript createBlock serve as.

    For instance, the heading part of a piece is represented by means of the next object:

    if ( '' !== $heading ) {
    	$blocks[] = array(
    		'identify'       => 'core/heading',
    		'attributes' => array(
    			'content material' => $heading,
    			'stage'   => ( 3 === $stage ) ? 3 : 2,
    		),
    	);
    }

    After getting registered your capacity, you’ll be able to run the similar WP-CLI instructions observed above on your terminal to get the main points. The next code will generate the enter schema on your capacity:

    wp --user=1 eval '
    $capacity = wp_get_ability( "ai-content-builder/audio-to-gutenberg-blocks" );
    
    if ( ! $capacity ) {
        echo "Talent no longer foundn";
        go out( 1 );
    }
    
    echo "Enter Schema:n";
    var_dump( $ability->get_input_schema() );
    '

    Here’s the end result within the terminal:

    Enter Schema:
    array(3) {
    	["type"]=>
    	string(6) "object"
    	["properties"]=>
    	array(1) {
    		["audio_id"]=>
    		array(2) {
    			["type"]=>
    			string(7) "integer"
    			["description"]=>
    			string(76) "The ID of the audio attachment to procedure and convert into Gutenberg blocks."
    		}
    	}
    	["required"]=>
    	array(1) {
    		[0]=>
    		string(8) "audio_id"
    	}
    }

    In the similar approach, you’ll be able to retrieve the output schema of the facility:

    wp --user=1 eval '
    $capacity = wp_get_ability( "ai-content-builder/audio-to-gutenberg-blocks" );
    
    if ( ! $capacity ) {
        echo "Talent no longer foundn";
        go out( 1 );
    }
    
    echo "Output Schema:n";
    var_dump( $ability->get_output_schema() );
    '

    You’ll additionally show your entire object of your capacity with the next command:

    wp eval '
    $capacity = wp_get_ability( "ai-content-builder/audio-to-gutenberg-blocks" );
    
    if ( ! $capacity ) {
    	echo "Talent no longer foundn";
    	go out( 1 );
    }
    
    echo "Title: " . $ability->get_name() . "n";
    echo "Label: " . $ability->get_label() . "n";
    echo "Class: " . $ability->get_category() . "n";
    echo "Description: " . $ability->get_description() . "n";
    echo "nInput Schema:n";
    var_dump( $ability->get_input_schema() );
    echo "nOutput Schema:n";
    var_dump( $ability->get_output_schema() );
    '

    Executing a capability

    To run a capability, you’ll use the execute() approach of the $capacity object. You’ll take a look at working the next PHP code by means of WP-CLI to cause the core/get-site-info capacity:

    wp --user=1 eval '
    $capacity = wp_get_ability( "core/get-site-info" );
    
    if ( ! $capacity ) {
    	echo "Talent no longer foundn";
    	go out(1);
    }
    
    $outcome = $ability->execute();
    
    if ( is_wp_error( $outcome ) ) {
    	echo "ERROR: " . $result->get_error_message() . "n";
    	go out(1);
    }
    
    echo json_encode( $outcome, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . "n";
    '

    While you run this command, the facility will supply a JSON object very similar to the next:

    {
    	"identify": "WordPress 7.0",
    	"description": "",
    	"url": "http://yoursite.kinsta.cloud",
    	"wpurl": "http://yoursite.kinsta.cloud",
    	"admin_email": "[email protected]",
    	"charset": "UTF-8",
    	"language": "en-US",
    	"model": "7.1-alpha-62550"
    }

    The above is only a easy instance of a capability that gives knowledge on your web site.

    As discussed above, a capability can require enter knowledge, carry out operations on that knowledge, and go back a structured output. We will be able to see an instance of this with the facility we registered within the earlier segment.

    Nonetheless on your terminal, navigate for your web site’s root listing and run the next PHP code:

    wp --user=1 eval '
    $capacity = wp_get_ability( "ai-content-builder/audio-to-gutenberg-blocks" );
    
    if ( ! $capacity ) {
    	echo "Talent no longer foundn";
    	go out( 1 );
    }
    
    $enter = array( "audio_id" => 1755 );
    
    $outcome = $ability->execute( $enter );
    
    if ( is_wp_error( $outcome ) ) {
    	echo "ERROR: " . $result->get_error_message() . "n";
    	go out( 1 );
    }
    
    echo json_encode( $outcome, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . "n";
    '

    The execute approach passes the structured enter knowledge to the facility, which returns an array of gadgets waiting to be transformed into Gutenberg blocks:

    [
    	{
    		"name": "core/heading",
    		"attributes": {
    			"content": "A Well-Deserved Rest Day in Marrakech",
    			"level": 2
    		}
    	},
    	{
    		"name": "core/paragraph",
    		"attributes": {
    			"content": "On April 24th, our group of seven motorcyclists took a break from the open road..."
    		}
    	},
    	{
    		"name": "core/heading",
    		"attributes": {
    			"content": "Exploring Jemaa el-Fnaa and the Medina",
    			"level": 2
    		}
    	},
    	{
    		"name": "core/paragraph",
    		"attributes": {
    			"content": "Our journey led us straight to Jemaa el-Fnaa, the legendary main square of Marrakech..."
    		}
    	},
    	{
    		"name": "core/list",
    		"attributes": {
    			"values": "
    • Navigating the bustling souks and narrow alleys of the ancient Medina.
    • Savoring traditional Moroccan and Berber dishes.
    • Experiencing the vibrant street performances and food stalls of Jemaa el-Fnaa at night.
    " } }, ... ]

    REST API Integration

    The WordPress Skills API supplies a unified routing construction that permits exterior brokers to programmatically question to be had capacity classes (/classes), check up on explicit capacity contracts (/skills/{identify}), and execute a particular capacity the usage of the usual run endpoint (/skills/{identify}/run).

    Right here, for instance, is a GET request that returns the record of classes from our take a look at web site:

    https://yoursite.kinsta.cloud/wp-json/wp-abilities/v1/classes
    GET request for ability categories in Postman
    All requests will have to be approved

    After we registered the facility within the earlier instance, we set the show_in_rest parameter to true. Via doing so, we made our capacity routinely available by means of those local WordPress REST API endpoints underneath the centralized core namespace (wp-abilities/v1).

    Which means you don’t want to manually sign in customized routes from scratch to invoke a capability from an exterior surroundings. Exterior brokers can uncover and execute your capacity the usage of same old HTTP requests.

    You’ll check up on the precise contract of our capacity with the next GET request:

    https://yoursite.kinsta.cloud/wp-json/wp-abilities/v1/skills/ai-content-builder/audio-to-gutenberg-blocks

    In any case, you’ll be able to cause the facility with an authenticated POST request:

    https://yoursite.kinsta.cloud/wp-json/wp-abilities/v1/skills/ai-content-builder/audio-to-gutenberg-blocks/run

    When sending this sort of request, be sure to have specified the enter knowledge. For our instance, we have now set the next JSON within the request frame:

    {
    	"enter": {
    		"audio_id": YOUR_AUDIO_ID
    	}
    }
    Executing an ability via HTTP request in Postman
    Executing a capability by means of HTTP request in Postman

    Our capacity processed the audio and dispatched it to the AI fashion configured at the web site. The fashion returned a structured output that used to be due to this fact normalized and clean upd, in spite of everything returning the next array of gadgets containing the block attributes:

    {
    	"blocks": [
    		{
    			"name": "core/heading",
    			"attributes": { "content": "A Welcome Rest Day in Marrakech", "level": 2 }
    		},
    		{
    			"name": "core/paragraph",
    			"attributes": { "content": "On April 24, our group of seven motorcyclists paused our journey..." }
    		}
    	]
    }

    And that is exactly the result we have been aiming for.

    The way forward for WordPress is agentic

    Whilst the AI Consumer and the brand new connector structure deliver AI processing features inside of WordPress, the Skills API redefines how WordPress interacts with the outdoor international. We’re witnessing a drastic paradigm shift, shifting from a standard internet structure—in response to guide consumer interplay the place each and every integration required customized endpoints and guide mapping—to an intent-driven structure designed from the bottom up for automation.

    For WordPress builders, the brand new Skills API represents an architectural turning level, characterised by means of decoupling capability from plugins that comprise its common sense, implementing safety in the course of the enter/output contract, and enabling local interoperability throughout all the ecosystem.

    Taken in combination, those options make sure that the Skills API isn’t just any other API, however a real allotted execution engine that provides a glimpse into an an increasing number of agentic long term for WordPress.

    The submit Getting began with the WordPress Skills API: A sensible information gave the impression first on Kinsta®.

    WP Hosting

    [ continue ]