Skip to main content

benecaster_get_ai_model_catalog()

Utilities Free
benecaster_get_ai_model_catalog( string $provider ): array

For an add-on that calls an AI provider with the podcaster’s own key, such as AI Search or Transcription: the list of models it may offer, kept up to date by Benecaster, so a new or retired model needs no release of your add-on.

Benecaster keeps its own copy of the list and refreshes it on its daily license check. This function only reads that copy, so it never calls out and is safe on any request.

Parameters

Name Type Default Required Description
$provider string — Yes The AI provider: anthropic, openai, cohere or gemini today. Case does not matter.

Return Value

Type: array

The models Benecaster lists for that provider, in the order it published them, or []. Each entry: id (what to send to the provider), label and description (English only), kind (text, embedding or transcription), retired (bool) and min_addon_version (entitlement slug ⇒ version, such as [ 'benecaster-addon-ai-search' => '1.4.0' ]).

Example

foreach ( benecaster_get_ai_model_catalog( 'openai' ) as $model ) {
    $needs = $model['min_addon_version']['benecaster-addon-my-ai-tool'] ?? null;
    if ( null === $needs || version_compare( MY_ADDON_VERSION, $needs, '<' ) || $model['retired'] ) {
        continue;
    }
    $choices[ $model['id'] ] = $model['label'];
}

Notes

[] means "use your shipped list": before the first refresh, and for a provider with nothing listed. Keep your own list as the fallback and as the source of translated labels.

Offer an entry only when your own entitlement slug is a key of min_addon_version and your version is at least its value (version_compare()). A new model can need request code an older release lacks, so an entry that names no add-on is offered by none. Offer no retired entry as a new choice, and move a saved one to the provider's default rather than leaving the field blank. Match kind to the field you fill.

Entries are checked before you see them: one with a malformed id, no label or no recognized kind is left out, and so is a min_addon_version pair whose version is not two to four dot-separated numbers. Labels are plain text, at most 100 characters; descriptions at most 300. Worked example: Offer AI models from the catalog in your add-on's settings.

Need this built rather than just documented? See our services →