Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zuisong/gemini-openai-proxy
OpenAI to Google Gemini https://gemini-openai-proxy.deno.dev
https://github.com/zuisong/gemini-openai-proxy
ai bun chatgpt-api deno deno-deploy gemini-pro gemini-pro-vision gemini-protocol hono node openai-api serverless
Last synced: about 6 hours ago
JSON representation
OpenAI to Google Gemini https://gemini-openai-proxy.deno.dev
- Host: GitHub
- URL: https://github.com/zuisong/gemini-openai-proxy
- Owner: zuisong
- License: mit
- Created: 2024-01-04T05:58:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-24T07:40:40.000Z (9 days ago)
- Last Synced: 2025-01-26T07:01:51.384Z (7 days ago)
- Topics: ai, bun, chatgpt-api, deno, deno-deploy, gemini-pro, gemini-pro-vision, gemini-protocol, hono, node, openai-api, serverless
- Language: TypeScript
- Homepage: https://gemini-openai-proxy.zuisong.workers.dev
- Size: 2.46 MB
- Stars: 356
- Watchers: 6
- Forks: 101
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# Gemini-OpenAI-Proxy
Gemini-OpenAI-Proxy is a proxy software. It is designed to convert OpenAI API
protocol calls into Google Gemini Pro protocol, so that software using OpenAI
protocol can use Gemini Pro model without perception.If you're interested in using Google Gemini but don't want to modify your
software, Gemini-OpenAI-Proxy is a great option. It allows you to easily
integrate the powerful features of Google Gemini without having to do any
complex development work.## Demo
> Get api key from
✅ Gemini Pro
```shell
curl -s http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello, Who are you?"}],
"temperature": 0.7
}'
```![demo](./assets/demo.png)
✅ Gemini Pro Vision
```shell
curl -s http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4-vision-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What do you see in this picture?"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAnAgMAAAA0vyM3AAAACVBMVEX/4WwCAgF3aTMcpbzGAAAAa0lEQVR4nGOgAWB1QOYEIHFEcXKmhCBxQqYgcSLEEGymAFEEhzFAFYmTwNoA53A6IDmB1YETidPAiLBVFGgEgrNqJYIzNTQU4Z5QZA6QNQ3hGpAZcNegceBOADFQOQlQDhfQyUwLkPxKVwAABbkRCcDA66QAAAAASUVORK5CYII="
}
}
]
}
],
"stream": false
}'
```![vision demo](./assets/vision-demo.jpeg)
## Plan
- [x] `/v1/chat/completions`
- [x] stream
- [x] complete## Model Mappings
| Request Model | Target Gemini Model |
| -------------------- | -------------------------- |
| gpt-3.5-turbo | gemini-1.5-flash-8b-latest |
| gpt-4 | gemini-1.5-pro-latest |
| gpt-4o | gemini-1.5-flash-latest |
| gpt-4o-mini | gemini-1.5-flash-8b-latest |
| gpt-4-vision-preview | gemini-1.5-flash-latest |
| gpt-4-turbo | gemini-1.5-pro-latest |
| gpt-4-turbo-preview | gemini-2.0-flash-exp |
| gemini* | gemini* |
| ...(others) | gemini-1.5-flash-latest |## Run On Serverless
### [Cloudflare Workers](https://workers.cloudflare.com)
> build command `npm run build:cf_worker`
Copy [`main_cloudflare-workers.mjs`](./dist/main_cloudflare-workers.mjs) to
`cloudflare-workers`### [Deno Deploy](https://deno.com/deploy)
> build command `npm run build:deno`
Copy [`main_deno.mjs`](./dist/main_deno.mjs) to `deno deploy`
### [Vercel](https://vercel.com)
> build command `npm run build:cf_worker`
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/zuisong/gemini-openai-proxy&repository-name=gemini-openai-proxy)
- Alternatively can be deployed with [cli](https://vercel.com/docs/cli):
`vercel deploy`
- Serve locally: `vercel dev`
- Vercel _Functions_
[limitations](https://vercel.com/docs/functions/limitations) (with _Edge_
runtime)## Run On Local
### deno
```shell
deno task start:deno
```### node
```shell
npm install && npm run start:node
```### bun
```shell
bun run start:bun
```### docker
```shell
docker run -d -p 8000:8000 ghcr.io/zuisong/gemini-openai-proxy:deno
## or
docker run -d -p 8000:8000 ghcr.io/zuisong/gemini-openai-proxy:bun
## or
docker run -d -p 8000:8000 ghcr.io/zuisong/gemini-openai-proxy:node
```## Star History