- Notifications
You must be signed in to change notification settings - Fork1
Golang implementation of yihong0618/BingImageCreator
License
NotificationsYou must be signed in to change notification settings
mrchi/bing-dalle3
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
bing-dalle3
is a Golang implementation ofyihong0618/BingImageCreator. It allows you to access theImage Creator from Microsoft Bing service through API calls.
In comparison toyihong0618/BingImageCreator,bing-dalle3
simplifies certain features, including:
- The addition of a random
x-forwarded-for
header to disguise the source IP of requests (useful if Bing does not correctly implement code to obtain the real IP). - The ability to save generated images to disk.
- Implementation of a CLI command.
Please refer to the README ofyihong0618/BingImageCreator to obtain your Bing cookie.
package mainimport ("fmt""os"bingdalle3"github.com/mrchi/bing-dalle3")funcmain() {prompt:="月落乌啼霜满天,江枫渔火对愁眠。"bingClient:=bingdalle3.NewBingDalle3("Your Bing cookie")balance,err:=bingClient.GetTokenBalance()iferr!=nil {panic(err)}fmt.Println("balance: ",balance)writingId,err:=bingClient.CreateImage(prompt)iferr!=nil {panic(err)}fmt.Println("writingId: ",writingId)imageUrls,err:=bingClient.QueryResult(writingId,prompt)iferr!=nil {panic(err)}fmt.Println("imageUrls: ",imageUrls)imageContent,err:=bingClient.DownloadImage(imageUrls[0])iferr!=nil {panic(err)}iferr=os.WriteFile("output.jpeg",*imageContent,0644);err!=nil {panic(err)}}
I'd like to express my gratitude to@yihong0618 and the original author@acheong08 for their contributions.