genai-sdk

Guides Gemini API usage on Vertex AI with the Gen AI SDK across five languages.

783|307|Updated May 27, 2021
One-click install
npx skills add https://github.com/GoogleCloudPlatform/vertex-ai-samples --skill genai-sdk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: genai-sdk
Source: https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/skills/genai-sdk
Command: npx skills add https://github.com/GoogleCloudPlatform/vertex-ai-samples --skill genai-sdk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires google-genai, @google/genai, google.golang.org/genai, Google.GenAI, and includes references (resource) components.

What problem does it solve?

Developers integrating Gemini models on Google Cloud Vertex AI often struggle with fragmented documentation, deprecated legacy SDKs, and inconsistent code patterns across languages. This Skill provides authoritative, up-to-date guidance for using the unified Gen AI SDK, preventing the use of deprecated libraries like google-cloud-aiplatform or google-generativeai.

Core Features & Use Cases

  • Multi-language SDK guidance: Provides installation and initialization patterns for Python, JavaScript/TypeScript, Go, Java, and C#/.NET using the unified Gen AI SDK.
  • Full capability coverage: Includes reference implementations for text generation, multimodal inputs, function calling, structured output, embeddings, image/video generation, Live API streaming, context caching, batch prediction, and model tuning.
  • Authentication setup: Covers Application Default Credentials and Express Mode API key configuration with environment variables.
  • Use Case: A developer needs to build a Python app that generates structured JSON from Gemini with Google Search grounding on Vertex AI. This Skill supplies the correct SDK, model name, authentication setup, and working code pattern.

Quick Start

Ask the assistant to generate Python code using the Gen AI SDK to call Gemini on Vertex AI with your project ID and location.

Frequently Asked Questions about genai-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the Gemini API on Vertex AI in Python?

Install the google-genai package with pip, set GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, and GOOGLE_GENAI_USE_VERTEXAI=true environment variables, then create a client with genai.Client() and call client.models.generate_content with a model like gemini-3-flash-preview.

What is the difference between google-genai and google-cloud-aiplatform?

google-genai is the current unified Gen AI SDK for the Gemini API on Vertex AI, while google-cloud-aiplatform, @google-cloud/vertexai, and google-generativeai are deprecated legacy SDKs. New development should use google-genai and migrate away from legacy libraries.

Does the Gen AI SDK support languages other than Python?

Yes, the Gen AI SDK supports JavaScript/TypeScript via @google/genai, Go via google.golang.org/genai, Java via com.google.genai:google-genai, and C#/.NET via Google.GenAI. Each provides equivalent generate content capabilities.

How do I authenticate the Gen AI SDK with Vertex AI?

Use Application Default Credentials by setting GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, and GOOGLE_GENAI_USE_VERTEXAI=true environment variables. Alternatively, Express Mode uses an API key via GOOGLE_API_KEY with GOOGLE_GENAI_USE_VERTEXAI=true.

Can I generate images and video with the Gemini API on Vertex AI?

Yes, image generation uses models like gemini-3-pro-image-preview or gemini-2.5-flash-image, and video generation uses Veo models such as veo-3.1-fast-generate-001 through client.models.generate_videos as an async operation.

Which Gemini models should I use on Vertex AI?

Use gemini-3.1-pro-preview for complex reasoning, gemini-3-flash-preview for fast balanced performance, gemini-3-pro-image-preview for image generation, and gemini-live-2.5-flash-native-audio for the Live API. Older gemini-2.0 and gemini-1.5 models are deprecated.