CSAI Developer Guide
In this article we will go over our CSAI Developer features.
CSAI is very extendable. New providers can be defined by you. Calling provider actions can also be done by you.
Registering New Providers
cs_ai_provider_register
Arguments
$id
unique string ID to use for the AI provider. Such asopenai
.$config
an array of options
label | ✔ | string | Localized label to display in various places |
logo | string | URL of the logo of this AI | |
description | string | Extra info of this AI provider, displayed on the dashboard | |
Key | Required | Type | Description |
---|
Actions are defined by their ID (such as txt2img
). Each action object has a controls
, values
, and callable
.
controls
controls to display for the provider action settings. This uses the Cornerstone control array system.values
default values for the controls above.callable
when a use sends a request in the App for this action and provider, this is the function that gets called.
Default Actions
chat
General text generation.txt2img
Image generation.img2img
Image generation from a reference image.txt2speech
Text to speech / audio generation.txt2video
Video Generation
Sample
cs_ai_provider_register('my_ai', [
'label' => __('My AI'),
'logo' => 'https://theme.co/logo.png',
'txt2img' => [
'values' => [
'my_option' => true,
],
'controls' => [
[
'key' => 'my_option',
'type' => 'toggle',
],
],
'callable' => function($request) {
// These are values defined by the `values` key above.
$settings = $request['settings'];
// Make request to an AI
/* wp_remote_request( ... ); */
// You can return multiple messages here as well
return [
'message' => [
'content' => '', // Response from an AI
'info' => [], // Extra info for debug popup
],
];
},
],
]);
Provider API
Below is a list of our Provider API functions
// Get all Providers
$providers = cs_ai_providers();
// Get singular provider
$provider = cs_ai_provider_get('openai');
// Get a providers action configuration
$txt2imgAction = cs_ai_provider_action('openai', 'txt2img');
// Get all defined provider values
$providerSettings = cs_ai_provider_settings();
// Set and save a provider setting for a given action
cs_ai_provider_settings_set('openai', 'txt2img', [
'model' => 'gpt-5',
]);
// Gets all providers as a valid option for a selectbox or choose control
$providerChoices = cs_ai_provider_choices_with_action();
See something inaccurate? Let us know