Agent skill
Gemini Agent SDK Setup
Integrate OpenAI Agent SDK with Google Gemini backend into FastAPI service using the official Google Gemini API via OpenAI compatibility layer.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/devops/gemini-agent-sdk-setup
SKILL.md
Gemini Agent SDK Setup
Instructions
-
Generate the Agent SDK client initialization in app/services/agent/client.py:
- Import OpenAI from openai package
- Configure client with GEMINI_API_KEY
- Set base_url to Google's Gemini OpenAI compatibility endpoint: "https://generativelanguage.googleapis.com/v1beta/openai/"
- Ensure proper error handling and retry logic
-
Create agent configuration in app/services/agent/config.py:
- Define model name constants (gemini-1.5-flash, gemini-2.5-flash)
- Set up default parameters for agent calls
- Include proper timeout and retry configurations
-
Implement tool registration system in app/services/tools/registry.py:
- Create function to register tools with the agent
- Define tool schemas following OpenAI Agent SDK specification
- Include validation for tool inputs and outputs
-
Create utility functions for calling Gemini models in app/services/agent/utils.py:
- Wrapper function for agent completion calls
- Error handling and logging utilities
- Response parsing and validation
-
Follow Context7 MCP conventions:
- Only use Gemini models (no OpenAI inference)
- Follow deterministic output formatting
- Include proper error handling and logging
Examples
Input: "Setup Gemini Agent SDK integration" Output: Creates client.py with:
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("GEMINI_API_KEY"),
base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
)
def call_gemini_agent(messages, tools=None, model="gemini-1.5-flash"):
"""Call the Gemini agent with provided messages and tools."""
try:
response = client.chat.completions.create(
model=model,
messages=messages,
tools=tools,
temperature=0.1
)
return response
except Exception as e:
# Handle errors appropriately
raise e
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?