Railway

Deploy Gemini API Gateway – OpenAI-Compatible REST API for Gemini & Claude

Turn Gemini CLI into OpenAI, Gemini & Claude compatible REST APIs.

Deploy Gemini API Gateway – OpenAI-Compatible REST API for Gemini & Claude

Just deployed

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

https://railway.com

Environment Variables

Required Variables

VariableDescriptionDefault
PASSWORDShared password for both API and Dashboardpwd
PORTApplication port7861

Recommended Production Variables

VariableDescription
API_PASSWORDPassword for API endpoints
PANEL_PASSWORDPassword for Web Dashboard
HOSTServer bind address
LOG_LEVELLogging level
LOG_FILELog file location

Database Variables

VariableDescription
MONGODB_URIMongoDB connection string
MONGODB_DATABASEMongoDB database name

Network Variables

VariableDescription
PROXYHTTP/HTTPS proxy
OAUTH_PROXY_URLOAuth proxy
GOOGLEAPIS_PROXY_URLGoogle APIs proxy
METADATA_SERVICE_URLMetadata proxy

Performance Variables

VariableDescription
RETRY_429_ENABLEDEnable automatic retry on rate limits
RETRY_429_MAX_RETRIESMaximum retry attempts
RETRY_429_INTERVALRetry interval
ANTI_TRUNCATION_MAX_ATTEMPTSContinue truncated responses
AUTO_BANAutomatically disable unhealthy credentials
COMPATIBILITY_MODEImprove 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

More templates in this category

View Template
Rocky Linux
[Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
16
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
70
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
45