GithubHelp home page GithubHelp logo

danchaw / gemini-openai-proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zuisong/gemini-openai-proxy

0.0 0.0 0.0 2.27 MB

Convert OpenAI protocol to Google Gemini Pro protocol https://gemini-openai-proxy.zuisong.workers.dev

Home Page: https://gemini-openai-proxy.deno.dev

License: MIT License

JavaScript 0.28% TypeScript 99.54% Dockerfile 0.18%

gemini-openai-proxy's Introduction

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 https://makersuite.google.com/app/apikey

โœ… Gemini Pro
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

โœ… Gemini Pro Vision
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

Plan

  • /v1/chat/completions
    • stream
    • complete

Model Mappings

OpenAI Model Gemini Model
gpt-3.5-turbo gemini-1.0-pro-latest
gpt-4 gemini-1.5-pro-latest
gpt-4-vision-preview gemini-1.0-pro-vision-latest
gpt-4-turbo gemini-1.5-pro-latest
gpt-4o gemini-1.5-flash-latest
gpt-4-turbo-preview gemini-1.5-pro-latest
...others gemini-1.0-pro-latest

Run On Serverless

build command npm run build:cf_worker

Copy main_cloudflare-workers.mjs to cloudflare-workers

build command npm run build:deno

Copy main_deno.mjs to deno deploy

build command npm run build:cf_worker

Deploy with Vercel

  • Alternatively can be deployed with cli: vercel deploy
  • Serve locally: vercel dev
  • Vercel Functions limitations (with Edge runtime)

Run On Local

deno

deno task start:deno

node

npm install && npm run start:node

bun

bun run start:bun

docker

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

Star History Chart

gemini-openai-proxy's People

Contributors

zuisong avatar github-actions[bot] avatar dependabot[bot] avatar radiquum avatar quilljou avatar vuchaev2015 avatar greenjerry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.