HooksFiltering AI models for OpenRouter
Filtering AI models for OpenRouter
You can predefine which AI models are available for translation through OpenRouter.
Do so via the following hook:
gatompl:ai_service_models:openrouter
The hook receives the list of models from OpenRouter, as a list of [model_id => model_name]
pairs, and returns the filtered list.
For instance, to only show OpenAI models, you can do this:
add_filter(
'gatompl:ai_service_models:openrouter',
/**
* @param array<string,string> $models
* @return array<string,string>
*/
fn (array $models) => array_filter(
$models,
fn (string $model): bool => str_starts_with($model, 'openai/'),
ARRAY_FILTER_USE_KEY
)
);