PublicAffairs / openai-gemini

Gemini ➜ OpenAI API proxy. Serverless!
https://my-openai-gemini-demo.vercel.app/
MIT License
307 stars 183 forks source link
chatgpt-api gemini-ai gemini-pro gemini-pro-vision gpt-4-vision-preview openai proxy serverless

Why

The Gemini API is free, but there are many tools that work exclusively with the OpenAI API.

This project provides a personal OpenAI-compatible endpoint for free.

Serverless?

Although it runs in the cloud, it does not require server maintenance. It can be easily deployed to various providers for free (with generous limits suitable for personal use).

[!TIP] Running the proxy endpoint locally is also an option, though it's more appropriate for development use.

How to start

You will need a personal Google API key.

[!IMPORTANT] Even if you are located outside of the supported regions (e.g., in Europe), it is still possible to acquire one using a VPN.

Deploy the project to one of the providers, using the instructions below. You will need to set up an account there.

If you opt for “button-deploy”, you'll be guided through the process of forking the repository first, which is necessary for continuous integration (CI).

Deploy with Vercel

Deploy with Vercel

Deploy to Netlify

Deploy to Netlify

Deploy to Cloudflare

Deploy to Cloudflare Workers

How to use

If you open your newly-deployed site in a browser, you will only see a 404 Not Found message. This is expected, as the API is not designed for direct browser access. To utilize it, you should enter your API address and your Gemini API key into the corresponding fields in your software settings.

[!NOTE] Not all software tools allow overriding the OpenAI endpoint, but many do (however these settings can sometimes be deeply hidden).

Typically, you should specify the API base in this format:
https://my-super-proxy.vercel.app/v1

However, some software may expect it without the /v1 ending:
https://my-super-proxy.vercel.app

The relevant field may be labeled as "OpenAI proxy". You might need to look under "Advanced settings" or similar sections. Alternatively, it could be in some config file (check the relevant documentation for details).

For some command-line tools, you may need to set an environment variable, e.g.:

set OPENAI_BASE_URL=https://my-super-proxy.vercel.app/v1

..or:

set OPENAI_API_BASE=https://my-super-proxy.vercel.app/v1

Models

In case the model specified in the request differs from "gemini-*", the default model gemini-1.5-pro will be used.


Possible further development