Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Classes/Provider/SymfonyAi/SymfonyAiPlatformAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,18 @@ private function buildOptions(string $model, int $maxTokens, float $temperature,
}

/**
* Resolve the max-tokens option key expected by a Symfony AI bridge based on the used bridge
* Resolve the max-tokens option key expected by a Symfony AI bridge.
*
* Each bridge keeps the option naming convention of its underlying API:
* - Gemini uses camelCase (Google REST API: "maxOutputTokens")
* - OpenAI / OpenResponses use snake_case "max_output_tokens"
* - Anthropic / Mistral / Ollama and most others use legacy "max_tokens"
*/
public static function resolveMaxTokensKey(string $factoryClass): string
{
if (str_contains($factoryClass, '\\Bridge\\Gemini\\')) {
return 'maxOutputTokens';
}
if (str_contains($factoryClass, '\\Bridge\\OpenAi\\')
|| str_contains($factoryClass, '\\Bridge\\OpenResponses\\')
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public static function maxTokensKeyProvider(): \Generator
'Symfony\\AI\\Platform\\Bridge\\OpenResponses\\PlatformFactory',
'max_output_tokens',
];
yield 'Gemini uses camelCase per Google REST API' => [
'Symfony\\AI\\Platform\\Bridge\\Gemini\\PlatformFactory',
'maxOutputTokens',
];
yield 'Anthropic Messages API' => [
'Symfony\\AI\\Platform\\Bridge\\Anthropic\\PlatformFactory',
'max_tokens',
Expand Down