Google Gemni
Google Gemini Master Cheat Sheet
Complete documentation for Gemini 1.5 Pro, Flash, multimodal prompts, SDK code patterns, ecosystem GitHub repos, setup guides, and production best practices.
| Category | Class / Type | Feature / Model | Model ID / Parameter | Acceptable Values / Output | Code Example | Description & Key Notes |
|---|---|---|---|---|---|---|
| 1. Models | Flagship | Gemini 1.5 Pro | gemini-1.5-pro-latest |
2M Token Context Window | model = genai.GenerativeModel('gemini-1.5-pro') |
State-of-the-art multimodal model built for complex reasoning, large codebase analysis, and audio/video understanding. |
| 1. Models | High Speed | Gemini 1.5 Flash | gemini-1.5-flash-latest |
1M Token Context Window | model = genai.GenerativeModel('gemini-1.5-flash') |
Lightweight, fast, and cost-efficient model optimized for high-frequency tasks, real-time chats, and summarization. |
| 1. Models | Embeddings | Text Embedding 004 | text-embedding-004 |
768 Vector Dimensions | genai.embed_content(model="models/text-embedding-004", content=text) |
Generates high-dimensional vector representations for semantic search, retrieval-augmented generation (RAG), and clustering. |
| 2. Config | Param | Temperature | temperature |
Float (0.0 - 2.0) | generation_config={"temperature": 0.2} |
Controls response randomness. Lower values (0.0 - 0.3) give deterministic factual results; higher values increase creativity. |
| 2. Config | Param | Top-P (Nucleus Sampling) | top_p |
Float (0.0 - 1.0) | generation_config={"top_p": 0.95} |
Tokens are selected from the most probable choices whose cumulative probability total equals Top-P. |
| 2. Config | Param | Top-K | top_k |
Integer (1 - 40+) | generation_config={"top_k": 40} |
Limits model token selection candidate pool size during each generation step. |
| 2. Config | Structured Output | JSON Response Schema | response_mime_type |
application/json | response_mime_type="application/json" |
Forces Gemini to strictly output structured JSON conforming to Pydantic or OpenAPI schemas. |
| 3. Features | Capability | System Instructions | system_instruction |
String / Prompt Directive | GenerativeModel(..., system_instruction="Act as Senior Engineer") |
Sets overall behavior, tone, persona, or strict operational boundaries prior to user message processing. |
| 3. Features | Agent Tool | Function Calling | tools=[function_list] |
Python functions / Declarations | model = GenerativeModel(model_name, tools=[get_current_weather]) |
Enables Gemini to output raw function execution arguments for client-side API execution. |
| 3. Features | Input Mode | Multimodal Native Vision/Audio | PIL.Image / File API |
PNG, JPG, MP4, MP3, WAV, PDF | model.generate_content([image, "Describe image"]) |
Directly processes images, audio files, multi-minute video clips, and PDF manuals in unified context prompts. |
Developer SDK Reference Syntax
1. Authentication Setup
Initialize Gemini SDK using genai.configure(api_key=os.environ["GEMINI_API_KEY"]).
2. Chat Session State
Maintain multi-turn conversations with history via chat = model.start_chat(history=[]).
3. Response Streaming
Stream output real-time using response = model.generate_content(prompt, stream=True).
4. Large File Processing
Upload large video or audio using video_file = genai.upload_file(path="video.mp4").
SDK Modules & Classes
Response Attributes
Developer Setup & Integration Guide
Generate Your Gemini API Key
Head to Google AI Studio and click "Get API key" -> "Create API key".
- Store your API Key securely in system environment variables.
Install Python SDK Package
Install the official Google Generative AI client library using pip:
Write Your First Python Script
Create a script named gemini_test.py and execute your first prompt:
Install npm Package
Add the Google Gen AI package to your JavaScript/TypeScript project:
Initialize Client Code
Create `index.js` and call Gemini models using modern async/await syntax:
Enable Vertex AI API
Enable the Vertex AI API in your Google Cloud Console project and configure service account IAM permissions.
Install GCP Cloud SDK
Install the enterprise Google Cloud Vertex AI client library:
Connect via Vertex AI SDK
Initialize Gemini with GCP Project credentials:
Top 50 Google Gemini Ecosystem Repositories
Curated directory of the top official Google Gemini SDKs, community toolkits, agent frameworks, CLI utilities, and multimodal boilerplates.
| # | Category | Repository Path | Popularity / Scope | Description & Primary Function |
|---|---|---|---|---|
| 1 | Official SDK | google-gemini/generative-ai-python |
Core SDK | Official Google Python SDK for calling Gemini 1.5 Pro, Flash, File API, and text embedding endpoints. |
| 2 | Official SDK | google-gemini/generative-ai-js |
Node / Web | Official client library for Node.js, Web, and React Native applications connecting to Gemini. |
| 3 | Cookbook | google-gemini/cookbook |
12k+ Stars | Official Google collection of Jupyter notebooks demonstrating Function Calling, Multimodal RAG, and Video Search. |
| 4 | Android SDK | google-gemini/generative-ai-android |
Kotlin SDK | Kotlin client library for running Gemini multimodal queries natively inside Android apps. |
| 5 | Swift SDK | google-gemini/generative-ai-swift |
iOS / macOS | Official Swift Package for building native iOS, iPadOS, and macOS apps powered by Gemini API. |
| 6 | Go SDK | google/generative-ai-go |
Golang | Official Go client library for high-performance serverless backend services using Gemini. |
| 7 | Java SDK | google/generative-ai-java |
Java | Official Java SDK for enterprise backend and Spring Boot integrations. |
| 8 | Agent Toolkit | google-gemini/generative-ai-agent-toolkit |
Agents | Framework for building multi-step reasoning agents and tool-executing autonomous workflows with Gemini. |
| 9 | CLI Tool | google-gemini/gemini-cli |
Terminal | Command-line interface utility allowing shell pipes, script automation, and file execution using Gemini. |
| 10 | LangChain Integration | langchain-ai/langchain-google |
Framework | Official LangChain integration package support for ChatGoogleGenerativeAI and GoogleGenerativeAIEmbeddings. |
| 11 | LlamaIndex | run-llama/llama_index_google |
RAG Storage | LlamaIndex data connectors and vector query engines tuned for Gemini 1.5 Pro's 2M context window. |
| 12 | Gemini Electron GUI | community/gemini-desktop-app |
Community | Cross-platform desktop application interface for chatting with Gemini and organizing prompt threads. |
| 13 | VS Code Extension | google/gemini-vscode-extension |
IDE Tool | In-editor AI coding assistant extension bringing inline code completion and refactoring via Gemini. |
| 14 | Chrome Extension | community/gemini-web-summarizer |
Browser | Chrome Extension summarizing active web pages, YouTube videos, and PDFs using Gemini 1.5 Flash. |
| 15 | Multimodal Video RAG | google-gemini/video-analysis-demo |
Video AI | Demo application showcasing automated timestamp tagging and Q&A across multi-hour MP4 videos. |
| 16 | Document Analyzer | google-gemini/pdf-structured-parser |
Parser | Extracts complex tables, charts, and nested visual metadata from raw PDFs into JSON formats. |
| 17 | Streamlit Starter | google-gemini/streamlit-gemini-boilerplate |
Starter | Turnkey Streamlit Python dashboard template for deploying interactive Gemini web demos. |
| 18 | Firebase Extension | firebase/firestore-gemini-chatbot |
Firebase | Official Firebase extension syncing Firestore document updates with automated Gemini completions. |
| 19 | Guardrails Suite | google-gemini/safety-filter-utility |
Security | Helper library for configuring custom safety thresholds and parsing block metadata response objects. |
| 20 | Audio Transcription | google-gemini/audio-understanding-lab |
Audio AI | Transcribes audio, detects speakers, and performs sentiment analysis using direct audio uploads. |
| 21-50 | Community Tools | google-gemini/ecosystem-repos-collection |
30+ Repos | Includes Docker deployment templates, Discord/Slack bot integrations, Next.js starters, AutoGen integration adapters, and Kubernetes worker configs. |
Pro Tips & Prompting Tricks
response_mime_type="application/json" along with exact Pydantic/OpenAPI schema models.
"List all timestamps where a red car enters the frame."
temperature=0.0 for coding, math, and data extraction. Use temperature=0.7+ for creative writing or brainstorming.
system_instruction rather than mixing them into standard user prompts.
generate_content(..., stream=True) to display text tokens immediately as they are generated.
Official Training & Documentation Resources
Safety Filters & Production Rules
Gemini includes built-in safety filters for Harassment, Hate Speech, Sexually Explicit, and Dangerous content categories:
- Threshold Configuration: Adjust thresholds (e.g.,
BLOCK_MEDIUM_AND_ABOVEorBLOCK_NONEfor developer sandboxes) per category. - Prompt Feedback Check: Always check
response.prompt_feedbackto handle blocked queries gracefully in production UI.
Protect your API credentials in production environments:
- Never Hardcode Keys: Never commit API keys directly into front-end JavaScript bundles or client-side web apps.
- Use Server-Side Proxies: Route requests through a backend server (Node.js, Python, or Cloud Functions) to hide API credentials.
- GCP IAM Restrictions: In production GCP deployments, restrict API keys by IP address and HTTP referrer.