client icon indicating copy to clipboard operation
client copied to clipboard

Add responseMimeType and responseSchema to GenerationConfig

Open evandromurilo opened this issue 11 months ago • 2 comments

This allows structured output usage.

$client = new Client($key);
$clent = $client->withV1BetaVersion()->generativeModel('gemini-2.0-flash');

$config = (new GenerationConfig())
              ->withResponseMimeType(MimeType::APPLICATION_JSON)
              ->withResponseSchema([
                'type' => 'string',
                'enum' => [
                    'hotdog',
                    'fries',
                    'coke'
                ]
              ]);
        

$client->withGenerationConfig($config)->generateContent('....');

evandromurilo avatar Feb 08 '25 18:02 evandromurilo