Skip to content

[Platform] Allow fetching available models per platform #629

@ohader

Description

@ohader

Description

In scenarios where one needs to configure multiple platforms and specific models for a particular task within a user interface (such as CMS integration of symfony/ai) it would be beneficial to have a feature that allows to retrieve the actual available models for a given platform.

Example Code

<?php
use Symfony\AI\Platform\Bridge\Ollama\PlatformFactory;
use Symfony\AI\Platform\Capability;

require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
$modelDefinitions = $platform->fetchModelDefinitions();

echo "Available models:\n";
foreach ($modelDefinitions as $modelDefinition) {
    $modelCapabilities = array_map(
        static fn(Capability $capability): string => $capability->value,
        $modelDefinition->getCapabilities()
    );
    echo sprintf(
        " + %s (%s)\n",
        $modelDefinition->getName(),
        implode(', ', $modelCapabilities)
    );
}

Example Output

Available models:
 + llama3.2:latest (input-messages, output-text, output-structured, tool-calling)
 + gemma3:latest (input-messages, output-text, output-structured, input-image)
 + gpt-oss:latest (input-messages, output-text, output-structured, tool-calling)
 + llama3.1:latest (input-messages, output-text, output-structured, tool-calling)
 + qwen2.5-coder:14b (input-messages, output-text, output-structured, tool-calling)
 + qwen3:latest (input-messages, output-text, output-structured, tool-calling)

Metadata

Metadata

Assignees

No one assigned

    Labels

    PlatformIssues & PRs about the AI Platform componentRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions