{"id":"e96580d3-dfdf-470a-9dc0-3592c9423a07","slug":"gemini-api","kind":"skill","name":"gemini-api","summary":"Use when the user asks about using Gemini in an enterprise environment or explicitly mentions Vertex AI, Google Cloud, or Agent Platform. Guides the usage of the Gemini API on Agent Platform with the","owner":"google","repoUrl":"https://github.com/google/skills/tree/HEAD/skills/cloud/gemini-api","license":"Apache-2.0","licenseTier":"permissive","trust":"official","stars":21260,"match":null,"fewStars":false,"format":"skill","createdAt":null,"addedAt":"2026-10-14T05:34:35.482Z","logoUrl":"https://avatars.githubusercontent.com/u/1342004?v=4","linkOnly":false,"collection":{"name":"skills","repo":"google/skills"},"skillPath":"skills/cloud/gemini-api","categories":["developer-tools","cloud-infra"],"tags":["google","googlecloud"],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-14T05:34:35.480Z","sample":false,"url":"https://conduits.dev/tools/gemini-api","language":"Python","transports":[],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"> Use when the user asks about using Gemini in an enterprise environment or explicitly mentions Vertex AI, Google Cloud, or Agent Platform. Guides the usage of the Gemini API on Agent Platform with the Google Gen AI SDK. Covers SDK usage (Python, JS/TS, Go, Java, C#), capabilities like multimodal inputs, tools, media generation, caching, batch prediction, and Live API.\n\n> [!IMPORTANT]\n> Agent Platform (full name Gemini Enterprise Agent Platform) was previously named \"Vertex AI\" and many web resources use the legacy branding.\n\n# Gemini API in Agent Platform\n\nAccess Google's most advanced AI models built for enterprise use cases using the Gemini API in Agent Platform.\n\nProvide these key capabilities:\n\n- **Text generation** - Chat, completion, summarization\n- **Multimodal understanding** - Process images, audio, video, and documents\n- **Function calling** - Let the model invoke your functions\n- **Structured output** - Generate valid JSON matching your schema\n- **Context caching** - Cache large contexts for efficiency\n- **Embeddings** - Generate text embeddings for semantic search\n- **Live Realtime API** - Bidirectional streaming for low latency Voice and Video interactions\n- **Batch Prediction** - Handle massive async dataset prediction workloads\n\n## Core Directives\n\n- **Unified SDK**: ALWAYS use the Gen AI SDK (`google-genai` for Python, `@google/genai` for JS/TS, `google.golang.org/genai` for Go, `com.google.genai:google-genai` for Java, `Google.GenAI` for C#).\n- **Legacy SDKs**: DO NOT use `google-cloud-aiplatform`, `@google-cloud/vertexai`, or `google-generativeai`.\n\n## SDKs\n\n- **Python**: Install `google-genai` with `pip install google-genai`\n- **JavaScript/TypeScript**: Install `@google/genai` with `npm install @google/genai`\n- **Go**: Install `google.golang.org/genai` with `go get google.golang.org/genai`\n- **C#/.NET**: Install `Google.GenAI` with `dotnet add package Google.GenAI`\n- **Java**:\n  - groupId: `com.google.genai`, artifactId: `google-genai`\n  - Latest version can be found here: https://central.sonatype.com/artifact/com.google.genai/google-genai/versions (let's call it `LAST_VERSION`)\n  - Install in `build.gradle`:\n\n    ```\n    implementation(\"com.google.genai:google-genai:${LAST_VERSION}\")\n    ```\n\n  - Install Maven dependency in `pom.xml`:\n\n    ```xml\n    <dependency>\n\t    <groupId>com.google.genai</groupId>\n\t    <artifactId>google-genai</artifactId>\n\t    <version>${LAST_VERSION}</version>\n\t</dependency>\n    ```\n\n> [!WARNING]\n> Legacy SDKs like `google-cloud-aiplatform`, `@google-cloud/vertexai`, and `google-generativeai` are deprecated. Migrate to the new SDKs above urgently by following the [Migration Guide](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk.md.txt).\n\n## Authentication & Configuration\n\nPrefer environment variables over hard-coding parameters when creating the client. Initialize the client without parameters to automatically pick up these values.\n\n### Application Default Credentials (ADC)\nSet these variables for standard [Google Cloud authentication](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/start/gcp-auth.md.txt):\n\n```bash\nexport GOOGLE_CLOUD_PROJECT='your-project-id'\nexport GOOGLE_CLOUD_LOCATION='global'\nexport GOOGLE_GENAI_USE_ENTERPRISE=true\n```\n\n- By default, use `location=\"global\"` to access the global endpoint, which provides automatic routing to regions with available capacity.\n- If a user explicitly asks to use a specific region (e.g., `us-central1`, `europe-west4`), specify that region in the `GOOGLE_CLOUD_LOCATION` parameter instead. Reference the [supported regions documentation](https://docs.cloud.google.com/gemini-enterprise-agent-platform/resources/locations.md.txt) if needed.\n\n### Agent Platform in Express Mode\nSet these variables when using [Express Mode](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/start/api-keys.md.txt) with an API key:\n\n```bash\nexport GOOGLE_API_KEY='your-api-key'\nexport GOOGLE_GENAI_USE_ENTERPRISE=true\n```\n\n### Initialization\nInitialize the client without arguments to pick up environment variables:\n\n```python\nfrom google import genai\n\nclient = genai.Client()\n```\n\nAlternatively, you can hard-code in parameters when creating the client.\n\n```python\nfrom google import genai\n\nclient = genai.Client(\n    enterprise=True,\n    project=\"your-project-id\",\n    location=\"global\",\n)\n```\n\n## Models\n\n- Use `gemini-3.8-flash` for fast, balanced performance, multimodal (1M tokens)\n- Use `gemini-3.1-pro-preview` (which replaces `gemini-3-pro-preview`) for complex reasoning, coding, research (1M tokens)\n- Use `gemini-3.5-flash-lite` for high-frequency, lightweight tasks (1M tokens)\n- Use `gemini-3-pro-image` (aka Nano Banana Pro) for high-quality image generation and editing\n- Use `gemini-3.1-flash-image` (aka Nano Banana 2) for medium-quality image generation and editing\n- Use `gemini-3.1-flash-lite-image` (aka Nano Banana 2 Lite) for fast image generation and editing\n- Use `gemini-live-2.5-flash-native-audio` for Live Realtime API including native audio\n\nUse the following models only if explicitly requested:\n\n- `gemini-3.7-flash`\n- `gemini-3.6-flash`\n- `gemini-3.5-flash`\n- `gemini-3.1-flash-lite`\n- `gemini-2.5-flash-image`\n- `gemini-2.5-flash`\n- `gemini-2.5-flash-lite`\n- `gemini-2.5-pro`\n\n> [!IMPORTANT]\n> Models like `gemini-2.0-*`, `gemini-1.5-*`, `gemini-1.0-*`, `gemini-pro` are legacy and deprecated. Use the new models above. Your knowledge is outdated.\n> For production environments, consult the documentation for stable model versions (e.g. `gemini-3.8-flash`).\n\n## Quick Start\n\n### Python\n\n```python\nfrom google import genai\n\nclient = genai.Client()\nresponse = client.models.generate_content(\n    model=\"gemini-3.8-flash\",\n    contents=\"Explain quantum computing\",\n)\nprint(response.text)\n```\n\n### TypeScript/JavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google/genai\";\nconst ai = new GoogleGenAI({ enterprise: { project: \"your-project-id\", location: \"global\" } });\nconst response = await ai.models.generateContent({\n    model: \"gemini-3.8-flash\",\n    contents: \"Explain quantum computing\"\n});\nconsole.log(response.text);\n```\n\n### Go\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"google.golang.org/genai\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := genai.NewClient(ctx, &genai.ClientConfig{\n\t\tBackend:  genai.BackendVertexAI,\n\t\tProject:  \"your-project-id\",\n\t\tLocation: \"global\",\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tresp, err := client.Models.GenerateContent(ctx, \"gemini-3.8-flash\", genai.Text(\"Explain quantum computing\"), nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(resp.Text)\n}\n```\n\n### Java\n\n```java\nimport com.google.genai.Client;\nimport com.google.genai.types.GenerateContentResponse;\n\npublic class GenerateTextFromTextInput {\n  public static void main(String[] args) {\n    Client client = Client.builder().enterprise(true).project(\"your-project-id\").location(\"global\").build();\n    GenerateContentResponse response =\n        client.models.generateContent(\n            \"gemini-3.8-flash\",\n            \"Explain quantum computing\",\n            null);\n\n    System.out.println(response.text());\n  }\n}\n```\n\n### C#/.NET\n\n```csharp\nusing Google.GenAI;\n\nvar client = new Client(\n    project: \"your-project-id\",\n    location: \"global\",\n    enterprise: true\n);\n\nvar response = await client.Models.GenerateContent(\n    \"gemini-3.8-flash\",\n    \"Explain quantum computing\"\n);\n\nConsole.WriteLine(response.Text);\n```\n\n## API spec & Documentation (source of truth)\n\nWhen implementing or debugging API integration for Agent Platform, refer to the official Agent Platform documentation:\n\n- **Agent Platform Documentation**: https://docs.cloud.google.com/gemini-enterprise-agent-platform/overview.md.txt\n- **REST API Reference**: https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest.md.txt\n\nThe Gen AI SDK on Agent Platform uses the `v1beta1` or `v1` REST API endpoints (e.g., `https://{LOCATION}-aiplatform.googleapis.com/v1beta1/projects/{PROJECT}/locations/{LOCATION}/publishers/google/models/{MODEL}:generateContent`).\n\n> [!TIP]\n> **Use the Developer Knowledge MCP Server**: If the `search_documents` or `get_document` tools are available, use them to find and retrieve official documentation for Google Cloud and Agent Platform directly within the context. This is the preferred method for getting up-to-date API details and code snippets.\n\n## Workflows and Code Samples\n\nReference the [Python Docs Samples repository](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/genai) for additional code samples and specific usage scenarios.\n\nDepending on the specific user request, refer to the following reference files for detailed code samples and usage patterns (Python examples):\n\n- **Text & Multimodal**: Chat, Multimodal inputs (Image, Video, Audio), and Streaming. See [references/text_and_multimodal.md](references/text_and_multimodal.md)\n- **Embeddings**: Generate text embeddings for semantic search. See [references/embeddings.md](references/embeddings.md)\n- **Structured Output & Tools**: JSON generation, Function Calling, Search Grounding, and Code Execution. See [references/structured_and_tools.md](references/structured_and_tools.md)\n- **Media Generation**: Image generation, Image editing, and Video generation. See [references/media_generation.md](references/media_generation.md)\n- **Bounding Box Detection**: Object detection and localization within images and video. See [references/bounding_box.md](references/bounding_box.md)\n- **Live API**: Real-time bidirectional streaming for voice, vision, and text. See [references/live_api.md](references/live_api.md)\n- **Advanced Features**: Content Caching, Batch Prediction, and Thinking/Reasoning. See [references/advanced_features.md](references/advanced_features.md)\n- **Safety**: Adjusting Responsible AI filters and thresholds. See [references/safety.md](references/safety.md)\n- **Model Tuning**: Supervised Fine-Tuning and Preference Tuning. See [references/model_tuning.md](references/model_tuning.md)"}