Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hktalent/ChatGPT-API
OpenAI ChatGPT, GPT-3, ChatGPT-API for go,ChatGPT in bash shell command line
https://github.com/hktalent/ChatGPT-API
bash chatgpt go golang
Last synced: 29 days ago
JSON representation
OpenAI ChatGPT, GPT-3, ChatGPT-API for go,ChatGPT in bash shell command line
- Host: GitHub
- URL: https://github.com/hktalent/ChatGPT-API
- Owner: hktalent
- Created: 2022-12-18T09:37:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-01T10:25:01.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T23:30:32.878Z (4 months ago)
- Topics: bash, chatgpt, go, golang
- Language: Go
- Homepage: https://ChatGPT.51pwn.com
- Size: 9.77 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-golang-repositories - ChatGPT-API - 3, ChatGPT-API for go,ChatGPT in bash shell command line (Repositories)
README
# ChatGPT-API
# How use
```
curl -XPOST -v -H "user-agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0" 'https://51pwn.com/chatGPT?q=介绍支持matrix协议、开源客户端聊天软件'
```#### download from release
https://github.com/hktalent/ChatGPT-API/releases```
wget -c https://github.com/hktalent/ChatGPT-API/releases/download/0.0.3/ChatGPT_0.0.3_macOS_amd64.zip
unzip -x ChatGPT_0.0.3_macOS_amd64.zip
./ChatGPT -i -k [your key]```
# Example
```go
package mainimport (
"bufio"
"flag"
"fmt"
gtp "github.com/hktalent/ChatGPT-API"
"os"
"strings"
)func doOne(q, k string) {
if got, err := gtp.Completions(q, k); nil == err {
fmt.Println(got)
} else if nil != err {
fmt.Println("gtp.Completions is err:", err)
}
}func main() {
key := flag.String("k", "", "your ChatGPT-API token key")
interact := flag.Bool("i", false, "interact")
q := flag.String("q", "", "your question")
flag.Parse()
if *key != "" {
if *interact {
buf := bufio.NewScanner(os.Stdin)
for buf.Scan() {
s := buf.Text()
x1 := strings.TrimSpace(strings.ToLower(s))
if x1 == "exit" || x1 == "quit" || x1 == "q" || x1 == "x" {
break
}
if "" != s {
doOne(s, *key)
}
if nil != buf.Err() {
break
}
}
} else if "" != *q {
doOne(*q, *key)
}
}
}```