Documentation 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.
Google is the primary entry point for the aisdk/google package — a static facade in the AiSdk namespace that manages a singleton GoogleProvider instance and vends model objects. Rather than constructing provider and option classes manually, you interact with the Google class exclusively through its static methods for the vast majority of use cases. The class uses the RegistersModels trait from AiSdk\Support\Concerns, which provides the underlying model registry infrastructure.
Namespace / Import
Methods
Google::create()
GoogleProvider from the given configuration array and stores it as the package-wide default singleton. Any subsequent call to Google::default(), Google::model(), or Google::image() will use this provider until Google::reset() is called or Google::create() is called again.
If called with an empty array (or no argument), all config values fall back to environment variables or their built-in defaults — see GoogleOptions::fromArray() for the full resolution order.
Associative configuration array. All keys are optional.
GoogleProvider — the newly created provider, which is also stored as the default singleton.
Google::default()
GoogleProvider. If no provider has been created yet (i.e. Google::create() has not been called), this method calls Google::create() with an empty config array, relying entirely on environment variables for the API key and all other settings.
Returns GoogleProvider
Google::model()
Google::default()->textModel($modelId). Returns a GoogleTextModel configured for the specified Gemini model ID. The returned object implements TextModelInterface from the core SDK contracts.
The Gemini text model identifier, for example
'gemini-2.5-flash' or 'gemini-2.5-pro'.TextModelInterface (concretely GoogleTextModel)
Google::image()
Google::default()->imageModel($modelId). Returns a GoogleImageModel configured for the specified Gemini image model ID. The returned object implements ImageModelInterface from the core SDK contracts.
The Gemini image model identifier, for example
'gemini-2.0-flash-preview-image-generation'.ImageModelInterface (concretely GoogleImageModel)
Google::reset()
null. Any subsequent call to Google::default(), Google::model(), or Google::image() will create a fresh provider. Call this in your test teardown methods (tearDown() / afterEach()) to prevent provider state — including API keys, custom headers, and HTTP client overrides — from leaking between test cases.
Full Usage Example
The example below shows the complete flow: configure the provider once withGoogle::create(), obtain a text model with Google::model(), then generate a response.
GEMINI_API_KEY set in your environment and need no extra configuration, you can skip Google::create() entirely: