aktonay/skillz / skills/cloud/gemini-api
gemini-api
VerifiedGuides the usage of the Gemini API on Agent Platform with the Google Gen AI SDK. Use when the user asks about using Gemini in an enterprise environment or explicitly mentions Vertex AI, Google Cloud, or Agent Platform. Covers SDK usage (Python, JS/TS, Go, Java, C#), capabilities like Live API, tools, multimedia generation, caching, and batch prediction.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.6 KB |
| references/advanced_features.md | markdown | 4.4 KB |
| references/bounding_box.md | markdown | 1.8 KB |
| references/embeddings.md | markdown | 3.0 KB |
| references/live_api.md | markdown | 1.0 KB |
| references/media_generation.md | markdown | 2.9 KB |
| references/model_tuning.md | markdown | 934 B |
| references/safety.md | markdown | 1.8 KB |
| references/structured_and_tools.md | markdown | 3.7 KB |
| references/text_and_multimodal.md | markdown | 2.3 KB |
references/embeddings.md
View on GitHub# Text and Multimodal Embeddings
Generate embeddings for text or multimodal content (images and videos) to perform semantic search, clustering, and other NLP tasks. Text and multimodal embedding vectors share the same semantic space, which allows you to use them interchangeably for cross-modal applications like searching for an image using a text query, or searching for a video using an image.
## Basic Usage (Text)
```python
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.embed_content(
model="gemini-embedding-2",
contents=[
"How do I get a driver's license/learner's permit?",
"How long is my driver's license valid for?",
],
# Optional Parameters
config=types.EmbedContentConfig(task_type="RETRIEVAL_DOCUMENT", output_dimensionality=768),
)
print(response.embeddings)
```
## Multimodal Embeddings (Image and Video)
To generate embeddings for images and videos, use the `types.Part.from_uri` method to point the model to a Google Cloud Storage (GCS) URI containing the media file, and provide the appropriate MIME type.
### Image Embeddings
For images, provide the GCS URI of the image and set the MIME type (e.g., `image/jpeg`).
```python
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.embed_content(
model="gemini-embedding-2",
contents=types.Part.from_uri(
file_uri="gs://github-repo/embeddings/getting_started_embeddings/gms_images/GGOEACBA104999.jpg",
mime_type="image/jpeg"
),
config=types.EmbedContentConfig(output_dimensionality=768),
)
image_embedding = response.embeddings[0].values
print(f"Length of image embedding: {len(image_embedding)}")
```
### Video Embeddings
Generating embeddings for a video works similarly. However, instead of a single vector, the API returns a list of embedding vectors—one representing each frame segment or interval of the processed video.
```python
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.embed_content(
model="gemini-embedding-2",
contents=types.Part.from_uri(
file_uri="gs://github-repo/embeddings/getting_started_embeddings/UCF-101-subset/BrushingTeeth/v_BrushingTeeth_g01_c02.mp4",
mime_type="video/mp4"
),
config=types.EmbedContentConfig(output_dimensionality=768),
)
# Extract embedding values for each video segment
video_embeddings =[emb.values for emb in response.embeddings]
print(f"Number of video segment embeddings returned: {len(video_embeddings)}")
print(f"First segment embedding length: {len(video_embeddings[0])}")
```
### Cross-Modal Search
Because these vectors share a semantic space, you can calculate the dot product or cosine similarity between different types of embeddings. For example, you can calculate the similarity between a text query embedding ("A music concert") and a pre-computed database of image or video embeddings to build a robust multimodal semantic search engine.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |