Skip to content

Conversation

glengemann
Copy link

Q A
Bug fix? no
New feature? yes
Docs? no
Issues Fix #...
License MIT

Hi! I've been playing around with the new OpenAI Responses API for a project. Just wondering if the changes in this branch are moving in the right direction.

@chr-hertel chr-hertel added the Platform Issues & PRs about the AI Platform component label Jul 17, 2025
@chr-hertel chr-hertel marked this pull request as draft July 17, 2025 20:52
@chr-hertel chr-hertel changed the title [RFC]: OpenAI Responses API [Platform][RFC]: OpenAI Responses API Jul 17, 2025
@chr-hertel
Copy link
Member

Hey @glengemann, thanks for working on this and thanks for checking in early for feedback 👍

I notice some things here:

  • in general I'd like to avoid different endpoint or models having impact to the Agent component - it might not always be possible and you found an unflexible part of the code there. I would rather try to bring in some extension points or contract handling - like with the tool schema - instead of just duplicating the AgentProcessor and ResponseFormatFactory
  • also with the changes within the Platform component there is a lot of duplication going on, e.g. 'GPTandResponsesclasses are basically the same - we just need it here because we can't differentiate the other extension points, like theInputBagNormalizer` in a different way - that's unfortunate.

what I'm basically saying here, I get why you checked in early - somehow this duplication feels odd, but the current extension points, like those supports methods, don't provide more flexibility.

In those cases I'd like to start from the user land code: how would we want the user to select the different apis? do they care at this point?

let's image we would use this:

use Symfony\AI\Platform\Bridge\OpenAI;

$platform = OpenAI\PlatformFactory($apiKey);
$model = new OpenAI\GPT();

$response = $platform->request($model, $messages);

vs.

use Symfony\AI\Platform\Bridge\OpenAI;

$platform = OpenAI\PlatformFactory($apiKey);
$model = new OpenAI\Responses();

$response = $platform->request($model, $messages);

So, my questions:

  • What would be the difference from a user point of view? Which features do we gain by adopting the Responses API?
  • If there is a benefit, could we go with something like this?
    use Symfony\AI\Platform\Bridge\OpenAI;
    
    $platform = OpenAI\PlatformFactory($apiKey);
    $model = new OpenAI\GPT();
    
    $response = $platform->request($model, $messages, ['api' => 'responses']); // with default ['api => 'completions']

If we'd go with an option, we would need to find a way to extend the supports methods to check for that - and the OpenAI\ModelClient would need to interpret that to choose the right endpoint.

@OskarStark OskarStark changed the title [Platform][RFC]: OpenAI Responses API [Platform][RFC] OpenAI Responses API Jul 18, 2025
@chr-hertel chr-hertel added RFC RFC = Request For Comments (proposals about features that you want to be discussed) Status: Needs Work labels Jul 19, 2025
@chr-hertel
Copy link
Member

@glengemann do you have some thoughts or plans with this or should we close this for now?

@glengemann
Copy link
Author

Hi @chr-hertel! Let me work on this feature a little more.

@MartkCz
Copy link

MartkCz commented Aug 24, 2025

@chr-hertel I was trying to finish the PR because I now need to use the responses API (the websearch function for GPT-5 is only available through the responses API, not the completions API anymore).

But I hit a problem here:
https://github.com/symfony/ai/blob/main/src/agent/src/StructuredOutput/AgentProcessor.php#L68

The response_format key for structured output is only required by the completions API. The responses API, on the other hand, expects it under the text key.

It looks like Ollama also doesn’t support response_format, see:
ollama/ollama#3102
https://ollama.com/blog/structured-outputs

So the question is: how do we deal with this?

The only solution I can think of is to remove ResponseFormatFactory and let the model itself decide how the output should look—since it’s the only one that actually knows the proper structure. Then in the agent, call something like:

$responseClass = $options['output_structure'];
$structuredOutputName = u($responseClass)->afterLast('\\')->toString();
$schema = $this->schemaFactory->buildProperties($responseClass);
$input->model->addStructuredOutputToInput($input, $structuredOutputName, $schema, $responseClass);

It might not even be necessary to pass that many parameters.

@glengemann glengemann closed this Aug 25, 2025
@glengemann glengemann force-pushed the openai-responses-api branch from a3ce02a to 899ca12 Compare August 25, 2025 23:14
@carsonbot carsonbot changed the title [Platform][RFC] OpenAI Responses API [Platform] OpenAI Responses API Aug 25, 2025
@chr-hertel
Copy link
Member

@MartkCz i guess this should cover the issue, doesn't it?

if (!$input->model->supports(Capability::OUTPUT_STRUCTURED)) {
throw MissingModelSupportException::forStructuredOutput($input->model::class);
}

basically if you use a model that doesn't support that feature, you can't use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Issues & PRs about the AI Platform component RFC RFC = Request For Comments (proposals about features that you want to be discussed) Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants