client

A central configuration and access object in Google's Generative AI SDK. It sets up access to Gemini or Vertex AI and provides the starting point for using the SDK.

In plain words
What is it for?
Configuring API access and connecting application code to Google's Gemini Developer API or Vertex AI services.
Why use it?
It keeps authentication, service selection, project details, location, and other connection settings in one place instead of repeating them for every request.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/altaidevorg/rules-for-ai/client
Clone the repo
git clone --depth 1 https://github.com/altaidevorg/rules-for-ai
Per session 3,141 This file is loaded in full into every session.
When invoked 3,141 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03141 $0.03141
Opus 5 $0.01571 $0.01571
Sonnet 5 $0.00628 $0.00628
Haiku 4.5 $0.00314 $0.00314

Measured yesterday against content hash e939cac3b40a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

client scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/google-genai/client.mdc · 277 lines

How it starts

The opening of the file, as written. The whole thing — 277 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Chapter 1: Client

Welcome to the google-genai SDK tutorial! This first chapter introduces the most fundamental concept: the Client class. Understanding the Client is essential because it's the primary gateway through which you'll interact with all the functionalities of the Google Generative AI APIs, whether you're targeting the Gemini Developer API or the Vertex AI platform.

Motivation and Use Case

Interacting with backend APIs like Google's Generative AI services requires handling various configurations: authentication (API keys or cloud credentials), target service endpoint (Gemini vs. Vertex AI), specific project and location details for Vertex AI, network options (like timeouts or API versions), and potentially debug settings. Managing these configurations manually for every API call would be cumbersome and error-prone.

The Client class solves this by acting as a central configuration hub and entry point. It abstracts away the complexities of setting up the connection and provides a simplified interface to different API functionalities.

Central Use Case: Imagine you want to start using the SDK to generate text using a Gemini model via the Gemini Developer API. Your first step will always be to instantiate the Client with your API key.

# Ensure you have installed the SDK: pip install google-genai
from google import genai
from google.genai import types

# Configure the client for the Gemini Developer API
# Replace 'YOUR_API_KEY' with your actual key
client = genai.Client(api_key='YOUR_API_KEY')

# Now you can use the client to access API modules, e.g., models
response = client.models.generate_content(
    model='gemini-1.5-flash', # Use an appropriate model name
    contents='Why is the sky blue?'
)

print(response.text)

This simple example demonstrates the core workflow: configure the Client once, then use its properties to access specific functionalities like models.generate_content.

Configuration and Initialization

Read the full file on GitHub · 277 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 277 lines · 3,141 tokens per session scan A e939cac3b40a

Subscribe to this mod's changes

client is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It adds 3,141 tokens to every session, about $0.0157 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.