Skip to content

Latest commit

 

History

History
129 lines (104 loc) · 3.96 KB

README_EN.MD

File metadata and controls

129 lines (104 loc) · 3.96 KB

Gemini 2.0 Playground

中文版

Author: Tech Shrimp

Available on Bilibili, YouTube, Douyin, and WeChat Official Account under the same name. Please credit the author when reposting.

Project Overview

Deploy a Gemini multimodal chat website in 10 seconds with just a Gemini API Key. Accessible from any region/network environment, ready to use immediately. Free serverless deployment using Deno/Cloudflare Worker. Converts Gemini Chat API to the more universal OpenAI format, accessible directly within China. Compatible with AI programming, can be integrated with ChatBox and other AI clients.

Deno Deployment (Recommended)

  1. Fork this project

  2. Login/Register at https://dash.deno.com/

  3. Create a project at https://dash.deno.com/new_project

  4. Select this project, enter project name (please choose carefully as it affects the auto-assigned domain)

  5. Set Entrypoint to src/deno_index.ts, leave other fields empty

    See image

    image

  6. Click Deploy Project

  7. After successful deployment, you'll get a domain name. The site is ready to use, and the domain can also be used as a Chat API proxy.

Cloudflare Worker Deployment

Deploy to Cloudflare Workers

  1. Click the deploy button

  2. Login to your Cloudflare account

  3. Enter Account ID and API Token

  4. Fork this project, enable Github Action

  5. Deploy, open dash.cloudflare.com to view the deployed worker

  6. For use in China, a custom domain name needs to be bound

    See image

    image

When using Cloudflare in China, you might encounter "400: User location is not supported for the API use." This might be due to Cloudflare routing to Hong Kong CDN nodes in the Guangdong-Hong Kong region. Recommend switching to Deno deployment.

Local Development

Install Deno on Windows:

irm https://deno.land/install.ps1 | iex

Install Deno on Mac/Linux:

curl -fsSL https://deno.land/install.sh | sh

Start the project:

cd project_directory
deno run --allow-net --allow-read src/deno_index.ts

Usage

Multimodal Chat

Enter API Key, click Connect button to start chatting. The three buttons are for:

  • Enable microphone
  • Enable camera
  • Share screen

![image](/docs/images/2.png)

API Proxy

The API has been proxied to OpenAI format and can be used directly with OpenAI format API. Remember to replace the domain and Gemini API Key.

Curl:

Available models:

curl --location 'http://your.domain.com/v1/models' \
--header 'Authorization: Bearer YOUR-GEMINI-API-KEY'

Chat:

curl --location 'https://your.domain.com/v1/chat/completions' \
--header 'Authorization: Bearer YOUR-GEMINI-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
    "messages": [
        {
            "role": "system",
            "content": "You are a test assistant."
        },
        {
            "role": "user",
            "content": "Testing. Just say hi and nothing else."
        }
    ],
    "model": "gemini-2.0-flash-exp"
}'

ChatBOX:

See image

image

Cursor Programming:

See image

image

Acknowledgments/References:

Website UI:

Author: ChrisKyle
Project: https://github.com/ViaAnthroposBenevolentia/gemini-2-live-api-demo
MIT License : https://github.com/ViaAnthroposBenevolentia/gemini-2-live-api-demo/blob/main/LICENSE

Gemini to OpenAI format conversion:

Author: PublicAffairs
Project: https://github.com/PublicAffairs/openai-gemini
MIT License : https://github.com/PublicAffairs/openai-gemini/blob/main/LICENSE