pks google

stable

Register and inspect the Google AI Studio API key that `pks image` and `pks promptwall` use for Gemini-based image generation.

Author: Poul Kjeldager
Usage: pks google <command> [options]
Category: infrastructure

Examples

$ pks google init

Register a key, or view the existing masked key

$ pks google init --force

Overwrite an already-registered key

$ pks google status

Check what key is stored and when

pks google manages the single Google AI Studio API key pks uses for Gemini-based image generation. The group itself takes no direct action — init registers and validates the key, status shows what's stored.

Overview

The key is a Google AI Studio ("Generative Language API") key, not an OAuth token or service account. pks google init prompts for it once with masked input, validates it with a live call to the Generative Language API, and stores it in ~/.pks-cli/settings.json. Two downstream commands consume it:

  • pks image — resolves the google provider automatically when --model names a Gemini image model, or when forced with --provider google.
  • pks promptwall — checks for a registered key before running and points back to pks google init if none is found.

Prerequisites

  • A Google AI Studio API key. Get one at https://aistudio.google.com/apikey — the init command prints this URL itself.
  • The "Generative Language API" enabled on the Google Cloud project behind the key. A key that looks correct but belongs to a project without this API enabled fails validation with a generic error and no further detail.

Synopsis

pks google <command> [options]
init      Register (or view) the Google AI Studio API key
status    Show whether a key is registered, masked

Global environment variables

pks google reads no environment variables of its own.

init

Registers a Google AI Studio API key for Gemini-based image generation. Prompts for the key with masked input, validates it with a live GET against the Generative Language API's models endpoint, and on success stores the key plus a UTC registration timestamp in ~/.pks-cli/settings.json. If a key is already registered, it short-circuits and prints the existing masked key and registration date instead of re-prompting, unless --force is passed. On validation failure it exits 1 without storing anything.

FlagDefaultDescription
--forcefalseRe-register even if a key is already stored.

Endpoint: GET https://generativelanguage.googleapis.com/v1beta/models?key=... — used only to validate the key; nothing is generated by this call.

pks google init

Prompts for the key, validates it, and stores it. If a key is already present, this prints the existing masked key instead of prompting again — pass --force to replace it.

pks google init --force

Prompts for a new key and overwrites whatever was previously stored, even if a key already exists.

status

Shows whether a Google AI API key is currently registered and, if so, its masked form and registration timestamp in a table. Read-only — it makes no network calls, only reads local config. Exits 1 with a pointer to pks google init if nothing is registered.

No flags.

pks google status

Prints the masked key (first 4 characters plus up to 8 asterisks) and the registration date, or reports that no key is registered.

Troubleshooting

Note. pks google status exits 1 when no key is registered — in scripts, treat that as an expected "not configured" state rather than a failure.

  • pks image or pks promptwall says no key is registered. Run pks google init. Both commands fail fast with an actionable message rather than silently falling back to another provider.
  • pks google init says validation failed, with no further detail. The HTTP call to the Generative Language API is wrapped in a catch-all that returns false on any exception, including network errors, a revoked or restricted key, and the "Generative Language API" not being enabled on the Google Cloud project. Re-check the key at https://aistudio.google.com/apikey and confirm the API is enabled on that project.
  • Re-running pks google init doesn't seem to do anything. Without --force, init is a no-op once a key exists — it only redisplays the existing masked key. Use --force to actually replace it.
  • No command removes the stored key. There is no delete, logout, or rotate subcommand under pks google. The only way to change the key is pks google init --force; to remove it entirely, edit ~/.pks-cli/settings.json by hand.
  • The stored key is plaintext. pks google init writes the raw key to ~/.pks-cli/settings.json in the open, not encrypted, even though the underlying config store supports an encrypt flag — this command doesn't use it. Treat that file as sensitive.
  • Only Gemini image models work with this key. Imagen models (imagen-3.x) require Vertex AI credentials and are not reachable through a Google AI Studio key.

See also

  • pks — the CLI's landing page, with the full command family overview