免代理使用Gemini 2.0 Flash

 首先打开 https://dash.cloudflare.com 在左侧菜单点击Workers 和 Pages



 works 代码


export default {

  async fetch(request, env) {

    const url = new URL(request.url);

    url.host = 'generativelanguage.googleapis.com';

    return fetch(new Request(url, request))

  }

}





Gemini官方给的例子是:

curl \
  -H 'Content-Type: application/json' \
  -d '{"contents":[{"parts":[{"text":"Write a story about a magic backpack"}]}]}' \
  -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY
Bash

我们替换generativelanguage.googleapis.com部分到我们的域名gemini.baipiao.io

curl \
  -H 'Content-Type: application/json' \
  -d '{"contents":[{"parts":[{"text":"Write a story about a magic backpack"}]}]}' \
  -X POST https://xxx/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY
Bash

Gemini Pro的api key获取地址:https://makersuite.google.com/app/apikey



参考:https://zhile.io/2023/12/24/gemini-pro-proxy.html

评论

此博客中的热门博文

Cloudflare WARP+,推出 MASQUE新协议,无需优选ip,直连,支持pc ,Android,ios ,MAC ,linux,附赠近1K个Warp+ 20-24PB的key

Serv00 sing-box reality + hy2 + vmess-argo +tuic5四合一,vps无交互一键安装脚本(已适配Alpine),支持纯V6 vps,默认解锁GPT和奈飞