How do I restrict the Gemini API to prevent extra spending

I was asked to restrict the API key as provided with five options none, website, IP address, android app, or iOS apps unfortunately they didn’t tell me what restriction I was supposed to put it on to prevent extra spending

Hello @Daniel_Klenda ,

Could you please share where you saw the prompt to restrict your API key (for example, the AI Studio API Keys page or the Google Cloud console)?

In the meantime, Application restrictions only limit where requests can come from (such as a backend server’s IP addresses) and do not cap spending. If the prompt came from the AI Studio API Keys page, you can restrict the key to the Gemini API there (Using Gemini API keys).

To limit spending:

In Google Cloud Console in API & Services under the sub category Credentials is the option to Edit API key

Name

Use a unique name to identify your API key

APIs that can be accessed using this key

Service account required: To use Agent Platform API or Gemini API, you must create an authorization key (auth key) by binding this API key to a service account. The option to bind will appear once you select either API.

Note: An organization policy governs creating API keys bound to a service account for projects with a Google Cloud organization. Learn more

Select API restrictions

1 API

Only Agent Platform (Vertex) API and Gemini API are supported by account bound keys at this time. Enable the service in API Library to use it.

Selected APIs:

  • Gemini API

Key restrictions

Add restrictions to reduce security risk and prevent unauthorized use. Learn more

Action recommended: this key can currently be used with any application. Restrict where it can be used to improve security. Learn more

Application restrictions

None
Websites
IP addresses
Android apps
iOS apps

Note: It may take up to 5 minutes for settings to take effect