Railway

Deploy Gemini-OpenAI-Proxy

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

Deploy Gemini-OpenAI-Proxy

Just deployed

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

DependencyRequiredPurpose
Google AI Studio API KeyYesAuthenticates requests to Gemini models.

Deployment Dependencies

ResourceLink
GitHub Repositoryhttps://github.com/zhu327/gemini-openai-proxy
Docker Imagehttps://hub.docker.com/r/zhu327/gemini-openai-proxy
Google AI Studiohttps://ai.google.dev
Google OpenAI Compatibility Documentationhttps://ai.google.dev/gemini-api/docs/openai
OpenAI API Referencehttps://platform.openai.com/docs/api-reference

Implementation Details

Docker

This template deploys the official Docker image:

zhu327/gemini-openai-proxy:latest

Railway pulls the prebuilt image directly.

Public Networking

SettingValue
Proxy TypeHTTP Proxy
Target Port8080

After deployment:

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

Your proxy endpoint will be available at:

https:///v1

Environment Variables

Configure the following Railway Variables before deployment.

VariableRequiredDescription
PORTNoInternal application port. Defaults to 8080.
GPT_4_VISION_PREVIEWNoGemini model used when clients request gpt-4-vision-preview.
DISABLE_MODEL_MAPPINGNoSet to 1 to disable automatic OpenAI → Gemini model mapping.

Raw Editor example:

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:

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 & 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:
https:///v1
  1. 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

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.

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:

GPT_4_VISION_PREVIEW=gemini-1.5-pro-latest

Embeddings Example

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:

{
  "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 ModelGemini Model
gpt-4gemini-1.5-flash-002
gpt-4-turbo-previewgemini-1.5-pro-latest
gpt-4ogemini-2.0-flash-exp
gpt-4-vision-previewgemini-1.5-flash-latest
text-embedding-ada-002text-embedding-004

Disable Model Mapping

To send Gemini model names directly, configure:

DISABLE_MODEL_MAPPING=1

Example request:

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

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.


Template Content

More templates in this category

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

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

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

Letta
52