---
title: "Deploy OpenAI, Gemini & Claude REST API Gateway"
description: "Unified REST API Gateway for OpenAI, Gemini, Antigravity and Claude models."
category: "AI/ML"
url: https://railway.com/deploy/gemini-api-gateway-one-api-for-gemini-cl
---

# Deploy OpenAI, Gemini & Claude REST API Gateway

Unified REST API Gateway for OpenAI, Gemini, Antigravity and Claude models.

**[Deploy OpenAI, Gemini & Claude REST API Gateway on Railway](https://railway.com/template/gemini-api-gateway-one-api-for-gemini-cl)**

- **Creator:** Muhammad Bilal
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### gcli2api

- **Source:** bilalnawaz072/gcli2api

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2.1
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Documentation

# 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

| 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:

```bash
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.

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/gemini-api-gateway-one-api-for-gemini-cl
