google-genai-sdk-python
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle 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), thought signatures.thinking_budget - 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
核心原则
- Unified SDK: Always use .
google-genai - Stateless Models: Use for single requests.
client.models - Stateful Chats: Use for conversations.
client.chats - Types: Import from .
google.genai.types
- 统一SDK:始终使用。
google-genai - 无状态模型:使用处理单次请求。
client.models - 有状态对话:使用处理对话场景。
client.chats - 类型导入:从导入类型。
google.genai.types