gemini-openai-api
Provides patterns for integrating Gemini via OpenAI-compatible endpoints, including thinking config and response formatting.
Install
mkdir -p .claude/skills/gemini-openai-api && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8089" && unzip -o skill.zip -d .claude/skills/gemini-openai-api && rm skill.zipInstalls to .claude/skills/gemini-openai-api
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Gemini 模型通过 OpenAI 兼容 API 接入指南。包含:(1) 辅助 API 配置(summary/correction/emotion/vision),(2) extra_body 格式用于控制 thinking,(3) 响应格式处理(markdown 代码块)。当需要将 Gemini 作为辅助模型接入、配置 thinking 参数、或处理 Gemini API 返回格式时使用。Key capabilities
- →Configures Gemini for OpenAI-compatible base URLs
- →Sets thinking budgets via extra_body
- →Parses markdown-wrapped JSON responses
- →Maps models to specific utility tasks
How it works
Provides structural patterns for mapping `extra_body` and base URLs to integrate Gemini into an OpenAI-compatible client wrapper.
Inputs & outputs
When to use gemini-openai-api
- →Configure Gemini thinking budget
- →Connect Gemini as auxiliary model
- →Handle markdown JSON responses
About this skill
Gemini OpenAI 兼容 API 接入
Gemini 提供 OpenAI 兼容端点,可作为辅助 API 使用。
[!IMPORTANT] memory/ + utils/ 下不要传
temperature。项目级约定:所有走utils.llm_client.create_chat_llm/ChatOpenAI的调用一律不下发temperature字段(默认None= 不写进请求体)。守门见scripts/check_no_temperature.py。extra_body(控制 thinking)/max_completion_tokens/timeout/max_retries这类参数继续按需配置,但 不要为了"调风格"再加temperature=...。
Base URL
https://generativelanguage.googleapis.com/v1beta/openai/
模型配置
| 用途 | 推荐模型 |
|---|---|
| Summary / Correction / Vision | gemini-3-flash-preview |
| Emotion Analysis | gemini-2.5-flash |
控制 Thinking
Gemini 2.5+ 模型需要通过 extra_body 控制 thinking 行为。
禁用 Thinking(用于 gemini-2.5-flash)
extra_body = {
"extra_body": {
"google": {
"thinking_config": {
"thinking_budget": 0
}
}
}
}
低级别 Thinking(用于 gemini-3-flash-preview)
extra_body = {
"extra_body": {
"google": {
"thinking_config": {
"thinking_level": "low",
"include_thoughts": False
}
}
}
}
[!IMPORTANT] extra_body 需要双层嵌套:外层
"extra_body"是传给 OpenAI client 的参数名,内层{"google": {...}}是 Gemini 的实际配置。
响应格式处理
Gemini 可能返回 markdown 代码块包装的 JSON:
```json
{"emotion": "happy", "confidence": 0.8}
处理方法:
```python
if result_text.startswith("```"):
lines = result_text.split("\n")
if lines[0].startswith("```"):
lines = lines[1:]
if lines and lines[-1].strip() == "```":
lines = lines[:-1]
result_text = "\n".join(lines).strip()
配置文件位置
config/api_providers.json- 添加 gemini 到assist_api_providersconfig/__init__.py- 添加EXTRA_BODY_GEMINI和MODELS_EXTRA_BODY_MAP
api_providers.json 示例
"gemini": {
"key": "gemini",
"name": "Gemini(Google)",
"description": "Google AI 辅助模型,国内无法使用",
"openrouter_url": "https://generativelanguage.googleapis.com/v1beta/openai/",
"summary_model": "gemini-3-flash-preview",
"correction_model": "gemini-3-flash-preview",
"emotion_model": "gemini-2.5-flash",
"vision_model": "gemini-3-flash-preview"
}
常见问题
"Unknown name 'google': Cannot find field"
原因:extra_body 格式错误,缺少外层 "extra_body" 包装。
解决:使用双层嵌套格式 {"extra_body": {"google": {...}}}。
JSON 解析失败
原因:
- 响应被截断(token 限制太小)
- 响应包含 markdown 代码块
解决:
- 增加
max_completion_tokens - 添加 markdown 代码块处理逻辑
When not to use it
- →Native SDK integrations
- →Projects already using standard OpenAI clients without provider-specific configuration
Limitations
- →Strict parameter constraints regarding temperature usage
- →Requires custom parsing of markdown blocks
How it compares
Provides a specific architectural bridge for using Gemini models within an existing OpenAI-focused client ecosystem.
Compared to similar skills
gemini-openai-api side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| gemini-openai-api (this skill) | 0 | 3mo | No flags | Advanced |
| openai-knowledge | 5 | 4mo | No flags | Intermediate |
| openrouter-function-calling | 5 | 25d | Review | Intermediate |
| openrouter-hello-world | 7 | 25d | Caution | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by Project-N-E-K-O
View all by Project-N-E-K-O →You might also like
openai-knowledge
openai
Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.
openrouter-function-calling
jeremylongshore
Implement function/tool calling with OpenRouter models. Use when building agents or structured outputs. Trigger with phrases like 'openrouter functions', 'openrouter tools', 'openrouter agent', 'function calling'.
openrouter-hello-world
jeremylongshore
Create your first OpenRouter API request with a simple example. Use when learning OpenRouter or testing your setup. Trigger with phrases like 'openrouter hello world', 'openrouter first request', 'openrouter quickstart', 'test openrouter'.
openrouter-openai-compat
jeremylongshore
Configure OpenRouter as an OpenAI API drop-in replacement. Use when migrating from OpenAI or using OpenAI-compatible libraries. Trigger with phrases like 'openrouter openai', 'openrouter drop-in', 'openrouter compatibility', 'migrate to openrouter'.
using-openrouter
HasanZiyade
>-
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.