google-genai-typescript

google-genai-typescript is a cursor rule for Cursor from yu-iskw/llmops-demo-ts. It costs 1,945 tokens per session, scanned A, original, Apache-2.0.

A usage guide for the Google Gen AI SDK, a TypeScript library for calling Google Gemini models. It covers setup, authentication, installation, text generation, streaming, function calls, and structured results.

In plain words
What is it for?
Use it when adding Gemini generation, streamed responses, function calling, or structured output to a TypeScript or JavaScript application.
Why use it?
It gives developers the required setup and usage patterns for connecting a TypeScript application to Google AI services instead of relying on incomplete or outdated examples.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding Gemini generation, streamed responses, function calling, or structured output to a TypeScript or JavaScript application.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/yu-iskw/llmops-demo-ts/google-genai-typescript
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.

Clone the repo
git clone --depth 1 https://github.com/yu-iskw/llmops-demo-ts

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for google-genai-typescript

README.md
[![agentmods](https://agentmods.dev/badge/rules/yu-iskw/llmops-demo-ts/google-genai-typescript/github.svg)](https://agentmods.dev/rules/yu-iskw/llmops-demo-ts/google-genai-typescript)
Your own site
<a href="https://agentmods.dev/rules/yu-iskw/llmops-demo-ts/google-genai-typescript"><img src="https://agentmods.dev/badge/rules/yu-iskw/llmops-demo-ts/google-genai-typescript/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for google-genai-typescript

Your own site · 80×15
<a href="https://agentmods.dev/rules/yu-iskw/llmops-demo-ts/google-genai-typescript"><img src="https://agentmods.dev/badge/rules/yu-iskw/llmops-demo-ts/google-genai-typescript.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,945 This file is loaded in full into every session.
When invoked 1,945 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.01945 $0.01945
Opus 5 $0.00972 $0.00972
Sonnet 5 $0.00389 $0.00389
Haiku 4.5 $0.00194 $0.00194

Measured 4d ago against content hash 455ad2cafdca, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

google-genai-typescript 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 4d ago.

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.

.cursor/rules/google-genai-typescript.mdc · 212 lines

How it starts

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

Utilizing @google/genai in TypeScript

This guide provides comprehensive instructions and best practices for integrating the Google Gen AI SDK (@google/genai) into your TypeScript applications. This SDK allows you to build powerful applications leveraging Gemini models, supporting both the Gemini Developer API and Vertex AI.

1. Introduction to @google/genai

The @google/genai SDK is Google DeepMind’s primary SDK for its generative AI offerings, designed for TypeScript and JavaScript developers to build applications powered by Gemini. It is where new AI features are added.

2. Prerequisites

  • Node.js: Version 20 or later.

For Vertex AI Users (excluding Vertex AI Studio)

  1. Google Cloud Project: Select or create one.
  2. Billing: Enable billing for your project.
  3. Vertex AI API: Enable the Vertex AI API.
  4. Authentication:
    • Install the gcloud CLI.
    • Initialize the gcloud CLI.
    • Create local authentication credentials: gcloud auth application-default login

3. Installation

To install the SDK, use pnpm:

pnpm add @google/genai

4. Initialization

The SDK supports initialization for both Google AI Studio (API Key) and Vertex AI implementations.

4.1. Gemini Developer API (Using an API Key)

For server-side applications, obtain an API key from Google AI Studio and initialize the client:

import { GoogleGenAI } from '@google/genai';

const GEMINI_API_KEY = process.env.GEMINI_API_KEY; // It is recommended to use environment variables for API keys.

const ai = new GoogleGenAI({ apiKey: GEMINI_API_KEY });

Caution: Avoid exposing API keys in client-side code. Use server-side implementations in production.

4.2. Vertex AI

Initialize the client for Vertex AI by specifying your Google Cloud project and location:

import { GoogleGenAI } from '@google/genai';

const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT_ID || "your-gcp-project-id";
const LOCATION = process.env.GOOGLE_CLOUD_LOCATION || "us-central1"; // e.g., "us-central1"

const ai = new GoogleGenAI({
    vertexai: true,
    project: PROJECT_ID,
    location: LOCATION,
});

Read the full file on GitHub · 212 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. 4d ago First seen · 212 lines · 1,945 tokens per session scan A 455ad2cafdca

Subscribe to this mod's changes

google-genai-typescript is a cursor rule published in the GitHub repository yu-iskw/llmops-demo-ts (6 stars, last pushed 7d ago), licensed Apache-2.0. It adds 1,945 tokens to every session, about $0.0097 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-09-04.