Deploy Gemini API Gateway – OpenAI-Compatible REST API for Gemini & Claude
Turn Gemini CLI into OpenAI, Gemini & Claude compatible REST APIs.
gcli2api
Just deployed
Just deployed
Redis
Just deployed
Deploy and Host Gemini CLI into Claude & OpenAI on Railway
Gemini API Gateway is a self-hosted AI gateway that converts Gemini CLI into OpenAI, Gemini Native, and Claude-compatible REST APIs. It provides OAuth credential management, automatic credential rotation, streaming responses, multimodal support, image generation, and a powerful web dashboard, making it easy to integrate Gemini into any AI application, automation workflow, or developer tool.
About Hosting Gemini CLI to API
Deploy Gemini API Gateway on Railway in minutes with a production-ready Docker setup. The gateway exposes standardized OpenAI, Gemini Native, and Claude-compatible endpoints while automatically managing Google OAuth credentials, load balancing requests across multiple accounts, monitoring credential health, and retrying failed requests. It supports real-time streaming, multimodal inputs, image generation, proxy configuration, and both SQLite and MongoDB storage. Whether you're building AI assistants, chatbots, automation tools, or internal developer platforms, Railway provides a simple, scalable environment for running your own secure AI gateway.
Common Use Cases
- Build applications using the OpenAI SDK while powered by Google Gemini.
- Host a unified API for OpenAI, Gemini Native, and Claude-compatible clients.
- Deploy AI assistants, chatbots, automation workflows, and internal AI tools.
- Manage multiple Google OAuth credentials with automatic rotation.
- Enable streaming, multimodal AI, and image generation through one API.
- Self-host a secure AI gateway for production workloads.
Dependencies for Gemini API Gateway – One API for Gemini, Claude & OpenAI Hosting
- Docker
- Railway
- Google Gemini CLI OAuth Credentials
- Python 3.12+
- Optional MongoDB database
- Postgress and Redis
Deployment Dependencies
Project Repository
https://github.com/su-kaka/gcli2api
Docker Image
https://github.com/su-kaka/gcli2api/pkgs/container/gcli2api
Railway
Environment Variables
Required Variables
| Variable | Description | Default |
|---|---|---|
PASSWORD | Shared password for both API and Dashboard | pwd |
PORT | Application port | 7861 |
Recommended Production Variables
| Variable | Description |
|---|---|
API_PASSWORD | Password for API endpoints |
PANEL_PASSWORD | Password for Web Dashboard |
HOST | Server bind address |
LOG_LEVEL | Logging level |
LOG_FILE | Log file location |
Database Variables
| Variable | Description |
|---|---|
MONGODB_URI | MongoDB connection string |
MONGODB_DATABASE | MongoDB database name |
Network Variables
| Variable | Description |
|---|---|
PROXY | HTTP/HTTPS proxy |
OAUTH_PROXY_URL | OAuth proxy |
GOOGLEAPIS_PROXY_URL | Google APIs proxy |
METADATA_SERVICE_URL | Metadata proxy |
Performance Variables
| Variable | Description |
|---|---|
RETRY_429_ENABLED | Enable automatic retry on rate limits |
RETRY_429_MAX_RETRIES | Maximum retry attempts |
RETRY_429_INTERVAL | Retry interval |
ANTI_TRUNCATION_MAX_ATTEMPTS | Continue truncated responses |
AUTO_BAN | Automatically disable unhealthy credentials |
COMPATIBILITY_MODE | Improve compatibility with some clients |
API Endpoints
OpenAI Compatible
/v1/chat/completions
/v1/models
Gemini Native
/v1/models/{model}:generateContent
/v1/models/{model}:streamGenerateContent
Claude Compatible
/v1/messages
Antigravity
/antigravity/v1/chat/completions
/antigravity/v1/messages
/antigravity/v1/models/{model}:generateContent
Implementation Details
Example OpenAI-compatible request:
curl -X POST https://YOUR-RAILWAY-URL/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_PASSWORD" \
-H "Content-Type: application/json" \
-d '{
"model":"gemini-2.5-pro",
"messages":[
{
"role":"user",
"content":"Hello!"
}
],
"stream":true
}'
Features
- ✅ OpenAI Compatible API
- ✅ Gemini Native API
- ✅ Claude Compatible API
- ✅ OAuth Authentication
- ✅ Automatic Credential Rotation
- ✅ Multi-Account Load Balancing
- ✅ Streaming Responses
- ✅ Multimodal Support
- ✅ Image Generation
- ✅ Web Dashboard
- ✅ Real-Time Logs
- ✅ SQLite Support
- ✅ MongoDB Support
- ✅ Docker Ready
- ✅ Railway Ready
- ✅ Self-Hosted
- ✅ Production Ready
Why Deploy on Railway?
- 🚀 One-click deployment
- 🔒 Secure environment variables
- ⚡ Fast global infrastructure
- 🐳 Native Docker support
- 📈 Automatic scaling
- 💾 Persistent storage
- 🌍 Public HTTPS endpoint
- 🔄 Simple updates and rollbacks
Gemini API Gateway gives developers a production-ready, self-hosted AI gateway that exposes OpenAI, Gemini Native, and Claude-compatible APIs through a single deployment, making it easy to integrate Google Gemini into modern AI applications and developer workflows.
Template Content
