google-genai-sdk-python

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google GenAI Python SDK Skill

Google GenAI Python SDK 技能指南

Use this skill to write high-quality, idiomatic Python code for the Gemini API.
使用本技能为Gemini API编写高质量、符合Python风格的代码。

Reference Materials

参考资料

Identify the user's task and refer to the relevant file:
  • Setup & Client: Installation, auth, client initialization.
  • Models: Recommended models (Flash, Pro, Lite, Imagen, Veo).
  • Text Generation: Basic inference, streaming, system instructions, safety.
  • Chat: Multi-turn conversations and history.
  • Reasoning: Thinking config (
    thinking_level
    /
    thinking_budget
    ), thought signatures.
  • Structured Output: JSON schemas, Pydantic models, Enums.
  • Multimodal Inputs: Images, audio, video, PDFs, media resolution.
  • Tools: Function calling, code execution, Google Search grounding.
  • Media Generation: Image generation/editing (Imagen), video generation (Veo).
  • Source Code: Raw SDK source code for deep inspection.
根据用户的任务需求,参考对应的文档:
  • 环境配置与客户端:安装、认证、客户端初始化。
  • 模型:推荐模型(Flash、Pro、Lite、Imagen、Veo)。
  • 文本生成:基础推理、流式输出、系统指令、安全设置。
  • 对话功能:多轮对话与对话历史管理。
  • 推理能力:思考配置(
    thinking_level
    /
    thinking_budget
    )、思考签名。
  • 结构化输出:JSON 模式、Pydantic 模型、枚举类型。
  • 多模态输入:图片、音频、视频、PDF、媒体分辨率。
  • 工具调用:函数调用、代码执行、基于Google搜索的 grounding。
  • 媒体生成:图片生成/编辑(Imagen)、视频生成(Veo)。
  • 源代码:用于深度研究的SDK原始源代码。

Core Principles

核心原则

  1. Unified SDK: Always use
    google-genai
    .
  2. Stateless Models: Use
    client.models
    for single requests.
  3. Stateful Chats: Use
    client.chats
    for conversations.
  4. Types: Import from
    google.genai.types
    .
  1. 统一SDK:始终使用
    google-genai
  2. 无状态模型:使用
    client.models
    处理单次请求。
  3. 有状态对话:使用
    client.chats
    处理对话场景。
  4. 类型导入:从
    google.genai.types
    导入类型。