← 开源
gzzhongqi

geminicli2api

InfrastructureDeploy & ServeGatewayPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
590
Star
627
Fork
+0
本周
1
贡献者
创建于 2025-06-26 · 更新于 2026-10-14 · 今日第 16457 名
主要开发者

gzzhongqi/geminicli2api 排名第 16,457,有 590 个星标。

同类别比较

gzzhongqi/geminicli2api 排名第 16,457,此处有 8 个同类条目;keldenl/gpt-llama.cpp 排名第 16,458。

同类别比较
名称排名指标
VictoriaMetrics/operator16,398
语言:
Go
星标数:
594
分叉数:
239
简介:
Kubernetes operator for Victoria Metrics
Trans-N-ai/swama16,407
语言:
Swift
星标数:
593
分叉数:
31
简介:
High-performance MLX-based LLM inference engine for macOS with native Swift implementation
strongdm/leash16,428
语言:
Go
星标数:
592
分叉数:
46
简介:
Leash by StrongDM - take your AI agents for a walk
thunder-id/thunderid16,446
语言:
Go
星标数:
591
分叉数:
394
简介:
ThunderID is a high-performance, open-source identity stack designed for developers to secure and manage access for humans, AI agents, and machines through fully composable identity flows.
keldenl/gpt-llama.cpp16,458
语言:
JavaScript
星标数:
590
分叉数:
66
简介:
A llama.cpp drop-in replacement for OpenAI's GPT endpoints, allowing GPT-powered apps to run off local llama.cpp models instead of OpenAI.
openxla/xprof16,460
语言:
C++
星标数:
590
分叉数:
100
简介:
A profiling and performance analysis tool for machine learning
YotpoLtd/metorikku16,466
语言:
Scala
星标数:
589
分叉数:
156
简介:
A simplified, lightweight ETL Framework based on Apache Spark
ccpopy/antissh16,468
语言:
Shell
星标数:
589
分叉数:
38
简介:
反重力Agent代理一键脚本,支持WSL、SSH远程
关键参数与规格
关键参数与规格
参数值
语言Python
类别Infrastructure
子类别Deploy & Serve,Gateway
关键词Agent-ready APIs, Client integration, Multimodal
星标数590
分叉数627
贡献者1
创建日期2025-06-26
更新日期2026-10-14
1 天星标数0
7 天星标数0
排名16,457
上次排名6,829
排名变化-9,628
7 天星标排名15,540
上次 7 天星标排名11,298
7 天星标排名变化-4,242
总星标排名16,993
上次总星标排名16,961
总星标排名变化-32
README 摘录

This allows you to leverage Google's free Gemini API quota through familiar OpenAI API interfaces or direct Gemini API calls. 🚀 Features **OpenAI-Compatible API**: Drop-in replacement for OpenAI's chat completions API **Native Gemini API**: Direct proxy to Google's Gemini API **Streaming Support**: Real-time streaming responses for both API formats **Multimodal Support**: Text and image inputs **Authentication**: Multiple auth methods (Bearer, Basic, API key) **Google Search Grounding**: Enable Google Search for grounded responses using models. **Thinking/Reasoning Control**: Control

Gemini's thinking process with and models. **Docker Ready**: Containerized for easy deployment **Hugging Face Spaces**: Ready for deployment on Hugging Face 🔧 Environment Variables Required : Authentication password for API access Optional Credential Sources (choose one) : JSON string containing Google OAuth credentials : Path to Google OAuth credentials file : Google Cloud project ID : Alternative project ID variable Example Credentials JSON 📡 API Endpoints OpenAI-Compatible Endpoints - Chat completions (streaming & non-streaming) - List available models Native Gemini Endpoints - List Gemini models - Generate content - Stream content

All other Gemini API endpoints are proxied through Utility Endpoints - Health check for container orchestration 🔐 Authentication The API supports multiple authentication methods: 1. **Google Header**: 🐳 Docker Usage Docker Compose 🤗 Hugging Face Spaces This project is configured for Hugging Face Spaces deployment: 1. Set the required environment variables in Space settings: - (or other credential source) The Space will automatically build and deploy using the included Dockerfile. 📝 OpenAI API Example 🔧 Native Gemini API Example 🎯 Supported Models Base Models Model Variants The proxy

automatically creates variants for and models: ** **: Appends to a model name to enable Google Search grounding. Example: ** **: Appends to minimize reasoning steps. Example: ** **: Appends to maximize the reasoning budget. Example: 📄 License MIT License - see LICENSE file for details. 🤝 Contributing Contributions are welcome! Please feel free to submit a Pull Request.

常见问题

记录了多少星标和分叉?

gzzhongqi/geminicli2api 有 590 个星标和 627 个分叉。

仓库排名是多少?

gzzhongqi/geminicli2api 排名第 16,457。

记录的语言和类别是什么?

gzzhongqi/geminicli2api 有 590 个星标,语言为 Python,类别为 Infrastructure。

哪个仓库排名最接近?

gzzhongqi/geminicli2api 与 keldenl/gpt-llama.cpp 比较,后者排名第 16,458,有 590 个星标。

README

title: Gemini CLI to API Proxy emoji: 🤖 colorFrom: blue colorTo: purple sdk: docker pinned: false license: mit app_port: 7860

Gemini CLI to API Proxy (geminicli2api)

A FastAPI-based proxy server that converts the Gemini CLI tool into both OpenAI-compatible and native Gemini API endpoints. This allows you to leverage Google's free Gemini API quota through familiar OpenAI API interfaces or direct Gemini API calls.

🚀 Features

  • OpenAI-Compatible API: Drop-in replacement for OpenAI's chat completions API
  • Native Gemini API: Direct proxy to Google's Gemini API
  • Streaming Support: Real-time streaming responses for both API formats
  • Multimodal Support: Text and image inputs
  • Authentication: Multiple auth methods (Bearer, Basic, API key)
  • Google Search Grounding: Enable Google Search for grounded responses using -search models.
  • Thinking/Reasoning Control: Control Gemini's thinking process with -nothinking and -maxthinking models.
  • Docker Ready: Containerized for easy deployment
  • Hugging Face Spaces: Ready for deployment on Hugging Face

🔧 Environment Variables

Required

  • GEMINI_AUTH_PASSWORD: Authentication password for API access

Optional Credential Sources (choose one)

  • GEMINI_CREDENTIALS: JSON string containing Google OAuth credentials
  • GOOGLE_APPLICATION_CREDENTIALS: Path to Google OAuth credentials file
  • GOOGLE_CLOUD_PROJECT: Google Cloud project ID
  • GEMINI_PROJECT_ID: Alternative project ID variable

Example Credentials JSON

{
  "client_id": "your-client-id",
  "client_secret": "your-client-secret", 
  "token": "your-access-token",
  "refresh_token": "your-refresh-token",
  "scopes": ["https://www.googleapis.com/auth/cloud-platform"],
  "token_uri": "https://oauth2.googleapis.com/token"
}

📡 API Endpoints

OpenAI-Compatible Endpoints

  • POST /v1/chat/completions - Chat completions (streaming & non-streaming)
  • GET /v1/models - List available models

Native Gemini Endpoints

  • GET /v1beta/models - List Gemini models
  • POST /v1beta/models/{model}:generateContent - Generate content
  • POST /v1beta/models/{model}:streamGenerateContent - Stream content
  • All other Gemini API endpoints are proxied through

Utility Endpoints

  • GET /health - Health check for container orchestration

🔐 Authentication

The API supports multiple authentication methods:

  1. Bearer Token: Authorization: Bearer YOUR_PASSWORD
  2. Basic Auth: Authorization: Basic base64(username:YOUR_PASSWORD)
  3. Query Parameter: ?key=YOUR_PASSWORD
  4. Google Header: x-goog-api-key: YOUR_PASSWORD

🐳 Docker Usage

# Build the image
docker build -t geminicli2api .

# Run on default port 8888 (compatibility)
docker run -p 8888:8888 \
  -e GEMINI_AUTH_PASSWORD=your_password \
  -e GEMINI_CREDENTIALS='{"client_id":"...","token":"..."}' \
  -e PORT=8888 \
  geminicli2api

# Run on port 7860 (Hugging Face compatible)
docker run -p 7860:7860 \
  -e GEMINI_AUTH_PASSWORD=your_password \
  -e GEMINI_CREDENTIALS='{"client_id":"...","token":"..."}' \
  -e PORT=7860 \
  geminicli2api

Docker Compose

# Default setup (port 8888)
docker-compose up -d

# Hugging Face setup (port 7860)
docker-compose --profile hf up -d geminicli2api-hf

🤗 Hugging Face Spaces

This project is configured for Hugging Face Spaces deployment:

  1. Fork this repository
  2. Create a new Space on Hugging Face
  3. Connect your repository
  4. Set the required environment variables in Space settings:
    • GEMINI_AUTH_PASSWORD
    • GEMINI_CREDENTIALS (or other credential source)

The Space will automatically build and deploy using the included Dockerfile.

📝 OpenAI API Example

import openai

# Configure client to use your proxy
client = openai.OpenAI(
    base_url="http://localhost:8888/v1",  # or 7860 for HF
    api_key="your_password"  # Your GEMINI_AUTH_PASSWORD
)

# Use like normal OpenAI API
response = client.chat.completions.create(
    model="gemini-2.5-pro-maxthinking",
    messages=[
        {"role": "user", "content": "Explain the theory of relativity in simple terms."}
    ],
    stream=True
)

# Separate reasoning from the final answer
for chunk in response:
    if chunk.choices[0].delta.reasoning_content:
        print(f"Thinking: {chunk.choices[0].delta.reasoning_content}")
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

🔧 Native Gemini API Example

import requests

headers = {
    "Authorization": "Bearer your_password",
    "Content-Type": "application/json"
}

data = {
    "contents": [
        {
            "role": "user",
            "parts": [{"text": "Explain the theory of relativity in simple terms."}]
        }
    ],
    "thinkingConfig": {
        "thinkingBudget": 32768,
        "includeThoughts": True
    }
}

response = requests.post(
    "http://localhost:8888/v1beta/models/gemini-2.5-pro:generateContent",  # or 7860 for HF
    headers=headers,
    json=data
)

print(response.json())

🎯 Supported Models

Base Models

  • gemini-2.5-pro
  • gemini-2.5-flash
  • gemini-1.5-pro
  • gemini-1.5-flash
  • gemini-1.0-pro

Model Variants

The proxy automatically creates variants for gemini-2.5-pro and gemini-2.5-flash models:

  • -search: Appends -search to a model name to enable Google Search grounding.
    • Example: gemini-2.5-pro-search
  • -nothinking: Appends -nothinking to minimize reasoning steps.
    • Example: gemini-2.5-flash-nothinking
  • -maxthinking: Appends -maxthinking to maximize the reasoning budget.
    • Example: gemini-2.5-pro-maxthinking

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

排名相邻
同类项目