All provider guides

Set up Gemini

PHP

Researched from Gemini's official documentation on 2026-11-02. Not yet walked through end to end.

Open your Gemini console (sign-in required)

  1. Current: Select a Cloud project

    Sign in to Google AI Studio and accept the applicable terms. Select or import the Google Cloud project you intend to use.

  2. Not started: Create and restrict an API key

    Open API keys and create an auth key for that project. Use the current key type and restrictions described by Google’s key guide.

  3. Not started: Check quota and billing

    Check the project’s API quotas, model availability and billing. Store the key only in your local application environment.

  4. Not started: Configure your .env

    Use the environment names below in your own application. Keep its environment file out of source control. Never paste a key into this website.

  5. Not started: Run the local check

    Choose a model you can use and run the matching example below on your own machine. Check any applicable usage charges first.

This provider is available in PHP Prism. The TypeScript and Python ports do not implement it.

Configure and verify locally

Environment names and defaults below come from the installed package. Choose a model you can use by setting PRISM_SETUP_MODEL on your machine. Run the verification only when you are ready for one billed request. No request is sent by this page.

Approximate text cost is input tokens × your model’s input rate, plus at most 32 output tokens × its output rate, divided by the rate’s token unit. Add any provider fees. Check your model and region’s current price; the token limit is not a money cap.

php environment names
# Set GEMINI_API_KEY privately if required for your configuration.
# url (default)
# GEMINI_URL=https://generativelanguage.googleapis.com/v1beta/models
php local verification
use Prism\Prism\Facades\Prism;

// Run in your own configured Laravel app (for example, php artisan tinker).
$model = getenv('PRISM_SETUP_MODEL');
if (!$model) {
    throw new RuntimeException('Set PRISM_SETUP_MODEL to your model.');
}
try {
    $result = Prism::text()
        ->using('gemini', $model)
        ->withPrompt('Say hello.')
        ->withMaxTokens(32)
        ->asText();
    echo $result->text, PHP_EOL;
} catch (Throwable $error) {
    echo get_class($error), PHP_EOL;
}

Official sources