---
title: "Deploy Gemini-OpenAI-Proxy"
description: "Converting the OpenAI API protocol to the Google Gemini Pro protocol."
category: "Other"
url: https://railway.com/deploy/gemini-openai-proxy
---

# Deploy Gemini-OpenAI-Proxy

Converting the OpenAI API protocol to the Google Gemini Pro protocol.

**[Deploy Gemini-OpenAI-Proxy on Railway](https://railway.com/template/gemini-openai-proxy)**

- **Creator:** Muhammad Bilal
- **Category:** Other
- **Total deploys:** 5

## Template content

### gemini-openai-proxy

- **Image:** zhu327/gemini-openai-proxy:latest
- **Public domain:** Yes

## Documentation

# Deploy and Host Gemini-OpenAI-Proxy on Railway

Gemini-OpenAI-Proxy is an open-source gateway that translates the OpenAI API protocol into the Google Gemini API protocol. It enables OpenAI-compatible applications to communicate directly with Gemini models while supporting Chat Completions, Embeddings, Vision requests, and Model endpoints without requiring application code changes.

## About Hosting Gemini-OpenAI-Proxy

Railway provides a fast and reliable platform for deploying Gemini-OpenAI-Proxy using the official Docker image. The proxy runs as a lightweight stateless HTTP service that accepts OpenAI-compatible requests and forwards them to Google Gemini using your Google AI Studio API key. Railway automatically manages HTTPS, networking, deployments, and scaling, allowing developers to expose an OpenAI-compatible endpoint with minimal configuration. Since the application does not persist state, no database or Railway Volume is required.

## Common Use Cases

- Connect OpenAI-compatible applications to Google Gemini without modifying client code.
- Replace OpenAI backends with Gemini while continuing to use existing SDKs.
- Proxy Chat, Embeddings, Vision, and Model API requests through a unified OpenAI-compatible endpoint.

## Dependencies for Gemini-OpenAI-Proxy Hosting

| Dependency | Required | Purpose |
|------------|----------|---------|
| Google AI Studio API Key | Yes | Authenticates requests to Gemini models. |

### Deployment Dependencies

| Resource | Link |
|----------|------|
| GitHub Repository | https://github.com/zhu327/gemini-openai-proxy |
| Docker Image | https://hub.docker.com/r/zhu327/gemini-openai-proxy |
| Google AI Studio | https://ai.google.dev |
| Google OpenAI Compatibility Documentation | https://ai.google.dev/gemini-api/docs/openai |
| OpenAI API Reference | https://platform.openai.com/docs/api-reference |

### Implementation Details

## Docker

This template deploys the official Docker image:

```text
zhu327/gemini-openai-proxy:latest
```

Railway pulls the prebuilt image directly.

## Public Networking

| Setting | Value |
|---------|-------|
| Proxy Type | HTTP Proxy |
| Target Port | 8080 |

After deployment:

1. Open your Railway service.
2. Navigate to **Settings → Networking**.
3. Click **Generate Domain**.

Your proxy endpoint will be available at:

```text
https:///v1
```

## Environment Variables

Configure the following Railway Variables before deployment.

| Variable | Required | Description |
|----------|----------|-------------|
| `PORT` | No | Internal application port. Defaults to `8080`. |
| `GPT_4_VISION_PREVIEW` | No | Gemini model used when clients request `gpt-4-vision-preview`. |
| `DISABLE_MODEL_MAPPING` | No | Set to `1` to disable automatic OpenAI → Gemini model mapping. |

Raw Editor example:

```env
PORT=8080
GPT_4_VISION_PREVIEW=gemini-1.5-flash-latest
DISABLE_MODEL_MAPPING=0
```

## Getting a Google AI Studio API Key

Before using the proxy:

1. Visit:

   https://ai.google.dev

2. Sign in with your Google account.

3. Open **Google AI Studio**.

4. Create a new API Key.

5. Copy the generated key.

When making requests to Gemini-OpenAI-Proxy, use the Google AI Studio API Key as the Bearer token:

```http
Authorization: Bearer YOUR_GOOGLE_AI_STUDIO_API_KEY
```

## Persistent Storage

No Railway Volume is required.

Gemini-OpenAI-Proxy is completely stateless and processes requests entirely in memory.

## Database

No database is required.

## Build &amp; Start

Railway deploys the official Docker image automatically.

No custom build or start commands are required.

## Accessing the Application

After deployment:

1. Generate a Railway Domain.
2. Configure your OpenAI-compatible application to use:

```text
https:///v1
```

3. Use your Google AI Studio API Key as the Bearer token.

Your existing OpenAI SDKs and clients can now communicate with Gemini through the proxy.

## Chat Completion Example

```bash
curl https:///v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_GOOGLE_AI_STUDIO_API_KEY" \
  -d '{
    "model":"gpt-3.5-turbo",
    "messages":[
      {
        "role":"user",
        "content":"Say this is a test!"
      }
    ],
    "temperature":0.7
}'
```

## Vision Example

Gemini-OpenAI-Proxy supports OpenAI Vision requests.

```bash
curl https:///v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_GOOGLE_AI_STUDIO_API_KEY" \
  -d '{
    "model":"gpt-4-vision-preview",
    "messages":[
      {
        "role":"user",
        "content":[
          {
            "type":"text",
            "text":"What is in this image?"
          },
          {
            "type":"image_url",
            "image_url":{
              "url":"https://example.com/image.jpg"
            }
          }
        ]
      }
    ]
}'
```

To use Gemini Pro Vision instead of the default model, configure:

```env
GPT_4_VISION_PREVIEW=gemini-1.5-pro-latest
```

## Embeddings Example

```bash
curl https:///v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_GOOGLE_AI_STUDIO_API_KEY" \
  -d '{
    "model":"text-embedding-ada-002",
    "input":"This is a test sentence."
}'
```

Multiple inputs are also supported:

```json
{
  "model": "text-embedding-ada-002",
  "input": [
    "Sentence one",
    "Sentence two"
  ]
}
```

## Model Mapping

By default, Gemini-OpenAI-Proxy automatically maps common OpenAI models to Gemini equivalents.

| OpenAI Model | Gemini Model |
|--------------|--------------|
| `gpt-4` | `gemini-1.5-flash-002` |
| `gpt-4-turbo-preview` | `gemini-1.5-pro-latest` |
| `gpt-4o` | `gemini-2.0-flash-exp` |
| `gpt-4-vision-preview` | `gemini-1.5-flash-latest` |
| `text-embedding-ada-002` | `text-embedding-004` |

## Disable Model Mapping

To send Gemini model names directly, configure:

```env
DISABLE_MODEL_MAPPING=1
```

Example request:

```json
{
  "model": "gemini-1.0-pro-latest",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}
```

## Supported Features

- OpenAI Chat Completions API
- OpenAI Embeddings API
- OpenAI Models API
- Image / Vision requests
- Automatic OpenAI → Gemini model mapping
- Optional direct Gemini model support
- Stateless architecture
- OpenAI SDK compatibility

## Compatibility Notice

Google AI Studio now provides an official OpenAI-compatible API endpoint.

For new projects, you may also consider Google's official compatibility layer:

- https://ai.google.dev/gemini-api/docs/openai

Gemini-OpenAI-Proxy remains useful for deployments that require its proxy-based architecture or custom model mapping behavior.

## Why Deploy Gemini-OpenAI-Proxy on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Gemini-OpenAI-Proxy on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/gemini-openai-proxy
