Skip to content

[Platform] Integrate with additional platform APIs #2402

Description

@viccherubini

I reviewed both open and closed issues but couldn't find much regarding the plan to integrate with additional platform APIs: file management and vector stores, in particular.

Every file a user uploads to my app is immediately uploaded to a model platform. This allows us to store the ID of that file in our database, and reference it when sending a request to a model. I know most platforms allow you to send a file URL, but that means the model has to download it for each request. Caching it with the model avoids that and I've found leads to speedier responses.

Additionally, some platforms require it to use other services they offer. For example, OpenAI requires you to upload a file before it can be imported into a vector store.

Without these kinds of integrations, I'm left with two choices:

  1. Write my own code for uploading files, creating vector stores, importing files into a vector store, etc and use Symfony AI only for the platform and agent libraries.
  2. Write my own code for all integrations to ensure it's standardized and uniform.

I really like the platform and agent libraries, but without deeper integration to other APIs the platforms offer, I'm left picking option 2 to ensure my codebase is uniform.

I'm envisioning something along these lines:

use Symfony\AI\Platform\Bridge\OpenAi\Factory;
use Symfony\AI\Platform\Message\Content\CachedFile;
use Symfony\AI\Platform\Message\Content\File;
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;

$platform = Factory::createPlatform(env('OPENAI_API_KEY'));

// Upload a file
$result = $platform->files->upload(File::fromFile('/path/to/file.pdf'));

printf("File ID: %s\n", $result->getId()); // File ID: file-1YWkCVEw4CwHUkVpxWmnC4

if (null !== $result->getExpiresAt()) {
    // Gemini automatically expires files after 48 hours, for example
    printf("Expires: %s\n", $result->getExpiresAt()->format('c')); // Expires: 2026-08-15T19:56:57+00:00
}

// Use the file ID in a prompt
$message = Message::ofUser('Write a short description of this file.', new CachedFile($result->getId()));

$result = $platform->invoke('gpt-5-mini', $message);

Would love to hear your thoughts on the matter. Thank you!

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