显示标签为“技术交流”的博文。显示所有博文
显示标签为“技术交流”的博文。显示所有博文

2025-01-03

Cloudflare Worker中转代理Gemini API,国内免费爽用,Gemini编程,音视频,多模态 API应用 - 开发调优 - LINUX DO

Cloudflare Worker中转代理Gemini API,国内免费爽用,Gemini编程,音视频,多模态 API应用 - 开发调优 - LINUX DO

视频版: Cloudflare中转顶级大模型API,国内免费爽用,Gemini编程,音视频,多模态能力测试_哔哩哔哩_bilibili

最近爬爬虾试用了Gemini 2.0 的多模态API,发现很有意思,跟佬友分享下。
试了下视频通话,我的梯子上行速度不稳延迟很高,就尝试了下用Cloudflare Worker代理API到国内,免费爽用。现在还很简陋,等有空整理一下,把几个项目整合到一起,做一个UI+全套代理的完整worker应用。

谷歌Gemini是所有一线顶级大模型当中唯一一个API可以免费白嫖的。我们可以借助互联网大善人Cloudflare来中转一下Gemini API,这样就得到一个国内免费爽用的顶级大模型。有了API以后,我们可以进行AI编程,可以聊天,可以音视频通话,做各种各样好玩的事情。

开始之前,我们需要先注册一个Cloudflare的账号,然后把一个域名托管到Cloudflare上面。爬爬虾之前有很多期视频介绍关于Cloudflare的使用,还有如何获得一个免费域名托管到Cloudflare上面,这里我就不赘述了。

Chat API

然后我们来到Github,找到这个项目叫做openai-gemini。

Gemini 转OpenAI格式: GitHub - PublicAffairs/openai-gemini: Gemini ➜ OpenAI API proxy. Serverless!

它的作用是把Gemini的API转换成OpenAI的API格式。我们可以看到,这里提供了一个部署到Cloudflare worker上面的方式。

部署到Cloudflare worker以后,它事实上达成了两个效果:

  1. 把API中转到了国内
  2. 把Gemini的API转换成更为通用的openai的格式

好,我们点击这个deploy with worker这个按钮,填写一个Account ID还有API TOKEN,下面都有获取方式的指引。我们先点击worker dashboard这个按钮,

进来以后我们可以看到右侧的账户ID,把它复制一下填写过来。

接下来我们来获取一个API TOKEN,点击这个my profile的按钮,

然后我们点击创建令牌,点击编辑cloudflare worker使用模板。

账户资源选择所有账户,选择包含所有区域,

点击继续以显示摘要,点击创建令牌。

我们把这个令牌也复制一下,粘贴到API Token里面,然后点击connect account。

接下来我们需要在浏览器登录一下自己的Github账户。这里我登录技术爬爬虾的账号,然后点击这个fork repository。这里指的是把项目复刻一份到自己的名字底下。然后我们需要开启fork出来项目的Github action功能,这里点击这个按钮,

点击中间这个绿色按钮,

开启Github action功能。

后我们回到刚才的页面,点击workflow enabled,最后点击deploy。

等待worker部署完成。

我们点击下面的worker Dash,进入Cloudflare worker的dashboard。

我们可以看到有一个名字叫Gemini的worker,就是我们刚刚部署好的那个worker。我们点进来找到设置,这里需要给它添加一个域名,才能在国内正常使用。

我已经把tech-shrimp.com的域名托管到Cloudflare上面了,我们就来使用这个域名。

下一步,我们来申请一个免费的Gemini API key。我们来到这个地址,

Gemini API申请: https://aistudio.google.com/

我们需要一个能连上谷歌的上网环境才能进入这个页面。进来以后我们点击这个Get API key,找到这里的密钥,创建API密钥,然后随便填上一个项目,点击创建好,这样我们就拿到了API密钥。

这里我打开一个API测试工具,比如postman,测试一下,注意修改其中的域名与API Key

curl --location 'https://gemini.tech-shrimp.com/v1/models' \ --header 'Authorization: Bearer AIzaSyBMEmq3MiK2zdWJovLlJ7zKmQK0ZBi5gwg

这里返回了一个模型列表,gemini-2.0-flash-exp是目前速度最快的模型,gemini-exp-1206应该是目前谷歌最强大的模型,在大模型竞技场上也是位居榜首的。

API 实战

AI对话

接下来我用几个实战案例带大家看一下这个API如何使用。我们来看AI聊天,这是我在Github上面找的一个开源项目叫做chatbox,就是一个大模型聊天的客户端。

ChatBox:GitHub - Bin-Huang/chatbox: User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)

把它下载安装好以后,我们点击左下角的设置,然后模型这里我们还是用OpenAI的API,这个域名我们当然填写自己的域名。API密钥我们还是填写谷歌的Gemini API Key。

然后我们在下面选择自定义模型,然后填一个模型的名字,这里我填gemini-2.0-flash-exp,最后点击保存。

AI编程

我们来看如何使用Gemini API进行AI编程。cursor应该是目前最多人使用的AI编码工具,我们先把它下载安装一下。安装完成我们点击右上角的这个设置,选择Models,然后往下找。这里Open AI API Key,我们先把链接填上,我们填写自己的域名。接下来我们填写这个API Key,我们填写Gemini的API Key过来。

接下来我们点击这个add model按钮,我们填写一个模型的名字,这里我填写Google最强的编程大模型gemini-exp-1206,

把这里勾选上,最后我们保存一下。

使用Gemini进行AI编程,它的最大优势是上下文长度。我们看到,2.0 Flash模型的上下文长度比Claude3.5要大了5倍,对于中小型的项目,它甚至一次性可以把源代码全部读完。

多模态API

Gemini最强的就是它的原生多模态能力,也就是实时的音视频通话。不过这个功能是使用websocket的API来实现的。爬爬虾自己写了一个项目用来代理Gemini的Websocket API。

Worker代理WebSocket多模态:GitHub - tech-shrimp/gemini-proxy: 使用Cloudflare Worker代理Gemini 多模态 API

现在项目还非常的简陋,如果视频点赞播放量高的话,我会把这个项目完善一下,把前后台的功能都加上。

这里我回到Cloudflare,找到左侧的workers and page,点击创建,点击创建worker。

worker的名字我叫做gemini-websocket-proxy,在右下角点击部署好,右上角点击编辑代码。

这里来到我写的这个Github项目,把这个worker.js里面的代码复制出来,然后拷贝到cloudflare的worker.js,把它覆盖掉。

拷贝完成以后,我们点击右上角的部署,点击设置,这里还是给他添加一个域名。

我们来测试一下。我在Github上面找了一个Gemini的客户端项目,这个项目只有5个star,它是使用原生js来实现的一个Gemini的多模态API,现在都非常的简陋。我们先跑起来再说,后期有时间,我把它跟proxy项目合并起来,改造一下。

Gemini多模态客户端:GitHub - ViaAnthroposBenevolentia/gemini-2-live-api-demo: Vanilla JS web interface for Gemini 2.0 Flash Experimental Multimodal API with text, audio, camera, screen inputs and audio response and function calling from the LLM

首先我先把配置文件创建出来,按照模板新建一个config.js文件 。把我谷歌GMAI的API Key填到里面。

接下来我来修改这个文件,在core里面有一个websocket-client.js,把这个连接地址改一下,改成我自己的域名。

我把它启动一下,我们按照他的说明把项目启动一下。我打开一个命令提示符CD,然后进入项目目录。接下来,我把这个命令执行一下,启动成功。

2009-04-08

Windows 7 Shell 命令大名单

Windows 7 Shell 命令大名单_Windows 7_cnBeta.COM

对于熟悉了命令行的人而言,用键盘调用程序比鼠标更快更省力,以下就是国外网站整理出来的有关Windows 7的Shell 命令大名单.
您可以用"Shell:"命令调用一切可以用资源管理器打开的项目甚至是一次完成.需要很多步骤才能完成的任务.

Windows 7 Only
shell:Libraries
shell:MusicLibrary
shell:VideosLibrary
shell:OtherUsersFolder
shell:Device Metadata Store
shell:PublicSuggestedLocations
shell:DocumentsLibrary
shell:User Pinned
shell:UsersLibrariesFolder
shell:PicturesLibrary
shell:ImplicitAppShortcuts
shell:Ringtones
shell:CommonRingtones

Windows Vista & 7
shell:Common Programs
shell:GameTasks
shell:UserProfiles
shell:MyComputerFolder
shell:SyncSetupFolder
shell:DpapiKeys
shell:SamplePlaylists
shell:Favorites
shell:My Video
shell:SearchHomeFolder
shell:System
shell:CommonVideo
shell:SyncResultsFolder
shell:LocalizedResourcesDir
shell:Cookies
shell:Original Images
shell:CommonMusic
shell:My Pictures
shell:Cache
shell:Downloads
shell:CommonDownloads
shell:AppData
shell:SyncCenterFolder
shell:My Music
shell:ConflictFolder
shell:SavedGames
shell:InternetFolder
shell:Quick Launch
shell:SystemCertificates
shell:Contacts
shell:TreePropertiesFolder
shell:Profile
shell:Start Menu
shell:Common AppData
shell:PhotoAlbums
shell:ConnectionsFolder
shell:Administrative Tools
shell:PrintersFolder
shell:Default Gadgets
shell:ProgramFilesX86
shell:Searches
shell:Common Startup
shell:ControlPanelFolder
shell:SampleVideos
shell:SendTo
shell:ResourceDir
shell:ProgramFiles
shell:CredentialManager
shell:PrintHood
shell:MAPIFolder
shell:CD Burning
shell:AppUpdatesFolder
shell:Common Start Menu
shell:LocalAppDataLow
shell:Templates
shell:Gadgets
shell:Programs
shell:Recent
shell:SampleMusic
shell:Desktop
shell:CommonPictures
shell:RecycleBinFolder
shell:CryptoKeys
shell:Common Templates
shell:Startup
shell:Links
shell:OEM Links
shell:SamplePictures
shell:Common Desktop
shell:NetHood
shell:Games
shell:Common Administrative Tools
shell:NetworkPlacesFolder
shell:SystemX86
shell:History
shell:AddNewProgramsFolder
shell:Playlists
shell:ProgramFilesCommonX86
shell:PublicGameTasks
shell:ChangeRemoveProgramsFolder
shell:Public
shell:Common Documents
shell:CSCFolder
shell:Local AppData
shell:Windows
shell:UsersFilesFolder
shell:ProgramFilesCommon
shell:Fonts
shell:Personal

Windows 7 Shortcuts
I compiled the following list with an early Alpha build of Windows 7. It is possible that some of these have changed with newer versions. If you find one that is wrong please let me know so I can correct it.

Wireless Networks pop-up
rundll32.exe van.dll,RunVAN

Advanced Restore
sdclt.exe /restorewizardadmin

Restore Files
sdclt.exe /restorewizard

Backup Location & Settings
sdclt.exe /configure

Add Network Location (wizard)
rundll32.exe shwebsvc.dll,AddNetPlaceRunDll

Indexing Options
control.exe srchadmin.dll

Notification Cache
rundll32.exe shell32.dll,Options_RunDLL 5

Aero (Transparency) Off
Rundll32.exe DwmApi #104

Aero (Transparency) On
Rundll32.exe DwmApi #102

Welcome Center
rundll32.exe oobefldr.dll,ShowWelcomeCenter

Add/Remove Programs
RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0

Content Advisor
RunDll32.exe msrating.dll,RatingSetupUI

Control Panel
RunDll32.exe shell32.dll,Control_RunDLL

Date and Time Properties
RunDll32.exe shell32.dll,Control_RunDLL timedate.cpl

Display Settings
RunDll32.exe shell32.dll,Control_RunDLL access.cpl,,3

Device Manager
RunDll32.exe devmgr.dll DeviceManager_Execute

Folder Options - File Types
RunDll32.exe shell32.dll,Control_Options 2

Folder Options - General
RunDll32.exe shell32.dll,Options_RunDLL 0

Folder Options - Search
RunDll32.exe shell32.dll,Options_RunDLL 2

Folder Options - View
RunDll32.exe shell32.dll,Options_RunDLL 7

Forgotten Password Wizard
RunDll32.exe keymgr.dll,PRShowSaveWizardExW

Hibernate
RunDll32.exe powrprof.dll,SetSuspendState

Keyboard Properties
RunDll32.exe shell32.dll,Control_RunDLL main.cpl @1

Lock Screen
RunDll32.exe user32.dll,LockWorkStation

Mouse Properties
RunDll32.exe shell32.dll,Control_RunDLL main.cpl @0

Map Network Drive
RunDll32.exe shell32.dll,SHHelpShortcuts_RunDLL Connect

Network Connections
RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl

Power Options
RunDll32.exe Shell32.dll,Control_RunDLL powercfg.cpl

Regional Settings
RunDll32.exe shell32.dll,Control_RunDLL intl.cpl,,3

Stored Usernames and Passwords
RunDll32.exe keymgr.dll,KRShowKeyMgr

System Properties: Advanced
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4

System Properties: Automatic Updates
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5

Taskbar Properties
RunDll32.exe shell32.dll,Options_RunDLL 1

User Accounts
RunDll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl

Windows Security Center
RunDll32.exe shell32.dll,Control_RunDLL wscui.cpl

Windows - About
RunDll32.exe SHELL32.DLL,ShellAboutW

Unplug/Eject Hardware
RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll

Windows Firewall
RunDll32.exe shell32.dll,Control_RunDLL firewall.cpl

Wireless Network Setup
RunDll32.exe shell32.dll,Control_RunDLL NetSetup.cpl,@0,WNSW

Open Control Panel (All Items)
explorer.exe shell:::{21ec2020-3aea-1069-a2dd-08002b30309d}

Manage Wireless Networks
explorer.exe shell:::{1fa9085f-25a2-489b-85d4-86326eedcd87}

Sound Control Playback Tab
rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl

Sound Control Sounds Tab
rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl,,2

Sound Control Recording Tab
rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl,,1

Add/Remove Programs
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl

Add/Remove Windows Components
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2

Set Program Access and Computer Defaults
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3

People Near Me
rundll32.exe shell32.dll,Control_RunDLL collab.cpl

People Near Me Sign In Tab
rundll32.exe shell32.dll,Control_RunDLL collab.cpl,,1

Screan Resolution
rundll32.exe shell32.dll,Control_RunDLL desk.cpl

Personalization
rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2

Screen Saver
rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1

Windows Firewall
rundll32.exe shell32.dll,Control_RunDLL firewall.cpl

Device Manager
rundll32.exe shell32.dll,Control_RunDLL hdwwiz.cpl

Power Options
rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl

Power Options Change Plan Settings
rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl,,1

System Properties
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl

System Properties Hardware Tab
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2

System Properties Advanced Tab
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,3

System Properties System Protection Tab
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4

System Properties Remote Tab
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5

Pen and Touch Tablet PC Settings
rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl

Pen and Touch Tablet PC Settings Flicks Tab
rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl,,1

Pen and Touch Tablet PC Settings Handwriting Tab
rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl,,2

Phone and Modem Options
rundll32.exe shell32.dll,Control_RunDLL telephon.cpl

Phone and Modem Options Modems Tab
rundll32.exe shell32.dll,Control_RunDLL telephon.cpl,,1

Phone and Modems Options Advanced Tab
rundll32.exe shell32.dll,Control_RunDLL telephon.cpl,,2

Date and Time
rundll32.exe shell32.dll,Control_RunDLL timedate.cpl

Date and Time Additional Clocks
rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

Action Center
rundll32.exe shell32.dll,Control_RunDLL wscui.cpl

Unplug/Eject Hardware
RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll

Internet Explorer Specific Commands
Delete Temporary Internet Files:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Delete Cookies:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete History:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Form Data:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete Passwords:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All + files and settings stored by Add-ons:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

If anyone has additional ones that I have missed you can submit them and I will add them to this list.
查看:Huge list of Windows 7 Shell Commands

精选文章

Tailscale的开源仓库ScaleTail 项目分析

Tailscale的开源仓库ScaleTail 项目分析 一、项目定位 ScaleTail 是 Tailscale 官方维护的开源仓库,地址为 github.com/tailscale-dev/ScaleTail 。它本质上不是一个传统意义上的 “库",而是一个 ...