The PHP AI SDK’s portable interface covers the parameters that are common across all providers — temperature, max tokens, top-p, structured output, and so on. Google’s Gemini API exposes many additional knobs that have no equivalent in the portable layer. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/google/llms.txt
Use this file to discover all available pages before exploring further.
providerOptions() method gives you a direct escape hatch: you can pass any Gemini-native parameter alongside your portable request and it will be forwarded to the API without the SDK interpreting it.
The raw Key
Calling ->providerOptions('google', ['raw' => [...]]) on any Generate request injects a shallow merge on top of the assembled request body immediately before the HTTP call is made. Inside GoogleRequestBuilder::build(), the merge is performed with PHP’s native array_replace():
array_replace() performs a shallow replacement: top-level keys in $raw overwrite the corresponding top-level keys in the request body. This means passing 'generation_config' => [...] inside raw replaces the entire generation_config object that the SDK built from your portable options. If you only want to tweak one field inside generation_config, include all the other fields you need as well, or use the sub-key examples shown below.
Basic Example
The following snippet overrides the temperature to0.2 and disables request storage, both using raw passthrough:
Common Use Cases
Override Temperature and Top-P
Usegeneration_config to tune sampling parameters beyond what the portable API exposes:
Set Safety Settings
Adjust Gemini’s content-filtering thresholds per harm category:Disable Request Storage
Passstore: false to opt out of Google’s request-storage feature:
Set candidate_count
The portable SDK always requests a single candidate. If you need multiple response candidates from a single call — a feature not exposed in the portable interface — you can request them via raw passthrough:
The SDK’s response parser is designed around a single candidate. When you request multiple candidates via
candidate_count, you will need to handle the additional candidates in the raw HTTP response yourself; the parsed $result->text will reflect only the first candidate.Image Generation Raw Passthrough
For image requests, the equivalent passthrough lives inGoogleImageRequestBuilder::build(). The key difference is that image requests use array_replace_recursive() instead of the shallow array_replace() used for text:
generation_config — such as image_config — without losing sibling keys the SDK set. For example, to force a specific image configuration key alongside the SDK-managed response_modalities:
response_modalities key that the SDK placed inside generation_config is preserved; only the image_config sub-key is replaced.
Conflict Resolution
Theraw array always wins when its keys collide with keys the SDK has already set — whether the merge is shallow (text) or recursive (image).
When a key in the
raw array matches a key that the SDK already set in the request body, the raw value always wins. This applies equally to top-level keys (for text requests) and nested keys (for image requests). If you pass 'generation_config' via raw in a text request, the entire SDK-built generation_config — including max_output_tokens and temperature from portable options — is discarded and replaced by your raw value.Tuning with generation_config
Gemini groups all sampling and output-control parameters under a single generation_config object in the request body. When using raw passthrough to tune any of these values, nest them inside that key rather than placing them at the top level of raw.