Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计异常

gemini-apiGemini API 文档

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

1,008

周安装

42

GitHub Stars

6

下载量

336
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gemini-api(Gemini API 文档)
来源仓库:https://github.com/diskd-ai/gemini-api
仓库路径:skills/gemini-api
安装命令:
npx skills add https://github.com/diskd-ai/gemini-api --skill gemini-api
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/diskd-ai/gemini-api --skill gemini-api

简介

gemini-api 封装 Google Gemini 多模态接口调用,支持文本、图像与音视频混合输入处理。

  • 适用于内容生成、智能分析与跨媒体理解等 AI 增强应用场景。
  • 提供模型选型建议与上下文长度管理策略,平衡成本与效果。
  • 必须配置有效 API Key 且遵守配额限制,敏感数据不建议直接传入云端模型。
  • gemini-api 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Gemini API

Generate text from text, images, video, and audio using Google's Gemini API.

Models

ModelCodeI/OContextThinking
Gemini 3 Progemini-3-pro-previewText/Image/Video/Audio/PDF -> Text1M/64KYes
Gemini 3 Flashgemini-3-flash-previewText/Image/Video/Audio/PDF -> Text1M/64KYes
Gemini 2.5 Progemini-2.5-proText/Image/Video/Audio/PDF -> Text1M/65KYes
Gemini 2.5 Flashgemini-2.5-flashText/Image/Video/Audio -> Text1M/65KYes
Nano Bananagemini-2.5-flash-imageText/Image -> Image-No
Nano Banana Progemini-3-pro-image-previewText/Image -> Image (up to 4K)65K/32KYes
Veo 3.1veo-3.1-generate-previewText/Image/Video -> Video+Audio--
Veo 3veo-3-generate-previewText/Image -> Video+Audio--
Veo 2veo-2.0-generate-001Text/Image -> Video (silent)--
Lyria RealTimelyria-realtime-expText -> Music (streaming)--
Embeddingsgemini-embedding-001Text -> Embeddings2KNo

Free Tier: Flash models only (no free tier for gemini-3-pro-preview in API). Default Temperature: 1.0 (do not change for Gemini 3).

Pricing (per 1M tokens):

  • Gemini 3 Pro: $2/$12 (<200k), $4/$18 (>200k)
  • Gemini 3 Flash: $0.50/$3
  • Nano Banana Pro: $2 (text) / $0.134 (image)

Basic Text Generation

Python

from google import genai

client = genai.Client()
response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents="How does AI work?"
)
print(response.text)

JavaScript

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

const ai = new GoogleGenAI({});
const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: "How does AI work?",
});
console.log(response.text);

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"contents": [{"parts": [{"text": "How does AI work?"}]}]}'

System Instructions

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    config=types.GenerateContentConfig(
        system_instruction="You are a helpful assistant."
    ),
    contents="Hello"
)
const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: "Hello",
  config: { systemInstruction: "You are a helpful assistant." },
});

Streaming

for chunk in client.models.generate_content_stream(
    model="gemini-3-flash-preview",
    contents="Tell me a story"
):
    print(chunk.text, end="")
const response = await ai.models.generateContentStream({
  model: "gemini-3-flash-preview",
  contents: "Tell me a story",
});
for await (const chunk of response) {
  console.log(chunk.text);
}

Multi-turn Chat

chat = client.chats.create(model="gemini-3-flash-preview")
response = chat.send_message("I have 2 dogs.")
print(response.text)
response = chat.send_message("How many paws total?")
print(response.text)
const chat = ai.chats.create({ model: "gemini-3-flash-preview" });
const response = await chat.sendMessage({ message: "I have 2 dogs." });
console.log(response.text);

Multimodal (Image)

from PIL import Image

image = Image.open("/path/to/image.png")
response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents=[image, "Describe this image"]
)
const image = await ai.files.upload({ file: "/path/to/image.png" });
const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: [
    createUserContent([
      "Describe this image",
      createPartFromUri(image.uri, image.mimeType),
    ]),
  ],
});

Document Processing (PDF)

Process PDFs with native vision understanding (up to 1000 pages).

from google.genai import types
import pathlib

filepath = pathlib.Path('document.pdf')
response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents=[
        types.Part.from_bytes(data=filepath.read_bytes(), mime_type='application/pdf'),
        "Summarize this document"
    ]
)
import * as fs from 'fs';

const response = await ai.models.generateContent({
    model: "gemini-3-flash-preview",
    contents: [
        { text: "Summarize this document" },
        {
            inlineData: {
                mimeType: 'application/pdf',
                data: Buffer.from(fs.readFileSync("document.pdf")).toString("base64")
            }
        }
    ]
});

For large PDFs, use Files API (stored 48 hours):

uploaded_file = client.files.upload(file=pathlib.Path('large.pdf'))
response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents=[uploaded_file, "Summarize this document"]
)

See references/documents.md for Files API, multiple PDFs, and best practices.


Image Generation (Nano Banana)

Generate and edit images conversationally.

response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents="Create a picture of a sunset over mountains",
)

for part in response.parts:
    if part.inline_data is not None:
        part.as_image().save("generated.png")
const response = await ai.models.generateContent({
  model: "gemini-2.5-flash-image",
  contents: "Create a picture of a sunset over mountains",
});

for (const part of response.candidates[0].content.parts) {
  if (part.inlineData) {
    const buffer = Buffer.from(part.inlineData.data, "base64");
    fs.writeFileSync("generated.png", buffer);
  }
}

Nano Banana Pro (gemini-3-pro-image-preview): 4K output, Google Search grounding, up to 14 reference images, conversational editing with thought signatures.

See references/image-generation.md for editing, multi-turn, and advanced features. See references/gemini-3.md for Gemini 3 image capabilities.


Video Generation (Veo)

Generate 8-second 720p, 1080p, or 4K videos with native audio using Veo.

import time
from google import genai

client = genai.Client()

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt="A cinematic shot of a majestic lion in the savannah at golden hour",
)

# Poll until complete (video generation is async)
while not operation.done:
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the video
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("lion.mp4")
let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: "A cinematic shot of a majestic lion in the savannah at golden hour",
});

while (!operation.done) {
    await new Promise(resolve => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({ operation });
}

ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "lion.mp4",
});

Veo 3.1 features: Portrait (9:16), video extension (up to 148s), 4K resolution, native audio with dialogue/SFX.

See references/veo.md for image-to-video, reference images, video extension, and prompting guide.


Music Generation (Lyria RealTime)

Generate continuous instrumental music in real-time with dynamic steering.

import asyncio
from google import genai
from google.genai import types

client = genai.Client()

async def main():
    async with client.aio.live.music.connect(model='models/lyria-realtime-exp') as session:
        # Set prompts and config
        await session.set_weighted_prompts(
            prompts=[types.WeightedPrompt(text='minimal techno', weight=1.0)]
        )
        await session.set_music_generation_config(
            config=types.LiveMusicGenerationConfig(bpm=90, temperature=1.0)
        )

        # Start streaming
        await session.play()

        # Receive audio chunks
        async for message in session.receive():
            if message.server_content and message.server_content.audio_chunks:
                audio_data = message.server_content.audio_chunks[0].data
                # Process audio...

asyncio.run(main())
const session = await ai.live.music.connect({
    model: "models/lyria-realtime-exp",
    callbacks: {
        onmessage: (message) => {
            if (message.serverContent?.audioChunks) {
                for (const chunk of message.serverContent.audioChunks) {
                    const audioBuffer = Buffer.from(chunk.data, "base64");
                    // Process audio...
                }
            }
        },
    },
});

await session.setWeightedPrompts({
    weightedPrompts: [{ text: "minimal techno", weight: 1.0 }],
});

await session.setMusicGenerationConfig({
    musicGenerationConfig: { bpm: 90, temperature: 1.0 },
});

await session.play();

Output: 48kHz stereo 16-bit PCM. Instrumental only. Configurable BPM, scale, density, brightness.

See references/lyria.md for steering music, configuration, and prompting guide.


Embeddings

Generate text embeddings for semantic similarity, search, and classification.

result = client.models.embed_content(
    model="gemini-embedding-001",
    contents="What is the meaning of life?"
)
print(result.embeddings)
const response = await ai.models.embedContent({
    model: 'gemini-embedding-001',
    contents: 'What is the meaning of life?',
});
console.log(response.embeddings);

Task types: SEMANTIC_SIMILARITY, CLASSIFICATION, CLUSTERING, RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY

Output dimensions: 768, 1536, 3072 (default)

See references/embeddings.md for batch processing, task types, and normalization.


Thinking (Gemini 3)

Control reasoning depth with thinking_level: minimal (Flash only), low, medium (Flash only), high (default).

from google.genai import types

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents="Solve this math problem...",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_level="high")
    ),
)
import { ThinkingLevel } from "@google/genai";

const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: "Solve this math problem...",
  config: { thinkingConfig: { thinkingLevel: ThinkingLevel.HIGH } },
});

Note: Cannot mix thinking_level with legacy thinking_budget (returns 400 error).

For Gemini 2.5, use thinking_budget (0-32768) instead. See references/thinking.md.

For complete Gemini 3 features (thought signatures, media resolution, etc.), see references/gemini-3.md.


Structured Outputs

Generate JSON responses adhering to a schema.

from pydantic import BaseModel
from typing import List

class Recipe(BaseModel):
    name: str
    ingredients: List[str]

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents="Extract: chocolate chip cookies need flour, sugar, chips",
    config={
        "response_mime_type": "application/json",
        "response_json_schema": Recipe.model_json_schema(),
    },
)
recipe = Recipe.model_validate_json(response.text)
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";

const recipeSchema = z.object({
  name: z.string(),
  ingredients: z.array(z.string()),
});

const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: "Extract: chocolate chip cookies need flour, sugar, chips",
  config: {
    responseMimeType: "application/json",
    responseJsonSchema: zodToJsonSchema(recipeSchema),
  },
});

See references/structured-outputs.md for advanced patterns.


Built-in Tools (Gemini 3)

Available: Google Search, File Search, Code Execution, URL Context, Function Calling

Not supported: Google Maps grounding, Computer Use (use Gemini 2.5 for these)

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    contents="What's the latest news on AI?",
    config={"tools": [{"google_search": {}}]},
)
const response = await ai.models.generateContent({
  model: "gemini-3-pro-preview",
  contents: "What's the latest news on AI?",
  config: { tools: [{ googleSearch: {} }] },
});

Structured outputs + tools: Gemini 3 supports combining JSON schemas with built-in tools (Google Search, URL Context, Code Execution). See references/gemini-3.md.

See references/tools.md for all tool patterns.


Function Calling

Connect models to external tools and APIs. The model determines when to call functions and provides parameters.

from google.genai import types

# Define function
get_weather = {
    "name": "get_weather",
    "description": "Get weather for a location",
    "parameters": {
        "type": "object",
        "properties": {
            "location": {"type": "string", "description": "City name"},
        },
        "required": ["location"],
    },
}

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents="What's the weather in Tokyo?",
    config=types.GenerateContentConfig(
        tools=[types.Tool(function_declarations=[get_weather])]
    ),
)

# Check for function call
if response.function_calls:
    fc = response.function_calls[0]
    print(f"Call {fc.name} with {fc.args}")
const response = await ai.models.generateContent({
  model: "gemini-3-flash-preview",
  contents: "What's the weather in Tokyo?",
  config: {
    tools: [{ functionDeclarations: [getWeather] }],
  },
});

if (response.functionCalls) {
  const { name, args } = response.functionCalls[0];
  // Execute function and send result back
}

Automatic function calling (Python): Pass functions directly as tools for automatic execution.

See references/function-calling.md for execution modes, compositional calling, multimodal responses, MCP integration, and best practices.


Quick Reference

FeaturePythonJavaScript
Generategenerate_content()generateContent()
Streamgenerate_content_stream()generateContentStream()
Chatchats.create()chats.create()
Structuredresponse_json_schema=responseJsonSchema:
Image Gengemini-2.5-flash-imagegemini-2.5-flash-image
Video Gengenerate_videos()generateVideos()
Music Genlive.music.connect()live.music.connect()
Function Callfunction_declarationsfunctionDeclarations
Embeddingsembed_content()embedContent()
Files APIfiles.upload()files.upload()

Gemini 3 Specific Features

For advanced Gemini 3 features, see references/gemini-3.md:

  • Thinking levels: Control reasoning depth (minimal, low, medium, high)
  • Media resolution: Fine-grained multimodal processing (media_resolution_low to ultra_high)
  • Thought signatures: Required for function calling and image editing context
  • Structured outputs + tools: Combine JSON schemas with Google Search, URL Context
  • Multimodal function responses: Return images in tool responses

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.37%
按下载量换算89

Gemini CLI

24.89%
按下载量换算84

Antigravity

16.41%
按下载量换算55

OpenCode

11.59%
按下载量换算39

Codex

8.59%
按下载量换算29

Cursor

3.9%
按下载量换算13

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills